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
= 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 /* Property page dialog callback */
109 static INT_PTR CALLBACK
110 InstallPageProc(HWND hwndDlg
,UINT uMsg
,WPARAM wParam
,LPARAM lParam
)
112 TCHAR pszName
[MAX_PATH
];
113 TCHAR pszDisplayName
[MAX_PATH
];
125 EnableWindow(GetDlgItem(hwndDlg
,IDC_INSTALL
), FALSE
);
126 if (RegOpenKey(HKEY_LOCAL_MACHINE
,
127 _TEXT("Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall"),
128 &hKey
) != ERROR_SUCCESS
)
131 _TEXT("Unable to open Uninstall Key"),
139 while (RegEnumKeyEx (hKey
, i
, pszName
, &dwSize
, NULL
, NULL
, NULL
, &FileTime
) == ERROR_SUCCESS
)
141 if (RegOpenKey(hKey
,pszName
,&hSubKey
)==ERROR_SUCCESS
)
145 if (RegQueryValueEx(hSubKey
,
146 _TEXT("DisplayName"),
149 (LPBYTE
)pszDisplayName
,
150 &dwSize
) == ERROR_SUCCESS
)
152 index
= SendDlgItemMessage(hwndDlg
,IDC_SOFTWARELIST
,LB_ADDSTRING
,0,(LPARAM
)pszDisplayName
);
153 SendDlgItemMessage(hwndDlg
,IDC_SOFTWARELIST
,LB_SETITEMDATA
,index
,(LPARAM
)hSubKey
);
165 switch (LOWORD(wParam
))
167 case IDC_SOFTWARELIST
:
168 if (HIWORD(wParam
) == LBN_DBLCLK
)
170 CallUninstall(hwndDlg
);
175 CallUninstall(hwndDlg
);
185 /* Property page dialog callback */
186 static INT_PTR CALLBACK
187 RosPageProc(HWND hwndDlg
,UINT uMsg
,WPARAM wParam
,LPARAM lParam
)
200 InitPropSheetPage(PROPSHEETPAGE
*psp
, WORD idDlg
, DLGPROC DlgProc
)
202 ZeroMemory(psp
, sizeof(PROPSHEETPAGE
));
203 psp
->dwSize
= sizeof(PROPSHEETPAGE
);
204 psp
->dwFlags
= PSP_DEFAULT
;
205 psp
->hInstance
= hApplet
;
206 psp
->pszTemplate
= MAKEINTRESOURCE(idDlg
);
207 psp
->pfnDlgProc
= DlgProc
;
216 PROPSHEETPAGE psp
[2];
220 LoadString(hApplet
, IDS_CPLSYSTEMNAME
, Caption
, sizeof(Caption
) / sizeof(TCHAR
));
222 ZeroMemory(&psh
, sizeof(PROPSHEETHEADER
));
223 psh
.dwSize
= sizeof(PROPSHEETHEADER
);
224 psh
.dwFlags
= PSH_PROPSHEETPAGE
| PSH_PROPTITLE
;
225 psh
.hwndParent
= NULL
;
226 psh
.hInstance
= hApplet
;
227 psh
.hIcon
= LoadIcon(hApplet
, MAKEINTRESOURCE(IDI_CPLSYSTEM
));
228 psh
.pszCaption
= Caption
;
229 psh
.nPages
= sizeof(psp
) / sizeof(PROPSHEETPAGE
);
232 psh
.pfnCallback
= NULL
;
234 InitPropSheetPage(&psp
[0], IDD_PROPPAGEINSTALL
, InstallPageProc
);
235 InitPropSheetPage(&psp
[1], IDD_PROPPAGEROSSETUP
, RosPageProc
);
237 return (LONG
)(PropertySheet(&psh
) != -1);
241 /* Control Panel Callback */
243 CPlApplet(HWND hwndCPl
, UINT uMsg
, LPARAM lParam1
, LPARAM lParam2
)
258 CPlInfo
= (CPLINFO
*)lParam2
;
260 CPlInfo
->idIcon
= Applets
[i
].idIcon
;
261 CPlInfo
->idName
= Applets
[i
].idName
;
262 CPlInfo
->idInfo
= Applets
[i
].idDescription
;
266 Applets
[i
].AppletProc();
275 DllMain(HINSTANCE hinstDLL
, DWORD dwReason
, LPVOID lpvReserved
)
279 case DLL_PROCESS_ATTACH
:
280 case DLL_THREAD_ATTACH
: