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: lib/cpl/system/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."),
108 static void FillSoftwareList(HWND hwndDlg
)
110 TCHAR pszName
[MAX_PATH
];
111 TCHAR pszDisplayName
[MAX_PATH
];
112 TCHAR pszParentKeyName
[MAX_PATH
];
119 BOOL bIsUpdate
= FALSE
;
120 BOOL bIsSystemComponent
= FALSE
;
121 BOOL bShowUpdates
= FALSE
;
125 bShowUpdates
= (SendMessage(GetDlgItem(hwndDlg
, IDC_SHOWUPDATES
), BM_GETCHECK
, 0, 0) == BST_CHECKED
);
127 if (RegOpenKey(HKEY_LOCAL_MACHINE
,
128 _TEXT("Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall"),
129 &hKey
) != ERROR_SUCCESS
)
132 _TEXT("Unable to open Uninstall Key"),
140 while (RegEnumKeyEx (hKey
, i
, pszName
, &dwSize
, NULL
, NULL
, NULL
, &FileTime
) == ERROR_SUCCESS
)
142 if (RegOpenKey(hKey
,pszName
,&hSubKey
)==ERROR_SUCCESS
)
145 dwSize
= sizeof(DWORD
);
146 if (RegQueryValueEx(hSubKey
,
147 _TEXT("SystemComponent"),
151 &dwSize
) == ERROR_SUCCESS
)
153 bIsSystemComponent
= (dwValue
== 0x1);
156 bIsSystemComponent
= FALSE
;
160 bIsUpdate
= (RegQueryValueEx(hSubKey
,
161 _TEXT("ParentKeyName"),
164 (LPBYTE
)pszParentKeyName
,
165 &dwSize
) == ERROR_SUCCESS
);
167 if (RegQueryValueEx(hSubKey
,
168 _TEXT("DisplayName"),
171 (LPBYTE
)pszDisplayName
,
172 &dwSize
) == ERROR_SUCCESS
)
174 if ((!bIsUpdate
) && (!bIsSystemComponent
))
176 index
= (ULONG
) SendDlgItemMessage(hwndDlg
,IDC_SOFTWARELIST
,LB_ADDSTRING
,0,(LPARAM
)pszDisplayName
);
177 SendDlgItemMessage(hwndDlg
,IDC_SOFTWARELIST
,LB_SETITEMDATA
,index
,(LPARAM
)hSubKey
);
179 else if (bIsUpdate
&& bShowUpdates
)
181 index
= (ULONG
) SendDlgItemMessage(hwndDlg
,IDC_SOFTWARELIST
,LB_ADDSTRING
,0,(LPARAM
)pszDisplayName
);
182 SendDlgItemMessage(hwndDlg
,IDC_SOFTWARELIST
,LB_SETITEMDATA
,index
,(LPARAM
)hSubKey
);
194 /* Property page dialog callback */
195 static INT_PTR CALLBACK
196 InstallPageProc(HWND hwndDlg
,UINT uMsg
,WPARAM wParam
,LPARAM lParam
)
198 UNREFERENCED_PARAMETER(lParam
);
202 EnableWindow(GetDlgItem(hwndDlg
,IDC_INSTALL
), FALSE
);
203 FillSoftwareList(hwndDlg
);
207 switch (LOWORD(wParam
))
209 case IDC_SHOWUPDATES
:
210 if (HIWORD(wParam
) == BN_CLICKED
)
212 SendDlgItemMessage(hwndDlg
, IDC_SOFTWARELIST
, LB_RESETCONTENT
, 0, 0);
213 FillSoftwareList(hwndDlg
);
216 case IDC_SOFTWARELIST
:
217 if (HIWORD(wParam
) == LBN_DBLCLK
)
219 CallUninstall(hwndDlg
);
224 CallUninstall(hwndDlg
);
234 /* Property page dialog callback */
235 static INT_PTR CALLBACK
236 RosPageProc(HWND hwndDlg
,UINT uMsg
,WPARAM wParam
,LPARAM lParam
)
238 UNREFERENCED_PARAMETER(lParam
);
239 UNREFERENCED_PARAMETER(wParam
);
240 UNREFERENCED_PARAMETER(hwndDlg
);
252 InitPropSheetPage(PROPSHEETPAGE
*psp
, WORD idDlg
, DLGPROC DlgProc
)
254 ZeroMemory(psp
, sizeof(PROPSHEETPAGE
));
255 psp
->dwSize
= sizeof(PROPSHEETPAGE
);
256 psp
->dwFlags
= PSP_DEFAULT
;
257 psp
->hInstance
= hApplet
;
258 psp
->pszTemplate
= MAKEINTRESOURCE(idDlg
);
259 psp
->pfnDlgProc
= DlgProc
;
268 PROPSHEETPAGE psp
[2];
272 LoadString(hApplet
, IDS_CPLSYSTEMNAME
, Caption
, sizeof(Caption
) / sizeof(TCHAR
));
274 ZeroMemory(&psh
, sizeof(PROPSHEETHEADER
));
275 psh
.dwSize
= sizeof(PROPSHEETHEADER
);
276 psh
.dwFlags
= PSH_PROPSHEETPAGE
| PSH_PROPTITLE
;
277 psh
.hwndParent
= NULL
;
278 psh
.hInstance
= hApplet
;
279 psh
.hIcon
= LoadIcon(hApplet
, MAKEINTRESOURCE(IDI_CPLSYSTEM
));
280 psh
.pszCaption
= Caption
;
281 psh
.nPages
= sizeof(psp
) / sizeof(PROPSHEETPAGE
);
284 psh
.pfnCallback
= NULL
;
286 InitPropSheetPage(&psp
[0], IDD_PROPPAGEINSTALL
, (DLGPROC
) InstallPageProc
);
287 InitPropSheetPage(&psp
[1], IDD_PROPPAGEROSSETUP
, (DLGPROC
) RosPageProc
);
289 return (LONG
)(PropertySheet(&psh
) != -1);
293 /* Control Panel Callback */
295 CPlApplet(HWND hwndCPl
, UINT uMsg
, LPARAM lParam1
, LPARAM lParam2
)
300 UNREFERENCED_PARAMETER(hwndCPl
);
312 CPlInfo
= (CPLINFO
*)lParam2
;
314 CPlInfo
->idIcon
= Applets
[i
].idIcon
;
315 CPlInfo
->idName
= Applets
[i
].idName
;
316 CPlInfo
->idInfo
= Applets
[i
].idDescription
;
320 Applets
[i
].AppletProc();
329 DllMain(HINSTANCE hinstDLL
, DWORD dwReason
, LPVOID lpvReserved
)
331 UNREFERENCED_PARAMETER(lpvReserved
);
334 case DLL_PROCESS_ATTACH
:
335 case DLL_THREAD_ATTACH
: