3 * Copyright (C) 2004 ReactOS Team
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 * PROJECT: ReactOS Software Control Panel
22 * FILE: dll/cpl/appwiz/appwiz.c
23 * PURPOSE: ReactOS Software Control Panel
24 * PROGRAMMER: Gero Kuehn (reactos.filter@gkware.com)
42 #define NUM_APPLETS (1)
44 LONG CALLBACK
SystemApplet(VOID
);
45 INT_PTR CALLBACK
GeneralPageProc(HWND hwndDlg
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
);
46 INT_PTR CALLBACK
ComputerPageProc(HWND hwndDlg
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
);
47 HINSTANCE hApplet
= 0;
50 APPLET Applets
[NUM_APPLETS
] =
52 {IDI_CPLSYSTEM
, IDS_CPLSYSTEMNAME
, IDS_CPLSYSTEMDESCRIPTION
, SystemApplet
}
57 CallUninstall(HWND hwndDlg
)
60 PROCESS_INFORMATION pi
;
64 TCHAR pszUninstallString
[MAX_PATH
];
67 nIndex
= (INT
)SendDlgItemMessage(hwndDlg
, IDC_SOFTWARELIST
, LB_GETCURSEL
, 0, 0);
71 _TEXT("No item selected"),
77 hKey
= (HKEY
)SendDlgItemMessage(hwndDlg
, IDC_SOFTWARELIST
, LB_GETITEMDATA
, (WPARAM
)nIndex
, 0);
81 if (RegQueryValueEx(hKey
,
82 _TEXT("UninstallString"),
85 (LPBYTE
)pszUninstallString
,
86 &dwSize
) == ERROR_SUCCESS
)
88 ZeroMemory(&si
, sizeof(si
));
90 si
.wShowWindow
= SW_SHOW
;
91 if (CreateProcess(NULL
,pszUninstallString
,NULL
,NULL
,FALSE
,0,NULL
,NULL
,&si
,&pi
))
93 CloseHandle(pi
.hProcess
);
94 CloseHandle(pi
.hThread
);
100 _TEXT("Unable to read UninstallString. This entry is invalid or has been created by an MSI installer."),
109 FillSoftwareList(HWND hwndDlg
)
111 TCHAR pszName
[MAX_PATH
];
112 TCHAR pszDisplayName
[MAX_PATH
];
113 TCHAR pszParentKeyName
[MAX_PATH
];
120 BOOL bIsUpdate
= FALSE
;
121 BOOL bIsSystemComponent
= FALSE
;
122 BOOL bShowUpdates
= FALSE
;
126 bShowUpdates
= (SendMessage(GetDlgItem(hwndDlg
, IDC_SHOWUPDATES
), BM_GETCHECK
, 0, 0) == BST_CHECKED
);
128 if (RegOpenKey(HKEY_LOCAL_MACHINE
,
129 _TEXT("Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall"),
130 &hKey
) != ERROR_SUCCESS
)
133 _TEXT("Unable to open Uninstall Key"),
141 while (RegEnumKeyEx (hKey
, i
, pszName
, &dwSize
, NULL
, NULL
, NULL
, &FileTime
) == ERROR_SUCCESS
)
143 if (RegOpenKey(hKey
,pszName
,&hSubKey
) == ERROR_SUCCESS
)
146 dwSize
= sizeof(DWORD
);
147 if (RegQueryValueEx(hSubKey
,
148 _TEXT("SystemComponent"),
152 &dwSize
) == ERROR_SUCCESS
)
154 bIsSystemComponent
= (dwValue
== 0x1);
158 bIsSystemComponent
= FALSE
;
163 bIsUpdate
= (RegQueryValueEx(hSubKey
,
164 _TEXT("ParentKeyName"),
167 (LPBYTE
)pszParentKeyName
,
168 &dwSize
) == ERROR_SUCCESS
);
170 if (RegQueryValueEx(hSubKey
,
171 _TEXT("DisplayName"),
174 (LPBYTE
)pszDisplayName
,
175 &dwSize
) == ERROR_SUCCESS
)
177 if ((!bIsUpdate
) && (!bIsSystemComponent
))
179 ulIndex
= (ULONG
)SendDlgItemMessage(hwndDlg
,IDC_SOFTWARELIST
,LB_ADDSTRING
,0,(LPARAM
)pszDisplayName
);
180 SendDlgItemMessage(hwndDlg
,IDC_SOFTWARELIST
,LB_SETITEMDATA
,ulIndex
,(LPARAM
)hSubKey
);
182 else if (bIsUpdate
&& bShowUpdates
)
184 ulIndex
= (ULONG
)SendDlgItemMessage(hwndDlg
,IDC_SOFTWARELIST
,LB_ADDSTRING
,0,(LPARAM
)pszDisplayName
);
185 SendDlgItemMessage(hwndDlg
,IDC_SOFTWARELIST
,LB_SETITEMDATA
,ulIndex
,(LPARAM
)hSubKey
);
198 /* Property page dialog callback */
199 static INT_PTR CALLBACK
200 InstallPageProc(HWND hwndDlg
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
)
202 UNREFERENCED_PARAMETER(lParam
);
207 EnableWindow(GetDlgItem(hwndDlg
, IDC_INSTALL
), FALSE
);
208 FillSoftwareList(hwndDlg
);
212 switch (LOWORD(wParam
))
214 case IDC_SHOWUPDATES
:
215 if (HIWORD(wParam
) == BN_CLICKED
)
217 SendDlgItemMessage(hwndDlg
, IDC_SOFTWARELIST
, LB_RESETCONTENT
, 0, 0);
218 FillSoftwareList(hwndDlg
);
222 case IDC_SOFTWARELIST
:
223 if (HIWORD(wParam
) == LBN_DBLCLK
)
225 CallUninstall(hwndDlg
);
230 CallUninstall(hwndDlg
);
240 /* Property page dialog callback */
241 static INT_PTR CALLBACK
242 RosPageProc(HWND hwndDlg
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
)
244 UNREFERENCED_PARAMETER(lParam
);
245 UNREFERENCED_PARAMETER(wParam
);
246 UNREFERENCED_PARAMETER(hwndDlg
);
259 InitPropSheetPage(PROPSHEETPAGE
*psp
, WORD idDlg
, DLGPROC DlgProc
)
261 ZeroMemory(psp
, sizeof(PROPSHEETPAGE
));
262 psp
->dwSize
= sizeof(PROPSHEETPAGE
);
263 psp
->dwFlags
= PSP_DEFAULT
;
264 psp
->hInstance
= hApplet
;
265 psp
->pszTemplate
= MAKEINTRESOURCE(idDlg
);
266 psp
->pfnDlgProc
= DlgProc
;
275 PROPSHEETPAGE psp
[2];
279 LoadString(hApplet
, IDS_CPLSYSTEMNAME
, Caption
, sizeof(Caption
) / sizeof(TCHAR
));
281 ZeroMemory(&psh
, sizeof(PROPSHEETHEADER
));
282 psh
.dwSize
= sizeof(PROPSHEETHEADER
);
283 psh
.dwFlags
= PSH_PROPSHEETPAGE
;
284 psh
.hwndParent
= NULL
;
285 psh
.hInstance
= hApplet
;
286 psh
.hIcon
= LoadIcon(hApplet
, MAKEINTRESOURCE(IDI_CPLSYSTEM
));
287 psh
.pszCaption
= Caption
;
288 psh
.nPages
= sizeof(psp
) / sizeof(PROPSHEETPAGE
);
291 psh
.pfnCallback
= NULL
;
293 InitPropSheetPage(&psp
[0], IDD_PROPPAGEINSTALL
, (DLGPROC
) InstallPageProc
);
294 InitPropSheetPage(&psp
[1], IDD_PROPPAGEROSSETUP
, (DLGPROC
) RosPageProc
);
296 return (LONG
)(PropertySheet(&psh
) != -1);
300 /* Control Panel Callback */
302 CPlApplet(HWND hwndCPl
, UINT uMsg
, LPARAM lParam1
, LPARAM lParam2
)
307 UNREFERENCED_PARAMETER(hwndCPl
);
319 CPlInfo
= (CPLINFO
*)lParam2
;
321 CPlInfo
->idIcon
= Applets
[i
].idIcon
;
322 CPlInfo
->idName
= Applets
[i
].idName
;
323 CPlInfo
->idInfo
= Applets
[i
].idDescription
;
327 Applets
[i
].AppletProc();
336 DllMain(HINSTANCE hinstDLL
, DWORD dwReason
, LPVOID lpvReserved
)
338 UNREFERENCED_PARAMETER(lpvReserved
);
342 case DLL_PROCESS_ATTACH
:
343 case DLL_THREAD_ATTACH
:
353 WelcomeDlgProc(HWND hwndDlg
,
361 PropSheet_SetWizButtons(GetParent(hwndDlg
), 0);
364 switch(HIWORD(wParam
))
367 if (SendDlgItemMessage(hwndDlg
, IDC_SHORTCUT_LOCATION
, WM_GETTEXTLENGTH
, 0, 0))
369 PropSheet_SetWizButtons(GetParent(hwndDlg
), PSWIZB_NEXT
);
373 PropSheet_SetWizButtons(GetParent(hwndDlg
), 0);
383 FinishDlgProc(HWND hwndDlg
,
391 PropSheet_SetWizButtons(GetParent(hwndDlg
), PSWIZB_BACK
| PSWIZB_FINISH
);
399 NewLinkHere(HWND hwndCPl
, UINT uMsg
, LPARAM lParam1
, LPARAM lParam2
)
401 PROPSHEETHEADERW psh
;
402 HPROPSHEETPAGE ahpsp
[2];
406 /* Create the Welcome page */
407 psp
.dwSize
= sizeof(PROPSHEETPAGE
);
408 psp
.dwFlags
= PSP_DEFAULT
| PSP_HIDEHEADER
;
409 psp
.hInstance
= hApplet
;
410 psp
.pfnDlgProc
= WelcomeDlgProc
;
411 psp
.pszTemplate
= MAKEINTRESOURCE(IDD_SHORTCUT_LOCATION
);
412 ahpsp
[nPages
++] = CreatePropertySheetPage(&psp
);
414 /* Create the Finish page */
415 psp
.dwFlags
= PSP_DEFAULT
| PSP_HIDEHEADER
;
416 psp
.pfnDlgProc
= FinishDlgProc
;
417 psp
.pszTemplate
= MAKEINTRESOURCE(IDD_SHORTCUT_FINISH
);
418 ahpsp
[nPages
++] = CreatePropertySheetPage(&psp
);
421 /* Create the property sheet */
422 psh
.dwSize
= sizeof(PROPSHEETHEADER
);
423 psh
.dwFlags
= PSH_WIZARD97
| PSH_WATERMARK
;
424 psh
.hInstance
= hApplet
;
425 psh
.hwndParent
= NULL
;
429 psh
.pszbmWatermark
= MAKEINTRESOURCE(IDB_WATERMARK
);
431 /* Display the wizard */