2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: System setup
4 * FILE: dll/win32/syssetup/wizard.c
5 * PURPOSE: GUI controls
6 * PROGRAMMERS: Eric Kohl
7 * Pierre Schweitzer <heis_spiter@hotmail.com>
8 * Ismael Ferreras Morezuelas <swyterzone+ros@gmail.com>
11 /* INCLUDES *****************************************************************/
25 #define PM_REGISTRATION_NOTIFY (WM_APP + 1)
26 /* Private Message used to communicate progress from the background
27 registration thread to the main thread.
28 wParam = 0 Registration in progress
29 = 1 Registration completed
30 lParam = Pointer to a REGISTRATIONNOTIFY structure */
32 typedef struct _REGISTRATIONNOTIFY
38 } REGISTRATIONNOTIFY
, *PREGISTRATIONNOTIFY
;
40 typedef struct _REGISTRATIONDATA
46 } REGISTRATIONDATA
, *PREGISTRATIONDATA
;
49 /* FUNCTIONS ****************************************************************/
51 extern void WINAPI
Control_RunDLLW(HWND hWnd
, HINSTANCE hInst
, LPCWSTR cmd
, DWORD nCmdShow
);
54 GetRosInstallCD(WCHAR
*pwszPath
, DWORD cchPathMax
);
58 CenterWindow(HWND hWnd
)
64 hWndParent
= GetParent(hWnd
);
65 if (hWndParent
== NULL
)
66 hWndParent
= GetDesktopWindow();
68 GetWindowRect(hWndParent
, &rcParent
);
69 GetWindowRect(hWnd
, &rcWindow
);
73 ((rcParent
.right
- rcParent
.left
) - (rcWindow
.right
- rcWindow
.left
)) / 2,
74 ((rcParent
.bottom
- rcParent
.top
) - (rcWindow
.bottom
- rcWindow
.top
)) / 2,
84 LOGFONTW LogFont
= {0};
88 LogFont
.lfWeight
= FW_HEAVY
;
89 wcscpy(LogFont
.lfFaceName
, L
"MS Shell Dlg");
92 LogFont
.lfHeight
= -MulDiv(12, GetDeviceCaps(hdc
, LOGPIXELSY
), 72);
94 hFont
= CreateFontIndirectW(&LogFont
);
105 LOGFONTW tmpFont
= {0};
109 /* Grabs the Drawing Context */
112 tmpFont
.lfHeight
= -MulDiv(8, GetDeviceCaps(hDc
, LOGPIXELSY
), 72);
113 tmpFont
.lfWeight
= FW_HEAVY
;
114 wcscpy(tmpFont
.lfFaceName
, L
"MS Shell Dlg");
116 hBoldFont
= CreateFontIndirectW(&tmpFont
);
118 ReleaseDC(NULL
, hDc
);
123 static INT_PTR CALLBACK
124 GplDlgProc(HWND hwndDlg
,
129 HRSRC GplTextResource
;
139 GplTextResource
= FindResourceW(hDllInstance
, MAKEINTRESOURCE(IDR_GPL
), L
"RT_TEXT");
140 if (NULL
== GplTextResource
)
144 Size
= SizeofResource(hDllInstance
, GplTextResource
);
149 GplText
= HeapAlloc(GetProcessHeap(), 0, Size
+ 1);
154 GplTextMem
= LoadResource(hDllInstance
, GplTextResource
);
155 if (NULL
== GplTextMem
)
157 HeapFree(GetProcessHeap(), 0, GplText
);
160 GplTextLocked
= LockResource(GplTextMem
);
161 if (NULL
== GplTextLocked
)
163 HeapFree(GetProcessHeap(), 0, GplText
);
166 memcpy(GplText
, GplTextLocked
, Size
);
167 GplText
[Size
] = '\0';
168 SendMessageA(GetDlgItem(hwndDlg
, IDC_GPL_TEXT
), WM_SETTEXT
, 0, (LPARAM
) GplText
);
169 HeapFree(GetProcessHeap(), 0, GplText
);
170 SetFocus(GetDlgItem(hwndDlg
, IDOK
));
174 EndDialog(hwndDlg
, IDCANCEL
);
178 if (HIWORD(wParam
) == BN_CLICKED
&& IDOK
== LOWORD(wParam
))
180 EndDialog(hwndDlg
, IDOK
);
192 static INT_PTR CALLBACK
193 WelcomeDlgProc(HWND hwndDlg
,
198 PSETUPDATA pSetupData
;
200 pSetupData
= (PSETUPDATA
)GetWindowLongPtr(hwndDlg
, DWLP_USER
);
209 /* Get pointer to the global setup data */
210 pSetupData
= (PSETUPDATA
)((LPPROPSHEETPAGE
)lParam
)->lParam
;
211 SetWindowLongPtr(hwndDlg
, DWLP_USER
, (LONG_PTR
)pSetupData
);
213 hwndControl
= GetParent(hwndDlg
);
215 /* Center the wizard window */
216 CenterWindow (hwndControl
);
218 /* Hide the system menu */
219 dwStyle
= GetWindowLongPtr(hwndControl
, GWL_STYLE
);
220 SetWindowLongPtr(hwndControl
, GWL_STYLE
, dwStyle
& ~WS_SYSMENU
);
222 /* Hide and disable the 'Cancel' button */
223 hwndControl
= GetDlgItem(GetParent(hwndDlg
), IDCANCEL
);
224 ShowWindow (hwndControl
, SW_HIDE
);
225 EnableWindow (hwndControl
, FALSE
);
228 SendDlgItemMessage(hwndDlg
,
231 (WPARAM
)pSetupData
->hTitleFont
,
239 LPNMHDR lpnm
= (LPNMHDR
)lParam
;
244 LogItem(L
"BEGIN", L
"WelcomePage");
245 /* Enable the Next button */
246 PropSheet_SetWizButtons(GetParent(hwndDlg
), PSWIZB_NEXT
);
247 if (pSetupData
->UnattendSetup
)
249 SetWindowLongPtr(hwndDlg
, DWLP_MSGRESULT
, IDD_ACKPAGE
);
255 LogItem(L
"END", L
"WelcomePage");
259 pSetupData
->UnattendSetup
= FALSE
;
276 static INT_PTR CALLBACK
277 AckPageDlgProc(HWND hwndDlg
,
284 PWCHAR End
, CurrentProject
;
285 INT ProjectsSize
, ProjectsCount
;
286 PSETUPDATA pSetupData
;
288 pSetupData
= (PSETUPDATA
)GetWindowLongPtr(hwndDlg
, DWLP_USER
);
294 pSetupData
= (PSETUPDATA
)((LPPROPSHEETPAGE
)lParam
)->lParam
;
295 SetWindowLongPtr(hwndDlg
, DWLP_USER
, (LONG_PTR
)pSetupData
);
301 Projects
= HeapAlloc(GetProcessHeap(), 0, ProjectsSize
* sizeof(WCHAR
));
302 if (NULL
== Projects
)
306 ProjectsCount
= LoadStringW(hDllInstance
, IDS_ACKPROJECTS
, Projects
, ProjectsSize
);
307 if (0 == ProjectsCount
)
309 HeapFree(GetProcessHeap(), 0, Projects
);
312 if (ProjectsCount
< ProjectsSize
- 1)
316 HeapFree(GetProcessHeap(), 0, Projects
);
320 CurrentProject
= Projects
;
321 while (*CurrentProject
!= L
'\0')
323 End
= wcschr(CurrentProject
, L
'\n');
328 (void)ListBox_AddString(GetDlgItem(hwndDlg
, IDC_PROJECTS
), CurrentProject
);
331 CurrentProject
= End
+ 1;
335 CurrentProject
+= wcslen(CurrentProject
);
338 HeapFree(GetProcessHeap(), 0, Projects
);
343 if (HIWORD(wParam
) == BN_CLICKED
&& IDC_VIEWGPL
== LOWORD(wParam
))
345 DialogBox(hDllInstance
, MAKEINTRESOURCE(IDD_GPL
), NULL
, GplDlgProc
);
346 SetForegroundWindow(GetParent(hwndDlg
));
352 lpnm
= (LPNMHDR
)lParam
;
357 /* Enable the Back and Next buttons */
358 PropSheet_SetWizButtons(GetParent(hwndDlg
), PSWIZB_BACK
| PSWIZB_NEXT
);
359 if (pSetupData
->UnattendSetup
)
361 SetWindowLongPtr(hwndDlg
, DWLP_MSGRESULT
, IDD_LOCALEPAGE
);
367 pSetupData
->UnattendSetup
= FALSE
;
385 WriteOwnerSettings(WCHAR
* OwnerName
,
386 WCHAR
* OwnerOrganization
)
391 res
= RegOpenKeyExW(HKEY_LOCAL_MACHINE
,
392 L
"Software\\Microsoft\\Windows NT\\CurrentVersion",
397 if (res
!= ERROR_SUCCESS
)
402 res
= RegSetValueExW(hKey
,
407 (wcslen(OwnerName
) + 1) * sizeof(WCHAR
));
409 if (res
!= ERROR_SUCCESS
)
415 res
= RegSetValueExW(hKey
,
416 L
"RegisteredOrganization",
419 (LPBYTE
)OwnerOrganization
,
420 (wcslen(OwnerOrganization
) + 1) * sizeof(WCHAR
));
423 return (res
== ERROR_SUCCESS
);
426 static INT_PTR CALLBACK
427 OwnerPageDlgProc(HWND hwndDlg
,
433 WCHAR OwnerOrganization
[51];
435 WCHAR ErrorName
[256];
437 PSETUPDATA pSetupData
;
439 pSetupData
= (PSETUPDATA
)GetWindowLongPtr(hwndDlg
, DWLP_USER
);
445 pSetupData
= (PSETUPDATA
)((LPPROPSHEETPAGE
)lParam
)->lParam
;
446 SetWindowLongPtr(hwndDlg
, DWLP_USER
, (LONG_PTR
)pSetupData
);
448 /* set a localized ('Owner') placeholder string as default */
449 if (LoadStringW(hDllInstance
, IDS_MACHINE_OWNER_NAME
, OwnerName
, _countof(OwnerName
)))
451 SendDlgItemMessage(hwndDlg
, IDC_OWNERNAME
, WM_SETTEXT
, 0, (LPARAM
)OwnerName
);
454 SendDlgItemMessage(hwndDlg
, IDC_OWNERNAME
, EM_LIMITTEXT
, 50, 0);
455 SendDlgItemMessage(hwndDlg
, IDC_OWNERORGANIZATION
, EM_LIMITTEXT
, 50, 0);
457 /* Set focus to owner name */
458 SetFocus(GetDlgItem(hwndDlg
, IDC_OWNERNAME
));
460 /* Select the default text to quickly overwrite it by typing */
461 SendDlgItemMessage(hwndDlg
, IDC_OWNERNAME
, EM_SETSEL
, 0, -1);
468 lpnm
= (LPNMHDR
)lParam
;
473 /* Enable the Back and Next buttons */
474 PropSheet_SetWizButtons(GetParent(hwndDlg
), PSWIZB_BACK
| PSWIZB_NEXT
);
475 if (pSetupData
->UnattendSetup
)
477 SendMessage(GetDlgItem(hwndDlg
, IDC_OWNERNAME
), WM_SETTEXT
, 0, (LPARAM
)pSetupData
->OwnerName
);
478 SendMessage(GetDlgItem(hwndDlg
, IDC_OWNERORGANIZATION
), WM_SETTEXT
, 0, (LPARAM
)pSetupData
->OwnerOrganization
);
479 if (WriteOwnerSettings(pSetupData
->OwnerName
, pSetupData
->OwnerOrganization
))
481 SetWindowLongPtr(hwndDlg
, DWLP_MSGRESULT
, IDD_COMPUTERPAGE
);
489 if (GetDlgItemTextW(hwndDlg
, IDC_OWNERNAME
, OwnerName
, 50) == 0)
491 if (0 == LoadStringW(hDllInstance
, IDS_REACTOS_SETUP
, Title
, ARRAYSIZE(Title
)))
493 wcscpy(Title
, L
"ReactOS Setup");
495 if (0 == LoadStringW(hDllInstance
, IDS_WZD_NAME
, ErrorName
, ARRAYSIZE(ErrorName
)))
497 wcscpy(ErrorName
, L
"Setup cannot continue until you enter your name.");
499 MessageBoxW(hwndDlg
, ErrorName
, Title
, MB_ICONERROR
| MB_OK
);
501 SetFocus(GetDlgItem(hwndDlg
, IDC_OWNERNAME
));
502 SetWindowLongPtr(hwndDlg
, DWLP_MSGRESULT
, -1);
507 OwnerOrganization
[0] = 0;
508 GetDlgItemTextW(hwndDlg
, IDC_OWNERORGANIZATION
, OwnerOrganization
, 50);
510 if (!WriteOwnerSettings(OwnerName
, OwnerOrganization
))
512 SetFocus(GetDlgItem(hwndDlg
, IDC_OWNERNAME
));
513 SetWindowLongPtr(hwndDlg
, DWLP_MSGRESULT
, -1);
518 pSetupData
->UnattendSetup
= FALSE
;
536 WriteComputerSettings(WCHAR
* ComputerName
, HWND hwndDlg
)
539 WCHAR ErrorComputerName
[256];
541 if (!SetComputerNameW(ComputerName
))
545 if (0 == LoadStringW(hDllInstance
, IDS_REACTOS_SETUP
, Title
, ARRAYSIZE(Title
)))
547 wcscpy(Title
, L
"ReactOS Setup");
549 if (0 == LoadStringW(hDllInstance
, IDS_WZD_SETCOMPUTERNAME
, ErrorComputerName
,
550 ARRAYSIZE(ErrorComputerName
)))
552 wcscpy(ErrorComputerName
, L
"Setup failed to set the computer name.");
554 MessageBoxW(hwndDlg
, ErrorComputerName
, Title
, MB_ICONERROR
| MB_OK
);
560 /* Try to also set DNS hostname */
561 SetComputerNameExW(ComputerNamePhysicalDnsHostname
, ComputerName
);
563 /* Set the accounts domain name */
564 SetAccountsDomainSid(NULL
, ComputerName
);
572 WriteDefaultLogonData(LPWSTR Domain
)
574 WCHAR szAdministratorName
[256];
578 if (LoadStringW(hDllInstance
,
579 IDS_ADMINISTRATOR_NAME
,
581 ARRAYSIZE(szAdministratorName
)) == 0)
583 wcscpy(szAdministratorName
, L
"Administrator");
586 lError
= RegOpenKeyExW(HKEY_LOCAL_MACHINE
,
587 L
"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon",
591 if (lError
!= ERROR_SUCCESS
)
594 lError
= RegSetValueEx(hKey
,
595 L
"DefaultDomainName",
599 (wcslen(Domain
)+ 1) * sizeof(WCHAR
));
600 if (lError
!= ERROR_SUCCESS
)
602 DPRINT1("RegSetValueEx(\"DefaultDomainName\") failed!\n");
605 lError
= RegSetValueEx(hKey
,
609 (LPBYTE
)szAdministratorName
,
610 (wcslen(szAdministratorName
)+ 1) * sizeof(WCHAR
));
611 if (lError
!= ERROR_SUCCESS
)
613 DPRINT1("RegSetValueEx(\"DefaultUserName\") failed!\n");
622 /* lpBuffer will be filled with a 15-char string (plus the null terminator) */
624 GenerateComputerName(LPWSTR lpBuffer
)
626 static const WCHAR Chars
[] = L
"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
627 static const unsigned cChars
= sizeof(Chars
) / sizeof(WCHAR
) - 1;
630 wcscpy(lpBuffer
, L
"REACTOS-");
632 srand(GetTickCount());
634 /* fill in 7 characters */
635 for (i
= 8; i
< 15; i
++)
636 lpBuffer
[i
] = Chars
[rand() % cChars
];
638 lpBuffer
[15] = UNICODE_NULL
; /* NULL-terminate */
641 static INT_PTR CALLBACK
642 ComputerPageDlgProc(HWND hwndDlg
,
647 WCHAR ComputerName
[MAX_COMPUTERNAME_LENGTH
+ 1];
648 WCHAR Password1
[128];
649 WCHAR Password2
[128];
652 WCHAR EmptyComputerName
[256], NotMatchPassword
[256], WrongPassword
[256];
654 PSETUPDATA pSetupData
;
656 pSetupData
= (PSETUPDATA
)GetWindowLongPtr(hwndDlg
, DWLP_USER
);
658 if (0 == LoadStringW(hDllInstance
, IDS_REACTOS_SETUP
, Title
, ARRAYSIZE(Title
)))
660 wcscpy(Title
, L
"ReactOS Setup");
666 pSetupData
= (PSETUPDATA
)((LPPROPSHEETPAGE
)lParam
)->lParam
;
667 SetWindowLongPtr(hwndDlg
, DWLP_USER
, (LONG_PTR
)pSetupData
);
669 /* Generate a new pseudo-random computer name */
670 GenerateComputerName(ComputerName
);
672 /* Display current computer name */
673 SetDlgItemTextW(hwndDlg
, IDC_COMPUTERNAME
, ComputerName
);
675 /* Set text limits */
676 SendDlgItemMessage(hwndDlg
, IDC_COMPUTERNAME
, EM_LIMITTEXT
, MAX_COMPUTERNAME_LENGTH
, 0);
677 SendDlgItemMessage(hwndDlg
, IDC_ADMINPASSWORD1
, EM_LIMITTEXT
, 127, 0);
678 SendDlgItemMessage(hwndDlg
, IDC_ADMINPASSWORD2
, EM_LIMITTEXT
, 127, 0);
680 /* Set focus to computer name */
681 SetFocus(GetDlgItem(hwndDlg
, IDC_COMPUTERNAME
));
682 if (pSetupData
->UnattendSetup
)
684 SendMessage(GetDlgItem(hwndDlg
, IDC_COMPUTERNAME
), WM_SETTEXT
, 0, (LPARAM
)pSetupData
->ComputerName
);
685 SendMessage(GetDlgItem(hwndDlg
, IDC_ADMINPASSWORD1
), WM_SETTEXT
, 0, (LPARAM
)pSetupData
->AdminPassword
);
686 SendMessage(GetDlgItem(hwndDlg
, IDC_ADMINPASSWORD2
), WM_SETTEXT
, 0, (LPARAM
)pSetupData
->AdminPassword
);
687 WriteComputerSettings(pSetupData
->ComputerName
, NULL
);
688 SetAdministratorPassword(pSetupData
->AdminPassword
);
691 /* Store the administrator account name as the default user name */
692 WriteDefaultLogonData(pSetupData
->ComputerName
);
698 lpnm
= (LPNMHDR
)lParam
;
703 /* Enable the Back and Next buttons */
704 PropSheet_SetWizButtons(GetParent(hwndDlg
), PSWIZB_BACK
| PSWIZB_NEXT
);
705 if (pSetupData
->UnattendSetup
&& WriteComputerSettings(pSetupData
->ComputerName
, hwndDlg
))
707 SetWindowLongPtr(hwndDlg
, DWLP_MSGRESULT
, IDD_THEMEPAGE
);
713 if (0 == GetDlgItemTextW(hwndDlg
, IDC_COMPUTERNAME
, ComputerName
, MAX_COMPUTERNAME_LENGTH
+ 1))
715 if (0 == LoadStringW(hDllInstance
, IDS_WZD_COMPUTERNAME
, EmptyComputerName
,
716 ARRAYSIZE(EmptyComputerName
)))
718 wcscpy(EmptyComputerName
, L
"Setup cannot continue until you enter the name of your computer.");
720 MessageBoxW(hwndDlg
, EmptyComputerName
, Title
, MB_ICONERROR
| MB_OK
);
721 SetFocus(GetDlgItem(hwndDlg
, IDC_COMPUTERNAME
));
722 SetWindowLongPtr(hwndDlg
, DWLP_MSGRESULT
, -1);
726 /* No need to check computer name for invalid characters,
727 * SetComputerName() will do it for us */
729 if (!WriteComputerSettings(ComputerName
, hwndDlg
))
731 SetFocus(GetDlgItem(hwndDlg
, IDC_COMPUTERNAME
));
732 SetWindowLongPtr(hwndDlg
, DWLP_MSGRESULT
, -1);
737 /* Check if admin passwords have been entered */
738 if ((GetDlgItemText(hwndDlg
, IDC_ADMINPASSWORD1
, Password1
, 128) == 0) ||
739 (GetDlgItemText(hwndDlg
, IDC_ADMINPASSWORD2
, Password2
, 128) == 0))
741 if (0 == LoadStringW(hDllInstance
, IDS_WZD_PASSWORDEMPTY
, EmptyPassword
,
742 ARRAYSIZE(EmptyPassword
)))
744 wcscpy(EmptyPassword
, L
"You must enter a password !");
746 MessageBoxW(hwndDlg
, EmptyPassword
, Title
, MB_ICONERROR
| MB_OK
);
747 SetWindowLongPtr(hwndDlg
, DWLP_MSGRESULT
, -1);
751 GetDlgItemTextW(hwndDlg
, IDC_ADMINPASSWORD1
, Password1
, 128);
752 GetDlgItemTextW(hwndDlg
, IDC_ADMINPASSWORD2
, Password2
, 128);
754 /* Check if passwords match */
755 if (wcscmp(Password1
, Password2
))
757 if (0 == LoadStringW(hDllInstance
, IDS_WZD_PASSWORDMATCH
, NotMatchPassword
,
758 ARRAYSIZE(NotMatchPassword
)))
760 wcscpy(NotMatchPassword
, L
"The passwords you entered do not match. Please enter the desired password again.");
762 MessageBoxW(hwndDlg
, NotMatchPassword
, Title
, MB_ICONERROR
| MB_OK
);
763 SetWindowLongPtr(hwndDlg
, DWLP_MSGRESULT
, -1);
767 /* Check password for invalid characters */
768 Password
= (PWCHAR
)Password1
;
771 if (!isprint(*Password
))
773 if (0 == LoadStringW(hDllInstance
, IDS_WZD_PASSWORDCHAR
, WrongPassword
,
774 ARRAYSIZE(WrongPassword
)))
776 wcscpy(WrongPassword
, L
"The password you entered contains invalid characters. Please enter a cleaned password.");
778 MessageBoxW(hwndDlg
, WrongPassword
, Title
, MB_ICONERROR
| MB_OK
);
779 SetWindowLongPtr(hwndDlg
, DWLP_MSGRESULT
, -1);
785 /* Set admin password */
786 SetAdministratorPassword(Password1
);
790 pSetupData
->UnattendSetup
= FALSE
;
808 SetKeyboardLayoutName(HWND hwnd
)
811 TCHAR szLayoutPath
[256];
812 TCHAR szLocaleName
[32];
816 if (RegOpenKeyEx(HKEY_LOCAL_MACHINE
,
817 _T("SYSTEM\\CurrentControlSet\\Control\\NLS\\Locale"),
823 dwValueSize
= 16 * sizeof(TCHAR
);
824 if (RegQueryValueEx(hKey
,
835 _tcscpy(szLayoutPath
,
836 _T("SYSTEM\\CurrentControlSet\\Control\\Keyboard Layouts\\"));
837 _tcscat(szLayoutPath
,
840 if (RegOpenKeyEx(HKEY_LOCAL_MACHINE
,
847 dwValueSize
= 32 * sizeof(TCHAR
);
848 if (RegQueryValueEx(hKey
,
865 RunControlPanelApplet(HWND hwnd
, PCWSTR pwszCPLParameters
)
868 STARTUPINFOW StartupInfo
;
869 PROCESS_INFORMATION ProcessInformation
;
870 WCHAR CmdLine
[MAX_PATH
] = L
"rundll32.exe shell32.dll,Control_RunDLL ";
872 if (!pwszCPLParameters
)
874 MessageBoxW(hwnd
, L
"Error: Failed to launch the Control Panel Applet.", NULL
, MB_ICONERROR
);
878 ZeroMemory(&StartupInfo
, sizeof(StartupInfo
));
879 StartupInfo
.cb
= sizeof(StartupInfo
);
880 ZeroMemory(&ProcessInformation
, sizeof(ProcessInformation
));
882 ASSERT(_countof(CmdLine
) > wcslen(CmdLine
) + wcslen(pwszCPLParameters
));
883 wcscat(CmdLine
, pwszCPLParameters
);
885 if (!CreateProcessW(NULL
,
894 &ProcessInformation
))
896 MessageBoxW(hwnd
, L
"Error: Failed to launch the Control Panel Applet.", NULL
, MB_ICONERROR
);
900 while ((MsgWaitForMultipleObjects(1, &ProcessInformation
.hProcess
, FALSE
, INFINITE
, QS_ALLINPUT
|QS_ALLPOSTMESSAGE
)) != WAIT_OBJECT_0
)
902 while (PeekMessageW(&msg
, NULL
, 0, 0, PM_REMOVE
))
904 TranslateMessage(&msg
);
905 DispatchMessageW(&msg
);
908 CloseHandle(ProcessInformation
.hThread
);
909 CloseHandle(ProcessInformation
.hProcess
);
914 WriteUserLocale(VOID
)
920 lcid
= GetSystemDefaultLCID();
922 if (GetLocaleInfoW(MAKELCID(lcid
, SORT_DEFAULT
), LOCALE_ILANGUAGE
, Locale
, ARRAYSIZE(Locale
)) != 0)
924 if (RegCreateKeyExW(HKEY_CURRENT_USER
, L
"Control Panel\\International",
925 0, NULL
, REG_OPTION_NON_VOLATILE
,
926 KEY_WRITE
, NULL
, &hKey
, NULL
) == ERROR_SUCCESS
)
928 RegSetValueExW(hKey
, L
"Locale", 0, REG_SZ
, (LPBYTE
)Locale
, (wcslen(Locale
) + 1) * sizeof(WCHAR
));
934 static INT_PTR CALLBACK
935 LocalePageDlgProc(HWND hwndDlg
,
940 PSETUPDATA SetupData
;
942 /* Retrieve pointer to the global setup data */
943 SetupData
= (PSETUPDATA
)GetWindowLongPtr(hwndDlg
, GWLP_USERDATA
);
949 /* Save pointer to the global setup data */
950 SetupData
= (PSETUPDATA
)((LPPROPSHEETPAGE
)lParam
)->lParam
;
951 SetWindowLongPtr(hwndDlg
, GWLP_USERDATA
, (DWORD_PTR
)SetupData
);
954 SetKeyboardLayoutName(GetDlgItem(hwndDlg
, IDC_LAYOUTTEXT
));
959 if (HIWORD(wParam
) == BN_CLICKED
)
961 switch (LOWORD(wParam
))
963 case IDC_CUSTOMLOCALE
:
964 RunControlPanelApplet(hwndDlg
, L
"intl.cpl,,5");
965 /* FIXME: Update input locale name */
968 case IDC_CUSTOMLAYOUT
:
969 RunControlPanelApplet(hwndDlg
, L
"input.dll,@1");
977 LPNMHDR lpnm
= (LPNMHDR
)lParam
;
982 /* Enable the Back and Next buttons */
983 PropSheet_SetWizButtons(GetParent(hwndDlg
), PSWIZB_BACK
| PSWIZB_NEXT
);
984 if (SetupData
->UnattendSetup
)
986 WCHAR wszPath
[MAX_PATH
];
987 if (GetRosInstallCD(wszPath
, _countof(wszPath
)))
989 WCHAR wszParams
[1024];
990 swprintf(wszParams
, L
"intl.cpl,,/f:\"%sreactos\\unattend.inf\"", wszPath
);
991 RunControlPanelApplet(hwndDlg
, wszParams
);
995 RunControlPanelApplet(hwndDlg
, L
"intl.cpl,,/f:\"unattend.inf\"");
998 SetWindowLongPtr(hwndDlg
, DWLP_MSGRESULT
, IDD_OWNERPAGE
);
1007 SetupData
->UnattendSetup
= FALSE
;
1024 static PTIMEZONE_ENTRY
1025 GetLargerTimeZoneEntry(PSETUPDATA SetupData
, DWORD Index
)
1027 PTIMEZONE_ENTRY Entry
;
1029 Entry
= SetupData
->TimeZoneListHead
;
1030 while (Entry
!= NULL
)
1032 if (Entry
->Index
>= Index
)
1035 Entry
= Entry
->Next
;
1043 CreateTimeZoneList(PSETUPDATA SetupData
)
1045 WCHAR szKeyName
[256];
1053 PTIMEZONE_ENTRY Entry
;
1054 PTIMEZONE_ENTRY Current
;
1056 if (RegOpenKeyExW(HKEY_LOCAL_MACHINE
,
1057 L
"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Time Zones",
1066 dwNameSize
= 256 * sizeof(WCHAR
);
1067 lError
= RegEnumKeyExW(hZonesKey
,
1075 if (lError
!= ERROR_SUCCESS
&& lError
!= ERROR_MORE_DATA
)
1078 if (RegOpenKeyExW(hZonesKey
,
1085 Entry
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(TIMEZONE_ENTRY
));
1088 RegCloseKey(hZoneKey
);
1092 dwValueSize
= 64 * sizeof(WCHAR
);
1093 if (RegQueryValueExW(hZoneKey
,
1097 (LPBYTE
)&Entry
->Description
,
1100 RegCloseKey(hZoneKey
);
1104 dwValueSize
= 32 * sizeof(WCHAR
);
1105 if (RegQueryValueExW(hZoneKey
,
1109 (LPBYTE
)&Entry
->StandardName
,
1112 RegCloseKey(hZoneKey
);
1116 dwValueSize
= 32 * sizeof(WCHAR
);
1117 if (RegQueryValueExW(hZoneKey
,
1121 (LPBYTE
)&Entry
->DaylightName
,
1124 RegCloseKey(hZoneKey
);
1128 dwValueSize
= sizeof(DWORD
);
1129 if (RegQueryValueExW(hZoneKey
,
1133 (LPBYTE
)&Entry
->Index
,
1136 RegCloseKey(hZoneKey
);
1140 dwValueSize
= sizeof(TZ_INFO
);
1141 if (RegQueryValueExW(hZoneKey
,
1145 (LPBYTE
)&Entry
->TimezoneInfo
,
1148 RegCloseKey(hZoneKey
);
1152 RegCloseKey(hZoneKey
);
1154 if (SetupData
->TimeZoneListHead
== NULL
&&
1155 SetupData
->TimeZoneListTail
== NULL
)
1159 SetupData
->TimeZoneListHead
= Entry
;
1160 SetupData
->TimeZoneListTail
= Entry
;
1164 Current
= GetLargerTimeZoneEntry(SetupData
, Entry
->Index
);
1165 if (Current
!= NULL
)
1167 if (Current
== SetupData
->TimeZoneListHead
)
1169 /* Prepend to head */
1171 Entry
->Next
= SetupData
->TimeZoneListHead
;
1172 SetupData
->TimeZoneListHead
->Prev
= Entry
;
1173 SetupData
->TimeZoneListHead
= Entry
;
1177 /* Insert before current */
1178 Entry
->Prev
= Current
->Prev
;
1179 Entry
->Next
= Current
;
1180 Current
->Prev
->Next
= Entry
;
1181 Current
->Prev
= Entry
;
1186 /* Append to tail */
1187 Entry
->Prev
= SetupData
->TimeZoneListTail
;
1189 SetupData
->TimeZoneListTail
->Next
= Entry
;
1190 SetupData
->TimeZoneListTail
= Entry
;
1197 RegCloseKey(hZonesKey
);
1202 DestroyTimeZoneList(PSETUPDATA SetupData
)
1204 PTIMEZONE_ENTRY Entry
;
1206 while (SetupData
->TimeZoneListHead
!= NULL
)
1208 Entry
= SetupData
->TimeZoneListHead
;
1210 SetupData
->TimeZoneListHead
= Entry
->Next
;
1211 if (SetupData
->TimeZoneListHead
!= NULL
)
1213 SetupData
->TimeZoneListHead
->Prev
= NULL
;
1216 HeapFree(GetProcessHeap(), 0, Entry
);
1219 SetupData
->TimeZoneListTail
= NULL
;
1223 GetTimeZoneListIndex(LPDWORD lpIndex
)
1225 WCHAR szLanguageIdString
[9];
1232 BOOL bFound
= FALSE
;
1233 unsigned long iLanguageID
;
1237 *lpIndex
= 85; /* fallback to GMT time zone */
1239 if (RegOpenKeyExW(HKEY_LOCAL_MACHINE
,
1240 L
"SYSTEM\\CurrentControlSet\\Control\\NLS\\Language",
1246 dwValueSize
= 9 * sizeof(WCHAR
);
1247 if (RegQueryValueExW(hKey
,
1251 (LPBYTE
)szLanguageIdString
,
1258 iLanguageID
= wcstoul(szLanguageIdString
, NULL
, 16);
1263 iLanguageID
= *lpIndex
;
1266 if (RegOpenKeyExW(HKEY_LOCAL_MACHINE
,
1267 L
"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Time Zones",
1274 if (RegQueryValueExW(hKey
,
1285 Buffer
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, dwValueSize
);
1292 if (RegQueryValueExW(hKey
,
1299 HeapFree(GetProcessHeap(), 0, Buffer
);
1309 Length
= wcslen(Ptr
);
1310 if (wcstoul(Ptr
, NULL
, 16) == iLanguageID
)
1313 Ptr
= Ptr
+ Length
+ 1;
1319 *lpIndex
= wcstoul(Ptr
, &End
, 10);
1320 HeapFree(GetProcessHeap(), 0, Buffer
);
1324 Length
= wcslen(Ptr
);
1325 Ptr
= Ptr
+ Length
+ 1;
1328 HeapFree(GetProcessHeap(), 0, Buffer
);
1335 ShowTimeZoneList(HWND hwnd
, PSETUPDATA SetupData
, DWORD dwEntryIndex
)
1337 PTIMEZONE_ENTRY Entry
;
1341 GetTimeZoneListIndex(&dwEntryIndex
);
1343 Entry
= SetupData
->TimeZoneListHead
;
1344 while (Entry
!= NULL
)
1346 dwCount
= SendMessage(hwnd
,
1349 (LPARAM
)Entry
->Description
);
1351 if (dwEntryIndex
!= 0 && dwEntryIndex
== Entry
->Index
)
1354 Entry
= Entry
->Next
;
1365 SetLocalTimeZone(HWND hwnd
, PSETUPDATA SetupData
)
1367 TIME_ZONE_INFORMATION TimeZoneInformation
;
1368 PTIMEZONE_ENTRY Entry
;
1372 dwIndex
= SendMessage(hwnd
,
1378 Entry
= SetupData
->TimeZoneListHead
;
1385 Entry
= Entry
->Next
;
1388 wcscpy(TimeZoneInformation
.StandardName
,
1389 Entry
->StandardName
);
1390 wcscpy(TimeZoneInformation
.DaylightName
,
1391 Entry
->DaylightName
);
1393 TimeZoneInformation
.Bias
= Entry
->TimezoneInfo
.Bias
;
1394 TimeZoneInformation
.StandardBias
= Entry
->TimezoneInfo
.StandardBias
;
1395 TimeZoneInformation
.DaylightBias
= Entry
->TimezoneInfo
.DaylightBias
;
1397 memcpy(&TimeZoneInformation
.StandardDate
,
1398 &Entry
->TimezoneInfo
.StandardDate
,
1399 sizeof(SYSTEMTIME
));
1400 memcpy(&TimeZoneInformation
.DaylightDate
,
1401 &Entry
->TimezoneInfo
.DaylightDate
,
1402 sizeof(SYSTEMTIME
));
1404 /* Set time zone information */
1405 SetTimeZoneInformation(&TimeZoneInformation
);
1410 GetLocalSystemTime(HWND hwnd
, PSETUPDATA SetupData
)
1415 if (DateTime_GetSystemtime(GetDlgItem(hwnd
, IDC_DATEPICKER
), &Date
) != GDT_VALID
)
1420 if (DateTime_GetSystemtime(GetDlgItem(hwnd
, IDC_TIMEPICKER
), &Time
) != GDT_VALID
)
1425 SetupData
->SystemTime
.wYear
= Date
.wYear
;
1426 SetupData
->SystemTime
.wMonth
= Date
.wMonth
;
1427 SetupData
->SystemTime
.wDayOfWeek
= Date
.wDayOfWeek
;
1428 SetupData
->SystemTime
.wDay
= Date
.wDay
;
1429 SetupData
->SystemTime
.wHour
= Time
.wHour
;
1430 SetupData
->SystemTime
.wMinute
= Time
.wMinute
;
1431 SetupData
->SystemTime
.wSecond
= Time
.wSecond
;
1432 SetupData
->SystemTime
.wMilliseconds
= Time
.wMilliseconds
;
1439 SetAutoDaylightInfo(HWND hwnd
)
1444 if (SendMessage(hwnd
, BM_GETCHECK
, 0, 0) == BST_UNCHECKED
)
1446 if (RegOpenKeyExW(HKEY_LOCAL_MACHINE
,
1447 L
"SYSTEM\\CurrentControlSet\\Control\\TimeZoneInformation",
1453 RegSetValueExW(hKey
,
1454 L
"DisableAutoDaylightTimeSet",
1465 SetSystemLocalTime(HWND hwnd
, PSETUPDATA SetupData
)
1470 * Call SetLocalTime twice to ensure correct results
1472 Ret
= SetLocalTime(&SetupData
->SystemTime
) &&
1473 SetLocalTime(&SetupData
->SystemTime
);
1480 UpdateLocalSystemTime(HWND hwnd
)
1482 SYSTEMTIME LocalTime
;
1484 GetLocalTime(&LocalTime
);
1485 DateTime_SetSystemtime(GetDlgItem(hwnd
, IDC_DATEPICKER
), GDT_VALID
, &LocalTime
);
1486 DateTime_SetSystemtime(GetDlgItem(hwnd
, IDC_TIMEPICKER
), GDT_VALID
, &LocalTime
);
1491 WriteDateTimeSettings(HWND hwndDlg
, PSETUPDATA SetupData
)
1494 WCHAR ErrorLocalTime
[256];
1496 GetLocalSystemTime(hwndDlg
, SetupData
);
1497 SetLocalTimeZone(GetDlgItem(hwndDlg
, IDC_TIMEZONELIST
),
1500 SetAutoDaylightInfo(GetDlgItem(hwndDlg
, IDC_AUTODAYLIGHT
));
1501 if (!SetSystemLocalTime(hwndDlg
, SetupData
))
1503 if (0 == LoadStringW(hDllInstance
, IDS_REACTOS_SETUP
, Title
, ARRAYSIZE(Title
)))
1505 wcscpy(Title
, L
"ReactOS Setup");
1507 if (0 == LoadStringW(hDllInstance
, IDS_WZD_LOCALTIME
, ErrorLocalTime
,
1508 ARRAYSIZE(ErrorLocalTime
)))
1510 wcscpy(ErrorLocalTime
, L
"Setup was unable to set the local time.");
1512 MessageBoxW(hwndDlg
, ErrorLocalTime
, Title
, MB_ICONWARNING
| MB_OK
);
1520 static INT_PTR CALLBACK
1521 DateTimePageDlgProc(HWND hwndDlg
,
1526 PSETUPDATA SetupData
;
1528 /* Retrieve pointer to the global setup data */
1529 SetupData
= (PSETUPDATA
)GetWindowLongPtr(hwndDlg
, GWLP_USERDATA
);
1534 /* Save pointer to the global setup data */
1535 SetupData
= (PSETUPDATA
)((LPPROPSHEETPAGE
)lParam
)->lParam
;
1536 SetWindowLongPtr(hwndDlg
, GWLP_USERDATA
, (DWORD_PTR
)SetupData
);
1538 CreateTimeZoneList(SetupData
);
1540 if (SetupData
->UnattendSetup
)
1542 ShowTimeZoneList(GetDlgItem(hwndDlg
, IDC_TIMEZONELIST
),
1543 SetupData
, SetupData
->TimeZoneIndex
);
1545 if (!SetupData
->DisableAutoDaylightTimeSet
)
1547 SendDlgItemMessage(hwndDlg
, IDC_AUTODAYLIGHT
, BM_SETCHECK
, (WPARAM
)BST_CHECKED
, 0);
1552 ShowTimeZoneList(GetDlgItem(hwndDlg
, IDC_TIMEZONELIST
),
1555 SendDlgItemMessage(hwndDlg
, IDC_AUTODAYLIGHT
, BM_SETCHECK
, (WPARAM
)BST_CHECKED
, 0);
1560 UpdateLocalSystemTime(hwndDlg
);
1564 switch (((LPNMHDR
)lParam
)->code
)
1567 /* Enable the Back and Next buttons */
1568 PropSheet_SetWizButtons(GetParent(hwndDlg
), PSWIZB_BACK
| PSWIZB_NEXT
);
1569 if (SetupData
->UnattendSetup
&& WriteDateTimeSettings(hwndDlg
, SetupData
))
1571 SetWindowLongPtr(hwndDlg
, DWLP_MSGRESULT
, SetupData
->uFirstNetworkWizardPage
);
1574 SetTimer(hwndDlg
, 1, 1000, NULL
);
1577 case PSN_KILLACTIVE
:
1578 case DTN_DATETIMECHANGE
:
1579 KillTimer(hwndDlg
, 1);
1583 WriteDateTimeSettings(hwndDlg
, SetupData
);
1587 SetupData
->UnattendSetup
= FALSE
;
1596 DestroyTimeZoneList(SetupData
);
1607 static INT_PTR CALLBACK
1608 ThemePageDlgProc(HWND hwndDlg
,
1613 PSETUPDATA SetupData
;
1615 /* Retrieve pointer to the global setup data */
1616 SetupData
= (PSETUPDATA
)GetWindowLongPtr(hwndDlg
, GWLP_USERDATA
);
1622 BUTTON_IMAGELIST imldata
= {0, {0,10,0,10}, BUTTON_IMAGELIST_ALIGN_TOP
};
1624 /* Save pointer to the global setup data */
1625 SetupData
= (PSETUPDATA
)((LPPROPSHEETPAGE
)lParam
)->lParam
;
1626 SetWindowLongPtr(hwndDlg
, GWLP_USERDATA
, (DWORD_PTR
)SetupData
);
1628 imldata
.himl
= ImageList_LoadImage(hDllInstance
, MAKEINTRESOURCE(IDB_CLASSIC
), 0, 0, 0x00FF00FF, IMAGE_BITMAP
, LR_CREATEDIBSECTION
);
1629 SendDlgItemMessage(hwndDlg
, IDC_CLASSICSTYLE
, BCM_SETIMAGELIST
, 0, (LPARAM
)&imldata
);
1631 imldata
.himl
= ImageList_LoadImage(hDllInstance
, MAKEINTRESOURCE(IDB_LAUTUS
), 0, 0, 0x00FF00FF , IMAGE_BITMAP
, LR_CREATEDIBSECTION
);
1632 SendDlgItemMessage(hwndDlg
, IDC_THEMEDSTYLE
, BCM_SETIMAGELIST
, 0, (LPARAM
)&imldata
);
1634 SendDlgItemMessage(hwndDlg
, IDC_CLASSICSTYLE
, BM_SETCHECK
, BST_CHECKED
, 0);
1638 if (HIWORD(wParam
) == BN_CLICKED
)
1640 switch (LOWORD(wParam
))
1642 case IDC_THEMEDSTYLE
:
1644 WCHAR wszParams
[1024];
1645 WCHAR wszTheme
[MAX_PATH
];
1646 WCHAR
* format
= L
"desk.cpl desk,@Appearance /Action:ActivateMSTheme /file:\"%s\"";
1648 SHGetFolderPathAndSubDirW(0, CSIDL_RESOURCES
, NULL
, SHGFP_TYPE_DEFAULT
, L
"themes\\lautus\\lautus.msstyles", wszTheme
);
1649 swprintf(wszParams
, format
, wszTheme
);
1650 RunControlPanelApplet(hwndDlg
, wszParams
);
1653 case IDC_CLASSICSTYLE
:
1654 RunControlPanelApplet(hwndDlg
, L
"desk.cpl desk,@Appearance /Action:ActivateMSTheme");
1659 switch (((LPNMHDR
)lParam
)->code
)
1662 /* Enable the Back and Next buttons */
1663 PropSheet_SetWizButtons(GetParent(hwndDlg
), PSWIZB_BACK
| PSWIZB_NEXT
);
1664 if (SetupData
->UnattendSetup
)
1666 SetWindowLongPtr(hwndDlg
, DWLP_MSGRESULT
, SetupData
->uFirstNetworkWizardPage
);
1675 SetupData
->UnattendSetup
= FALSE
;
1690 static UINT CALLBACK
1691 RegistrationNotificationProc(PVOID Context
,
1696 PREGISTRATIONDATA RegistrationData
;
1697 REGISTRATIONNOTIFY RegistrationNotify
;
1698 PSP_REGISTER_CONTROL_STATUSW StatusInfo
;
1700 WCHAR ErrorMessage
[128];
1702 RegistrationData
= (PREGISTRATIONDATA
) Context
;
1704 if (SPFILENOTIFY_STARTREGISTRATION
== Notification
||
1705 SPFILENOTIFY_ENDREGISTRATION
== Notification
)
1707 StatusInfo
= (PSP_REGISTER_CONTROL_STATUSW
) Param1
;
1708 RegistrationNotify
.CurrentItem
= wcsrchr(StatusInfo
->FileName
, L
'\\');
1709 if (NULL
== RegistrationNotify
.CurrentItem
)
1711 RegistrationNotify
.CurrentItem
= StatusInfo
->FileName
;
1715 RegistrationNotify
.CurrentItem
++;
1718 if (SPFILENOTIFY_STARTREGISTRATION
== Notification
)
1720 DPRINT("Received SPFILENOTIFY_STARTREGISTRATION notification for %S\n",
1721 StatusInfo
->FileName
);
1722 RegistrationNotify
.ErrorMessage
= NULL
;
1723 RegistrationNotify
.Progress
= RegistrationData
->Registered
;
1727 DPRINT("Received SPFILENOTIFY_ENDREGISTRATION notification for %S\n",
1728 StatusInfo
->FileName
);
1729 DPRINT("Win32Error %u FailureCode %u\n", StatusInfo
->Win32Error
,
1730 StatusInfo
->FailureCode
);
1731 if (SPREG_SUCCESS
!= StatusInfo
->FailureCode
)
1733 switch(StatusInfo
->FailureCode
)
1735 case SPREG_LOADLIBRARY
:
1736 MessageID
= IDS_LOADLIBRARY_FAILED
;
1738 case SPREG_GETPROCADDR
:
1739 MessageID
= IDS_GETPROCADDR_FAILED
;
1742 MessageID
= IDS_REGSVR_FAILED
;
1744 case SPREG_DLLINSTALL
:
1745 MessageID
= IDS_DLLINSTALL_FAILED
;
1748 MessageID
= IDS_TIMEOUT
;
1751 MessageID
= IDS_REASON_UNKNOWN
;
1754 if (0 == LoadStringW(hDllInstance
, MessageID
,
1756 ARRAYSIZE(ErrorMessage
)))
1758 ErrorMessage
[0] = L
'\0';
1760 if (SPREG_TIMEOUT
!= StatusInfo
->FailureCode
)
1762 FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM
, NULL
,
1763 StatusInfo
->Win32Error
, 0,
1764 ErrorMessage
+ wcslen(ErrorMessage
),
1765 ARRAYSIZE(ErrorMessage
) - wcslen(ErrorMessage
),
1768 RegistrationNotify
.ErrorMessage
= ErrorMessage
;
1772 RegistrationNotify
.ErrorMessage
= NULL
;
1774 if (RegistrationData
->Registered
< RegistrationData
->DllCount
)
1776 RegistrationData
->Registered
++;
1780 RegistrationNotify
.Progress
= RegistrationData
->Registered
;
1781 RegistrationNotify
.ActivityID
= IDS_REGISTERING_COMPONENTS
;
1782 SendMessage(RegistrationData
->hwndDlg
, PM_REGISTRATION_NOTIFY
,
1783 0, (LPARAM
) &RegistrationNotify
);
1789 DPRINT1("Received unexpected notification %u\n", Notification
);
1790 return SetupDefaultQueueCallback(RegistrationData
->DefaultContext
,
1791 Notification
, Param1
, Param2
);
1796 static DWORD CALLBACK
1797 RegistrationProc(LPVOID Parameter
)
1799 PREGISTRATIONDATA RegistrationData
;
1800 REGISTRATIONNOTIFY RegistrationNotify
;
1801 DWORD LastError
= NO_ERROR
;
1802 WCHAR UnknownError
[84];
1804 RegistrationData
= (PREGISTRATIONDATA
) Parameter
;
1805 RegistrationData
->Registered
= 0;
1806 RegistrationData
->DefaultContext
= SetupInitDefaultQueueCallback(RegistrationData
->hwndDlg
);
1810 if (!SetupInstallFromInfSectionW(GetParent(RegistrationData
->hwndDlg
),
1812 L
"RegistrationPhase2",
1814 SPINST_REGISTERCALLBACKAWARE
|
1819 RegistrationNotificationProc
,
1824 LastError
= GetLastError();
1827 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
1829 DPRINT("Catching exception\n");
1830 LastError
= RtlNtStatusToDosError(_SEH2_GetExceptionCode());
1834 if (NO_ERROR
== LastError
)
1836 RegistrationNotify
.ErrorMessage
= NULL
;
1840 DPRINT1("SetupInstallFromInfSection failed with error %u\n",
1842 if (0 == FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER
|
1843 FORMAT_MESSAGE_FROM_SYSTEM
, NULL
, LastError
, 0,
1844 (LPWSTR
) &RegistrationNotify
.ErrorMessage
, 0,
1847 if (0 == LoadStringW(hDllInstance
, IDS_UNKNOWN_ERROR
,
1849 ARRAYSIZE(UnknownError
) - 20))
1851 wcscpy(UnknownError
, L
"Unknown error");
1853 wcscat(UnknownError
, L
" ");
1854 _ultow(LastError
, UnknownError
+ wcslen(UnknownError
), 10);
1855 RegistrationNotify
.ErrorMessage
= UnknownError
;
1859 RegistrationNotify
.Progress
= RegistrationData
->DllCount
;
1860 RegistrationNotify
.ActivityID
= IDS_REGISTERING_COMPONENTS
;
1861 RegistrationNotify
.CurrentItem
= NULL
;
1862 SendMessage(RegistrationData
->hwndDlg
, PM_REGISTRATION_NOTIFY
,
1863 1, (LPARAM
) &RegistrationNotify
);
1864 if (NULL
!= RegistrationNotify
.ErrorMessage
&&
1865 UnknownError
!= RegistrationNotify
.ErrorMessage
)
1867 LocalFree((PVOID
) RegistrationNotify
.ErrorMessage
);
1870 SetupTermDefaultQueueCallback(RegistrationData
->DefaultContext
);
1871 HeapFree(GetProcessHeap(), 0, RegistrationData
);
1873 RegisterTypeLibraries(hSysSetupInf
, L
"TypeLibraries");
1875 // FIXME: Move this call to a separate cleanup page!
1876 RtlCreateBootStatusDataFile();
1883 StartComponentRegistration(HWND hwndDlg
, PULONG MaxProgress
)
1885 HANDLE RegistrationThread
;
1888 WCHAR SectionName
[512];
1889 PREGISTRATIONDATA RegistrationData
;
1892 if (!SetupFindFirstLineW(hSysSetupInf
, L
"RegistrationPhase2",
1893 L
"RegisterDlls", &Context
))
1895 DPRINT1("No RegistrationPhase2 section found\n");
1898 if (!SetupGetStringFieldW(&Context
, 1, SectionName
,
1899 ARRAYSIZE(SectionName
),
1902 DPRINT1("Unable to retrieve section name\n");
1905 DllCount
= SetupGetLineCountW(hSysSetupInf
, SectionName
);
1906 DPRINT("SectionName %S DllCount %ld\n", SectionName
, DllCount
);
1909 SetLastError(STATUS_NOT_FOUND
);
1913 *MaxProgress
= (ULONG
) DllCount
;
1916 * Create a background thread to do the actual registrations, so the
1917 * main thread can just run its message loop.
1919 RegistrationThread
= NULL
;
1920 RegistrationData
= HeapAlloc(GetProcessHeap(), 0,
1921 sizeof(REGISTRATIONDATA
));
1922 if (RegistrationData
!= NULL
)
1924 RegistrationData
->hwndDlg
= hwndDlg
;
1925 RegistrationData
->DllCount
= DllCount
;
1926 RegistrationThread
= CreateThread(NULL
, 0, RegistrationProc
,
1927 RegistrationData
, 0, NULL
);
1928 if (RegistrationThread
!= NULL
)
1930 CloseHandle(RegistrationThread
);
1934 DPRINT1("CreateThread failed, error %u\n", GetLastError());
1935 HeapFree(GetProcessHeap(), 0, RegistrationData
);
1941 DPRINT1("HeapAlloc() failed, error %u\n", GetLastError());
1949 static INT_PTR CALLBACK
1950 ProcessPageDlgProc(HWND hwndDlg
,
1955 PSETUPDATA SetupData
;
1956 PREGISTRATIONNOTIFY RegistrationNotify
;
1957 static UINT oldActivityID
= -1;
1960 /* Retrieve pointer to the global setup data */
1961 SetupData
= (PSETUPDATA
)GetWindowLongPtr(hwndDlg
, GWLP_USERDATA
);
1967 /* Save pointer to the global setup data */
1968 SetupData
= (PSETUPDATA
)((LPPROPSHEETPAGE
)lParam
)->lParam
;
1969 SetWindowLongPtr(hwndDlg
, GWLP_USERDATA
, (DWORD_PTR
)SetupData
);
1975 LPNMHDR lpnm
= (LPNMHDR
)lParam
;
1976 ULONG MaxProgress
= 0;
1981 /* Disable the Back and Next buttons */
1982 PropSheet_SetWizButtons(GetParent(hwndDlg
), 0);
1984 StartComponentRegistration(hwndDlg
, &MaxProgress
);
1986 SendDlgItemMessage(hwndDlg
, IDC_PROCESSPROGRESS
, PBM_SETRANGE
,
1987 0, MAKELPARAM(0, MaxProgress
));
1988 SendDlgItemMessage(hwndDlg
, IDC_PROCESSPROGRESS
, PBM_SETPOS
,
1996 SetupData
->UnattendSetup
= FALSE
;
2005 case PM_REGISTRATION_NOTIFY
:
2008 RegistrationNotify
= (PREGISTRATIONNOTIFY
) lParam
;
2009 // update if necessary only
2010 if (oldActivityID
!= RegistrationNotify
->ActivityID
)
2012 if (0 != LoadStringW(hDllInstance
, RegistrationNotify
->ActivityID
,
2014 ARRAYSIZE(Activity
)))
2016 SendDlgItemMessageW(hwndDlg
, IDC_ACTIVITY
, WM_SETTEXT
,
2017 0, (LPARAM
) Activity
);
2019 oldActivityID
= RegistrationNotify
->ActivityID
;
2021 SendDlgItemMessageW(hwndDlg
, IDC_ITEM
, WM_SETTEXT
, 0,
2022 (LPARAM
)(NULL
== RegistrationNotify
->CurrentItem
?
2023 L
"" : RegistrationNotify
->CurrentItem
));
2024 SendDlgItemMessage(hwndDlg
, IDC_PROCESSPROGRESS
, PBM_SETPOS
,
2025 RegistrationNotify
->Progress
, 0);
2026 if (NULL
!= RegistrationNotify
->ErrorMessage
)
2028 if (0 == LoadStringW(hDllInstance
, IDS_REACTOS_SETUP
,
2029 Title
, ARRAYSIZE(Title
)))
2031 wcscpy(Title
, L
"ReactOS Setup");
2033 MessageBoxW(hwndDlg
, RegistrationNotify
->ErrorMessage
,
2034 Title
, MB_ICONERROR
| MB_OK
);
2040 /* Enable the Back and Next buttons */
2041 PropSheet_SetWizButtons(GetParent(hwndDlg
), PSWIZB_NEXT
);
2042 PropSheet_PressButton(GetParent(hwndDlg
), PSBTN_NEXT
);
2056 SetInstallationCompleted(VOID
)
2059 DWORD InProgress
= 0;
2062 if (RegOpenKeyExW( HKEY_LOCAL_MACHINE
,
2066 &hKey
) == ERROR_SUCCESS
)
2068 RegSetValueExW( hKey
, L
"SystemSetupInProgress", 0, REG_DWORD
, (LPBYTE
)&InProgress
, sizeof(InProgress
) );
2069 RegCloseKey( hKey
);
2072 if (RegOpenKeyExW( HKEY_LOCAL_MACHINE
,
2073 L
"Software\\Microsoft\\Windows NT\\CurrentVersion",
2076 &hKey
) == ERROR_SUCCESS
)
2078 InstallDate
= (DWORD
)time(NULL
);
2079 RegSetValueExW( hKey
, L
"InstallDate", 0, REG_DWORD
, (LPBYTE
)&InstallDate
, sizeof(InstallDate
) );
2080 RegCloseKey( hKey
);
2084 static INT_PTR CALLBACK
2085 FinishDlgProc(HWND hwndDlg
,
2095 /* Get pointer to the global setup data */
2096 PSETUPDATA SetupData
= (PSETUPDATA
)((LPPROPSHEETPAGE
)lParam
)->lParam
;
2098 if (!SetupData
->UnattendSetup
|| !SetupData
->DisableGeckoInst
)
2100 /* Run the Wine Gecko prompt */
2101 Control_RunDLLW(hwndDlg
, 0, L
"appwiz.cpl install_gecko", SW_SHOW
);
2104 /* Set title font */
2105 SendDlgItemMessage(hwndDlg
,
2108 (WPARAM
)SetupData
->hTitleFont
,
2110 if (SetupData
->UnattendSetup
)
2112 KillTimer(hwndDlg
, 1);
2113 SetInstallationCompleted();
2121 SetInstallationCompleted();
2131 hWndProgress
= GetDlgItem(hwndDlg
, IDC_RESTART_PROGRESS
);
2132 Position
= SendMessage(hWndProgress
, PBM_GETPOS
, 0, 0);
2133 if (Position
== 300)
2135 KillTimer(hwndDlg
, 1);
2136 PropSheet_PressButton(GetParent(hwndDlg
), PSBTN_FINISH
);
2140 SendMessage(hWndProgress
, PBM_SETPOS
, Position
+ 1, 0);
2147 LPNMHDR lpnm
= (LPNMHDR
)lParam
;
2152 /* Enable the correct buttons on for the active page */
2153 PropSheet_SetWizButtons(GetParent(hwndDlg
), PSWIZB_FINISH
);
2155 SendDlgItemMessage(hwndDlg
, IDC_RESTART_PROGRESS
, PBM_SETRANGE
, 0,
2156 MAKELPARAM(0, 300));
2157 SendDlgItemMessage(hwndDlg
, IDC_RESTART_PROGRESS
, PBM_SETPOS
, 0, 0);
2158 SetTimer(hwndDlg
, 1, 50, NULL
);
2162 DestroyWindow(GetParent(hwndDlg
));
2181 PSETUPDATA pSetupData
)
2183 INFCONTEXT InfContext
;
2185 WCHAR szValue
[MAX_PATH
];
2189 if (!SetupFindFirstLineW(pSetupData
->hUnattendedInf
,
2191 L
"UnattendSetupEnabled",
2194 DPRINT1("Error: Cannot find UnattendSetupEnabled Key! %d\n", GetLastError());
2198 if (!SetupGetStringFieldW(&InfContext
,
2204 DPRINT1("Error: SetupGetStringField failed with %d\n", GetLastError());
2208 if (_wcsicmp(szValue
, L
"yes") != 0)
2210 DPRINT("Unattend setup was disabled by UnattendSetupEnabled key.\n");
2214 pSetupData
->UnattendSetup
= TRUE
;
2216 if (!SetupFindFirstLineW(pSetupData
->hUnattendedInf
,
2221 DPRINT1("Error: SetupFindFirstLine failed %d\n", GetLastError());
2227 if (!SetupGetStringFieldW(&InfContext
,
2233 DPRINT1("Error: SetupGetStringField failed with %d\n", GetLastError());
2237 if (!SetupGetStringFieldW(&InfContext
,
2243 DPRINT1("Error: SetupGetStringField failed with %d\n", GetLastError());
2246 DPRINT1("Name %S Value %S\n", szName
, szValue
);
2247 if (!_wcsicmp(szName
, L
"FullName"))
2249 if (ARRAYSIZE(pSetupData
->OwnerName
) > LineLength
)
2251 wcscpy(pSetupData
->OwnerName
, szValue
);
2254 else if (!_wcsicmp(szName
, L
"OrgName"))
2256 if (ARRAYSIZE(pSetupData
->OwnerOrganization
) > LineLength
)
2258 wcscpy(pSetupData
->OwnerOrganization
, szValue
);
2261 else if (!_wcsicmp(szName
, L
"ComputerName"))
2263 if (ARRAYSIZE(pSetupData
->ComputerName
) > LineLength
)
2265 wcscpy(pSetupData
->ComputerName
, szValue
);
2268 else if (!_wcsicmp(szName
, L
"AdminPassword"))
2270 if (ARRAYSIZE(pSetupData
->AdminPassword
) > LineLength
)
2272 wcscpy(pSetupData
->AdminPassword
, szValue
);
2275 else if (!_wcsicmp(szName
, L
"TimeZoneIndex"))
2277 pSetupData
->TimeZoneIndex
= _wtoi(szValue
);
2279 else if (!_wcsicmp(szName
, L
"DisableAutoDaylightTimeSet"))
2281 pSetupData
->DisableAutoDaylightTimeSet
= _wtoi(szValue
);
2283 else if (!_wcsicmp(szName
, L
"DisableGeckoInst"))
2285 if (!_wcsicmp(szValue
, L
"yes"))
2286 pSetupData
->DisableGeckoInst
= TRUE
;
2288 pSetupData
->DisableGeckoInst
= FALSE
;
2291 } while (SetupFindNextLine(&InfContext
, &InfContext
));
2293 if (SetupFindFirstLineW(pSetupData
->hUnattendedInf
,
2298 DEVMODEW dm
= { { 0 } };
2299 dm
.dmSize
= sizeof(dm
);
2300 if (EnumDisplaySettingsW(NULL
, ENUM_CURRENT_SETTINGS
, &dm
))
2305 if (!SetupGetStringFieldW(&InfContext
,
2311 DPRINT1("Error: SetupGetStringField failed with %d\n", GetLastError());
2315 if (!SetupGetStringFieldW(&InfContext
,
2321 DPRINT1("Error: SetupGetStringField failed with %d\n", GetLastError());
2324 iValue
= _wtoi(szValue
);
2325 DPRINT1("Name %S Value %i\n", szName
, iValue
);
2330 if (!_wcsicmp(szName
, L
"BitsPerPel"))
2332 dm
.dmFields
|= DM_BITSPERPEL
;
2333 dm
.dmBitsPerPel
= iValue
;
2335 else if (!_wcsicmp(szName
, L
"XResolution"))
2337 dm
.dmFields
|= DM_PELSWIDTH
;
2338 dm
.dmPelsWidth
= iValue
;
2340 else if (!_wcsicmp(szName
, L
"YResolution"))
2342 dm
.dmFields
|= DM_PELSHEIGHT
;
2343 dm
.dmPelsHeight
= iValue
;
2345 else if (!_wcsicmp(szName
, L
"VRefresh"))
2347 dm
.dmFields
|= DM_DISPLAYFREQUENCY
;
2348 dm
.dmDisplayFrequency
= iValue
;
2350 } while (SetupFindNextLine(&InfContext
, &InfContext
));
2352 ChangeDisplaySettingsW(&dm
, CDS_UPDATEREGISTRY
);
2356 if (RegOpenKeyExW(HKEY_LOCAL_MACHINE
,
2357 L
"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\RunOnce",
2360 &hKey
) != ERROR_SUCCESS
)
2362 DPRINT1("Error: failed to open HKLM\\Software\\Microsoft\\Windows\\CurrentVersion\\RunOnce\n");
2366 if (SetupFindFirstLineW(pSetupData
->hUnattendedInf
,
2374 if (SetupGetStringFieldW(&InfContext
,
2380 WCHAR szPath
[MAX_PATH
];
2381 swprintf(szName
, L
"%d", i
);
2382 DPRINT("szName %S szValue %S\n", szName
, szValue
);
2384 if (ExpandEnvironmentStringsW(szValue
, szPath
, MAX_PATH
))
2386 DPRINT("value %S\n", szPath
);
2387 if (RegSetValueExW(hKey
,
2391 (const BYTE
*)szPath
,
2392 (wcslen(szPath
) + 1) * sizeof(WCHAR
)) == ERROR_SUCCESS
)
2398 } while (SetupFindNextLine(&InfContext
, &InfContext
));
2405 * GetRosInstallCD should find the path to ros installation medium
2407 * If there are more than one CDDrive in it containing a ReactOS
2408 * installation cd, then it will pick the first one regardless if
2409 * it is really the installation cd
2411 * The best way to implement this is to set the key
2412 * HKLM\Software\Microsoft\Windows NT\CurrentVersion\SourcePath (REG_SZ)
2416 GetRosInstallCD(WCHAR
*pwszPath
, DWORD cchPathMax
)
2418 WCHAR wszDrives
[512];
2422 cchDrives
= GetLogicalDriveStringsW(_countof(wszDrives
) - 1, wszDrives
);
2423 if (cchDrives
== 0 || cchDrives
>= _countof(wszDrives
))
2425 /* buffer too small or failure */
2426 LogItem(NULL
, L
"GetLogicalDriveStringsW failed");
2430 for (pwszDrive
= wszDrives
; pwszDrive
[0]; pwszDrive
+= wcslen(pwszDrive
) + 1)
2432 if (GetDriveTypeW(pwszDrive
) == DRIVE_CDROM
)
2434 WCHAR wszBuf
[MAX_PATH
];
2435 wsprintf(wszBuf
, L
"%sreactos\\system32\\ntoskrnl.exe", pwszDrive
);
2436 LogItem(NULL
, wszBuf
);
2437 if (GetFileAttributesW(wszBuf
) != INVALID_FILE_ATTRIBUTES
)
2439 /* the file exists, so this is the right drive */
2440 wcsncpy(pwszPath
, pwszDrive
, cchPathMax
);
2441 OutputDebugStringW(L
"GetRosInstallCD: ");OutputDebugStringW(pwszPath
);OutputDebugStringW(L
"\n");
2451 ProcessUnattendSetup(
2452 PSETUPDATA pSetupData
)
2454 WCHAR szPath
[MAX_PATH
];
2457 if (!GetRosInstallCD(szPath
, MAX_PATH
))
2459 /* no cd drive found */
2463 dwLength
= wcslen(szPath
);
2464 if (dwLength
+ 21 > MAX_PATH
)
2467 * allocate bigger buffer
2472 wcscat(szPath
, L
"reactos\\unattend.inf");
2474 pSetupData
->hUnattendedInf
= SetupOpenInfFileW(szPath
,
2478 if (pSetupData
->hUnattendedInf
!= INVALID_HANDLE_VALUE
)
2480 ProcessUnattendInf(pSetupData
);
2484 typedef DWORD(WINAPI
*PFNREQUESTWIZARDPAGES
)(PDWORD
, HPROPSHEETPAGE
*, PSETUPDATA
);
2489 PROPSHEETHEADER psh
;
2490 HPROPSHEETPAGE
*phpage
= NULL
;
2491 PROPSHEETPAGE psp
= {0};
2495 PSETUPDATA pSetupData
= NULL
;
2496 HMODULE hNetShell
= NULL
;
2497 PFNREQUESTWIZARDPAGES pfn
= NULL
;
2498 DWORD dwPageCount
= 9, dwNetworkPageCount
= 0;
2500 LogItem(L
"BEGIN_SECTION", L
"InstallWizard");
2502 /* Allocate setup data */
2503 pSetupData
= HeapAlloc(GetProcessHeap(),
2506 if (pSetupData
== NULL
)
2508 LogItem(NULL
, L
"SetupData allocation failed!");
2510 L
"Setup failed to allocate global data!",
2512 MB_ICONERROR
| MB_OK
);
2516 hNetShell
= LoadLibraryW(L
"netshell.dll");
2517 if (hNetShell
!= NULL
)
2519 DPRINT("Netshell.dll loaded!\n");
2521 pfn
= (PFNREQUESTWIZARDPAGES
)GetProcAddress(hNetShell
,
2522 "NetSetupRequestWizardPages");
2525 pfn(&dwNetworkPageCount
, NULL
, NULL
);
2526 dwPageCount
+= dwNetworkPageCount
;
2530 DPRINT("PageCount: %lu\n", dwPageCount
);
2532 phpage
= HeapAlloc(GetProcessHeap(),
2534 dwPageCount
* sizeof(HPROPSHEETPAGE
));
2537 LogItem(NULL
, L
"Page array allocation failed!");
2539 L
"Setup failed to allocate page array!",
2541 MB_ICONERROR
| MB_OK
);
2545 pSetupData
->hUnattendedInf
= INVALID_HANDLE_VALUE
;
2546 ProcessUnattendSetup(pSetupData
);
2548 /* Create the Welcome page */
2549 psp
.dwSize
= sizeof(PROPSHEETPAGE
);
2550 psp
.dwFlags
= PSP_DEFAULT
| PSP_HIDEHEADER
;
2551 psp
.hInstance
= hDllInstance
;
2552 psp
.lParam
= (LPARAM
)pSetupData
;
2553 psp
.pfnDlgProc
= WelcomeDlgProc
;
2554 psp
.pszTemplate
= MAKEINTRESOURCE(IDD_WELCOMEPAGE
);
2555 phpage
[nPages
++] = CreatePropertySheetPage(&psp
);
2557 /* Create the Acknowledgements page */
2558 psp
.dwFlags
= PSP_DEFAULT
| PSP_USEHEADERTITLE
| PSP_USEHEADERSUBTITLE
;
2559 psp
.pszHeaderTitle
= MAKEINTRESOURCE(IDS_ACKTITLE
);
2560 psp
.pszHeaderSubTitle
= MAKEINTRESOURCE(IDS_ACKSUBTITLE
);
2561 psp
.pszTemplate
= MAKEINTRESOURCE(IDD_ACKPAGE
);
2562 psp
.pfnDlgProc
= AckPageDlgProc
;
2563 phpage
[nPages
++] = CreatePropertySheetPage(&psp
);
2565 /* Create the Locale page */
2566 psp
.dwFlags
= PSP_DEFAULT
| PSP_USEHEADERTITLE
| PSP_USEHEADERSUBTITLE
;
2567 psp
.pszHeaderTitle
= MAKEINTRESOURCE(IDS_LOCALETITLE
);
2568 psp
.pszHeaderSubTitle
= MAKEINTRESOURCE(IDS_LOCALESUBTITLE
);
2569 psp
.pfnDlgProc
= LocalePageDlgProc
;
2570 psp
.pszTemplate
= MAKEINTRESOURCE(IDD_LOCALEPAGE
);
2571 phpage
[nPages
++] = CreatePropertySheetPage(&psp
);
2573 /* Create the Owner page */
2574 psp
.dwFlags
= PSP_DEFAULT
| PSP_USEHEADERTITLE
| PSP_USEHEADERSUBTITLE
;
2575 psp
.pszHeaderTitle
= MAKEINTRESOURCE(IDS_OWNERTITLE
);
2576 psp
.pszHeaderSubTitle
= MAKEINTRESOURCE(IDS_OWNERSUBTITLE
);
2577 psp
.pszTemplate
= MAKEINTRESOURCE(IDD_OWNERPAGE
);
2578 psp
.pfnDlgProc
= OwnerPageDlgProc
;
2579 phpage
[nPages
++] = CreatePropertySheetPage(&psp
);
2581 /* Create the Computer page */
2582 psp
.dwFlags
= PSP_DEFAULT
| PSP_USEHEADERTITLE
| PSP_USEHEADERSUBTITLE
;
2583 psp
.pszHeaderTitle
= MAKEINTRESOURCE(IDS_COMPUTERTITLE
);
2584 psp
.pszHeaderSubTitle
= MAKEINTRESOURCE(IDS_COMPUTERSUBTITLE
);
2585 psp
.pfnDlgProc
= ComputerPageDlgProc
;
2586 psp
.pszTemplate
= MAKEINTRESOURCE(IDD_COMPUTERPAGE
);
2587 phpage
[nPages
++] = CreatePropertySheetPage(&psp
);
2589 /* Create the DateTime page */
2590 psp
.dwFlags
= PSP_DEFAULT
| PSP_USEHEADERTITLE
| PSP_USEHEADERSUBTITLE
;
2591 psp
.pszHeaderTitle
= MAKEINTRESOURCE(IDS_DATETIMETITLE
);
2592 psp
.pszHeaderSubTitle
= MAKEINTRESOURCE(IDS_DATETIMESUBTITLE
);
2593 psp
.pfnDlgProc
= DateTimePageDlgProc
;
2594 psp
.pszTemplate
= MAKEINTRESOURCE(IDD_DATETIMEPAGE
);
2595 phpage
[nPages
++] = CreatePropertySheetPage(&psp
);
2597 /* Create the theme selection page */
2598 psp
.dwFlags
= PSP_DEFAULT
| PSP_USEHEADERTITLE
| PSP_USEHEADERSUBTITLE
;
2599 psp
.pszHeaderTitle
= MAKEINTRESOURCE(IDS_THEMESELECTIONTITLE
);
2600 psp
.pszHeaderSubTitle
= MAKEINTRESOURCE(IDS_THEMESELECTIONSUBTITLE
);
2601 psp
.pfnDlgProc
= ThemePageDlgProc
;
2602 psp
.pszTemplate
= MAKEINTRESOURCE(IDD_THEMEPAGE
);
2603 phpage
[nPages
++] = CreatePropertySheetPage(&psp
);
2605 pSetupData
->uFirstNetworkWizardPage
= IDD_PROCESSPAGE
;
2606 pSetupData
->uPostNetworkWizardPage
= IDD_PROCESSPAGE
;
2610 pfn(&dwNetworkPageCount
, &phpage
[nPages
], pSetupData
);
2611 nPages
+= dwNetworkPageCount
;
2614 /* Create the Process page */
2615 psp
.dwFlags
= PSP_DEFAULT
| PSP_USEHEADERTITLE
| PSP_USEHEADERSUBTITLE
;
2616 psp
.pszHeaderTitle
= MAKEINTRESOURCE(IDS_PROCESSTITLE
);
2617 psp
.pszHeaderSubTitle
= MAKEINTRESOURCE(IDS_PROCESSSUBTITLE
);
2618 psp
.pfnDlgProc
= ProcessPageDlgProc
;
2619 psp
.pszTemplate
= MAKEINTRESOURCE(IDD_PROCESSPAGE
);
2620 phpage
[nPages
++] = CreatePropertySheetPage(&psp
);
2622 /* Create the Finish page */
2623 psp
.dwFlags
= PSP_DEFAULT
| PSP_HIDEHEADER
;
2624 psp
.pfnDlgProc
= FinishDlgProc
;
2625 psp
.pszTemplate
= MAKEINTRESOURCE(IDD_FINISHPAGE
);
2626 phpage
[nPages
++] = CreatePropertySheetPage(&psp
);
2628 ASSERT(nPages
== dwPageCount
);
2630 /* Create the property sheet */
2631 psh
.dwSize
= sizeof(PROPSHEETHEADER
);
2632 psh
.dwFlags
= PSH_WIZARD97
| PSH_WATERMARK
| PSH_HEADER
| PSH_MODELESS
;
2633 psh
.hInstance
= hDllInstance
;
2634 psh
.hwndParent
= NULL
;
2635 psh
.nPages
= nPages
;
2637 psh
.phpage
= phpage
;
2638 psh
.pszbmWatermark
= MAKEINTRESOURCE(IDB_WATERMARK
);
2639 psh
.pszbmHeader
= MAKEINTRESOURCE(IDB_HEADER
);
2641 /* Create title font */
2642 pSetupData
->hTitleFont
= CreateTitleFont();
2643 pSetupData
->hBoldFont
= CreateBoldFont();
2645 /* Display the wizard */
2646 hWnd
= (HWND
)PropertySheet(&psh
);
2647 ShowWindow(hWnd
, SW_SHOW
);
2649 while (GetMessage(&msg
, NULL
, 0, 0))
2651 if (!IsDialogMessage(hWnd
, &msg
))
2653 TranslateMessage(&msg
);
2654 DispatchMessage(&msg
);
2658 if (pSetupData
->hUnattendedInf
!= INVALID_HANDLE_VALUE
)
2659 SetupCloseInfFile(pSetupData
->hUnattendedInf
);
2663 HeapFree(GetProcessHeap(), 0, phpage
);
2665 if (hNetShell
!= NULL
)
2666 FreeLibrary(hNetShell
);
2668 if (pSetupData
!= NULL
)
2670 DeleteObject(pSetupData
->hBoldFont
);
2671 DeleteObject(pSetupData
->hTitleFont
);
2672 HeapFree(GetProcessHeap(), 0, pSetupData
);
2675 LogItem(L
"END_SECTION", L
"InstallWizard");