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
, sizeof(Title
) / sizeof(Title
[0])))
493 wcscpy(Title
, L
"ReactOS Setup");
495 if (0 == LoadStringW(hDllInstance
, IDS_WZD_NAME
, ErrorName
, sizeof(ErrorName
) / sizeof(ErrorName
[0])))
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
, sizeof(Title
) / sizeof(Title
[0])))
547 wcscpy(Title
, L
"ReactOS Setup");
549 if (0 == LoadStringW(hDllInstance
, IDS_WZD_SETCOMPUTERNAME
, ErrorComputerName
,
550 sizeof(ErrorComputerName
) / sizeof(ErrorComputerName
[0])))
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 sizeof(szAdministratorName
) / sizeof(WCHAR
)) == 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
, sizeof(Title
) / sizeof(Title
[0])))
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 sizeof(EmptyComputerName
) / sizeof(EmptyComputerName
[0])))
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 sizeof(EmptyPassword
) / sizeof(EmptyPassword
[0])))
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 sizeof(NotMatchPassword
) / sizeof(NotMatchPassword
[0])))
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 sizeof(WrongPassword
) / sizeof(WrongPassword
[0])))
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
, sizeof(Locale
) / sizeof(Locale
[0])) != 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
, sizeof(Title
) / sizeof(Title
[0])))
1505 wcscpy(Title
, L
"ReactOS Setup");
1507 if (0 == LoadStringW(hDllInstance
, IDS_WZD_LOCALTIME
, ErrorLocalTime
,
1508 sizeof(ErrorLocalTime
) / sizeof(ErrorLocalTime
[0])))
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 sizeof(ErrorMessage
) /
1757 sizeof(ErrorMessage
[0])))
1759 ErrorMessage
[0] = L
'\0';
1761 if (SPREG_TIMEOUT
!= StatusInfo
->FailureCode
)
1763 FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM
, NULL
,
1764 StatusInfo
->Win32Error
, 0,
1765 ErrorMessage
+ wcslen(ErrorMessage
),
1766 sizeof(ErrorMessage
) / sizeof(ErrorMessage
[0]) -
1767 wcslen(ErrorMessage
), NULL
);
1769 RegistrationNotify
.ErrorMessage
= ErrorMessage
;
1773 RegistrationNotify
.ErrorMessage
= NULL
;
1775 if (RegistrationData
->Registered
< RegistrationData
->DllCount
)
1777 RegistrationData
->Registered
++;
1781 RegistrationNotify
.Progress
= RegistrationData
->Registered
;
1782 RegistrationNotify
.ActivityID
= IDS_REGISTERING_COMPONENTS
;
1783 SendMessage(RegistrationData
->hwndDlg
, PM_REGISTRATION_NOTIFY
,
1784 0, (LPARAM
) &RegistrationNotify
);
1790 DPRINT1("Received unexpected notification %u\n", Notification
);
1791 return SetupDefaultQueueCallback(RegistrationData
->DefaultContext
,
1792 Notification
, Param1
, Param2
);
1797 static DWORD CALLBACK
1798 RegistrationProc(LPVOID Parameter
)
1800 PREGISTRATIONDATA RegistrationData
;
1801 REGISTRATIONNOTIFY RegistrationNotify
;
1802 DWORD LastError
= NO_ERROR
;
1803 WCHAR UnknownError
[84];
1805 RegistrationData
= (PREGISTRATIONDATA
) Parameter
;
1806 RegistrationData
->Registered
= 0;
1807 RegistrationData
->DefaultContext
= SetupInitDefaultQueueCallback(RegistrationData
->hwndDlg
);
1811 if (!SetupInstallFromInfSectionW(GetParent(RegistrationData
->hwndDlg
),
1813 L
"RegistrationPhase2",
1815 SPINST_REGISTERCALLBACKAWARE
|
1820 RegistrationNotificationProc
,
1825 LastError
= GetLastError();
1828 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
1830 DPRINT("Catching exception\n");
1831 LastError
= RtlNtStatusToDosError(_SEH2_GetExceptionCode());
1835 if (NO_ERROR
== LastError
)
1837 RegistrationNotify
.ErrorMessage
= NULL
;
1841 DPRINT1("SetupInstallFromInfSection failed with error %u\n",
1843 if (0 == FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER
|
1844 FORMAT_MESSAGE_FROM_SYSTEM
, NULL
, LastError
, 0,
1845 (LPWSTR
) &RegistrationNotify
.ErrorMessage
, 0,
1848 if (0 == LoadStringW(hDllInstance
, IDS_UNKNOWN_ERROR
,
1850 sizeof(UnknownError
) / sizeof(UnknownError
[0]) -
1853 wcscpy(UnknownError
, L
"Unknown error");
1855 wcscat(UnknownError
, L
" ");
1856 _ultow(LastError
, UnknownError
+ wcslen(UnknownError
), 10);
1857 RegistrationNotify
.ErrorMessage
= UnknownError
;
1861 RegistrationNotify
.Progress
= RegistrationData
->DllCount
;
1862 RegistrationNotify
.ActivityID
= IDS_REGISTERING_COMPONENTS
;
1863 RegistrationNotify
.CurrentItem
= NULL
;
1864 SendMessage(RegistrationData
->hwndDlg
, PM_REGISTRATION_NOTIFY
,
1865 1, (LPARAM
) &RegistrationNotify
);
1866 if (NULL
!= RegistrationNotify
.ErrorMessage
&&
1867 UnknownError
!= RegistrationNotify
.ErrorMessage
)
1869 LocalFree((PVOID
) RegistrationNotify
.ErrorMessage
);
1872 SetupTermDefaultQueueCallback(RegistrationData
->DefaultContext
);
1873 HeapFree(GetProcessHeap(), 0, RegistrationData
);
1875 RegisterTypeLibraries(hSysSetupInf
, L
"TypeLibraries");
1877 // FIXME: Move this call to a separate cleanup page!
1878 RtlCreateBootStatusDataFile();
1885 StartComponentRegistration(HWND hwndDlg
, PULONG MaxProgress
)
1887 HANDLE RegistrationThread
;
1890 WCHAR SectionName
[512];
1891 PREGISTRATIONDATA RegistrationData
;
1894 if (!SetupFindFirstLineW(hSysSetupInf
, L
"RegistrationPhase2",
1895 L
"RegisterDlls", &Context
))
1897 DPRINT1("No RegistrationPhase2 section found\n");
1900 if (!SetupGetStringFieldW(&Context
, 1, SectionName
,
1901 sizeof(SectionName
) / sizeof(SectionName
[0]),
1904 DPRINT1("Unable to retrieve section name\n");
1907 DllCount
= SetupGetLineCountW(hSysSetupInf
, SectionName
);
1908 DPRINT("SectionName %S DllCount %ld\n", SectionName
, DllCount
);
1911 SetLastError(STATUS_NOT_FOUND
);
1915 *MaxProgress
= (ULONG
) DllCount
;
1918 * Create a background thread to do the actual registrations, so the
1919 * main thread can just run its message loop.
1921 RegistrationThread
= NULL
;
1922 RegistrationData
= HeapAlloc(GetProcessHeap(), 0,
1923 sizeof(REGISTRATIONDATA
));
1924 if (RegistrationData
!= NULL
)
1926 RegistrationData
->hwndDlg
= hwndDlg
;
1927 RegistrationData
->DllCount
= DllCount
;
1928 RegistrationThread
= CreateThread(NULL
, 0, RegistrationProc
,
1929 RegistrationData
, 0, NULL
);
1930 if (RegistrationThread
!= NULL
)
1932 CloseHandle(RegistrationThread
);
1936 DPRINT1("CreateThread failed, error %u\n", GetLastError());
1937 HeapFree(GetProcessHeap(), 0, RegistrationData
);
1943 DPRINT1("HeapAlloc() failed, error %u\n", GetLastError());
1951 static INT_PTR CALLBACK
1952 ProcessPageDlgProc(HWND hwndDlg
,
1957 PSETUPDATA SetupData
;
1958 PREGISTRATIONNOTIFY RegistrationNotify
;
1959 static UINT oldActivityID
= -1;
1962 /* Retrieve pointer to the global setup data */
1963 SetupData
= (PSETUPDATA
)GetWindowLongPtr(hwndDlg
, GWLP_USERDATA
);
1969 /* Save pointer to the global setup data */
1970 SetupData
= (PSETUPDATA
)((LPPROPSHEETPAGE
)lParam
)->lParam
;
1971 SetWindowLongPtr(hwndDlg
, GWLP_USERDATA
, (DWORD_PTR
)SetupData
);
1977 LPNMHDR lpnm
= (LPNMHDR
)lParam
;
1978 ULONG MaxProgress
= 0;
1983 /* Disable the Back and Next buttons */
1984 PropSheet_SetWizButtons(GetParent(hwndDlg
), 0);
1986 StartComponentRegistration(hwndDlg
, &MaxProgress
);
1988 SendDlgItemMessage(hwndDlg
, IDC_PROCESSPROGRESS
, PBM_SETRANGE
,
1989 0, MAKELPARAM(0, MaxProgress
));
1990 SendDlgItemMessage(hwndDlg
, IDC_PROCESSPROGRESS
, PBM_SETPOS
,
1998 SetupData
->UnattendSetup
= FALSE
;
2007 case PM_REGISTRATION_NOTIFY
:
2010 RegistrationNotify
= (PREGISTRATIONNOTIFY
) lParam
;
2011 // update if necessary only
2012 if (oldActivityID
!= RegistrationNotify
->ActivityID
)
2014 if (0 != LoadStringW(hDllInstance
, RegistrationNotify
->ActivityID
,
2016 sizeof(Activity
) / sizeof(Activity
[0])))
2018 SendDlgItemMessageW(hwndDlg
, IDC_ACTIVITY
, WM_SETTEXT
,
2019 0, (LPARAM
) Activity
);
2021 oldActivityID
= RegistrationNotify
->ActivityID
;
2023 SendDlgItemMessageW(hwndDlg
, IDC_ITEM
, WM_SETTEXT
, 0,
2024 (LPARAM
)(NULL
== RegistrationNotify
->CurrentItem
?
2025 L
"" : RegistrationNotify
->CurrentItem
));
2026 SendDlgItemMessage(hwndDlg
, IDC_PROCESSPROGRESS
, PBM_SETPOS
,
2027 RegistrationNotify
->Progress
, 0);
2028 if (NULL
!= RegistrationNotify
->ErrorMessage
)
2030 if (0 == LoadStringW(hDllInstance
, IDS_REACTOS_SETUP
,
2031 Title
, sizeof(Title
) / sizeof(Title
[0])))
2033 wcscpy(Title
, L
"ReactOS Setup");
2035 MessageBoxW(hwndDlg
, RegistrationNotify
->ErrorMessage
,
2036 Title
, MB_ICONERROR
| MB_OK
);
2042 /* Enable the Back and Next buttons */
2043 PropSheet_SetWizButtons(GetParent(hwndDlg
), PSWIZB_NEXT
);
2044 PropSheet_PressButton(GetParent(hwndDlg
), PSBTN_NEXT
);
2058 SetInstallationCompleted(VOID
)
2061 DWORD InProgress
= 0;
2064 if (RegOpenKeyExW( HKEY_LOCAL_MACHINE
,
2068 &hKey
) == ERROR_SUCCESS
)
2070 RegSetValueExW( hKey
, L
"SystemSetupInProgress", 0, REG_DWORD
, (LPBYTE
)&InProgress
, sizeof(InProgress
) );
2071 RegCloseKey( hKey
);
2074 if (RegOpenKeyExW( HKEY_LOCAL_MACHINE
,
2075 L
"Software\\Microsoft\\Windows NT\\CurrentVersion",
2078 &hKey
) == ERROR_SUCCESS
)
2080 InstallDate
= (DWORD
)time(NULL
);
2081 RegSetValueExW( hKey
, L
"InstallDate", 0, REG_DWORD
, (LPBYTE
)&InstallDate
, sizeof(InstallDate
) );
2082 RegCloseKey( hKey
);
2086 static INT_PTR CALLBACK
2087 FinishDlgProc(HWND hwndDlg
,
2097 /* Get pointer to the global setup data */
2098 PSETUPDATA SetupData
= (PSETUPDATA
)((LPPROPSHEETPAGE
)lParam
)->lParam
;
2100 if (!SetupData
->UnattendSetup
|| !SetupData
->DisableGeckoInst
)
2102 /* Run the Wine Gecko prompt */
2103 Control_RunDLLW(hwndDlg
, 0, L
"appwiz.cpl install_gecko", SW_SHOW
);
2106 /* Set title font */
2107 SendDlgItemMessage(hwndDlg
,
2110 (WPARAM
)SetupData
->hTitleFont
,
2112 if (SetupData
->UnattendSetup
)
2114 KillTimer(hwndDlg
, 1);
2115 SetInstallationCompleted();
2123 SetInstallationCompleted();
2133 hWndProgress
= GetDlgItem(hwndDlg
, IDC_RESTART_PROGRESS
);
2134 Position
= SendMessage(hWndProgress
, PBM_GETPOS
, 0, 0);
2135 if (Position
== 300)
2137 KillTimer(hwndDlg
, 1);
2138 PropSheet_PressButton(GetParent(hwndDlg
), PSBTN_FINISH
);
2142 SendMessage(hWndProgress
, PBM_SETPOS
, Position
+ 1, 0);
2149 LPNMHDR lpnm
= (LPNMHDR
)lParam
;
2154 /* Enable the correct buttons on for the active page */
2155 PropSheet_SetWizButtons(GetParent(hwndDlg
), PSWIZB_FINISH
);
2157 SendDlgItemMessage(hwndDlg
, IDC_RESTART_PROGRESS
, PBM_SETRANGE
, 0,
2158 MAKELPARAM(0, 300));
2159 SendDlgItemMessage(hwndDlg
, IDC_RESTART_PROGRESS
, PBM_SETPOS
, 0, 0);
2160 SetTimer(hwndDlg
, 1, 50, NULL
);
2164 DestroyWindow(GetParent(hwndDlg
));
2183 PSETUPDATA pSetupData
)
2185 INFCONTEXT InfContext
;
2187 WCHAR szValue
[MAX_PATH
];
2191 if (!SetupFindFirstLineW(pSetupData
->hUnattendedInf
,
2193 L
"UnattendSetupEnabled",
2196 DPRINT1("Error: Cannot find UnattendSetupEnabled Key! %d\n", GetLastError());
2200 if (!SetupGetStringFieldW(&InfContext
,
2203 sizeof(szValue
) / sizeof(WCHAR
),
2206 DPRINT1("Error: SetupGetStringField failed with %d\n", GetLastError());
2210 if (wcscmp(szValue
, L
"yes") != 0)
2212 DPRINT("Unattend setup was disabled by UnattendSetupEnabled key.\n");
2216 pSetupData
->UnattendSetup
= TRUE
;
2218 if (!SetupFindFirstLineW(pSetupData
->hUnattendedInf
,
2223 DPRINT1("Error: SetupFindFirstLine failed %d\n", GetLastError());
2229 if (!SetupGetStringFieldW(&InfContext
,
2232 sizeof(szName
) / sizeof(WCHAR
),
2235 DPRINT1("Error: SetupGetStringField failed with %d\n", GetLastError());
2239 if (!SetupGetStringFieldW(&InfContext
,
2242 sizeof(szValue
) / sizeof(WCHAR
),
2245 DPRINT1("Error: SetupGetStringField failed with %d\n", GetLastError());
2248 DPRINT1("Name %S Value %S\n", szName
, szValue
);
2249 if (!wcscmp(szName
, L
"FullName"))
2251 if ((sizeof(pSetupData
->OwnerName
) / sizeof(TCHAR
)) > LineLength
)
2253 wcscpy(pSetupData
->OwnerName
, szValue
);
2256 else if (!wcscmp(szName
, L
"OrgName"))
2258 if ((sizeof(pSetupData
->OwnerOrganization
) / sizeof(WCHAR
)) > LineLength
)
2260 wcscpy(pSetupData
->OwnerOrganization
, szValue
);
2263 else if (!wcscmp(szName
, L
"ComputerName"))
2265 if ((sizeof(pSetupData
->ComputerName
) / sizeof(WCHAR
)) > LineLength
)
2267 wcscpy(pSetupData
->ComputerName
, szValue
);
2270 else if (!wcscmp(szName
, L
"AdminPassword"))
2272 if ((sizeof(pSetupData
->AdminPassword
) / sizeof(WCHAR
)) > LineLength
)
2274 wcscpy(pSetupData
->AdminPassword
, szValue
);
2277 else if (!wcscmp(szName
, L
"TimeZoneIndex"))
2279 pSetupData
->TimeZoneIndex
= _wtoi(szValue
);
2281 else if (!wcscmp(szName
, L
"DisableAutoDaylightTimeSet"))
2283 pSetupData
->DisableAutoDaylightTimeSet
= _wtoi(szValue
);
2285 else if (!wcscmp(szName
, L
"DisableGeckoInst"))
2287 if(!wcscmp(szValue
, L
"yes"))
2288 pSetupData
->DisableGeckoInst
= TRUE
;
2290 pSetupData
->DisableGeckoInst
= FALSE
;
2293 } while (SetupFindNextLine(&InfContext
, &InfContext
));
2295 if (SetupFindFirstLineW(pSetupData
->hUnattendedInf
,
2300 DEVMODEW dm
= { { 0 } };
2301 dm
.dmSize
= sizeof(dm
);
2302 if (EnumDisplaySettingsW(NULL
, ENUM_CURRENT_SETTINGS
, &dm
))
2307 if (!SetupGetStringFieldW(&InfContext
,
2310 sizeof(szName
) / sizeof(WCHAR
),
2313 DPRINT1("Error: SetupGetStringField failed with %d\n", GetLastError());
2317 if (!SetupGetStringFieldW(&InfContext
,
2320 sizeof(szValue
) / sizeof(WCHAR
),
2323 DPRINT1("Error: SetupGetStringField failed with %d\n", GetLastError());
2326 iValue
= _wtoi(szValue
);
2327 DPRINT1("Name %S Value %i\n", szName
, iValue
);
2332 if (!wcscmp(szName
, L
"BitsPerPel"))
2334 dm
.dmFields
|= DM_BITSPERPEL
;
2335 dm
.dmBitsPerPel
= iValue
;
2337 else if (!wcscmp(szName
, L
"XResolution"))
2339 dm
.dmFields
|= DM_PELSWIDTH
;
2340 dm
.dmPelsWidth
= iValue
;
2342 else if (!wcscmp(szName
, L
"YResolution"))
2344 dm
.dmFields
|= DM_PELSHEIGHT
;
2345 dm
.dmPelsHeight
= iValue
;
2347 else if (!wcscmp(szName
, L
"VRefresh"))
2349 dm
.dmFields
|= DM_DISPLAYFREQUENCY
;
2350 dm
.dmDisplayFrequency
= iValue
;
2352 } while (SetupFindNextLine(&InfContext
, &InfContext
));
2354 ChangeDisplaySettingsW(&dm
, CDS_UPDATEREGISTRY
);
2358 if (RegOpenKeyExW(HKEY_LOCAL_MACHINE
,
2359 L
"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\RunOnce",
2362 &hKey
) != ERROR_SUCCESS
)
2364 DPRINT1("Error: failed to open HKLM\\Software\\Microsoft\\Windows\\CurrentVersion\\RunOnce\n");
2368 if (SetupFindFirstLineW(pSetupData
->hUnattendedInf
,
2376 if (SetupGetStringFieldW(&InfContext
,
2379 sizeof(szValue
) / sizeof(WCHAR
),
2382 WCHAR szPath
[MAX_PATH
];
2383 swprintf(szName
, L
"%d", i
);
2384 DPRINT("szName %S szValue %S\n", szName
, szValue
);
2386 if (ExpandEnvironmentStringsW(szValue
, szPath
, MAX_PATH
))
2388 DPRINT("value %S\n", szPath
);
2389 if (RegSetValueExW(hKey
,
2393 (const BYTE
*)szPath
,
2394 (wcslen(szPath
) + 1) * sizeof(WCHAR
)) == ERROR_SUCCESS
)
2400 } while (SetupFindNextLine(&InfContext
, &InfContext
));
2407 * GetRosInstallCD should find the path to ros installation medium
2409 * If there are more than one CDDrive in it containing a ReactOS
2410 * installation cd, then it will pick the first one regardless if
2411 * it is really the installation cd
2413 * The best way to implement this is to set the key
2414 * HKLM\Software\Microsoft\Windows NT\CurrentVersion\SourcePath (REG_SZ)
2418 GetRosInstallCD(WCHAR
*pwszPath
, DWORD cchPathMax
)
2420 WCHAR wszDrives
[512];
2424 cchDrives
= GetLogicalDriveStringsW(_countof(wszDrives
) - 1, wszDrives
);
2425 if (cchDrives
== 0 || cchDrives
>= _countof(wszDrives
))
2427 /* buffer too small or failure */
2428 LogItem(NULL
, L
"GetLogicalDriveStringsW failed");
2432 for (pwszDrive
= wszDrives
; pwszDrive
[0]; pwszDrive
+= wcslen(pwszDrive
) + 1)
2434 if (GetDriveTypeW(pwszDrive
) == DRIVE_CDROM
)
2436 WCHAR wszBuf
[MAX_PATH
];
2437 wsprintf(wszBuf
, L
"%sreactos\\system32\\ntoskrnl.exe", pwszDrive
);
2438 LogItem(NULL
, wszBuf
);
2439 if (GetFileAttributesW(wszBuf
) != INVALID_FILE_ATTRIBUTES
)
2441 /* the file exists, so this is the right drive */
2442 wcsncpy(pwszPath
, pwszDrive
, cchPathMax
);
2443 OutputDebugStringW(L
"GetRosInstallCD: ");OutputDebugStringW(pwszPath
);OutputDebugStringW(L
"\n");
2453 ProcessUnattendSetup(
2454 PSETUPDATA pSetupData
)
2456 WCHAR szPath
[MAX_PATH
];
2459 if (!GetRosInstallCD(szPath
, MAX_PATH
))
2461 /* no cd drive found */
2465 dwLength
= wcslen(szPath
);
2466 if (dwLength
+ 21 > MAX_PATH
)
2469 * allocate bigger buffer
2474 wcscat(szPath
, L
"reactos\\unattend.inf");
2476 pSetupData
->hUnattendedInf
= SetupOpenInfFileW(szPath
,
2480 if (pSetupData
->hUnattendedInf
!= INVALID_HANDLE_VALUE
)
2482 ProcessUnattendInf(pSetupData
);
2486 typedef DWORD(WINAPI
*PFNREQUESTWIZARDPAGES
)(PDWORD
, HPROPSHEETPAGE
*, PSETUPDATA
);
2491 PROPSHEETHEADER psh
;
2492 HPROPSHEETPAGE
*phpage
= NULL
;
2493 PROPSHEETPAGE psp
= {0};
2497 PSETUPDATA pSetupData
= NULL
;
2498 HMODULE hNetShell
= NULL
;
2499 PFNREQUESTWIZARDPAGES pfn
= NULL
;
2500 DWORD dwPageCount
= 9, dwNetworkPageCount
= 0;
2502 LogItem(L
"BEGIN_SECTION", L
"InstallWizard");
2504 /* Allocate setup data */
2505 pSetupData
= HeapAlloc(GetProcessHeap(),
2508 if (pSetupData
== NULL
)
2510 LogItem(NULL
, L
"SetupData allocation failed!");
2512 L
"Setup failed to allocate global data!",
2514 MB_ICONERROR
| MB_OK
);
2518 hNetShell
= LoadLibraryW(L
"netshell.dll");
2519 if (hNetShell
!= NULL
)
2521 DPRINT("Netshell.dll loaded!\n");
2523 pfn
= (PFNREQUESTWIZARDPAGES
)GetProcAddress(hNetShell
,
2524 "NetSetupRequestWizardPages");
2527 pfn(&dwNetworkPageCount
, NULL
, NULL
);
2528 dwPageCount
+= dwNetworkPageCount
;
2532 DPRINT("PageCount: %lu\n", dwPageCount
);
2534 phpage
= HeapAlloc(GetProcessHeap(),
2536 dwPageCount
* sizeof(HPROPSHEETPAGE
));
2539 LogItem(NULL
, L
"Page array allocation failed!");
2541 L
"Setup failed to allocate page array!",
2543 MB_ICONERROR
| MB_OK
);
2547 pSetupData
->hUnattendedInf
= INVALID_HANDLE_VALUE
;
2548 ProcessUnattendSetup(pSetupData
);
2550 /* Create the Welcome page */
2551 psp
.dwSize
= sizeof(PROPSHEETPAGE
);
2552 psp
.dwFlags
= PSP_DEFAULT
| PSP_HIDEHEADER
;
2553 psp
.hInstance
= hDllInstance
;
2554 psp
.lParam
= (LPARAM
)pSetupData
;
2555 psp
.pfnDlgProc
= WelcomeDlgProc
;
2556 psp
.pszTemplate
= MAKEINTRESOURCE(IDD_WELCOMEPAGE
);
2557 phpage
[nPages
++] = CreatePropertySheetPage(&psp
);
2559 /* Create the Acknowledgements page */
2560 psp
.dwFlags
= PSP_DEFAULT
| PSP_USEHEADERTITLE
| PSP_USEHEADERSUBTITLE
;
2561 psp
.pszHeaderTitle
= MAKEINTRESOURCE(IDS_ACKTITLE
);
2562 psp
.pszHeaderSubTitle
= MAKEINTRESOURCE(IDS_ACKSUBTITLE
);
2563 psp
.pszTemplate
= MAKEINTRESOURCE(IDD_ACKPAGE
);
2564 psp
.pfnDlgProc
= AckPageDlgProc
;
2565 phpage
[nPages
++] = CreatePropertySheetPage(&psp
);
2567 /* Create the Locale page */
2568 psp
.dwFlags
= PSP_DEFAULT
| PSP_USEHEADERTITLE
| PSP_USEHEADERSUBTITLE
;
2569 psp
.pszHeaderTitle
= MAKEINTRESOURCE(IDS_LOCALETITLE
);
2570 psp
.pszHeaderSubTitle
= MAKEINTRESOURCE(IDS_LOCALESUBTITLE
);
2571 psp
.pfnDlgProc
= LocalePageDlgProc
;
2572 psp
.pszTemplate
= MAKEINTRESOURCE(IDD_LOCALEPAGE
);
2573 phpage
[nPages
++] = CreatePropertySheetPage(&psp
);
2575 /* Create the Owner page */
2576 psp
.dwFlags
= PSP_DEFAULT
| PSP_USEHEADERTITLE
| PSP_USEHEADERSUBTITLE
;
2577 psp
.pszHeaderTitle
= MAKEINTRESOURCE(IDS_OWNERTITLE
);
2578 psp
.pszHeaderSubTitle
= MAKEINTRESOURCE(IDS_OWNERSUBTITLE
);
2579 psp
.pszTemplate
= MAKEINTRESOURCE(IDD_OWNERPAGE
);
2580 psp
.pfnDlgProc
= OwnerPageDlgProc
;
2581 phpage
[nPages
++] = CreatePropertySheetPage(&psp
);
2583 /* Create the Computer page */
2584 psp
.dwFlags
= PSP_DEFAULT
| PSP_USEHEADERTITLE
| PSP_USEHEADERSUBTITLE
;
2585 psp
.pszHeaderTitle
= MAKEINTRESOURCE(IDS_COMPUTERTITLE
);
2586 psp
.pszHeaderSubTitle
= MAKEINTRESOURCE(IDS_COMPUTERSUBTITLE
);
2587 psp
.pfnDlgProc
= ComputerPageDlgProc
;
2588 psp
.pszTemplate
= MAKEINTRESOURCE(IDD_COMPUTERPAGE
);
2589 phpage
[nPages
++] = CreatePropertySheetPage(&psp
);
2591 /* Create the DateTime page */
2592 psp
.dwFlags
= PSP_DEFAULT
| PSP_USEHEADERTITLE
| PSP_USEHEADERSUBTITLE
;
2593 psp
.pszHeaderTitle
= MAKEINTRESOURCE(IDS_DATETIMETITLE
);
2594 psp
.pszHeaderSubTitle
= MAKEINTRESOURCE(IDS_DATETIMESUBTITLE
);
2595 psp
.pfnDlgProc
= DateTimePageDlgProc
;
2596 psp
.pszTemplate
= MAKEINTRESOURCE(IDD_DATETIMEPAGE
);
2597 phpage
[nPages
++] = CreatePropertySheetPage(&psp
);
2599 /* Create the theme selection page */
2600 psp
.dwFlags
= PSP_DEFAULT
| PSP_USEHEADERTITLE
| PSP_USEHEADERSUBTITLE
;
2601 psp
.pszHeaderTitle
= MAKEINTRESOURCE(IDS_THEMESELECTIONTITLE
);
2602 psp
.pszHeaderSubTitle
= MAKEINTRESOURCE(IDS_THEMESELECTIONSUBTITLE
);
2603 psp
.pfnDlgProc
= ThemePageDlgProc
;
2604 psp
.pszTemplate
= MAKEINTRESOURCE(IDD_THEMEPAGE
);
2605 phpage
[nPages
++] = CreatePropertySheetPage(&psp
);
2607 pSetupData
->uFirstNetworkWizardPage
= IDD_PROCESSPAGE
;
2608 pSetupData
->uPostNetworkWizardPage
= IDD_PROCESSPAGE
;
2612 pfn(&dwNetworkPageCount
, &phpage
[nPages
], pSetupData
);
2613 nPages
+= dwNetworkPageCount
;
2616 /* Create the Process page */
2617 psp
.dwFlags
= PSP_DEFAULT
| PSP_USEHEADERTITLE
| PSP_USEHEADERSUBTITLE
;
2618 psp
.pszHeaderTitle
= MAKEINTRESOURCE(IDS_PROCESSTITLE
);
2619 psp
.pszHeaderSubTitle
= MAKEINTRESOURCE(IDS_PROCESSSUBTITLE
);
2620 psp
.pfnDlgProc
= ProcessPageDlgProc
;
2621 psp
.pszTemplate
= MAKEINTRESOURCE(IDD_PROCESSPAGE
);
2622 phpage
[nPages
++] = CreatePropertySheetPage(&psp
);
2624 /* Create the Finish page */
2625 psp
.dwFlags
= PSP_DEFAULT
| PSP_HIDEHEADER
;
2626 psp
.pfnDlgProc
= FinishDlgProc
;
2627 psp
.pszTemplate
= MAKEINTRESOURCE(IDD_FINISHPAGE
);
2628 phpage
[nPages
++] = CreatePropertySheetPage(&psp
);
2630 ASSERT(nPages
== dwPageCount
);
2632 /* Create the property sheet */
2633 psh
.dwSize
= sizeof(PROPSHEETHEADER
);
2634 psh
.dwFlags
= PSH_WIZARD97
| PSH_WATERMARK
| PSH_HEADER
| PSH_MODELESS
;
2635 psh
.hInstance
= hDllInstance
;
2636 psh
.hwndParent
= NULL
;
2637 psh
.nPages
= nPages
;
2639 psh
.phpage
= phpage
;
2640 psh
.pszbmWatermark
= MAKEINTRESOURCE(IDB_WATERMARK
);
2641 psh
.pszbmHeader
= MAKEINTRESOURCE(IDB_HEADER
);
2643 /* Create title font */
2644 pSetupData
->hTitleFont
= CreateTitleFont();
2645 pSetupData
->hBoldFont
= CreateBoldFont();
2647 /* Display the wizard */
2648 hWnd
= (HWND
)PropertySheet(&psh
);
2649 ShowWindow(hWnd
, SW_SHOW
);
2651 while (GetMessage(&msg
, NULL
, 0, 0))
2653 if (!IsDialogMessage(hWnd
, &msg
))
2655 TranslateMessage(&msg
);
2656 DispatchMessage(&msg
);
2660 if (pSetupData
->hUnattendedInf
!= INVALID_HANDLE_VALUE
)
2661 SetupCloseInfFile(pSetupData
->hUnattendedInf
);
2665 HeapFree(GetProcessHeap(), 0, phpage
);
2667 if (hNetShell
!= NULL
)
2668 FreeLibrary(hNetShell
);
2670 if (pSetupData
!= NULL
)
2672 DeleteObject(pSetupData
->hBoldFont
);
2673 DeleteObject(pSetupData
->hTitleFont
);
2674 HeapFree(GetProcessHeap(), 0, pSetupData
);
2677 LogItem(L
"END_SECTION", L
"InstallWizard");