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>
10 /* INCLUDES *****************************************************************/
19 #define PM_REGISTRATION_NOTIFY (WM_APP + 1)
20 /* Private Message used to communicate progress from the background
21 registration thread to the main thread.
22 wParam = 0 Registration in progress
23 = 1 Registration completed
24 lParam = Pointer to a REGISTRATIONNOTIFY structure */
26 typedef struct _REGISTRATIONNOTIFY
32 } REGISTRATIONNOTIFY
, *PREGISTRATIONNOTIFY
;
34 typedef struct _REGISTRATIONDATA
40 } REGISTRATIONDATA
, *PREGISTRATIONDATA
;
42 /* GLOBALS ******************************************************************/
47 /* FUNCTIONS ****************************************************************/
49 extern void WINAPI
Control_RunDLLW(HWND hWnd
, HINSTANCE hInst
, LPCWSTR cmd
, DWORD nCmdShow
);
52 GetRosInstallCD(WCHAR
*pwszPath
, DWORD cchPathMax
);
56 RunVMWInstall(HWND hWnd
)
58 PROCESS_INFORMATION ProcInfo
;
62 WCHAR InstallName
[] = L
"vmwinst.exe";
64 ZeroMemory(&si
, sizeof(si
));
67 if(CreateProcessW(NULL
, InstallName
, NULL
, NULL
, TRUE
, NORMAL_PRIORITY_CLASS
,
68 NULL
, NULL
, &si
, &ProcInfo
))
70 EnableWindow(hWnd
, FALSE
);
73 while (PeekMessage(&msg
, NULL
, 0, 0, PM_REMOVE
))
75 if (msg
.message
== WM_QUIT
)
77 TranslateMessage(&msg
);
78 DispatchMessage(&msg
);
81 ret
= MsgWaitForMultipleObjects(1, &ProcInfo
.hProcess
, FALSE
, INFINITE
, QS_ALLEVENTS
| QS_ALLINPUT
);
82 if (ret
== WAIT_OBJECT_0
)
86 EnableWindow(hWnd
, TRUE
);
88 CloseHandle(ProcInfo
.hThread
);
89 CloseHandle(ProcInfo
.hProcess
);
97 CenterWindow(HWND hWnd
)
103 hWndParent
= GetParent(hWnd
);
104 if (hWndParent
== NULL
)
105 hWndParent
= GetDesktopWindow();
107 GetWindowRect(hWndParent
, &rcParent
);
108 GetWindowRect(hWnd
, &rcWindow
);
112 ((rcParent
.right
- rcParent
.left
) - (rcWindow
.right
- rcWindow
.left
)) / 2,
113 ((rcParent
.bottom
- rcParent
.top
) - (rcWindow
.bottom
- rcWindow
.top
)) / 2,
121 CreateTitleFont(VOID
)
123 NONCLIENTMETRICSW ncm
;
129 ncm
.cbSize
= sizeof(NONCLIENTMETRICSW
);
130 SystemParametersInfo(SPI_GETNONCLIENTMETRICS
, 0, &ncm
, 0);
132 LogFont
= ncm
.lfMessageFont
;
133 LogFont
.lfWeight
= FW_BOLD
;
134 wcscpy(LogFont
.lfFaceName
, L
"MS Shell Dlg");
138 LogFont
.lfHeight
= 0 - GetDeviceCaps(hdc
, LOGPIXELSY
) * FontSize
/ 72;
139 hFont
= CreateFontIndirectW(&LogFont
);
140 ReleaseDC(NULL
, hdc
);
146 static INT_PTR CALLBACK
147 GplDlgProc(HWND hwndDlg
,
152 HRSRC GplTextResource
;
162 GplTextResource
= FindResourceW(hDllInstance
, MAKEINTRESOURCE(IDR_GPL
), L
"RT_TEXT");
163 if (NULL
== GplTextResource
)
167 Size
= SizeofResource(hDllInstance
, GplTextResource
);
172 GplText
= HeapAlloc(GetProcessHeap(), 0, Size
+ 1);
177 GplTextMem
= LoadResource(hDllInstance
, GplTextResource
);
178 if (NULL
== GplTextMem
)
180 HeapFree(GetProcessHeap(), 0, GplText
);
183 GplTextLocked
= LockResource(GplTextMem
);
184 if (NULL
== GplTextLocked
)
186 HeapFree(GetProcessHeap(), 0, GplText
);
189 memcpy(GplText
, GplTextLocked
, Size
);
190 GplText
[Size
] = '\0';
191 SendMessageA(GetDlgItem(hwndDlg
, IDC_GPL_TEXT
), WM_SETTEXT
, 0, (LPARAM
) GplText
);
192 HeapFree(GetProcessHeap(), 0, GplText
);
193 SetFocus(GetDlgItem(hwndDlg
, IDOK
));
197 EndDialog(hwndDlg
, IDCANCEL
);
201 if (HIWORD(wParam
) == BN_CLICKED
&& IDOK
== LOWORD(wParam
))
203 EndDialog(hwndDlg
, IDOK
);
215 static INT_PTR CALLBACK
216 WelcomeDlgProc(HWND hwndDlg
,
225 PSETUPDATA SetupData
;
229 /* Get pointer to the global setup data */
230 SetupData
= (PSETUPDATA
)((LPPROPSHEETPAGE
)lParam
)->lParam
;
232 hwndControl
= GetParent(hwndDlg
);
234 /* Center the wizard window */
235 CenterWindow (hwndControl
);
237 /* Hide the system menu */
238 dwStyle
= GetWindowLongPtr(hwndControl
, GWL_STYLE
);
239 SetWindowLongPtr(hwndControl
, GWL_STYLE
, dwStyle
& ~WS_SYSMENU
);
241 /* Hide and disable the 'Cancel' button */
242 hwndControl
= GetDlgItem(GetParent(hwndDlg
), IDCANCEL
);
243 ShowWindow (hwndControl
, SW_HIDE
);
244 EnableWindow (hwndControl
, FALSE
);
247 SendDlgItemMessage(hwndDlg
,
250 (WPARAM
)SetupData
->hTitleFont
,
258 LPNMHDR lpnm
= (LPNMHDR
)lParam
;
263 /* Enable the Next button */
264 PropSheet_SetWizButtons(GetParent(hwndDlg
), PSWIZB_NEXT
);
265 if (SetupData
.UnattendSetup
)
267 SetWindowLongPtr(hwndDlg
, DWL_MSGRESULT
, IDD_ACKPAGE
);
273 SetupData
.UnattendSetup
= FALSE
;
290 static INT_PTR CALLBACK
291 AckPageDlgProc(HWND hwndDlg
,
298 PWCHAR End
, CurrentProject
;
299 INT ProjectsSize
, ProjectsCount
;
309 Projects
= HeapAlloc(GetProcessHeap(), 0, ProjectsSize
* sizeof(WCHAR
));
310 if (NULL
== Projects
)
314 ProjectsCount
= LoadStringW(hDllInstance
, IDS_ACKPROJECTS
, Projects
, ProjectsSize
);
315 if (0 == ProjectsCount
)
317 HeapFree(GetProcessHeap(), 0, Projects
);
320 if (ProjectsCount
< ProjectsSize
- 1)
324 HeapFree(GetProcessHeap(), 0, Projects
);
328 CurrentProject
= Projects
;
329 while (L
'\0' != *CurrentProject
)
331 End
= wcschr(CurrentProject
, L
'\n');
336 (void)ListBox_AddString(GetDlgItem(hwndDlg
, IDC_PROJECTS
), CurrentProject
);
339 CurrentProject
= End
+ 1;
343 CurrentProject
+= wcslen(CurrentProject
);
346 HeapFree(GetProcessHeap(), 0, Projects
);
351 if (HIWORD(wParam
) == BN_CLICKED
&& IDC_VIEWGPL
== LOWORD(wParam
))
353 DialogBox(hDllInstance
, MAKEINTRESOURCE(IDD_GPL
), NULL
, GplDlgProc
);
354 SetForegroundWindow(GetParent(hwndDlg
));
360 lpnm
= (LPNMHDR
)lParam
;
365 /* Enable the Back and Next buttons */
366 PropSheet_SetWizButtons(GetParent(hwndDlg
), PSWIZB_BACK
| PSWIZB_NEXT
);
367 if (SetupData
.UnattendSetup
)
369 SetWindowLongPtr(hwndDlg
, DWL_MSGRESULT
, IDD_OWNERPAGE
);
375 SetupData
.UnattendSetup
= FALSE
;
393 WriteOwnerSettings(WCHAR
* OwnerName
,
394 WCHAR
* OwnerOrganization
)
401 res
= RegOpenKeyExW(HKEY_LOCAL_MACHINE
,
402 L
"Software\\Microsoft\\Windows NT\\CurrentVersion",
407 if (res
!= ERROR_SUCCESS
)
412 res
= RegSetValueExW(hKey
,
417 (wcslen(OwnerName
) + 1) * sizeof(WCHAR
));
419 if (res
!= ERROR_SUCCESS
)
425 res
= RegSetValueExW(hKey
,
426 L
"RegisteredOrganization",
429 (LPBYTE
)OwnerOrganization
,
430 (wcslen(OwnerOrganization
) + 1) * sizeof(WCHAR
));
433 return (res
== ERROR_SUCCESS
);
436 static INT_PTR CALLBACK
437 OwnerPageDlgProc(HWND hwndDlg
,
443 WCHAR OwnerOrganization
[51];
445 WCHAR ErrorName
[256];
452 SendDlgItemMessage(hwndDlg
, IDC_OWNERNAME
, EM_LIMITTEXT
, 50, 0);
453 SendDlgItemMessage(hwndDlg
, IDC_OWNERORGANIZATION
, EM_LIMITTEXT
, 50, 0);
455 /* Set focus to owner name */
456 SetFocus(GetDlgItem(hwndDlg
, IDC_OWNERNAME
));
463 lpnm
= (LPNMHDR
)lParam
;
468 /* Enable the Back and Next buttons */
469 PropSheet_SetWizButtons(GetParent(hwndDlg
), PSWIZB_BACK
| PSWIZB_NEXT
);
470 if (SetupData
.UnattendSetup
)
472 SendMessage(GetDlgItem(hwndDlg
, IDC_OWNERNAME
), WM_SETTEXT
, 0, (LPARAM
)SetupData
.OwnerName
);
473 SendMessage(GetDlgItem(hwndDlg
, IDC_OWNERORGANIZATION
), WM_SETTEXT
, 0, (LPARAM
)SetupData
.OwnerOrganization
);
474 if (WriteOwnerSettings(SetupData
.OwnerName
, SetupData
.OwnerOrganization
))
476 SetWindowLongPtr(hwndDlg
, DWL_MSGRESULT
, IDD_COMPUTERPAGE
);
484 if (GetDlgItemTextW(hwndDlg
, IDC_OWNERNAME
, OwnerName
, 50) == 0)
486 if (0 == LoadStringW(hDllInstance
, IDS_REACTOS_SETUP
, Title
, sizeof(Title
) / sizeof(Title
[0])))
488 wcscpy(Title
, L
"ReactOS Setup");
490 if (0 == LoadStringW(hDllInstance
, IDS_WZD_NAME
, ErrorName
, sizeof(ErrorName
) / sizeof(ErrorName
[0])))
492 wcscpy(ErrorName
, L
"Setup cannot continue until you enter your name.");
494 MessageBoxW(hwndDlg
, ErrorName
, Title
, MB_ICONERROR
| MB_OK
);
496 SetFocus(GetDlgItem(hwndDlg
, IDC_OWNERNAME
));
497 SetWindowLongPtr(hwndDlg
, DWL_MSGRESULT
, -1);
502 OwnerOrganization
[0] = 0;
503 GetDlgItemTextW(hwndDlg
, IDC_OWNERORGANIZATION
, OwnerOrganization
, 50);
505 if (!WriteOwnerSettings(OwnerName
, OwnerOrganization
))
507 SetFocus(GetDlgItem(hwndDlg
, IDC_OWNERNAME
));
508 SetWindowLongPtr(hwndDlg
, DWL_MSGRESULT
, -1);
513 SetupData
.UnattendSetup
= FALSE
;
531 WriteComputerSettings(WCHAR
* ComputerName
, HWND hwndDlg
)
534 WCHAR ErrorComputerName
[256];
535 if (!SetComputerNameW(ComputerName
))
537 if (0 == LoadStringW(hDllInstance
, IDS_REACTOS_SETUP
, Title
, sizeof(Title
) / sizeof(Title
[0])))
539 wcscpy(Title
, L
"ReactOS Setup");
541 if (0 == LoadStringW(hDllInstance
, IDS_WZD_SETCOMPUTERNAME
, ErrorComputerName
,
542 sizeof(ErrorComputerName
) / sizeof(ErrorComputerName
[0])))
544 wcscpy(ErrorComputerName
, L
"Setup failed to set the computer name.");
546 MessageBoxW(hwndDlg
, ErrorComputerName
, Title
, MB_ICONERROR
| MB_OK
);
551 /* Try to also set DNS hostname */
552 SetComputerNameExW(ComputerNamePhysicalDnsHostname
, ComputerName
);
554 /* Set the account domain name */
555 SetAccountDomain(ComputerName
, NULL
);
560 /* lpBuffer will be filled with a 15-char string (plus the null terminator) */
562 GenerateComputerName(LPWSTR lpBuffer
)
564 static const WCHAR Chars
[] = L
"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
565 static const unsigned cChars
= sizeof(Chars
) / sizeof(WCHAR
) - 1;
568 wcscpy(lpBuffer
, L
"REACTOS-");
570 srand(GetTickCount());
572 /* fill in 7 characters */
573 for (i
= 8; i
< 15; i
++)
574 lpBuffer
[i
] = Chars
[rand() % cChars
];
576 lpBuffer
[15] = UNICODE_NULL
; /* NULL-terminate */
579 static INT_PTR CALLBACK
580 ComputerPageDlgProc(HWND hwndDlg
,
585 WCHAR ComputerName
[MAX_COMPUTERNAME_LENGTH
+ 1];
590 WCHAR EmptyComputerName
[256], NotMatchPassword
[256], WrongPassword
[256];
593 if (0 == LoadStringW(hDllInstance
, IDS_REACTOS_SETUP
, Title
, sizeof(Title
) / sizeof(Title
[0])))
595 wcscpy(Title
, L
"ReactOS Setup");
602 /* Generate a new pseudo-random computer name */
603 GenerateComputerName(ComputerName
);
605 /* Display current computer name */
606 SetDlgItemTextW(hwndDlg
, IDC_COMPUTERNAME
, ComputerName
);
608 /* Set text limits */
609 SendDlgItemMessage(hwndDlg
, IDC_COMPUTERNAME
, EM_LIMITTEXT
, MAX_COMPUTERNAME_LENGTH
, 0);
610 SendDlgItemMessage(hwndDlg
, IDC_ADMINPASSWORD1
, EM_LIMITTEXT
, 14, 0);
611 SendDlgItemMessage(hwndDlg
, IDC_ADMINPASSWORD2
, EM_LIMITTEXT
, 14, 0);
613 /* Set focus to computer name */
614 SetFocus(GetDlgItem(hwndDlg
, IDC_COMPUTERNAME
));
615 if (SetupData
.UnattendSetup
)
617 SendMessage(GetDlgItem(hwndDlg
, IDC_COMPUTERNAME
), WM_SETTEXT
, 0, (LPARAM
)SetupData
.ComputerName
);
618 SendMessage(GetDlgItem(hwndDlg
, IDC_ADMINPASSWORD1
), WM_SETTEXT
, 0, (LPARAM
)SetupData
.AdminPassword
);
619 SendMessage(GetDlgItem(hwndDlg
, IDC_ADMINPASSWORD2
), WM_SETTEXT
, 0, (LPARAM
)SetupData
.AdminPassword
);
628 lpnm
= (LPNMHDR
)lParam
;
633 /* Enable the Back and Next buttons */
634 PropSheet_SetWizButtons(GetParent(hwndDlg
), PSWIZB_BACK
| PSWIZB_NEXT
);
635 if (SetupData
.UnattendSetup
&& WriteComputerSettings(SetupData
.ComputerName
, hwndDlg
))
637 SetWindowLongPtr(hwndDlg
, DWL_MSGRESULT
, IDD_LOCALEPAGE
);
643 if (0 == GetDlgItemTextW(hwndDlg
, IDC_COMPUTERNAME
, ComputerName
, MAX_COMPUTERNAME_LENGTH
+ 1))
645 if (0 == LoadStringW(hDllInstance
, IDS_WZD_COMPUTERNAME
, EmptyComputerName
,
646 sizeof(EmptyComputerName
) / sizeof(EmptyComputerName
[0])))
648 wcscpy(EmptyComputerName
, L
"Setup cannot continue until you enter the name of your computer.");
650 MessageBoxW(hwndDlg
, EmptyComputerName
, Title
, MB_ICONERROR
| MB_OK
);
651 SetFocus(GetDlgItem(hwndDlg
, IDC_COMPUTERNAME
));
652 SetWindowLongPtr(hwndDlg
, DWL_MSGRESULT
, -1);
656 /* No need to check computer name for invalid characters,
657 * SetComputerName() will do it for us */
659 if (!WriteComputerSettings(ComputerName
, hwndDlg
))
661 SetFocus(GetDlgItem(hwndDlg
, IDC_COMPUTERNAME
));
662 SetWindowLongPtr(hwndDlg
, DWL_MSGRESULT
, -1);
667 /* Check if admin passwords have been entered */
668 if ((GetDlgItemText(hwndDlg
, IDC_ADMINPASSWORD1
, Password1
, 15) == 0) ||
669 (GetDlgItemText(hwndDlg
, IDC_ADMINPASSWORD2
, Password2
, 15) == 0))
671 if (0 == LoadStringW(hDllInstance
, IDS_WZD_PASSWORDEMPTY
, EmptyPassword
,
672 sizeof(EmptyPassword
) / sizeof(EmptyPassword
[0])))
674 wcscpy(EmptyPassword
, L
"You must enter a password !");
676 MessageBoxW(hwndDlg
, EmptyPassword
, Title
, MB_ICONERROR
| MB_OK
);
677 SetWindowLongPtr(hwndDlg
, DWL_MSGRESULT
, -1);
681 GetDlgItemTextW(hwndDlg
, IDC_ADMINPASSWORD1
, Password1
, 15);
682 GetDlgItemTextW(hwndDlg
, IDC_ADMINPASSWORD2
, Password2
, 15);
684 /* Check if passwords match */
685 if (wcscmp(Password1
, Password2
))
687 if (0 == LoadStringW(hDllInstance
, IDS_WZD_PASSWORDMATCH
, NotMatchPassword
,
688 sizeof(NotMatchPassword
) / sizeof(NotMatchPassword
[0])))
690 wcscpy(NotMatchPassword
, L
"The passwords you entered do not match. Please enter the desired password again.");
692 MessageBoxW(hwndDlg
, NotMatchPassword
, Title
, MB_ICONERROR
| MB_OK
);
693 SetWindowLongPtr(hwndDlg
, DWL_MSGRESULT
, -1);
697 /* Check password for invalid characters */
698 Password
= (PWCHAR
)Password1
;
701 if (!isprint(*Password
))
703 if (0 == LoadStringW(hDllInstance
, IDS_WZD_PASSWORDCHAR
, WrongPassword
,
704 sizeof(WrongPassword
) / sizeof(WrongPassword
[0])))
706 wcscpy(WrongPassword
, L
"The password you entered contains invalid characters. Please enter a cleaned password.");
708 MessageBoxW(hwndDlg
, WrongPassword
, Title
, MB_ICONERROR
| MB_OK
);
709 SetWindowLongPtr(hwndDlg
, DWL_MSGRESULT
, -1);
715 /* Set admin password */
716 SetAdministratorPassword(Password1
);
720 SetupData
.UnattendSetup
= FALSE
;
738 SetKeyboardLayoutName(HWND hwnd
)
741 TCHAR szLayoutPath
[256];
742 TCHAR szLocaleName
[32];
746 if (RegOpenKeyEx(HKEY_LOCAL_MACHINE
,
747 _T("SYSTEM\\CurrentControlSet\\Control\\NLS\\Locale"),
753 dwValueSize
= 16 * sizeof(TCHAR
);
754 if (RegQueryValueEx(hKey
,
765 _tcscpy(szLayoutPath
,
766 _T("SYSTEM\\CurrentControlSet\\Control\\Keyboard Layouts\\"));
767 _tcscat(szLayoutPath
,
770 if (RegOpenKeyEx(HKEY_LOCAL_MACHINE
,
777 dwValueSize
= 32 * sizeof(TCHAR
);
778 if (RegQueryValueEx(hKey
,
795 RunControlPanelApplet(HWND hwnd
, PCWSTR pwszCPLParameters
)
797 if (pwszCPLParameters
)
799 STARTUPINFOW StartupInfo
;
800 PROCESS_INFORMATION ProcessInformation
;
801 WCHAR CmdLine
[MAX_PATH
] = L
"rundll32.exe shell32.dll,Control_RunDLL ";
803 ZeroMemory(&StartupInfo
, sizeof(StartupInfo
));
804 StartupInfo
.cb
= sizeof(StartupInfo
);
806 ASSERT(_countof(CmdLine
) > wcslen(CmdLine
) + wcslen(pwszCPLParameters
));
807 wcscat(CmdLine
, pwszCPLParameters
);
809 if (!CreateProcessW(NULL
,
818 &ProcessInformation
))
820 MessageBoxW(hwnd
, L
"Error: Failed to launch the Control Panel Applet.", NULL
, MB_ICONERROR
);
824 WaitForSingleObject(ProcessInformation
.hProcess
, INFINITE
);
825 CloseHandle(ProcessInformation
.hThread
);
826 CloseHandle(ProcessInformation
.hProcess
);
831 MessageBoxW(hwnd
, L
"Error: Failed to launch the Control Panel Applet.", NULL
, MB_ICONERROR
);
837 WriteUserLocale(VOID
)
843 lcid
= GetSystemDefaultLCID();
845 if (GetLocaleInfoW(MAKELCID(lcid
, SORT_DEFAULT
), LOCALE_ILANGUAGE
, Locale
, sizeof(Locale
) / sizeof(Locale
[0])) != 0)
847 if (RegCreateKeyExW(HKEY_CURRENT_USER
, L
"Control Panel\\International",
848 0, NULL
, REG_OPTION_NON_VOLATILE
,
849 KEY_WRITE
, NULL
, &hKey
, NULL
) == ERROR_SUCCESS
)
851 RegSetValueExW(hKey
, L
"Locale", 0, REG_SZ
, (LPBYTE
)Locale
, (wcslen(Locale
) + 1) * sizeof(WCHAR
));
857 static INT_PTR CALLBACK
858 LocalePageDlgProc(HWND hwndDlg
,
863 PSETUPDATA SetupData
;
865 /* Retrieve pointer to the global setup data */
866 SetupData
= (PSETUPDATA
)GetWindowLongPtr (hwndDlg
, GWL_USERDATA
);
872 /* Save pointer to the global setup data */
873 SetupData
= (PSETUPDATA
)((LPPROPSHEETPAGE
)lParam
)->lParam
;
874 SetWindowLongPtr(hwndDlg
, GWL_USERDATA
, (DWORD_PTR
)SetupData
);
877 SetKeyboardLayoutName(GetDlgItem(hwndDlg
, IDC_LAYOUTTEXT
));
882 if (HIWORD(wParam
) == BN_CLICKED
)
884 switch (LOWORD(wParam
))
886 case IDC_CUSTOMLOCALE
:
887 RunControlPanelApplet(hwndDlg
, L
"intl.cpl,,5");
888 /* FIXME: Update input locale name */
891 case IDC_CUSTOMLAYOUT
:
892 RunControlPanelApplet(hwndDlg
, L
"input.dll,@1");
900 LPNMHDR lpnm
= (LPNMHDR
)lParam
;
905 /* Enable the Back and Next buttons */
906 PropSheet_SetWizButtons(GetParent(hwndDlg
), PSWIZB_BACK
| PSWIZB_NEXT
);
907 if (SetupData
->UnattendSetup
)
909 WCHAR wszPath
[MAX_PATH
];
910 if (GetRosInstallCD(wszPath
, _countof(wszPath
)))
912 WCHAR wszParams
[1024];
913 swprintf(wszParams
, L
"intl.cpl,,/f:\"%sreactos\\unattend.inf\"", wszPath
);
914 RunControlPanelApplet(hwndDlg
, wszParams
);
918 RunControlPanelApplet(hwndDlg
, L
"intl.cpl,,/f:\"unattend.inf\"");
921 SetWindowLongPtr(hwndDlg
, DWL_MSGRESULT
, IDD_DATETIMEPAGE
);
930 SetupData
->UnattendSetup
= FALSE
;
947 static PTIMEZONE_ENTRY
948 GetLargerTimeZoneEntry(PSETUPDATA SetupData
, DWORD Index
)
950 PTIMEZONE_ENTRY Entry
;
952 Entry
= SetupData
->TimeZoneListHead
;
953 while (Entry
!= NULL
)
955 if (Entry
->Index
>= Index
)
966 CreateTimeZoneList(PSETUPDATA SetupData
)
968 WCHAR szKeyName
[256];
976 PTIMEZONE_ENTRY Entry
;
977 PTIMEZONE_ENTRY Current
;
979 if (RegOpenKeyExW(HKEY_LOCAL_MACHINE
,
980 L
"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Time Zones",
989 dwNameSize
= 256 * sizeof(WCHAR
);
990 lError
= RegEnumKeyExW(hZonesKey
,
998 if (lError
!= ERROR_SUCCESS
&& lError
!= ERROR_MORE_DATA
)
1001 if (RegOpenKeyExW(hZonesKey
,
1008 Entry
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(TIMEZONE_ENTRY
));
1011 RegCloseKey(hZoneKey
);
1015 dwValueSize
= 64 * sizeof(WCHAR
);
1016 if (RegQueryValueExW(hZoneKey
,
1020 (LPBYTE
)&Entry
->Description
,
1023 RegCloseKey(hZoneKey
);
1027 dwValueSize
= 32 * sizeof(WCHAR
);
1028 if (RegQueryValueExW(hZoneKey
,
1032 (LPBYTE
)&Entry
->StandardName
,
1035 RegCloseKey(hZoneKey
);
1039 dwValueSize
= 32 * sizeof(WCHAR
);
1040 if (RegQueryValueExW(hZoneKey
,
1044 (LPBYTE
)&Entry
->DaylightName
,
1047 RegCloseKey(hZoneKey
);
1051 dwValueSize
= sizeof(DWORD
);
1052 if (RegQueryValueExW(hZoneKey
,
1056 (LPBYTE
)&Entry
->Index
,
1059 RegCloseKey(hZoneKey
);
1063 dwValueSize
= sizeof(TZ_INFO
);
1064 if (RegQueryValueExW(hZoneKey
,
1068 (LPBYTE
)&Entry
->TimezoneInfo
,
1071 RegCloseKey(hZoneKey
);
1075 RegCloseKey(hZoneKey
);
1077 if (SetupData
->TimeZoneListHead
== NULL
&&
1078 SetupData
->TimeZoneListTail
== NULL
)
1082 SetupData
->TimeZoneListHead
= Entry
;
1083 SetupData
->TimeZoneListTail
= Entry
;
1087 Current
= GetLargerTimeZoneEntry(SetupData
, Entry
->Index
);
1088 if (Current
!= NULL
)
1090 if (Current
== SetupData
->TimeZoneListHead
)
1092 /* Prepend to head */
1094 Entry
->Next
= SetupData
->TimeZoneListHead
;
1095 SetupData
->TimeZoneListHead
->Prev
= Entry
;
1096 SetupData
->TimeZoneListHead
= Entry
;
1100 /* Insert before current */
1101 Entry
->Prev
= Current
->Prev
;
1102 Entry
->Next
= Current
;
1103 Current
->Prev
->Next
= Entry
;
1104 Current
->Prev
= Entry
;
1109 /* Append to tail */
1110 Entry
->Prev
= SetupData
->TimeZoneListTail
;
1112 SetupData
->TimeZoneListTail
->Next
= Entry
;
1113 SetupData
->TimeZoneListTail
= Entry
;
1120 RegCloseKey(hZonesKey
);
1125 DestroyTimeZoneList(PSETUPDATA SetupData
)
1127 PTIMEZONE_ENTRY Entry
;
1129 while (SetupData
->TimeZoneListHead
!= NULL
)
1131 Entry
= SetupData
->TimeZoneListHead
;
1133 SetupData
->TimeZoneListHead
= Entry
->Next
;
1134 if (SetupData
->TimeZoneListHead
!= NULL
)
1136 SetupData
->TimeZoneListHead
->Prev
= NULL
;
1139 HeapFree(GetProcessHeap(), 0, Entry
);
1142 SetupData
->TimeZoneListTail
= NULL
;
1146 GetTimeZoneListIndex(LPDWORD lpIndex
)
1148 WCHAR szLanguageIdString
[9];
1155 BOOL bFound
= FALSE
;
1156 unsigned long iLanguageID
;
1158 if (RegOpenKeyExW(HKEY_LOCAL_MACHINE
,
1159 L
"SYSTEM\\CurrentControlSet\\Control\\NLS\\Language",
1165 dwValueSize
= 9 * sizeof(WCHAR
);
1166 if (RegQueryValueExW(hKey
,
1170 (LPBYTE
)szLanguageIdString
,
1177 iLanguageID
= wcstoul(szLanguageIdString
, NULL
, 16);
1180 if (RegOpenKeyExW(HKEY_LOCAL_MACHINE
,
1181 L
"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Time Zones",
1188 if (RegQueryValueExW(hKey
,
1199 Buffer
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, dwValueSize
);
1206 if (RegQueryValueExW(hKey
,
1213 HeapFree(GetProcessHeap(), 0, Buffer
);
1223 Length
= wcslen(Ptr
);
1224 if (wcstoul(Ptr
, NULL
, 16) == iLanguageID
)
1227 Ptr
= Ptr
+ Length
+ 1;
1233 *lpIndex
= wcstoul(Ptr
, &End
, 10);
1234 HeapFree(GetProcessHeap(), 0, Buffer
);
1238 Length
= wcslen(Ptr
);
1239 Ptr
= Ptr
+ Length
+ 1;
1242 HeapFree(GetProcessHeap(), 0, Buffer
);
1249 ShowTimeZoneList(HWND hwnd
, PSETUPDATA SetupData
, DWORD dwEntryIndex
)
1251 PTIMEZONE_ENTRY Entry
;
1255 GetTimeZoneListIndex(&dwEntryIndex
);
1257 Entry
= SetupData
->TimeZoneListHead
;
1258 while (Entry
!= NULL
)
1260 dwCount
= SendMessage(hwnd
,
1263 (LPARAM
)Entry
->Description
);
1265 if (dwEntryIndex
!= 0 && dwEntryIndex
== Entry
->Index
)
1268 Entry
= Entry
->Next
;
1279 SetLocalTimeZone(HWND hwnd
, PSETUPDATA SetupData
)
1281 TIME_ZONE_INFORMATION TimeZoneInformation
;
1282 PTIMEZONE_ENTRY Entry
;
1286 dwIndex
= SendMessage(hwnd
,
1292 Entry
= SetupData
->TimeZoneListHead
;
1299 Entry
= Entry
->Next
;
1302 wcscpy(TimeZoneInformation
.StandardName
,
1303 Entry
->StandardName
);
1304 wcscpy(TimeZoneInformation
.DaylightName
,
1305 Entry
->DaylightName
);
1307 TimeZoneInformation
.Bias
= Entry
->TimezoneInfo
.Bias
;
1308 TimeZoneInformation
.StandardBias
= Entry
->TimezoneInfo
.StandardBias
;
1309 TimeZoneInformation
.DaylightBias
= Entry
->TimezoneInfo
.DaylightBias
;
1311 memcpy(&TimeZoneInformation
.StandardDate
,
1312 &Entry
->TimezoneInfo
.StandardDate
,
1313 sizeof(SYSTEMTIME
));
1314 memcpy(&TimeZoneInformation
.DaylightDate
,
1315 &Entry
->TimezoneInfo
.DaylightDate
,
1316 sizeof(SYSTEMTIME
));
1318 /* Set time zone information */
1319 SetTimeZoneInformation(&TimeZoneInformation
);
1324 GetLocalSystemTime(HWND hwnd
, PSETUPDATA SetupData
)
1329 if (DateTime_GetSystemtime(GetDlgItem(hwnd
, IDC_DATEPICKER
), &Date
) != GDT_VALID
)
1334 if (DateTime_GetSystemtime(GetDlgItem(hwnd
, IDC_TIMEPICKER
), &Time
) != GDT_VALID
)
1339 SetupData
->SystemTime
.wYear
= Date
.wYear
;
1340 SetupData
->SystemTime
.wMonth
= Date
.wMonth
;
1341 SetupData
->SystemTime
.wDayOfWeek
= Date
.wDayOfWeek
;
1342 SetupData
->SystemTime
.wDay
= Date
.wDay
;
1343 SetupData
->SystemTime
.wHour
= Time
.wHour
;
1344 SetupData
->SystemTime
.wMinute
= Time
.wMinute
;
1345 SetupData
->SystemTime
.wSecond
= Time
.wSecond
;
1346 SetupData
->SystemTime
.wMilliseconds
= Time
.wMilliseconds
;
1353 SetAutoDaylightInfo(HWND hwnd
)
1358 if (SendMessage(hwnd
, BM_GETCHECK
, 0, 0) == BST_UNCHECKED
)
1360 if (RegOpenKeyExW(HKEY_LOCAL_MACHINE
,
1361 L
"SYSTEM\\CurrentControlSet\\Control\\TimeZoneInformation",
1367 RegSetValueExW(hKey
,
1368 L
"DisableAutoDaylightTimeSet",
1379 SetSystemLocalTime(HWND hwnd
, PSETUPDATA SetupData
)
1384 * Call SetLocalTime twice to ensure correct results
1386 Ret
= SetLocalTime(&SetupData
->SystemTime
) &&
1387 SetLocalTime(&SetupData
->SystemTime
);
1393 WriteDateTimeSettings(HWND hwndDlg
, PSETUPDATA SetupData
)
1396 WCHAR ErrorLocalTime
[256];
1397 GetLocalSystemTime(hwndDlg
, SetupData
);
1398 SetLocalTimeZone(GetDlgItem(hwndDlg
, IDC_TIMEZONELIST
),
1401 SetAutoDaylightInfo(GetDlgItem(hwndDlg
, IDC_AUTODAYLIGHT
));
1402 if(!SetSystemLocalTime(hwndDlg
, SetupData
))
1404 if (0 == LoadStringW(hDllInstance
, IDS_REACTOS_SETUP
, Title
, sizeof(Title
) / sizeof(Title
[0])))
1406 wcscpy(Title
, L
"ReactOS Setup");
1408 if (0 == LoadStringW(hDllInstance
, IDS_WZD_LOCALTIME
, ErrorLocalTime
,
1409 sizeof(ErrorLocalTime
) / sizeof(ErrorLocalTime
[0])))
1411 wcscpy(ErrorLocalTime
, L
"Setup was unable to set the local time.");
1413 MessageBoxW(hwndDlg
, ErrorLocalTime
, Title
, MB_ICONWARNING
| MB_OK
);
1420 static INT_PTR CALLBACK
1421 DateTimePageDlgProc(HWND hwndDlg
,
1426 PSETUPDATA SetupData
;
1428 /* Retrieve pointer to the global setup data */
1429 SetupData
= (PSETUPDATA
)GetWindowLongPtr (hwndDlg
, GWL_USERDATA
);
1435 /* Save pointer to the global setup data */
1436 SetupData
= (PSETUPDATA
)((LPPROPSHEETPAGE
)lParam
)->lParam
;
1437 SetWindowLongPtr(hwndDlg
, GWL_USERDATA
, (DWORD_PTR
)SetupData
);
1439 CreateTimeZoneList(SetupData
);
1441 if (SetupData
->UnattendSetup
)
1443 ShowTimeZoneList(GetDlgItem(hwndDlg
, IDC_TIMEZONELIST
),
1444 SetupData
, SetupData
->TimeZoneIndex
);
1446 if (!SetupData
->DisableAutoDaylightTimeSet
)
1448 SendDlgItemMessage(hwndDlg
, IDC_AUTODAYLIGHT
, BM_SETCHECK
, (WPARAM
)BST_CHECKED
, 0);
1453 ShowTimeZoneList(GetDlgItem(hwndDlg
, IDC_TIMEZONELIST
),
1454 SetupData
, 85 /* GMT time zone */);
1456 SendDlgItemMessage(hwndDlg
, IDC_AUTODAYLIGHT
, BM_SETCHECK
, (WPARAM
)BST_CHECKED
, 0);
1465 LPNMHDR lpnm
= (LPNMHDR
)lParam
;
1470 /* Enable the Back and Next buttons */
1471 PropSheet_SetWizButtons(GetParent(hwndDlg
), PSWIZB_BACK
| PSWIZB_NEXT
);
1472 if (SetupData
->UnattendSetup
&& WriteDateTimeSettings(hwndDlg
, SetupData
))
1474 SetWindowLongPtr(hwndDlg
, DWL_MSGRESULT
, IDD_PROCESSPAGE
);
1481 WriteDateTimeSettings(hwndDlg
, SetupData
);
1486 SetupData
->UnattendSetup
= FALSE
;
1496 DestroyTimeZoneList(SetupData
);
1507 static UINT CALLBACK
1508 RegistrationNotificationProc(PVOID Context
,
1513 PREGISTRATIONDATA RegistrationData
;
1514 REGISTRATIONNOTIFY RegistrationNotify
;
1515 PSP_REGISTER_CONTROL_STATUSW StatusInfo
;
1517 WCHAR ErrorMessage
[128];
1519 RegistrationData
= (PREGISTRATIONDATA
) Context
;
1521 if (SPFILENOTIFY_STARTREGISTRATION
== Notification
||
1522 SPFILENOTIFY_ENDREGISTRATION
== Notification
)
1524 StatusInfo
= (PSP_REGISTER_CONTROL_STATUSW
) Param1
;
1525 RegistrationNotify
.CurrentItem
= wcsrchr(StatusInfo
->FileName
, L
'\\');
1526 if (NULL
== RegistrationNotify
.CurrentItem
)
1528 RegistrationNotify
.CurrentItem
= StatusInfo
->FileName
;
1532 RegistrationNotify
.CurrentItem
++;
1535 if (SPFILENOTIFY_STARTREGISTRATION
== Notification
)
1537 DPRINT("Received SPFILENOTIFY_STARTREGISTRATION notification for %S\n",
1538 StatusInfo
->FileName
);
1539 RegistrationNotify
.ErrorMessage
= NULL
;
1540 RegistrationNotify
.Progress
= RegistrationData
->Registered
;
1544 DPRINT("Received SPFILENOTIFY_ENDREGISTRATION notification for %S\n",
1545 StatusInfo
->FileName
);
1546 DPRINT("Win32Error %u FailureCode %u\n", StatusInfo
->Win32Error
,
1547 StatusInfo
->FailureCode
);
1548 if (SPREG_SUCCESS
!= StatusInfo
->FailureCode
)
1550 switch(StatusInfo
->FailureCode
)
1552 case SPREG_LOADLIBRARY
:
1553 MessageID
= IDS_LOADLIBRARY_FAILED
;
1555 case SPREG_GETPROCADDR
:
1556 MessageID
= IDS_GETPROCADDR_FAILED
;
1559 MessageID
= IDS_REGSVR_FAILED
;
1561 case SPREG_DLLINSTALL
:
1562 MessageID
= IDS_DLLINSTALL_FAILED
;
1565 MessageID
= IDS_TIMEOUT
;
1568 MessageID
= IDS_REASON_UNKNOWN
;
1571 if (0 == LoadStringW(hDllInstance
, MessageID
,
1573 sizeof(ErrorMessage
) /
1574 sizeof(ErrorMessage
[0])))
1576 ErrorMessage
[0] = L
'\0';
1578 if (SPREG_TIMEOUT
!= StatusInfo
->FailureCode
)
1580 FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM
, NULL
,
1581 StatusInfo
->Win32Error
, 0,
1582 ErrorMessage
+ wcslen(ErrorMessage
),
1583 sizeof(ErrorMessage
) / sizeof(ErrorMessage
[0]) -
1584 wcslen(ErrorMessage
), NULL
);
1586 RegistrationNotify
.ErrorMessage
= ErrorMessage
;
1590 RegistrationNotify
.ErrorMessage
= NULL
;
1592 if (RegistrationData
->Registered
< RegistrationData
->DllCount
)
1594 RegistrationData
->Registered
++;
1598 RegistrationNotify
.Progress
= RegistrationData
->Registered
;
1599 RegistrationNotify
.ActivityID
= IDS_REGISTERING_COMPONENTS
;
1600 SendMessage(RegistrationData
->hwndDlg
, PM_REGISTRATION_NOTIFY
,
1601 0, (LPARAM
) &RegistrationNotify
);
1607 DPRINT1("Received unexpected notification %u\n", Notification
);
1608 return SetupDefaultQueueCallback(RegistrationData
->DefaultContext
,
1609 Notification
, Param1
, Param2
);
1614 static DWORD CALLBACK
1615 RegistrationProc(LPVOID Parameter
)
1617 PREGISTRATIONDATA RegistrationData
;
1618 REGISTRATIONNOTIFY RegistrationNotify
;
1619 DWORD LastError
= NO_ERROR
;
1620 WCHAR UnknownError
[84];
1622 RegistrationData
= (PREGISTRATIONDATA
) Parameter
;
1623 RegistrationData
->Registered
= 0;
1624 RegistrationData
->DefaultContext
= SetupInitDefaultQueueCallback(RegistrationData
->hwndDlg
);
1628 if (!SetupInstallFromInfSectionW(GetParent(RegistrationData
->hwndDlg
),
1630 L
"RegistrationPhase2",
1632 SPINST_REGISTERCALLBACKAWARE
|
1637 RegistrationNotificationProc
,
1642 LastError
= GetLastError();
1645 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
1647 DPRINT("Catching exception\n");
1648 LastError
= RtlNtStatusToDosError(_SEH2_GetExceptionCode());
1652 if (NO_ERROR
== LastError
)
1654 RegistrationNotify
.ErrorMessage
= NULL
;
1658 DPRINT1("SetupInstallFromInfSection failed with error %u\n",
1660 if (0 == FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER
|
1661 FORMAT_MESSAGE_FROM_SYSTEM
, NULL
, LastError
, 0,
1662 (LPWSTR
) &RegistrationNotify
.ErrorMessage
, 0,
1665 if (0 == LoadStringW(hDllInstance
, IDS_UNKNOWN_ERROR
,
1667 sizeof(UnknownError
) / sizeof(UnknownError
[0]) -
1670 wcscpy(UnknownError
, L
"Unknown error");
1672 wcscat(UnknownError
, L
" ");
1673 _ultow(LastError
, UnknownError
+ wcslen(UnknownError
), 10);
1674 RegistrationNotify
.ErrorMessage
= UnknownError
;
1678 RegistrationNotify
.Progress
= RegistrationData
->DllCount
;
1679 RegistrationNotify
.ActivityID
= IDS_REGISTERING_COMPONENTS
;
1680 RegistrationNotify
.CurrentItem
= NULL
;
1681 SendMessage(RegistrationData
->hwndDlg
, PM_REGISTRATION_NOTIFY
,
1682 1, (LPARAM
) &RegistrationNotify
);
1683 if (NULL
!= RegistrationNotify
.ErrorMessage
&&
1684 UnknownError
!= RegistrationNotify
.ErrorMessage
)
1686 LocalFree((PVOID
) RegistrationNotify
.ErrorMessage
);
1689 SetupTermDefaultQueueCallback(RegistrationData
->DefaultContext
);
1690 HeapFree(GetProcessHeap(), 0, RegistrationData
);
1692 RegisterTypeLibraries(hSysSetupInf
, L
"TypeLibraries");
1694 // FIXME: Move this call to a separate cleanup page!
1695 RtlCreateBootStatusDataFile();
1702 StartComponentRegistration(HWND hwndDlg
, PULONG MaxProgress
)
1704 HANDLE RegistrationThread
;
1707 WCHAR SectionName
[512];
1708 PREGISTRATIONDATA RegistrationData
;
1711 if (! SetupFindFirstLineW(hSysSetupInf
, L
"RegistrationPhase2",
1712 L
"RegisterDlls", &Context
))
1714 DPRINT1("No RegistrationPhase2 section found\n");
1717 if (! SetupGetStringFieldW(&Context
, 1, SectionName
,
1718 sizeof(SectionName
) / sizeof(SectionName
[0]),
1721 DPRINT1("Unable to retrieve section name\n");
1724 DllCount
= SetupGetLineCountW(hSysSetupInf
, SectionName
);
1725 DPRINT("SectionName %S DllCount %ld\n", SectionName
, DllCount
);
1728 SetLastError(STATUS_NOT_FOUND
);
1732 *MaxProgress
= (ULONG
) DllCount
;
1735 * Create a background thread to do the actual registrations, so the
1736 * main thread can just run its message loop.
1738 RegistrationThread
= NULL
;
1739 RegistrationData
= HeapAlloc(GetProcessHeap(), 0,
1740 sizeof(REGISTRATIONDATA
));
1741 if (RegistrationData
!= NULL
)
1743 RegistrationData
->hwndDlg
= hwndDlg
;
1744 RegistrationData
->DllCount
= DllCount
;
1745 RegistrationThread
= CreateThread(NULL
, 0, RegistrationProc
,
1746 (LPVOID
) RegistrationData
, 0, NULL
);
1747 if (RegistrationThread
!= NULL
)
1749 CloseHandle(RegistrationThread
);
1753 DPRINT1("CreateThread failed, error %u\n", GetLastError());
1754 HeapFree(GetProcessHeap(), 0, RegistrationData
);
1760 DPRINT1("HeapAlloc() failed, error %u\n", GetLastError());
1768 static INT_PTR CALLBACK
1769 ProcessPageDlgProc(HWND hwndDlg
,
1774 PSETUPDATA SetupData
;
1775 PREGISTRATIONNOTIFY RegistrationNotify
;
1776 static UINT oldActivityID
= -1;
1779 /* Retrieve pointer to the global setup data */
1780 SetupData
= (PSETUPDATA
)GetWindowLongPtr (hwndDlg
, GWL_USERDATA
);
1786 /* Save pointer to the global setup data */
1787 SetupData
= (PSETUPDATA
)((LPPROPSHEETPAGE
)lParam
)->lParam
;
1788 SetWindowLongPtr(hwndDlg
, GWL_USERDATA
, (DWORD_PTR
)SetupData
);
1794 LPNMHDR lpnm
= (LPNMHDR
)lParam
;
1795 ULONG MaxProgress
= 0;
1800 /* Disable the Back and Next buttons */
1801 PropSheet_SetWizButtons(GetParent(hwndDlg
), 0);
1803 StartComponentRegistration(hwndDlg
, &MaxProgress
);
1805 SendDlgItemMessage(hwndDlg
, IDC_PROCESSPROGRESS
, PBM_SETRANGE
,
1806 0, MAKELPARAM(0, MaxProgress
));
1807 SendDlgItemMessage(hwndDlg
, IDC_PROCESSPROGRESS
, PBM_SETPOS
,
1815 SetupData
->UnattendSetup
= FALSE
;
1824 case PM_REGISTRATION_NOTIFY
:
1827 RegistrationNotify
= (PREGISTRATIONNOTIFY
) lParam
;
1828 // update if necessary only
1829 if (oldActivityID
!= RegistrationNotify
->ActivityID
)
1831 if (0 != LoadStringW(hDllInstance
, RegistrationNotify
->ActivityID
,
1833 sizeof(Activity
) / sizeof(Activity
[0])))
1835 SendDlgItemMessageW(hwndDlg
, IDC_ACTIVITY
, WM_SETTEXT
,
1836 0, (LPARAM
) Activity
);
1838 oldActivityID
= RegistrationNotify
->ActivityID
;
1840 SendDlgItemMessageW(hwndDlg
, IDC_ITEM
, WM_SETTEXT
, 0,
1841 (LPARAM
)(NULL
== RegistrationNotify
->CurrentItem
?
1842 L
"" : RegistrationNotify
->CurrentItem
));
1843 SendDlgItemMessage(hwndDlg
, IDC_PROCESSPROGRESS
, PBM_SETPOS
,
1844 RegistrationNotify
->Progress
, 0);
1845 if (NULL
!= RegistrationNotify
->ErrorMessage
)
1847 if (0 == LoadStringW(hDllInstance
, IDS_REACTOS_SETUP
,
1848 Title
, sizeof(Title
) / sizeof(Title
[0])))
1850 wcscpy(Title
, L
"ReactOS Setup");
1852 MessageBoxW(hwndDlg
, RegistrationNotify
->ErrorMessage
,
1853 Title
, MB_ICONERROR
| MB_OK
);
1860 if(!SetupData
->UnattendSetup
&& !SetupData
->DisableVmwInst
)
1861 RunVMWInstall(GetParent(hwndDlg
));
1864 /* Enable the Back and Next buttons */
1865 PropSheet_SetWizButtons(GetParent(hwndDlg
), PSWIZB_NEXT
);
1866 PropSheet_PressButton(GetParent(hwndDlg
), PSBTN_NEXT
);
1880 SetInstallationCompleted(VOID
)
1883 DWORD InProgress
= 0;
1886 if (RegOpenKeyExW( HKEY_LOCAL_MACHINE
,
1890 &hKey
) == ERROR_SUCCESS
)
1892 RegSetValueExW( hKey
, L
"SystemSetupInProgress", 0, REG_DWORD
, (LPBYTE
)&InProgress
, sizeof(InProgress
) );
1893 RegCloseKey( hKey
);
1896 if (RegOpenKeyExW( HKEY_LOCAL_MACHINE
,
1897 L
"Software\\Microsoft\\Windows NT\\CurrentVersion",
1900 &hKey
) == ERROR_SUCCESS
)
1902 InstallDate
= (DWORD
)time(NULL
);
1903 RegSetValueExW( hKey
, L
"InstallDate", 0, REG_DWORD
, (LPBYTE
)&InstallDate
, sizeof(InstallDate
) );
1904 RegCloseKey( hKey
);
1908 static INT_PTR CALLBACK
1909 FinishDlgProc(HWND hwndDlg
,
1919 /* Get pointer to the global setup data */
1920 PSETUPDATA SetupData
= (PSETUPDATA
)((LPPROPSHEETPAGE
)lParam
)->lParam
;
1922 /* Run the Wine Gecko prompt */
1923 Control_RunDLLW(GetDesktopWindow(), 0, L
"appwiz.cpl install_gecko", SW_SHOW
);
1925 /* Set title font */
1926 SendDlgItemMessage(hwndDlg
,
1929 (WPARAM
)SetupData
->hTitleFont
,
1931 if (SetupData
->UnattendSetup
)
1933 KillTimer(hwndDlg
, 1);
1934 SetInstallationCompleted();
1942 SetInstallationCompleted();
1952 hWndProgress
= GetDlgItem(hwndDlg
, IDC_RESTART_PROGRESS
);
1953 Position
= SendMessage(hWndProgress
, PBM_GETPOS
, 0, 0);
1954 if (Position
== 300)
1956 KillTimer(hwndDlg
, 1);
1957 PropSheet_PressButton(GetParent(hwndDlg
), PSBTN_FINISH
);
1961 SendMessage(hWndProgress
, PBM_SETPOS
, Position
+ 1, 0);
1968 LPNMHDR lpnm
= (LPNMHDR
)lParam
;
1973 /* Enable the correct buttons on for the active page */
1974 PropSheet_SetWizButtons(GetParent(hwndDlg
), PSWIZB_FINISH
);
1976 SendDlgItemMessage(hwndDlg
, IDC_RESTART_PROGRESS
, PBM_SETRANGE
, 0,
1977 MAKELPARAM(0, 300));
1978 SendDlgItemMessage(hwndDlg
, IDC_RESTART_PROGRESS
, PBM_SETPOS
, 0, 0);
1979 SetTimer(hwndDlg
, 1, 50, NULL
);
1983 DestroyWindow(GetParent(hwndDlg
));
2001 ProcessUnattendInf(HINF hUnattendedInf
)
2003 INFCONTEXT InfContext
;
2005 WCHAR szValue
[MAX_PATH
];
2009 if (!SetupFindFirstLineW(hUnattendedInf
,
2011 L
"UnattendSetupEnabled",
2014 DPRINT1("Error: Cant find UnattendSetupEnabled Key! %d\n", GetLastError());
2018 if (!SetupGetStringFieldW(&InfContext
,
2021 sizeof(szValue
) / sizeof(WCHAR
),
2024 DPRINT1("Error: SetupGetStringField failed with %d\n", GetLastError());
2028 if (wcscmp(szValue
, L
"yes") != 0)
2030 DPRINT("Unattend setup was disabled by UnattendSetupEnabled key.\n");
2034 if (!SetupFindFirstLineW(hUnattendedInf
,
2039 DPRINT1("Error: SetupFindFirstLine failed %d\n", GetLastError());
2046 if (!SetupGetStringFieldW(&InfContext
,
2049 sizeof(szName
) / sizeof(WCHAR
),
2052 DPRINT1("Error: SetupGetStringField failed with %d\n", GetLastError());
2056 if (!SetupGetStringFieldW(&InfContext
,
2059 sizeof(szValue
) / sizeof(WCHAR
),
2062 DPRINT1("Error: SetupGetStringField failed with %d\n", GetLastError());
2065 DPRINT1("Name %S Value %S\n", szName
, szValue
);
2066 if (!wcscmp(szName
, L
"FullName"))
2068 if ((sizeof(SetupData
.OwnerName
) / sizeof(TCHAR
)) > LineLength
)
2070 wcscpy(SetupData
.OwnerName
, szValue
);
2073 else if (!wcscmp(szName
, L
"OrgName"))
2075 if ((sizeof(SetupData
.OwnerOrganization
) / sizeof(WCHAR
)) > LineLength
)
2077 wcscpy(SetupData
.OwnerOrganization
, szValue
);
2080 else if (!wcscmp(szName
, L
"ComputerName"))
2082 if ((sizeof(SetupData
.ComputerName
) / sizeof(WCHAR
)) > LineLength
)
2084 wcscpy(SetupData
.ComputerName
, szValue
);
2087 else if (!wcscmp(szName
, L
"AdminPassword"))
2089 if ((sizeof(SetupData
.AdminPassword
) / sizeof(WCHAR
)) > LineLength
)
2091 wcscpy(SetupData
.AdminPassword
, szValue
);
2094 else if (!wcscmp(szName
, L
"TimeZoneIndex"))
2096 SetupData
.TimeZoneIndex
= _wtoi(szValue
);
2098 else if (!wcscmp(szName
, L
"DisableAutoDaylightTimeSet"))
2100 SetupData
.DisableAutoDaylightTimeSet
= _wtoi(szValue
);
2102 else if (!wcscmp(szName
, L
"DisableVmwInst"))
2104 if(!wcscmp(szValue
, L
"yes"))
2105 SetupData
.DisableVmwInst
= 1;
2107 SetupData
.DisableVmwInst
= 0;
2111 while (SetupFindNextLine(&InfContext
, &InfContext
));
2113 if (RegOpenKeyExW(HKEY_LOCAL_MACHINE
,
2114 L
"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\RunOnce",
2117 &hKey
) != ERROR_SUCCESS
)
2119 DPRINT1("Error: failed to open HKLM\\Software\\Microsoft\\Windows\\CurrentVersion\\RunOnce\n");
2124 if (SetupFindFirstLineW(hUnattendedInf
,
2133 if(SetupGetStringFieldW(&InfContext
,
2136 sizeof(szValue
) / sizeof(WCHAR
),
2139 WCHAR szPath
[MAX_PATH
];
2140 swprintf(szName
, L
"%d", i
);
2141 DPRINT("szName %S szValue %S\n", szName
, szValue
);
2143 if (ExpandEnvironmentStringsW(szValue
, szPath
, MAX_PATH
))
2145 DPRINT("value %S\n", szPath
);
2146 if (RegSetValueExW(hKey
,
2150 (const BYTE
*)szPath
,
2151 (wcslen(szPath
) + 1) * sizeof(WCHAR
)) == ERROR_SUCCESS
)
2157 } while(SetupFindNextLine(&InfContext
, &InfContext
));
2165 * GetRosInstallCD should find the path to ros installation medium
2167 * If there are more than one CDDrive in it containing a ReactOS
2168 * installation cd, then it will pick the first one regardless if
2169 * it is really the installation cd
2171 * The best way to implement this is to set the key
2172 * HKLM\Software\Microsoft\Windows NT\CurrentVersion\SourcePath (REG_SZ)
2176 GetRosInstallCD(WCHAR
*pwszPath
, DWORD cchPathMax
)
2178 WCHAR wszDrives
[512];
2182 cchDrives
= GetLogicalDriveStringsW(_countof(wszDrives
) - 1, wszDrives
);
2183 if (cchDrives
== 0 || cchDrives
>= _countof(wszDrives
))
2185 /* buffer too small or failure */
2186 LogItem(SYSSETUP_SEVERITY_INFORMATION
, L
"GetLogicalDriveStringsW failed");
2190 for (pwszDrive
= wszDrives
; pwszDrive
[0]; pwszDrive
+= wcslen(pwszDrive
) + 1)
2192 if (GetDriveTypeW(pwszDrive
) == DRIVE_CDROM
)
2194 WCHAR wszBuf
[MAX_PATH
];
2195 wsprintf(wszBuf
, L
"%sreactos\\system32\\ntoskrnl.exe", pwszDrive
);
2196 LogItem(SYSSETUP_SEVERITY_INFORMATION
, wszBuf
);
2197 if (GetFileAttributesW(wszBuf
) != INVALID_FILE_ATTRIBUTES
)
2199 /* the file exists, so this is the right drive */
2200 wcsncpy(pwszPath
, pwszDrive
, cchPathMax
);
2201 OutputDebugStringW(L
"GetRosInstallCD: ");OutputDebugStringW(pwszPath
);OutputDebugStringW(L
"\n");
2211 ProcessUnattendSetup(VOID
)
2213 WCHAR szPath
[MAX_PATH
];
2214 HINF hUnattendedInf
;
2217 if (!GetRosInstallCD(szPath
, MAX_PATH
))
2219 /* no cd drive found */
2223 dwLength
= wcslen(szPath
);
2224 if (dwLength
+ 21 > MAX_PATH
)
2227 * allocate bigger buffer
2232 wcscat(szPath
, L
"reactos\\unattend.inf");
2234 hUnattendedInf
= SetupOpenInfFileW(szPath
,
2239 if (hUnattendedInf
!= INVALID_HANDLE_VALUE
)
2241 SetupData
.UnattendSetup
= ProcessUnattendInf(hUnattendedInf
);
2242 SetupCloseInfFile(hUnattendedInf
);
2250 PROPSHEETHEADER psh
;
2251 HPROPSHEETPAGE ahpsp
[8];
2252 PROPSHEETPAGE psp
= {0};
2257 /* Clear setup data */
2258 ZeroMemory(&SetupData
, sizeof(SETUPDATA
));
2260 ProcessUnattendSetup();
2262 /* Create the Welcome page */
2263 psp
.dwSize
= sizeof(PROPSHEETPAGE
);
2264 psp
.dwFlags
= PSP_DEFAULT
| PSP_HIDEHEADER
;
2265 psp
.hInstance
= hDllInstance
;
2266 psp
.lParam
= (LPARAM
)&SetupData
;
2267 psp
.pfnDlgProc
= WelcomeDlgProc
;
2268 psp
.pszTemplate
= MAKEINTRESOURCE(IDD_WELCOMEPAGE
);
2269 ahpsp
[nPages
++] = CreatePropertySheetPage(&psp
);
2271 /* Create the Acknowledgements page */
2272 psp
.dwFlags
= PSP_DEFAULT
| PSP_USEHEADERTITLE
| PSP_USEHEADERSUBTITLE
;
2273 psp
.pszHeaderTitle
= MAKEINTRESOURCE(IDS_ACKTITLE
);
2274 psp
.pszHeaderSubTitle
= MAKEINTRESOURCE(IDS_ACKSUBTITLE
);
2275 psp
.pszTemplate
= MAKEINTRESOURCE(IDD_ACKPAGE
);
2276 psp
.pfnDlgProc
= AckPageDlgProc
;
2277 ahpsp
[nPages
++] = CreatePropertySheetPage(&psp
);
2279 /* Create the Owner page */
2280 psp
.dwFlags
= PSP_DEFAULT
| PSP_USEHEADERTITLE
| PSP_USEHEADERSUBTITLE
;
2281 psp
.pszHeaderTitle
= MAKEINTRESOURCE(IDS_OWNERTITLE
);
2282 psp
.pszHeaderSubTitle
= MAKEINTRESOURCE(IDS_OWNERSUBTITLE
);
2283 psp
.pszTemplate
= MAKEINTRESOURCE(IDD_OWNERPAGE
);
2284 psp
.pfnDlgProc
= OwnerPageDlgProc
;
2285 ahpsp
[nPages
++] = CreatePropertySheetPage(&psp
);
2287 /* Create the Computer page */
2288 psp
.dwFlags
= PSP_DEFAULT
| PSP_USEHEADERTITLE
| PSP_USEHEADERSUBTITLE
;
2289 psp
.pszHeaderTitle
= MAKEINTRESOURCE(IDS_COMPUTERTITLE
);
2290 psp
.pszHeaderSubTitle
= MAKEINTRESOURCE(IDS_COMPUTERSUBTITLE
);
2291 psp
.pfnDlgProc
= ComputerPageDlgProc
;
2292 psp
.pszTemplate
= MAKEINTRESOURCE(IDD_COMPUTERPAGE
);
2293 ahpsp
[nPages
++] = CreatePropertySheetPage(&psp
);
2296 /* Create the Locale page */
2297 psp
.dwFlags
= PSP_DEFAULT
| PSP_USEHEADERTITLE
| PSP_USEHEADERSUBTITLE
;
2298 psp
.pszHeaderTitle
= MAKEINTRESOURCE(IDS_LOCALETITLE
);
2299 psp
.pszHeaderSubTitle
= MAKEINTRESOURCE(IDS_LOCALESUBTITLE
);
2300 psp
.pfnDlgProc
= LocalePageDlgProc
;
2301 psp
.pszTemplate
= MAKEINTRESOURCE(IDD_LOCALEPAGE
);
2302 ahpsp
[nPages
++] = CreatePropertySheetPage(&psp
);
2305 /* Create the DateTime page */
2306 psp
.dwFlags
= PSP_DEFAULT
| PSP_USEHEADERTITLE
| PSP_USEHEADERSUBTITLE
;
2307 psp
.pszHeaderTitle
= MAKEINTRESOURCE(IDS_DATETIMETITLE
);
2308 psp
.pszHeaderSubTitle
= MAKEINTRESOURCE(IDS_DATETIMESUBTITLE
);
2309 psp
.pfnDlgProc
= DateTimePageDlgProc
;
2310 psp
.pszTemplate
= MAKEINTRESOURCE(IDD_DATETIMEPAGE
);
2311 ahpsp
[nPages
++] = CreatePropertySheetPage(&psp
);
2314 /* Create the Process page */
2315 psp
.dwFlags
= PSP_DEFAULT
| PSP_USEHEADERTITLE
| PSP_USEHEADERSUBTITLE
;
2316 psp
.pszHeaderTitle
= MAKEINTRESOURCE(IDS_PROCESSTITLE
);
2317 psp
.pszHeaderSubTitle
= MAKEINTRESOURCE(IDS_PROCESSSUBTITLE
);
2318 psp
.pfnDlgProc
= ProcessPageDlgProc
;
2319 psp
.pszTemplate
= MAKEINTRESOURCE(IDD_PROCESSPAGE
);
2320 ahpsp
[nPages
++] = CreatePropertySheetPage(&psp
);
2323 /* Create the Finish page */
2324 psp
.dwFlags
= PSP_DEFAULT
| PSP_HIDEHEADER
;
2325 psp
.pfnDlgProc
= FinishDlgProc
;
2326 psp
.pszTemplate
= MAKEINTRESOURCE(IDD_FINISHPAGE
);
2327 ahpsp
[nPages
++] = CreatePropertySheetPage(&psp
);
2329 /* Create the property sheet */
2330 psh
.dwSize
= sizeof(PROPSHEETHEADER
);
2331 psh
.dwFlags
= PSH_WIZARD97
| PSH_WATERMARK
| PSH_HEADER
| PSH_MODELESS
;
2332 psh
.hInstance
= hDllInstance
;
2333 psh
.hwndParent
= NULL
;
2334 psh
.nPages
= nPages
;
2337 psh
.pszbmWatermark
= MAKEINTRESOURCE(IDB_WATERMARK
);
2338 psh
.pszbmHeader
= MAKEINTRESOURCE(IDB_HEADER
);
2340 /* Create title font */
2341 SetupData
.hTitleFont
= CreateTitleFont();
2343 /* Display the wizard */
2344 hWnd
= (HWND
)PropertySheet(&psh
);
2345 ShowWindow(hWnd
, SW_SHOW
);
2347 while (GetMessage(&msg
, NULL
, 0, 0))
2349 if(!IsDialogMessage(hWnd
, &msg
))
2351 TranslateMessage(&msg
);
2352 DispatchMessage(&msg
);
2356 DeleteObject(SetupData
.hTitleFont
);