2 * Add/Remove Programs applet
3 * Partially based on Wine Uninstaller
5 * Copyright 2000 Andreas Mohr
6 * Copyright 2004 Hannu Valtonen
7 * Copyright 2005 Jonathan Ernst
8 * Copyright 2001-2002, 2008 Owen Rudge
10 * This library is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU Lesser General Public
12 * License as published by the Free Software Foundation; either
13 * version 2.1 of the License, or (at your option) any later version.
15 * This library is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * Lesser General Public License for more details.
20 * You should have received a copy of the GNU Lesser General Public
21 * License along with this library; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
26 #define NONAMELESSUNION
29 #include "wine/port.h"
30 #include "wine/unicode.h"
31 #include "wine/debug.h"
49 WINE_DEFAULT_DEBUG_CHANNEL(appwizcpl
);
51 /* define a maximum length for various buffers we use */
52 #define MAX_STRING_LEN 1024
54 typedef struct APPINFO
{
68 WCHAR regkey
[MAX_STRING_LEN
];
73 static struct APPINFO
*AppInfo
= NULL
;
74 static HINSTANCE hInst
;
76 static const WCHAR openW
[] = {'o','p','e','n',0};
78 /* names of registry keys */
79 static const WCHAR BackSlashW
[] = { '\\', 0 };
80 static const WCHAR DisplayNameW
[] = {'D','i','s','p','l','a','y','N','a','m','e',0};
81 static const WCHAR DisplayIconW
[] = {'D','i','s','p','l','a','y','I','c','o','n',0};
82 static const WCHAR DisplayVersionW
[] = {'D','i','s','p','l','a','y','V','e','r',
84 static const WCHAR PublisherW
[] = {'P','u','b','l','i','s','h','e','r',0};
85 static const WCHAR ContactW
[] = {'C','o','n','t','a','c','t',0};
86 static const WCHAR HelpLinkW
[] = {'H','e','l','p','L','i','n','k',0};
87 static const WCHAR HelpTelephoneW
[] = {'H','e','l','p','T','e','l','e','p','h',
89 static const WCHAR ModifyPathW
[] = {'M','o','d','i','f','y','P','a','t','h',0};
90 static const WCHAR NoModifyW
[] = {'N','o','M','o','d','i','f','y',0};
91 static const WCHAR ReadmeW
[] = {'R','e','a','d','m','e',0};
92 static const WCHAR URLUpdateInfoW
[] = {'U','R','L','U','p','d','a','t','e','I',
94 static const WCHAR CommentsW
[] = {'C','o','m','m','e','n','t','s',0};
95 static const WCHAR UninstallCommandlineW
[] = {'U','n','i','n','s','t','a','l','l',
96 'S','t','r','i','n','g',0};
98 static const WCHAR PathUninstallW
[] = {
99 'S','o','f','t','w','a','r','e','\\',
100 'M','i','c','r','o','s','o','f','t','\\',
101 'W','i','n','d','o','w','s','\\',
102 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
103 'U','n','i','n','s','t','a','l','l',0 };
105 /******************************************************************************
107 * Description: Entry point for DLL file
109 BOOL WINAPI
DllMain(HINSTANCE hinstDLL
, DWORD fdwReason
,
112 TRACE("(%p, %d, %p)\n", hinstDLL
, fdwReason
, lpvReserved
);
116 case DLL_PROCESS_ATTACH
:
123 /******************************************************************************
125 * Description: Frees memory used by an AppInfo structure, and any children.
127 static void FreeAppInfo(APPINFO
*info
)
131 APPINFO
*next_info
= info
->next
;
133 HeapFree(GetProcessHeap(), 0, info
->title
);
134 HeapFree(GetProcessHeap(), 0, info
->path
);
135 HeapFree(GetProcessHeap(), 0, info
->path_modify
);
136 HeapFree(GetProcessHeap(), 0, info
->icon
);
137 HeapFree(GetProcessHeap(), 0, info
->publisher
);
138 HeapFree(GetProcessHeap(), 0, info
->version
);
139 HeapFree(GetProcessHeap(), 0, info
);
144 /******************************************************************************
145 * Name : ReadApplicationsFromRegistry
146 * Description: Creates a linked list of uninstallable applications from the
148 * Parameters : root - Which registry root to read from (HKCU/HKLM)
149 * Returns : TRUE if successful, FALSE otherwise
151 static BOOL
ReadApplicationsFromRegistry(HKEY root
)
153 HKEY hkeyUninst
, hkeyApp
;
155 DWORD sizeOfSubKeyName
, displen
, uninstlen
;
156 DWORD dwNoModify
, dwType
;
157 WCHAR subKeyName
[256];
158 WCHAR key_app
[MAX_STRING_LEN
];
160 APPINFO
*iter
= AppInfo
;
164 if (RegOpenKeyExW(root
, PathUninstallW
, 0, KEY_READ
, &hkeyUninst
) !=
168 lstrcpyW(key_app
, PathUninstallW
);
169 lstrcatW(key_app
, BackSlashW
);
170 p
= key_app
+lstrlenW(PathUninstallW
)+1;
172 sizeOfSubKeyName
= sizeof(subKeyName
) / sizeof(subKeyName
[0]);
176 /* find the end of the list */
177 for (iter
= AppInfo
; iter
->next
; iter
= iter
->next
);
180 for (i
= 0; RegEnumKeyExW(hkeyUninst
, i
, subKeyName
, &sizeOfSubKeyName
, NULL
,
181 NULL
, NULL
, NULL
) != ERROR_NO_MORE_ITEMS
; ++i
)
183 lstrcpyW(p
, subKeyName
);
184 RegOpenKeyExW(root
, key_app
, 0, KEY_READ
, &hkeyApp
);
189 if ((RegQueryValueExW(hkeyApp
, DisplayNameW
, 0, 0, NULL
, &displen
) ==
190 ERROR_SUCCESS
) && (RegQueryValueExW(hkeyApp
, UninstallCommandlineW
,
191 0, 0, NULL
, &uninstlen
) == ERROR_SUCCESS
))
193 /* if we already have iter, allocate the next entry */
196 iter
->next
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
,
197 sizeof(struct APPINFO
));
206 /* if not, start the list */
207 iter
= AppInfo
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
,
208 sizeof(struct APPINFO
));
214 iter
->title
= HeapAlloc(GetProcessHeap(), 0, displen
);
219 RegQueryValueExW(hkeyApp
, DisplayNameW
, 0, 0, (LPBYTE
)iter
->title
,
222 /* now get DisplayIcon */
224 RegQueryValueExW(hkeyApp
, DisplayIconW
, 0, 0, NULL
, &displen
);
230 iter
->icon
= HeapAlloc(GetProcessHeap(), 0, displen
);
235 RegQueryValueExW(hkeyApp
, DisplayIconW
, 0, 0, (LPBYTE
)iter
->icon
,
238 /* separate the index from the icon name, if supplied */
239 iconPtr
= strchrW(iter
->icon
, ',');
244 iter
->iconIdx
= atoiW(iconPtr
);
248 iter
->path
= HeapAlloc(GetProcessHeap(), 0, uninstlen
);
253 RegQueryValueExW(hkeyApp
, UninstallCommandlineW
, 0, 0,
254 (LPBYTE
)iter
->path
, &uninstlen
);
256 /* publisher, version */
257 if (RegQueryValueExW(hkeyApp
, PublisherW
, 0, 0, NULL
, &displen
) ==
260 iter
->publisher
= HeapAlloc(GetProcessHeap(), 0, displen
);
262 if (!iter
->publisher
)
265 RegQueryValueExW(hkeyApp
, PublisherW
, 0, 0, (LPBYTE
)iter
->publisher
,
269 if (RegQueryValueExW(hkeyApp
, DisplayVersionW
, 0, 0, NULL
, &displen
) ==
272 iter
->version
= HeapAlloc(GetProcessHeap(), 0, displen
);
277 RegQueryValueExW(hkeyApp
, DisplayVersionW
, 0, 0, (LPBYTE
)iter
->version
,
281 /* Check if NoModify is set */
284 displen
= sizeof(DWORD
);
286 if (RegQueryValueExW(hkeyApp
, NoModifyW
, NULL
, &dwType
, (LPBYTE
)&dwNoModify
, &displen
)
292 /* Some installers incorrectly create a REG_SZ instead of a REG_DWORD - check for
293 ASCII 49, which equals 1 */
294 if (dwType
== REG_SZ
)
295 dwNoModify
= (dwNoModify
== 49) ? 1 : 0;
297 /* Fetch the modify path */
298 if ((dwNoModify
== 0) && (RegQueryValueExW(hkeyApp
, ModifyPathW
, 0, 0, NULL
, &displen
)
301 iter
->path_modify
= HeapAlloc(GetProcessHeap(), 0, displen
);
303 if (!iter
->path_modify
)
306 RegQueryValueExW(hkeyApp
, ModifyPathW
, 0, 0, (LPBYTE
)iter
->path_modify
, &displen
);
310 iter
->regroot
= root
;
311 lstrcpyW(iter
->regkey
, subKeyName
);
316 RegCloseKey(hkeyApp
);
317 sizeOfSubKeyName
= sizeof(subKeyName
) / sizeof(subKeyName
[0]);
324 RegCloseKey(hkeyApp
);
328 RegCloseKey(hkeyUninst
);
333 /******************************************************************************
334 * Name : AddApplicationsToList
335 * Description: Populates the list box with applications.
336 * Parameters : hWnd - Handle of the dialog box
338 static void AddApplicationsToList(HWND hWnd
, HIMAGELIST hList
)
340 APPINFO
*iter
= AppInfo
;
352 if (ExtractIconExW(iter
->icon
, iter
->iconIdx
, NULL
, &hIcon
, 1) == 1)
354 index
= ImageList_AddIcon(hList
, hIcon
);
359 lvItem
.mask
= LVIF_IMAGE
| LVIF_TEXT
| LVIF_PARAM
;
360 lvItem
.iItem
= iter
->id
;
362 lvItem
.pszText
= iter
->title
;
363 lvItem
.iImage
= index
;
364 lvItem
.lParam
= iter
->id
;
366 index
= ListView_InsertItemW(hWnd
, &lvItem
);
368 /* now add the subitems (columns) */
369 ListView_SetItemTextW(hWnd
, index
, 1, iter
->publisher
);
370 ListView_SetItemTextW(hWnd
, index
, 2, iter
->version
);
376 /******************************************************************************
377 * Name : RemoveItemsFromList
378 * Description: Clears the application list box.
379 * Parameters : hWnd - Handle of the dialog box
381 static void RemoveItemsFromList(HWND hWnd
)
383 SendDlgItemMessageW(hWnd
, IDL_PROGRAMS
, LVM_DELETEALLITEMS
, 0, 0);
386 /******************************************************************************
388 * Description: Frees memory used by the application linked list.
390 static inline void EmptyList(void)
392 FreeAppInfo(AppInfo
);
396 /******************************************************************************
397 * Name : UpdateButtons
398 * Description: Enables/disables the Add/Remove button depending on current
399 * selection in list box.
400 * Parameters : hWnd - Handle of the dialog box
402 static void UpdateButtons(HWND hWnd
)
404 BOOL sel
= SendMessageW(GetDlgItem(hWnd
, IDL_PROGRAMS
), LVM_GETSELECTEDCOUNT
, 0, 0) != 0;
406 EnableWindow(GetDlgItem(hWnd
, IDC_ADDREMOVE
), sel
);
407 EnableWindow(GetDlgItem(hWnd
, IDC_SUPPORT_INFO
), sel
);
410 /******************************************************************************
411 * Name : InstallProgram
412 * Description: Search for potential Installer and execute it.
413 * Parameters : hWnd - Handle of the dialog box
415 static void InstallProgram(HWND hWnd
)
418 WCHAR titleW
[MAX_STRING_LEN
];
419 WCHAR FilterBufferW
[MAX_STRING_LEN
];
420 WCHAR FileNameBufferW
[MAX_PATH
];
422 LoadStringW(hInst
, IDS_CPL_TITLE
, titleW
, sizeof(titleW
)/sizeof(WCHAR
));
423 LoadStringW(hInst
, IDS_INSTALL_FILTER
, FilterBufferW
, sizeof(FilterBufferW
)/sizeof(WCHAR
));
425 memset(&ofn
, 0, sizeof(OPENFILENAMEW
));
426 ofn
.lStructSize
= sizeof(OPENFILENAMEW
);
427 ofn
.hwndOwner
= hWnd
;
428 ofn
.hInstance
= hInst
;
429 ofn
.lpstrFilter
= FilterBufferW
;
430 ofn
.nFilterIndex
= 0;
431 ofn
.lpstrFile
= FileNameBufferW
;
432 ofn
.nMaxFile
= MAX_PATH
;
433 ofn
.lpstrFileTitle
= NULL
;
434 ofn
.nMaxFileTitle
= 0;
435 ofn
.lpstrTitle
= titleW
;
436 ofn
.Flags
= OFN_HIDEREADONLY
| OFN_ENABLESIZING
;
437 FileNameBufferW
[0] = 0;
439 if (GetOpenFileNameW(&ofn
))
441 SHELLEXECUTEINFOW sei
;
442 memset(&sei
, 0, sizeof(sei
));
443 sei
.cbSize
= sizeof(sei
);
445 sei
.nShow
= SW_SHOWDEFAULT
;
446 sei
.fMask
= SEE_MASK_NO_CONSOLE
;
447 sei
.lpFile
= ofn
.lpstrFile
;
449 ShellExecuteExW(&sei
);
453 /******************************************************************************
454 * Name : UninstallProgram
455 * Description: Executes the specified program's installer.
456 * Parameters : id - the internal ID of the installer to remove
458 static void UninstallProgram(int id
)
462 PROCESS_INFORMATION info
;
463 WCHAR errormsg
[MAX_STRING_LEN
];
464 WCHAR sUninstallFailed
[MAX_STRING_LEN
];
468 LoadStringW(hInst
, IDS_UNINSTALL_FAILED
, sUninstallFailed
,
469 sizeof(sUninstallFailed
) / sizeof(sUninstallFailed
[0]));
471 for (iter
= AppInfo
; iter
; iter
= iter
->next
)
475 TRACE("Uninstalling %s (%s)\n", wine_dbgstr_w(iter
->title
),
476 wine_dbgstr_w(iter
->path
));
478 memset(&si
, 0, sizeof(STARTUPINFOW
));
479 si
.cb
= sizeof(STARTUPINFOW
);
480 si
.wShowWindow
= SW_NORMAL
;
481 res
= CreateProcessW(NULL
, iter
->path
, NULL
, NULL
, FALSE
, 0, NULL
,
486 CloseHandle(info
.hThread
);
488 /* wait for the process to exit */
489 WaitForSingleObject(info
.hProcess
, INFINITE
);
490 CloseHandle(info
.hProcess
);
494 wsprintfW(errormsg
, sUninstallFailed
, iter
->path
);
496 if (MessageBoxW(0, errormsg
, iter
->title
, MB_YESNO
|
497 MB_ICONQUESTION
) == IDYES
)
499 /* delete the application's uninstall entry */
500 RegOpenKeyExW(iter
->regroot
, PathUninstallW
, 0, KEY_READ
, &hkey
);
501 RegDeleteKeyW(hkey
, iter
->regkey
);
511 /**********************************************************************************
512 * Name : SetInfoDialogText
513 * Description: Sets the text of a label in a window, based upon a registry entry
514 * or string passed to the function.
515 * Parameters : hKey - registry entry to read from, NULL if not reading
517 * lpKeyName - key to read from, or string to check if hKey is NULL
518 * lpAltMessage - alternative message if entry not found
519 * hWnd - handle of dialog box
520 * iDlgItem - ID of label in dialog box
522 static void SetInfoDialogText(HKEY hKey
, LPWSTR lpKeyName
, LPWSTR lpAltMessage
,
523 HWND hWnd
, int iDlgItem
)
525 WCHAR buf
[MAX_STRING_LEN
];
529 hWndDlgItem
= GetDlgItem(hWnd
, iDlgItem
);
531 /* if hKey is null, lpKeyName contains the string we want to check */
534 if ((lpKeyName
) && (lstrlenW(lpKeyName
) > 0))
535 SetWindowTextW(hWndDlgItem
, lpKeyName
);
537 SetWindowTextW(hWndDlgItem
, lpAltMessage
);
541 buflen
= MAX_STRING_LEN
;
543 if ((RegQueryValueExW(hKey
, lpKeyName
, 0, 0, (LPBYTE
) buf
, &buflen
) ==
544 ERROR_SUCCESS
) && (lstrlenW(buf
) > 0))
545 SetWindowTextW(hWndDlgItem
, buf
);
547 SetWindowTextW(hWndDlgItem
, lpAltMessage
);
551 /******************************************************************************
552 * Name : SupportInfoDlgProc
553 * Description: Callback procedure for support info dialog
554 * Parameters : hWnd - hWnd of the window
555 * msg - reason for calling function
556 * wParam - additional parameter
557 * lParam - additional parameter
558 * Returns : Dependant on message
560 static BOOL CALLBACK
SupportInfoDlgProc(HWND hWnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
)
564 WCHAR oldtitle
[MAX_STRING_LEN
];
565 WCHAR buf
[MAX_STRING_LEN
];
566 WCHAR key
[MAX_STRING_LEN
];
567 WCHAR notfound
[MAX_STRING_LEN
];
572 for (iter
= AppInfo
; iter
; iter
= iter
->next
)
574 if (iter
->id
== (int) lParam
)
576 lstrcpyW(key
, PathUninstallW
);
577 lstrcatW(key
, BackSlashW
);
578 lstrcatW(key
, iter
->regkey
);
580 /* check the application's registry entries */
581 RegOpenKeyExW(iter
->regroot
, key
, 0, KEY_READ
, &hkey
);
583 /* Load our "not specified" string */
584 LoadStringW(hInst
, IDS_NOT_SPECIFIED
, notfound
,
585 sizeof(notfound
) / sizeof(notfound
[0]));
587 /* Update the data for items already read into the structure */
588 SetInfoDialogText(NULL
, iter
->publisher
, notfound
, hWnd
,
590 SetInfoDialogText(NULL
, iter
->version
, notfound
, hWnd
,
593 /* And now update the data for those items in the registry */
594 SetInfoDialogText(hkey
, (LPWSTR
) ContactW
, notfound
, hWnd
,
596 SetInfoDialogText(hkey
, (LPWSTR
) HelpLinkW
, notfound
, hWnd
,
598 SetInfoDialogText(hkey
, (LPWSTR
) HelpTelephoneW
, notfound
, hWnd
,
600 SetInfoDialogText(hkey
, (LPWSTR
) ReadmeW
, notfound
, hWnd
,
602 SetInfoDialogText(hkey
, (LPWSTR
) URLUpdateInfoW
, notfound
, hWnd
,
604 SetInfoDialogText(hkey
, (LPWSTR
) CommentsW
, notfound
, hWnd
,
607 /* Update the main label with the app name */
608 if (GetWindowTextW(GetDlgItem(hWnd
, IDC_INFO_LABEL
), oldtitle
,
609 MAX_STRING_LEN
) != 0)
611 wsprintfW(buf
, oldtitle
, iter
->title
);
612 SetWindowTextW(GetDlgItem(hWnd
, IDC_INFO_LABEL
), buf
);
627 switch (LOWORD(wParam
))
630 EndDialog(hWnd
, TRUE
);
641 /******************************************************************************
643 * Description: Displays the Support Information dialog
644 * Parameters : hWnd - Handle of the main dialog
645 * id - ID of the application to display information for
647 static void SupportInfo(HWND hWnd
, int id
)
649 DialogBoxParamW(hInst
, MAKEINTRESOURCEW(IDD_INFO
), hWnd
, (DLGPROC
)
650 SupportInfoDlgProc
, (LPARAM
) id
);
653 /* Definition of column headers for AddListViewColumns function */
654 typedef struct AppWizColumn
{
660 static const AppWizColumn columns
[] = {
661 {200, LVCFMT_LEFT
, IDS_COLUMN_NAME
},
662 {150, LVCFMT_LEFT
, IDS_COLUMN_PUBLISHER
},
663 {100, LVCFMT_LEFT
, IDS_COLUMN_VERSION
},
666 /******************************************************************************
667 * Name : AddListViewColumns
668 * Description: Adds column headers to the list view control.
669 * Parameters : hWnd - Handle of the list view control.
670 * Returns : TRUE if completed successfully, FALSE otherwise.
672 static BOOL
AddListViewColumns(HWND hWnd
)
674 WCHAR buf
[MAX_STRING_LEN
];
678 lvc
.mask
= LVCF_FMT
| LVCF_TEXT
| LVCF_SUBITEM
| LVCF_WIDTH
;
680 /* Add the columns */
681 for (i
= 0; i
< sizeof(columns
) / sizeof(columns
[0]); i
++)
686 /* set width and format */
687 lvc
.cx
= columns
[i
].width
;
688 lvc
.fmt
= columns
[i
].fmt
;
690 LoadStringW(hInst
, columns
[i
].title
, buf
, sizeof(buf
) / sizeof(buf
[0]));
692 if (ListView_InsertColumnW(hWnd
, i
, &lvc
) == -1)
699 /******************************************************************************
700 * Name : AddListViewImageList
701 * Description: Creates an ImageList for the list view control.
702 * Parameters : hWnd - Handle of the list view control.
703 * Returns : Handle of the image list.
705 static HIMAGELIST
AddListViewImageList(HWND hWnd
)
710 hSmall
= ImageList_Create(GetSystemMetrics(SM_CXSMICON
), GetSystemMetrics(SM_CYSMICON
),
713 /* Add default icon to image list */
714 hDefaultIcon
= LoadIconW(hInst
, MAKEINTRESOURCEW(ICO_MAIN
));
715 ImageList_AddIcon(hSmall
, hDefaultIcon
);
716 DestroyIcon(hDefaultIcon
);
718 SendMessageW(hWnd
, LVM_SETIMAGELIST
, LVSIL_SMALL
, (LPARAM
)hSmall
);
723 /******************************************************************************
724 * Name : ResetApplicationList
725 * Description: Empties the app list, if need be, and recreates it.
726 * Parameters : bFirstRun - TRUE if this is the first time this is run, FALSE otherwise
727 * hWnd - handle of the dialog box
728 * hImageList - handle of the image list
729 * Returns : New handle of the image list.
731 static HIMAGELIST
ResetApplicationList(BOOL bFirstRun
, HWND hWnd
, HIMAGELIST hImageList
)
735 hWndListView
= GetDlgItem(hWnd
, IDL_PROGRAMS
);
737 /* if first run, create the image list and add the listview columns */
740 if (!AddListViewColumns(hWndListView
))
743 else /* we need to remove the existing things first */
745 RemoveItemsFromList(hWnd
);
746 ImageList_Destroy(hImageList
);
748 /* reset the list, since it's probably changed if the uninstallation was
753 /* now create the image list and add the applications to the listview */
754 hImageList
= AddListViewImageList(hWndListView
);
756 ReadApplicationsFromRegistry(HKEY_LOCAL_MACHINE
);
757 ReadApplicationsFromRegistry(HKEY_CURRENT_USER
);
759 AddApplicationsToList(hWndListView
, hImageList
);
765 /******************************************************************************
767 * Description: Callback procedure for main tab
768 * Parameters : hWnd - hWnd of the window
769 * msg - reason for calling function
770 * wParam - additional parameter
771 * lParam - additional parameter
772 * Returns : Dependant on message
774 static BOOL CALLBACK
MainDlgProc(HWND hWnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
)
777 static HIMAGELIST hImageList
;
784 hImageList
= ResetApplicationList(TRUE
, hWnd
, hImageList
);
792 RemoveItemsFromList(hWnd
);
793 ImageList_Destroy(hImageList
);
800 nmh
= (LPNMHDR
) lParam
;
807 case LVN_ITEMCHANGED
:
817 switch (LOWORD(wParam
))
820 InstallProgram(hWnd
);
824 selitem
= SendDlgItemMessageW(hWnd
, IDL_PROGRAMS
,
825 LVM_GETNEXTITEM
, -1, LVNI_FOCUSED
|LVNI_SELECTED
);
829 lvItem
.iItem
= selitem
;
830 lvItem
.mask
= LVIF_PARAM
;
832 if (SendDlgItemMessageW(hWnd
, IDL_PROGRAMS
, LVM_GETITEMW
,
833 0, (LPARAM
) &lvItem
))
834 UninstallProgram(lvItem
.lParam
);
837 hImageList
= ResetApplicationList(FALSE
, hWnd
, hImageList
);
841 case IDC_SUPPORT_INFO
:
842 selitem
= SendDlgItemMessageW(hWnd
, IDL_PROGRAMS
,
843 LVM_GETNEXTITEM
, -1, LVNI_FOCUSED
| LVNI_SELECTED
);
847 lvItem
.iItem
= selitem
;
848 lvItem
.mask
= LVIF_PARAM
;
850 if (SendDlgItemMessageW(hWnd
, IDL_PROGRAMS
, LVM_GETITEMW
,
851 0, (LPARAM
) &lvItem
))
852 SupportInfo(hWnd
, lvItem
.lParam
);
864 /******************************************************************************
866 * Description: Main routine for applet
867 * Parameters : hWnd - hWnd of the Control Panel
869 static void StartApplet(HWND hWnd
)
872 PROPSHEETHEADERW psh
;
873 WCHAR tab_title
[MAX_STRING_LEN
], app_title
[MAX_STRING_LEN
];
875 /* Load the strings we will use */
876 LoadStringW(hInst
, IDS_TAB1_TITLE
, tab_title
, sizeof(tab_title
) / sizeof(tab_title
[0]));
877 LoadStringW(hInst
, IDS_CPL_TITLE
, app_title
, sizeof(app_title
) / sizeof(app_title
[0]));
879 /* Fill out the PROPSHEETPAGE */
880 psp
.dwSize
= sizeof (PROPSHEETPAGEW
);
881 psp
.dwFlags
= PSP_USETITLE
;
882 psp
.hInstance
= hInst
;
883 psp
.u
.pszTemplate
= MAKEINTRESOURCEW (IDD_MAIN
);
884 psp
.u2
.pszIcon
= NULL
;
885 psp
.pfnDlgProc
= (DLGPROC
) MainDlgProc
;
886 psp
.pszTitle
= tab_title
;
889 /* Fill out the PROPSHEETHEADER */
890 psh
.dwSize
= sizeof (PROPSHEETHEADERW
);
891 psh
.dwFlags
= PSH_PROPSHEETPAGE
| PSH_USEICONID
;
892 psh
.hwndParent
= hWnd
;
893 psh
.hInstance
= hInst
;
894 psh
.u
.pszIcon
= NULL
;
895 psh
.pszCaption
= app_title
;
898 psh
.pfnCallback
= NULL
;
899 psh
.u2
.nStartPage
= 0;
901 /* Display the property sheet */
902 PropertySheetW (&psh
);
905 /******************************************************************************
907 * Description: Entry point for Control Panel applets
908 * Parameters : hwndCPL - hWnd of the Control Panel
909 * message - reason for calling function
910 * lParam1 - additional parameter
911 * lParam2 - additional parameter
912 * Returns : Dependant on message
914 LONG CALLBACK
CPlApplet(HWND hwndCPL
, UINT message
, LPARAM lParam1
, LPARAM lParam2
)
916 INITCOMMONCONTROLSEX iccEx
;
921 iccEx
.dwSize
= sizeof(iccEx
);
922 iccEx
.dwICC
= ICC_LISTVIEW_CLASSES
| ICC_TAB_CLASSES
;
924 InitCommonControlsEx(&iccEx
);
933 CPLINFO
*appletInfo
= (CPLINFO
*) lParam2
;
935 appletInfo
->idIcon
= ICO_MAIN
;
936 appletInfo
->idName
= IDS_CPL_TITLE
;
937 appletInfo
->idInfo
= IDS_CPL_DESC
;
938 appletInfo
->lData
= 0;
944 StartApplet(hwndCPL
);