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 *****************************************************************/
24 #define PM_REGISTRATION_NOTIFY (WM_APP + 1)
25 /* Private Message used to communicate progress from the background
26 registration thread to the main thread.
27 wParam = 0 Registration in progress
28 = 1 Registration completed
29 lParam = Pointer to a REGISTRATIONNOTIFY structure */
31 typedef struct _REGISTRATIONNOTIFY
37 } REGISTRATIONNOTIFY
, *PREGISTRATIONNOTIFY
;
39 typedef struct _REGISTRATIONDATA
45 } REGISTRATIONDATA
, *PREGISTRATIONDATA
;
47 /* GLOBALS ******************************************************************/
52 /* FUNCTIONS ****************************************************************/
54 extern void WINAPI
Control_RunDLLW(HWND hWnd
, HINSTANCE hInst
, LPCWSTR cmd
, DWORD nCmdShow
);
57 GetRosInstallCD(WCHAR
*pwszPath
, DWORD cchPathMax
);
61 RunVMWInstall(HWND hWnd
)
63 PROCESS_INFORMATION ProcInfo
;
67 WCHAR InstallName
[] = L
"vmwinst.exe";
69 ZeroMemory(&si
, sizeof(si
));
72 if(CreateProcessW(NULL
, InstallName
, NULL
, NULL
, TRUE
, NORMAL_PRIORITY_CLASS
,
73 NULL
, NULL
, &si
, &ProcInfo
))
75 EnableWindow(hWnd
, FALSE
);
78 while (PeekMessage(&msg
, NULL
, 0, 0, PM_REMOVE
))
80 if (msg
.message
== WM_QUIT
)
82 TranslateMessage(&msg
);
83 DispatchMessage(&msg
);
86 ret
= MsgWaitForMultipleObjects(1, &ProcInfo
.hProcess
, FALSE
, INFINITE
, QS_ALLEVENTS
| QS_ALLINPUT
);
87 if (ret
== WAIT_OBJECT_0
)
91 EnableWindow(hWnd
, TRUE
);
93 CloseHandle(ProcInfo
.hThread
);
94 CloseHandle(ProcInfo
.hProcess
);
102 CenterWindow(HWND hWnd
)
108 hWndParent
= GetParent(hWnd
);
109 if (hWndParent
== NULL
)
110 hWndParent
= GetDesktopWindow();
112 GetWindowRect(hWndParent
, &rcParent
);
113 GetWindowRect(hWnd
, &rcWindow
);
117 ((rcParent
.right
- rcParent
.left
) - (rcWindow
.right
- rcWindow
.left
)) / 2,
118 ((rcParent
.bottom
- rcParent
.top
) - (rcWindow
.bottom
- rcWindow
.top
)) / 2,
126 CreateTitleFont(VOID
)
128 NONCLIENTMETRICSW ncm
;
134 ncm
.cbSize
= sizeof(NONCLIENTMETRICSW
);
135 SystemParametersInfo(SPI_GETNONCLIENTMETRICS
, 0, &ncm
, 0);
137 LogFont
= ncm
.lfMessageFont
;
138 LogFont
.lfWeight
= FW_BOLD
;
139 wcscpy(LogFont
.lfFaceName
, L
"MS Shell Dlg");
143 LogFont
.lfHeight
= 0 - GetDeviceCaps(hdc
, LOGPIXELSY
) * FontSize
/ 72;
144 hFont
= CreateFontIndirectW(&LogFont
);
145 ReleaseDC(NULL
, hdc
);
151 static INT_PTR CALLBACK
152 GplDlgProc(HWND hwndDlg
,
157 HRSRC GplTextResource
;
167 GplTextResource
= FindResourceW(hDllInstance
, MAKEINTRESOURCE(IDR_GPL
), L
"RT_TEXT");
168 if (NULL
== GplTextResource
)
172 Size
= SizeofResource(hDllInstance
, GplTextResource
);
177 GplText
= HeapAlloc(GetProcessHeap(), 0, Size
+ 1);
182 GplTextMem
= LoadResource(hDllInstance
, GplTextResource
);
183 if (NULL
== GplTextMem
)
185 HeapFree(GetProcessHeap(), 0, GplText
);
188 GplTextLocked
= LockResource(GplTextMem
);
189 if (NULL
== GplTextLocked
)
191 HeapFree(GetProcessHeap(), 0, GplText
);
194 memcpy(GplText
, GplTextLocked
, Size
);
195 GplText
[Size
] = '\0';
196 SendMessageA(GetDlgItem(hwndDlg
, IDC_GPL_TEXT
), WM_SETTEXT
, 0, (LPARAM
) GplText
);
197 HeapFree(GetProcessHeap(), 0, GplText
);
198 SetFocus(GetDlgItem(hwndDlg
, IDOK
));
202 EndDialog(hwndDlg
, IDCANCEL
);
206 if (HIWORD(wParam
) == BN_CLICKED
&& IDOK
== LOWORD(wParam
))
208 EndDialog(hwndDlg
, IDOK
);
220 static INT_PTR CALLBACK
221 WelcomeDlgProc(HWND hwndDlg
,
230 PSETUPDATA SetupData
;
234 /* Get pointer to the global setup data */
235 SetupData
= (PSETUPDATA
)((LPPROPSHEETPAGE
)lParam
)->lParam
;
237 hwndControl
= GetParent(hwndDlg
);
239 /* Center the wizard window */
240 CenterWindow (hwndControl
);
242 /* Hide the system menu */
243 dwStyle
= GetWindowLongPtr(hwndControl
, GWL_STYLE
);
244 SetWindowLongPtr(hwndControl
, GWL_STYLE
, dwStyle
& ~WS_SYSMENU
);
246 /* Hide and disable the 'Cancel' button */
247 hwndControl
= GetDlgItem(GetParent(hwndDlg
), IDCANCEL
);
248 ShowWindow (hwndControl
, SW_HIDE
);
249 EnableWindow (hwndControl
, FALSE
);
252 SendDlgItemMessage(hwndDlg
,
255 (WPARAM
)SetupData
->hTitleFont
,
263 LPNMHDR lpnm
= (LPNMHDR
)lParam
;
268 /* Enable the Next button */
269 PropSheet_SetWizButtons(GetParent(hwndDlg
), PSWIZB_NEXT
);
270 if (SetupData
.UnattendSetup
)
272 SetWindowLongPtr(hwndDlg
, DWL_MSGRESULT
, IDD_ACKPAGE
);
278 SetupData
.UnattendSetup
= FALSE
;
295 static INT_PTR CALLBACK
296 AckPageDlgProc(HWND hwndDlg
,
303 PWCHAR End
, CurrentProject
;
304 INT ProjectsSize
, ProjectsCount
;
314 Projects
= HeapAlloc(GetProcessHeap(), 0, ProjectsSize
* sizeof(WCHAR
));
315 if (NULL
== Projects
)
319 ProjectsCount
= LoadStringW(hDllInstance
, IDS_ACKPROJECTS
, Projects
, ProjectsSize
);
320 if (0 == ProjectsCount
)
322 HeapFree(GetProcessHeap(), 0, Projects
);
325 if (ProjectsCount
< ProjectsSize
- 1)
329 HeapFree(GetProcessHeap(), 0, Projects
);
333 CurrentProject
= Projects
;
334 while (L
'\0' != *CurrentProject
)
336 End
= wcschr(CurrentProject
, L
'\n');
341 (void)ListBox_AddString(GetDlgItem(hwndDlg
, IDC_PROJECTS
), CurrentProject
);
344 CurrentProject
= End
+ 1;
348 CurrentProject
+= wcslen(CurrentProject
);
351 HeapFree(GetProcessHeap(), 0, Projects
);
356 if (HIWORD(wParam
) == BN_CLICKED
&& IDC_VIEWGPL
== LOWORD(wParam
))
358 DialogBox(hDllInstance
, MAKEINTRESOURCE(IDD_GPL
), NULL
, GplDlgProc
);
359 SetForegroundWindow(GetParent(hwndDlg
));
365 lpnm
= (LPNMHDR
)lParam
;
370 /* Enable the Back and Next buttons */
371 PropSheet_SetWizButtons(GetParent(hwndDlg
), PSWIZB_BACK
| PSWIZB_NEXT
);
372 if (SetupData
.UnattendSetup
)
374 SetWindowLongPtr(hwndDlg
, DWL_MSGRESULT
, IDD_LOCALEPAGE
);
380 SetupData
.UnattendSetup
= FALSE
;
398 WriteOwnerSettings(WCHAR
* OwnerName
,
399 WCHAR
* OwnerOrganization
)
406 res
= RegOpenKeyExW(HKEY_LOCAL_MACHINE
,
407 L
"Software\\Microsoft\\Windows NT\\CurrentVersion",
412 if (res
!= ERROR_SUCCESS
)
417 res
= RegSetValueExW(hKey
,
422 (wcslen(OwnerName
) + 1) * sizeof(WCHAR
));
424 if (res
!= ERROR_SUCCESS
)
430 res
= RegSetValueExW(hKey
,
431 L
"RegisteredOrganization",
434 (LPBYTE
)OwnerOrganization
,
435 (wcslen(OwnerOrganization
) + 1) * sizeof(WCHAR
));
438 return (res
== ERROR_SUCCESS
);
441 static INT_PTR CALLBACK
442 OwnerPageDlgProc(HWND hwndDlg
,
448 WCHAR OwnerOrganization
[51];
450 WCHAR ErrorName
[256];
457 SendDlgItemMessage(hwndDlg
, IDC_OWNERNAME
, EM_LIMITTEXT
, 50, 0);
458 SendDlgItemMessage(hwndDlg
, IDC_OWNERORGANIZATION
, EM_LIMITTEXT
, 50, 0);
460 /* Set focus to owner name */
461 SetFocus(GetDlgItem(hwndDlg
, IDC_OWNERNAME
));
468 lpnm
= (LPNMHDR
)lParam
;
473 /* Enable the Back and Next buttons */
474 PropSheet_SetWizButtons(GetParent(hwndDlg
), PSWIZB_BACK
| PSWIZB_NEXT
);
475 if (SetupData
.UnattendSetup
)
477 SendMessage(GetDlgItem(hwndDlg
, IDC_OWNERNAME
), WM_SETTEXT
, 0, (LPARAM
)SetupData
.OwnerName
);
478 SendMessage(GetDlgItem(hwndDlg
, IDC_OWNERORGANIZATION
), WM_SETTEXT
, 0, (LPARAM
)SetupData
.OwnerOrganization
);
479 if (WriteOwnerSettings(SetupData
.OwnerName
, SetupData
.OwnerOrganization
))
481 SetWindowLongPtr(hwndDlg
, DWL_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
, DWL_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
, DWL_MSGRESULT
, -1);
518 SetupData
.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 account domain name */
564 SetAccountDomain(ComputerName
, NULL
);
569 /* lpBuffer will be filled with a 15-char string (plus the null terminator) */
571 GenerateComputerName(LPWSTR lpBuffer
)
573 static const WCHAR Chars
[] = L
"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
574 static const unsigned cChars
= sizeof(Chars
) / sizeof(WCHAR
) - 1;
577 wcscpy(lpBuffer
, L
"REACTOS-");
579 srand(GetTickCount());
581 /* fill in 7 characters */
582 for (i
= 8; i
< 15; i
++)
583 lpBuffer
[i
] = Chars
[rand() % cChars
];
585 lpBuffer
[15] = UNICODE_NULL
; /* NULL-terminate */
588 static INT_PTR CALLBACK
589 ComputerPageDlgProc(HWND hwndDlg
,
594 WCHAR ComputerName
[MAX_COMPUTERNAME_LENGTH
+ 1];
599 WCHAR EmptyComputerName
[256], NotMatchPassword
[256], WrongPassword
[256];
602 if (0 == LoadStringW(hDllInstance
, IDS_REACTOS_SETUP
, Title
, sizeof(Title
) / sizeof(Title
[0])))
604 wcscpy(Title
, L
"ReactOS Setup");
611 /* Generate a new pseudo-random computer name */
612 GenerateComputerName(ComputerName
);
614 /* Display current computer name */
615 SetDlgItemTextW(hwndDlg
, IDC_COMPUTERNAME
, ComputerName
);
617 /* Set text limits */
618 SendDlgItemMessage(hwndDlg
, IDC_COMPUTERNAME
, EM_LIMITTEXT
, MAX_COMPUTERNAME_LENGTH
, 0);
619 SendDlgItemMessage(hwndDlg
, IDC_ADMINPASSWORD1
, EM_LIMITTEXT
, 14, 0);
620 SendDlgItemMessage(hwndDlg
, IDC_ADMINPASSWORD2
, EM_LIMITTEXT
, 14, 0);
622 /* Set focus to computer name */
623 SetFocus(GetDlgItem(hwndDlg
, IDC_COMPUTERNAME
));
624 if (SetupData
.UnattendSetup
)
626 SendMessage(GetDlgItem(hwndDlg
, IDC_COMPUTERNAME
), WM_SETTEXT
, 0, (LPARAM
)SetupData
.ComputerName
);
627 SendMessage(GetDlgItem(hwndDlg
, IDC_ADMINPASSWORD1
), WM_SETTEXT
, 0, (LPARAM
)SetupData
.AdminPassword
);
628 SendMessage(GetDlgItem(hwndDlg
, IDC_ADMINPASSWORD2
), WM_SETTEXT
, 0, (LPARAM
)SetupData
.AdminPassword
);
629 WriteComputerSettings(SetupData
.ComputerName
, NULL
);
630 SetAdministratorPassword(SetupData
.AdminPassword
);
639 lpnm
= (LPNMHDR
)lParam
;
644 /* Enable the Back and Next buttons */
645 PropSheet_SetWizButtons(GetParent(hwndDlg
), PSWIZB_BACK
| PSWIZB_NEXT
);
646 if (SetupData
.UnattendSetup
&& WriteComputerSettings(SetupData
.ComputerName
, hwndDlg
))
648 SetWindowLongPtr(hwndDlg
, DWL_MSGRESULT
, IDD_DATETIMEPAGE
);
654 if (0 == GetDlgItemTextW(hwndDlg
, IDC_COMPUTERNAME
, ComputerName
, MAX_COMPUTERNAME_LENGTH
+ 1))
656 if (0 == LoadStringW(hDllInstance
, IDS_WZD_COMPUTERNAME
, EmptyComputerName
,
657 sizeof(EmptyComputerName
) / sizeof(EmptyComputerName
[0])))
659 wcscpy(EmptyComputerName
, L
"Setup cannot continue until you enter the name of your computer.");
661 MessageBoxW(hwndDlg
, EmptyComputerName
, Title
, MB_ICONERROR
| MB_OK
);
662 SetFocus(GetDlgItem(hwndDlg
, IDC_COMPUTERNAME
));
663 SetWindowLongPtr(hwndDlg
, DWL_MSGRESULT
, -1);
667 /* No need to check computer name for invalid characters,
668 * SetComputerName() will do it for us */
670 if (!WriteComputerSettings(ComputerName
, hwndDlg
))
672 SetFocus(GetDlgItem(hwndDlg
, IDC_COMPUTERNAME
));
673 SetWindowLongPtr(hwndDlg
, DWL_MSGRESULT
, -1);
678 /* Check if admin passwords have been entered */
679 if ((GetDlgItemText(hwndDlg
, IDC_ADMINPASSWORD1
, Password1
, 15) == 0) ||
680 (GetDlgItemText(hwndDlg
, IDC_ADMINPASSWORD2
, Password2
, 15) == 0))
682 if (0 == LoadStringW(hDllInstance
, IDS_WZD_PASSWORDEMPTY
, EmptyPassword
,
683 sizeof(EmptyPassword
) / sizeof(EmptyPassword
[0])))
685 wcscpy(EmptyPassword
, L
"You must enter a password !");
687 MessageBoxW(hwndDlg
, EmptyPassword
, Title
, MB_ICONERROR
| MB_OK
);
688 SetWindowLongPtr(hwndDlg
, DWL_MSGRESULT
, -1);
692 GetDlgItemTextW(hwndDlg
, IDC_ADMINPASSWORD1
, Password1
, 15);
693 GetDlgItemTextW(hwndDlg
, IDC_ADMINPASSWORD2
, Password2
, 15);
695 /* Check if passwords match */
696 if (wcscmp(Password1
, Password2
))
698 if (0 == LoadStringW(hDllInstance
, IDS_WZD_PASSWORDMATCH
, NotMatchPassword
,
699 sizeof(NotMatchPassword
) / sizeof(NotMatchPassword
[0])))
701 wcscpy(NotMatchPassword
, L
"The passwords you entered do not match. Please enter the desired password again.");
703 MessageBoxW(hwndDlg
, NotMatchPassword
, Title
, MB_ICONERROR
| MB_OK
);
704 SetWindowLongPtr(hwndDlg
, DWL_MSGRESULT
, -1);
708 /* Check password for invalid characters */
709 Password
= (PWCHAR
)Password1
;
712 if (!isprint(*Password
))
714 if (0 == LoadStringW(hDllInstance
, IDS_WZD_PASSWORDCHAR
, WrongPassword
,
715 sizeof(WrongPassword
) / sizeof(WrongPassword
[0])))
717 wcscpy(WrongPassword
, L
"The password you entered contains invalid characters. Please enter a cleaned password.");
719 MessageBoxW(hwndDlg
, WrongPassword
, Title
, MB_ICONERROR
| MB_OK
);
720 SetWindowLongPtr(hwndDlg
, DWL_MSGRESULT
, -1);
726 /* Set admin password */
727 SetAdministratorPassword(Password1
);
731 SetupData
.UnattendSetup
= FALSE
;
749 SetKeyboardLayoutName(HWND hwnd
)
752 TCHAR szLayoutPath
[256];
753 TCHAR szLocaleName
[32];
757 if (RegOpenKeyEx(HKEY_LOCAL_MACHINE
,
758 _T("SYSTEM\\CurrentControlSet\\Control\\NLS\\Locale"),
764 dwValueSize
= 16 * sizeof(TCHAR
);
765 if (RegQueryValueEx(hKey
,
776 _tcscpy(szLayoutPath
,
777 _T("SYSTEM\\CurrentControlSet\\Control\\Keyboard Layouts\\"));
778 _tcscat(szLayoutPath
,
781 if (RegOpenKeyEx(HKEY_LOCAL_MACHINE
,
788 dwValueSize
= 32 * sizeof(TCHAR
);
789 if (RegQueryValueEx(hKey
,
806 RunControlPanelApplet(HWND hwnd
, PCWSTR pwszCPLParameters
)
808 if (pwszCPLParameters
)
810 STARTUPINFOW StartupInfo
;
811 PROCESS_INFORMATION ProcessInformation
;
812 WCHAR CmdLine
[MAX_PATH
] = L
"rundll32.exe shell32.dll,Control_RunDLL ";
814 ZeroMemory(&StartupInfo
, sizeof(StartupInfo
));
815 StartupInfo
.cb
= sizeof(StartupInfo
);
817 ASSERT(_countof(CmdLine
) > wcslen(CmdLine
) + wcslen(pwszCPLParameters
));
818 wcscat(CmdLine
, pwszCPLParameters
);
820 if (!CreateProcessW(NULL
,
829 &ProcessInformation
))
831 MessageBoxW(hwnd
, L
"Error: Failed to launch the Control Panel Applet.", NULL
, MB_ICONERROR
);
835 WaitForSingleObject(ProcessInformation
.hProcess
, INFINITE
);
836 CloseHandle(ProcessInformation
.hThread
);
837 CloseHandle(ProcessInformation
.hProcess
);
842 MessageBoxW(hwnd
, L
"Error: Failed to launch the Control Panel Applet.", NULL
, MB_ICONERROR
);
848 WriteUserLocale(VOID
)
854 lcid
= GetSystemDefaultLCID();
856 if (GetLocaleInfoW(MAKELCID(lcid
, SORT_DEFAULT
), LOCALE_ILANGUAGE
, Locale
, sizeof(Locale
) / sizeof(Locale
[0])) != 0)
858 if (RegCreateKeyExW(HKEY_CURRENT_USER
, L
"Control Panel\\International",
859 0, NULL
, REG_OPTION_NON_VOLATILE
,
860 KEY_WRITE
, NULL
, &hKey
, NULL
) == ERROR_SUCCESS
)
862 RegSetValueExW(hKey
, L
"Locale", 0, REG_SZ
, (LPBYTE
)Locale
, (wcslen(Locale
) + 1) * sizeof(WCHAR
));
868 static INT_PTR CALLBACK
869 LocalePageDlgProc(HWND hwndDlg
,
874 PSETUPDATA SetupData
;
876 /* Retrieve pointer to the global setup data */
877 SetupData
= (PSETUPDATA
)GetWindowLongPtr (hwndDlg
, GWL_USERDATA
);
883 /* Save pointer to the global setup data */
884 SetupData
= (PSETUPDATA
)((LPPROPSHEETPAGE
)lParam
)->lParam
;
885 SetWindowLongPtr(hwndDlg
, GWL_USERDATA
, (DWORD_PTR
)SetupData
);
888 SetKeyboardLayoutName(GetDlgItem(hwndDlg
, IDC_LAYOUTTEXT
));
893 if (HIWORD(wParam
) == BN_CLICKED
)
895 switch (LOWORD(wParam
))
897 case IDC_CUSTOMLOCALE
:
898 RunControlPanelApplet(hwndDlg
, L
"intl.cpl,,5");
899 /* FIXME: Update input locale name */
902 case IDC_CUSTOMLAYOUT
:
903 RunControlPanelApplet(hwndDlg
, L
"input.dll,@1");
911 LPNMHDR lpnm
= (LPNMHDR
)lParam
;
916 /* Enable the Back and Next buttons */
917 PropSheet_SetWizButtons(GetParent(hwndDlg
), PSWIZB_BACK
| PSWIZB_NEXT
);
918 if (SetupData
->UnattendSetup
)
920 WCHAR wszPath
[MAX_PATH
];
921 if (GetRosInstallCD(wszPath
, _countof(wszPath
)))
923 WCHAR wszParams
[1024];
924 swprintf(wszParams
, L
"intl.cpl,,/f:\"%sreactos\\unattend.inf\"", wszPath
);
925 RunControlPanelApplet(hwndDlg
, wszParams
);
929 RunControlPanelApplet(hwndDlg
, L
"intl.cpl,,/f:\"unattend.inf\"");
932 SetWindowLongPtr(hwndDlg
, DWL_MSGRESULT
, IDD_OWNERPAGE
);
941 SetupData
->UnattendSetup
= FALSE
;
958 static PTIMEZONE_ENTRY
959 GetLargerTimeZoneEntry(PSETUPDATA SetupData
, DWORD Index
)
961 PTIMEZONE_ENTRY Entry
;
963 Entry
= SetupData
->TimeZoneListHead
;
964 while (Entry
!= NULL
)
966 if (Entry
->Index
>= Index
)
977 CreateTimeZoneList(PSETUPDATA SetupData
)
979 WCHAR szKeyName
[256];
987 PTIMEZONE_ENTRY Entry
;
988 PTIMEZONE_ENTRY Current
;
990 if (RegOpenKeyExW(HKEY_LOCAL_MACHINE
,
991 L
"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Time Zones",
1000 dwNameSize
= 256 * sizeof(WCHAR
);
1001 lError
= RegEnumKeyExW(hZonesKey
,
1009 if (lError
!= ERROR_SUCCESS
&& lError
!= ERROR_MORE_DATA
)
1012 if (RegOpenKeyExW(hZonesKey
,
1019 Entry
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(TIMEZONE_ENTRY
));
1022 RegCloseKey(hZoneKey
);
1026 dwValueSize
= 64 * sizeof(WCHAR
);
1027 if (RegQueryValueExW(hZoneKey
,
1031 (LPBYTE
)&Entry
->Description
,
1034 RegCloseKey(hZoneKey
);
1038 dwValueSize
= 32 * sizeof(WCHAR
);
1039 if (RegQueryValueExW(hZoneKey
,
1043 (LPBYTE
)&Entry
->StandardName
,
1046 RegCloseKey(hZoneKey
);
1050 dwValueSize
= 32 * sizeof(WCHAR
);
1051 if (RegQueryValueExW(hZoneKey
,
1055 (LPBYTE
)&Entry
->DaylightName
,
1058 RegCloseKey(hZoneKey
);
1062 dwValueSize
= sizeof(DWORD
);
1063 if (RegQueryValueExW(hZoneKey
,
1067 (LPBYTE
)&Entry
->Index
,
1070 RegCloseKey(hZoneKey
);
1074 dwValueSize
= sizeof(TZ_INFO
);
1075 if (RegQueryValueExW(hZoneKey
,
1079 (LPBYTE
)&Entry
->TimezoneInfo
,
1082 RegCloseKey(hZoneKey
);
1086 RegCloseKey(hZoneKey
);
1088 if (SetupData
->TimeZoneListHead
== NULL
&&
1089 SetupData
->TimeZoneListTail
== NULL
)
1093 SetupData
->TimeZoneListHead
= Entry
;
1094 SetupData
->TimeZoneListTail
= Entry
;
1098 Current
= GetLargerTimeZoneEntry(SetupData
, Entry
->Index
);
1099 if (Current
!= NULL
)
1101 if (Current
== SetupData
->TimeZoneListHead
)
1103 /* Prepend to head */
1105 Entry
->Next
= SetupData
->TimeZoneListHead
;
1106 SetupData
->TimeZoneListHead
->Prev
= Entry
;
1107 SetupData
->TimeZoneListHead
= Entry
;
1111 /* Insert before current */
1112 Entry
->Prev
= Current
->Prev
;
1113 Entry
->Next
= Current
;
1114 Current
->Prev
->Next
= Entry
;
1115 Current
->Prev
= Entry
;
1120 /* Append to tail */
1121 Entry
->Prev
= SetupData
->TimeZoneListTail
;
1123 SetupData
->TimeZoneListTail
->Next
= Entry
;
1124 SetupData
->TimeZoneListTail
= Entry
;
1131 RegCloseKey(hZonesKey
);
1136 DestroyTimeZoneList(PSETUPDATA SetupData
)
1138 PTIMEZONE_ENTRY Entry
;
1140 while (SetupData
->TimeZoneListHead
!= NULL
)
1142 Entry
= SetupData
->TimeZoneListHead
;
1144 SetupData
->TimeZoneListHead
= Entry
->Next
;
1145 if (SetupData
->TimeZoneListHead
!= NULL
)
1147 SetupData
->TimeZoneListHead
->Prev
= NULL
;
1150 HeapFree(GetProcessHeap(), 0, Entry
);
1153 SetupData
->TimeZoneListTail
= NULL
;
1157 GetTimeZoneListIndex(LPDWORD lpIndex
)
1159 WCHAR szLanguageIdString
[9];
1166 BOOL bFound
= FALSE
;
1167 unsigned long iLanguageID
;
1169 if (RegOpenKeyExW(HKEY_LOCAL_MACHINE
,
1170 L
"SYSTEM\\CurrentControlSet\\Control\\NLS\\Language",
1176 dwValueSize
= 9 * sizeof(WCHAR
);
1177 if (RegQueryValueExW(hKey
,
1181 (LPBYTE
)szLanguageIdString
,
1188 iLanguageID
= wcstoul(szLanguageIdString
, NULL
, 16);
1191 if (RegOpenKeyExW(HKEY_LOCAL_MACHINE
,
1192 L
"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Time Zones",
1199 if (RegQueryValueExW(hKey
,
1210 Buffer
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, dwValueSize
);
1217 if (RegQueryValueExW(hKey
,
1224 HeapFree(GetProcessHeap(), 0, Buffer
);
1234 Length
= wcslen(Ptr
);
1235 if (wcstoul(Ptr
, NULL
, 16) == iLanguageID
)
1238 Ptr
= Ptr
+ Length
+ 1;
1244 *lpIndex
= wcstoul(Ptr
, &End
, 10);
1245 HeapFree(GetProcessHeap(), 0, Buffer
);
1249 Length
= wcslen(Ptr
);
1250 Ptr
= Ptr
+ Length
+ 1;
1253 HeapFree(GetProcessHeap(), 0, Buffer
);
1260 ShowTimeZoneList(HWND hwnd
, PSETUPDATA SetupData
, DWORD dwEntryIndex
)
1262 PTIMEZONE_ENTRY Entry
;
1266 GetTimeZoneListIndex(&dwEntryIndex
);
1268 Entry
= SetupData
->TimeZoneListHead
;
1269 while (Entry
!= NULL
)
1271 dwCount
= SendMessage(hwnd
,
1274 (LPARAM
)Entry
->Description
);
1276 if (dwEntryIndex
!= 0 && dwEntryIndex
== Entry
->Index
)
1279 Entry
= Entry
->Next
;
1290 SetLocalTimeZone(HWND hwnd
, PSETUPDATA SetupData
)
1292 TIME_ZONE_INFORMATION TimeZoneInformation
;
1293 PTIMEZONE_ENTRY Entry
;
1297 dwIndex
= SendMessage(hwnd
,
1303 Entry
= SetupData
->TimeZoneListHead
;
1310 Entry
= Entry
->Next
;
1313 wcscpy(TimeZoneInformation
.StandardName
,
1314 Entry
->StandardName
);
1315 wcscpy(TimeZoneInformation
.DaylightName
,
1316 Entry
->DaylightName
);
1318 TimeZoneInformation
.Bias
= Entry
->TimezoneInfo
.Bias
;
1319 TimeZoneInformation
.StandardBias
= Entry
->TimezoneInfo
.StandardBias
;
1320 TimeZoneInformation
.DaylightBias
= Entry
->TimezoneInfo
.DaylightBias
;
1322 memcpy(&TimeZoneInformation
.StandardDate
,
1323 &Entry
->TimezoneInfo
.StandardDate
,
1324 sizeof(SYSTEMTIME
));
1325 memcpy(&TimeZoneInformation
.DaylightDate
,
1326 &Entry
->TimezoneInfo
.DaylightDate
,
1327 sizeof(SYSTEMTIME
));
1329 /* Set time zone information */
1330 SetTimeZoneInformation(&TimeZoneInformation
);
1335 GetLocalSystemTime(HWND hwnd
, PSETUPDATA SetupData
)
1340 if (DateTime_GetSystemtime(GetDlgItem(hwnd
, IDC_DATEPICKER
), &Date
) != GDT_VALID
)
1345 if (DateTime_GetSystemtime(GetDlgItem(hwnd
, IDC_TIMEPICKER
), &Time
) != GDT_VALID
)
1350 SetupData
->SystemTime
.wYear
= Date
.wYear
;
1351 SetupData
->SystemTime
.wMonth
= Date
.wMonth
;
1352 SetupData
->SystemTime
.wDayOfWeek
= Date
.wDayOfWeek
;
1353 SetupData
->SystemTime
.wDay
= Date
.wDay
;
1354 SetupData
->SystemTime
.wHour
= Time
.wHour
;
1355 SetupData
->SystemTime
.wMinute
= Time
.wMinute
;
1356 SetupData
->SystemTime
.wSecond
= Time
.wSecond
;
1357 SetupData
->SystemTime
.wMilliseconds
= Time
.wMilliseconds
;
1364 SetAutoDaylightInfo(HWND hwnd
)
1369 if (SendMessage(hwnd
, BM_GETCHECK
, 0, 0) == BST_UNCHECKED
)
1371 if (RegOpenKeyExW(HKEY_LOCAL_MACHINE
,
1372 L
"SYSTEM\\CurrentControlSet\\Control\\TimeZoneInformation",
1378 RegSetValueExW(hKey
,
1379 L
"DisableAutoDaylightTimeSet",
1390 SetSystemLocalTime(HWND hwnd
, PSETUPDATA SetupData
)
1395 * Call SetLocalTime twice to ensure correct results
1397 Ret
= SetLocalTime(&SetupData
->SystemTime
) &&
1398 SetLocalTime(&SetupData
->SystemTime
);
1404 WriteDateTimeSettings(HWND hwndDlg
, PSETUPDATA SetupData
)
1407 WCHAR ErrorLocalTime
[256];
1408 GetLocalSystemTime(hwndDlg
, SetupData
);
1409 SetLocalTimeZone(GetDlgItem(hwndDlg
, IDC_TIMEZONELIST
),
1412 SetAutoDaylightInfo(GetDlgItem(hwndDlg
, IDC_AUTODAYLIGHT
));
1413 if(!SetSystemLocalTime(hwndDlg
, SetupData
))
1415 if (0 == LoadStringW(hDllInstance
, IDS_REACTOS_SETUP
, Title
, sizeof(Title
) / sizeof(Title
[0])))
1417 wcscpy(Title
, L
"ReactOS Setup");
1419 if (0 == LoadStringW(hDllInstance
, IDS_WZD_LOCALTIME
, ErrorLocalTime
,
1420 sizeof(ErrorLocalTime
) / sizeof(ErrorLocalTime
[0])))
1422 wcscpy(ErrorLocalTime
, L
"Setup was unable to set the local time.");
1424 MessageBoxW(hwndDlg
, ErrorLocalTime
, Title
, MB_ICONWARNING
| MB_OK
);
1431 static INT_PTR CALLBACK
1432 DateTimePageDlgProc(HWND hwndDlg
,
1437 PSETUPDATA SetupData
;
1439 /* Retrieve pointer to the global setup data */
1440 SetupData
= (PSETUPDATA
)GetWindowLongPtr (hwndDlg
, GWL_USERDATA
);
1446 /* Save pointer to the global setup data */
1447 SetupData
= (PSETUPDATA
)((LPPROPSHEETPAGE
)lParam
)->lParam
;
1448 SetWindowLongPtr(hwndDlg
, GWL_USERDATA
, (DWORD_PTR
)SetupData
);
1450 CreateTimeZoneList(SetupData
);
1452 if (SetupData
->UnattendSetup
)
1454 ShowTimeZoneList(GetDlgItem(hwndDlg
, IDC_TIMEZONELIST
),
1455 SetupData
, SetupData
->TimeZoneIndex
);
1457 if (!SetupData
->DisableAutoDaylightTimeSet
)
1459 SendDlgItemMessage(hwndDlg
, IDC_AUTODAYLIGHT
, BM_SETCHECK
, (WPARAM
)BST_CHECKED
, 0);
1464 ShowTimeZoneList(GetDlgItem(hwndDlg
, IDC_TIMEZONELIST
),
1465 SetupData
, 85 /* GMT time zone */);
1467 SendDlgItemMessage(hwndDlg
, IDC_AUTODAYLIGHT
, BM_SETCHECK
, (WPARAM
)BST_CHECKED
, 0);
1476 LPNMHDR lpnm
= (LPNMHDR
)lParam
;
1481 /* Enable the Back and Next buttons */
1482 PropSheet_SetWizButtons(GetParent(hwndDlg
), PSWIZB_BACK
| PSWIZB_NEXT
);
1483 if (SetupData
->UnattendSetup
&& WriteDateTimeSettings(hwndDlg
, SetupData
))
1485 SetWindowLongPtr(hwndDlg
, DWL_MSGRESULT
, IDD_PROCESSPAGE
);
1492 WriteDateTimeSettings(hwndDlg
, SetupData
);
1497 SetupData
->UnattendSetup
= FALSE
;
1507 DestroyTimeZoneList(SetupData
);
1518 static UINT CALLBACK
1519 RegistrationNotificationProc(PVOID Context
,
1524 PREGISTRATIONDATA RegistrationData
;
1525 REGISTRATIONNOTIFY RegistrationNotify
;
1526 PSP_REGISTER_CONTROL_STATUSW StatusInfo
;
1528 WCHAR ErrorMessage
[128];
1530 RegistrationData
= (PREGISTRATIONDATA
) Context
;
1532 if (SPFILENOTIFY_STARTREGISTRATION
== Notification
||
1533 SPFILENOTIFY_ENDREGISTRATION
== Notification
)
1535 StatusInfo
= (PSP_REGISTER_CONTROL_STATUSW
) Param1
;
1536 RegistrationNotify
.CurrentItem
= wcsrchr(StatusInfo
->FileName
, L
'\\');
1537 if (NULL
== RegistrationNotify
.CurrentItem
)
1539 RegistrationNotify
.CurrentItem
= StatusInfo
->FileName
;
1543 RegistrationNotify
.CurrentItem
++;
1546 if (SPFILENOTIFY_STARTREGISTRATION
== Notification
)
1548 DPRINT("Received SPFILENOTIFY_STARTREGISTRATION notification for %S\n",
1549 StatusInfo
->FileName
);
1550 RegistrationNotify
.ErrorMessage
= NULL
;
1551 RegistrationNotify
.Progress
= RegistrationData
->Registered
;
1555 DPRINT("Received SPFILENOTIFY_ENDREGISTRATION notification for %S\n",
1556 StatusInfo
->FileName
);
1557 DPRINT("Win32Error %u FailureCode %u\n", StatusInfo
->Win32Error
,
1558 StatusInfo
->FailureCode
);
1559 if (SPREG_SUCCESS
!= StatusInfo
->FailureCode
)
1561 switch(StatusInfo
->FailureCode
)
1563 case SPREG_LOADLIBRARY
:
1564 MessageID
= IDS_LOADLIBRARY_FAILED
;
1566 case SPREG_GETPROCADDR
:
1567 MessageID
= IDS_GETPROCADDR_FAILED
;
1570 MessageID
= IDS_REGSVR_FAILED
;
1572 case SPREG_DLLINSTALL
:
1573 MessageID
= IDS_DLLINSTALL_FAILED
;
1576 MessageID
= IDS_TIMEOUT
;
1579 MessageID
= IDS_REASON_UNKNOWN
;
1582 if (0 == LoadStringW(hDllInstance
, MessageID
,
1584 sizeof(ErrorMessage
) /
1585 sizeof(ErrorMessage
[0])))
1587 ErrorMessage
[0] = L
'\0';
1589 if (SPREG_TIMEOUT
!= StatusInfo
->FailureCode
)
1591 FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM
, NULL
,
1592 StatusInfo
->Win32Error
, 0,
1593 ErrorMessage
+ wcslen(ErrorMessage
),
1594 sizeof(ErrorMessage
) / sizeof(ErrorMessage
[0]) -
1595 wcslen(ErrorMessage
), NULL
);
1597 RegistrationNotify
.ErrorMessage
= ErrorMessage
;
1601 RegistrationNotify
.ErrorMessage
= NULL
;
1603 if (RegistrationData
->Registered
< RegistrationData
->DllCount
)
1605 RegistrationData
->Registered
++;
1609 RegistrationNotify
.Progress
= RegistrationData
->Registered
;
1610 RegistrationNotify
.ActivityID
= IDS_REGISTERING_COMPONENTS
;
1611 SendMessage(RegistrationData
->hwndDlg
, PM_REGISTRATION_NOTIFY
,
1612 0, (LPARAM
) &RegistrationNotify
);
1618 DPRINT1("Received unexpected notification %u\n", Notification
);
1619 return SetupDefaultQueueCallback(RegistrationData
->DefaultContext
,
1620 Notification
, Param1
, Param2
);
1625 static DWORD CALLBACK
1626 RegistrationProc(LPVOID Parameter
)
1628 PREGISTRATIONDATA RegistrationData
;
1629 REGISTRATIONNOTIFY RegistrationNotify
;
1630 DWORD LastError
= NO_ERROR
;
1631 WCHAR UnknownError
[84];
1633 RegistrationData
= (PREGISTRATIONDATA
) Parameter
;
1634 RegistrationData
->Registered
= 0;
1635 RegistrationData
->DefaultContext
= SetupInitDefaultQueueCallback(RegistrationData
->hwndDlg
);
1639 if (!SetupInstallFromInfSectionW(GetParent(RegistrationData
->hwndDlg
),
1641 L
"RegistrationPhase2",
1643 SPINST_REGISTERCALLBACKAWARE
|
1648 RegistrationNotificationProc
,
1653 LastError
= GetLastError();
1656 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
1658 DPRINT("Catching exception\n");
1659 LastError
= RtlNtStatusToDosError(_SEH2_GetExceptionCode());
1663 if (NO_ERROR
== LastError
)
1665 RegistrationNotify
.ErrorMessage
= NULL
;
1669 DPRINT1("SetupInstallFromInfSection failed with error %u\n",
1671 if (0 == FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER
|
1672 FORMAT_MESSAGE_FROM_SYSTEM
, NULL
, LastError
, 0,
1673 (LPWSTR
) &RegistrationNotify
.ErrorMessage
, 0,
1676 if (0 == LoadStringW(hDllInstance
, IDS_UNKNOWN_ERROR
,
1678 sizeof(UnknownError
) / sizeof(UnknownError
[0]) -
1681 wcscpy(UnknownError
, L
"Unknown error");
1683 wcscat(UnknownError
, L
" ");
1684 _ultow(LastError
, UnknownError
+ wcslen(UnknownError
), 10);
1685 RegistrationNotify
.ErrorMessage
= UnknownError
;
1689 RegistrationNotify
.Progress
= RegistrationData
->DllCount
;
1690 RegistrationNotify
.ActivityID
= IDS_REGISTERING_COMPONENTS
;
1691 RegistrationNotify
.CurrentItem
= NULL
;
1692 SendMessage(RegistrationData
->hwndDlg
, PM_REGISTRATION_NOTIFY
,
1693 1, (LPARAM
) &RegistrationNotify
);
1694 if (NULL
!= RegistrationNotify
.ErrorMessage
&&
1695 UnknownError
!= RegistrationNotify
.ErrorMessage
)
1697 LocalFree((PVOID
) RegistrationNotify
.ErrorMessage
);
1700 SetupTermDefaultQueueCallback(RegistrationData
->DefaultContext
);
1701 HeapFree(GetProcessHeap(), 0, RegistrationData
);
1703 RegisterTypeLibraries(hSysSetupInf
, L
"TypeLibraries");
1705 // FIXME: Move this call to a separate cleanup page!
1706 RtlCreateBootStatusDataFile();
1713 StartComponentRegistration(HWND hwndDlg
, PULONG MaxProgress
)
1715 HANDLE RegistrationThread
;
1718 WCHAR SectionName
[512];
1719 PREGISTRATIONDATA RegistrationData
;
1722 if (! SetupFindFirstLineW(hSysSetupInf
, L
"RegistrationPhase2",
1723 L
"RegisterDlls", &Context
))
1725 DPRINT1("No RegistrationPhase2 section found\n");
1728 if (! SetupGetStringFieldW(&Context
, 1, SectionName
,
1729 sizeof(SectionName
) / sizeof(SectionName
[0]),
1732 DPRINT1("Unable to retrieve section name\n");
1735 DllCount
= SetupGetLineCountW(hSysSetupInf
, SectionName
);
1736 DPRINT("SectionName %S DllCount %ld\n", SectionName
, DllCount
);
1739 SetLastError(STATUS_NOT_FOUND
);
1743 *MaxProgress
= (ULONG
) DllCount
;
1746 * Create a background thread to do the actual registrations, so the
1747 * main thread can just run its message loop.
1749 RegistrationThread
= NULL
;
1750 RegistrationData
= HeapAlloc(GetProcessHeap(), 0,
1751 sizeof(REGISTRATIONDATA
));
1752 if (RegistrationData
!= NULL
)
1754 RegistrationData
->hwndDlg
= hwndDlg
;
1755 RegistrationData
->DllCount
= DllCount
;
1756 RegistrationThread
= CreateThread(NULL
, 0, RegistrationProc
,
1757 (LPVOID
) RegistrationData
, 0, NULL
);
1758 if (RegistrationThread
!= NULL
)
1760 CloseHandle(RegistrationThread
);
1764 DPRINT1("CreateThread failed, error %u\n", GetLastError());
1765 HeapFree(GetProcessHeap(), 0, RegistrationData
);
1771 DPRINT1("HeapAlloc() failed, error %u\n", GetLastError());
1779 static INT_PTR CALLBACK
1780 ProcessPageDlgProc(HWND hwndDlg
,
1785 PSETUPDATA SetupData
;
1786 PREGISTRATIONNOTIFY RegistrationNotify
;
1787 static UINT oldActivityID
= -1;
1790 /* Retrieve pointer to the global setup data */
1791 SetupData
= (PSETUPDATA
)GetWindowLongPtr (hwndDlg
, GWL_USERDATA
);
1797 /* Save pointer to the global setup data */
1798 SetupData
= (PSETUPDATA
)((LPPROPSHEETPAGE
)lParam
)->lParam
;
1799 SetWindowLongPtr(hwndDlg
, GWL_USERDATA
, (DWORD_PTR
)SetupData
);
1805 LPNMHDR lpnm
= (LPNMHDR
)lParam
;
1806 ULONG MaxProgress
= 0;
1811 /* Disable the Back and Next buttons */
1812 PropSheet_SetWizButtons(GetParent(hwndDlg
), 0);
1814 StartComponentRegistration(hwndDlg
, &MaxProgress
);
1816 SendDlgItemMessage(hwndDlg
, IDC_PROCESSPROGRESS
, PBM_SETRANGE
,
1817 0, MAKELPARAM(0, MaxProgress
));
1818 SendDlgItemMessage(hwndDlg
, IDC_PROCESSPROGRESS
, PBM_SETPOS
,
1826 SetupData
->UnattendSetup
= FALSE
;
1835 case PM_REGISTRATION_NOTIFY
:
1838 RegistrationNotify
= (PREGISTRATIONNOTIFY
) lParam
;
1839 // update if necessary only
1840 if (oldActivityID
!= RegistrationNotify
->ActivityID
)
1842 if (0 != LoadStringW(hDllInstance
, RegistrationNotify
->ActivityID
,
1844 sizeof(Activity
) / sizeof(Activity
[0])))
1846 SendDlgItemMessageW(hwndDlg
, IDC_ACTIVITY
, WM_SETTEXT
,
1847 0, (LPARAM
) Activity
);
1849 oldActivityID
= RegistrationNotify
->ActivityID
;
1851 SendDlgItemMessageW(hwndDlg
, IDC_ITEM
, WM_SETTEXT
, 0,
1852 (LPARAM
)(NULL
== RegistrationNotify
->CurrentItem
?
1853 L
"" : RegistrationNotify
->CurrentItem
));
1854 SendDlgItemMessage(hwndDlg
, IDC_PROCESSPROGRESS
, PBM_SETPOS
,
1855 RegistrationNotify
->Progress
, 0);
1856 if (NULL
!= RegistrationNotify
->ErrorMessage
)
1858 if (0 == LoadStringW(hDllInstance
, IDS_REACTOS_SETUP
,
1859 Title
, sizeof(Title
) / sizeof(Title
[0])))
1861 wcscpy(Title
, L
"ReactOS Setup");
1863 MessageBoxW(hwndDlg
, RegistrationNotify
->ErrorMessage
,
1864 Title
, MB_ICONERROR
| MB_OK
);
1871 if(!SetupData
->UnattendSetup
&& !SetupData
->DisableVmwInst
)
1872 RunVMWInstall(GetParent(hwndDlg
));
1875 /* Enable the Back and Next buttons */
1876 PropSheet_SetWizButtons(GetParent(hwndDlg
), PSWIZB_NEXT
);
1877 PropSheet_PressButton(GetParent(hwndDlg
), PSBTN_NEXT
);
1891 SetInstallationCompleted(VOID
)
1894 DWORD InProgress
= 0;
1897 if (RegOpenKeyExW( HKEY_LOCAL_MACHINE
,
1901 &hKey
) == ERROR_SUCCESS
)
1903 RegSetValueExW( hKey
, L
"SystemSetupInProgress", 0, REG_DWORD
, (LPBYTE
)&InProgress
, sizeof(InProgress
) );
1904 RegCloseKey( hKey
);
1907 if (RegOpenKeyExW( HKEY_LOCAL_MACHINE
,
1908 L
"Software\\Microsoft\\Windows NT\\CurrentVersion",
1911 &hKey
) == ERROR_SUCCESS
)
1913 InstallDate
= (DWORD
)time(NULL
);
1914 RegSetValueExW( hKey
, L
"InstallDate", 0, REG_DWORD
, (LPBYTE
)&InstallDate
, sizeof(InstallDate
) );
1915 RegCloseKey( hKey
);
1919 static INT_PTR CALLBACK
1920 FinishDlgProc(HWND hwndDlg
,
1930 /* Get pointer to the global setup data */
1931 PSETUPDATA SetupData
= (PSETUPDATA
)((LPPROPSHEETPAGE
)lParam
)->lParam
;
1933 /* Run the Wine Gecko prompt */
1934 Control_RunDLLW(GetDesktopWindow(), 0, L
"appwiz.cpl install_gecko", SW_SHOW
);
1936 /* Set title font */
1937 SendDlgItemMessage(hwndDlg
,
1940 (WPARAM
)SetupData
->hTitleFont
,
1942 if (SetupData
->UnattendSetup
)
1944 KillTimer(hwndDlg
, 1);
1945 SetInstallationCompleted();
1953 SetInstallationCompleted();
1963 hWndProgress
= GetDlgItem(hwndDlg
, IDC_RESTART_PROGRESS
);
1964 Position
= SendMessage(hWndProgress
, PBM_GETPOS
, 0, 0);
1965 if (Position
== 300)
1967 KillTimer(hwndDlg
, 1);
1968 PropSheet_PressButton(GetParent(hwndDlg
), PSBTN_FINISH
);
1972 SendMessage(hWndProgress
, PBM_SETPOS
, Position
+ 1, 0);
1979 LPNMHDR lpnm
= (LPNMHDR
)lParam
;
1984 /* Enable the correct buttons on for the active page */
1985 PropSheet_SetWizButtons(GetParent(hwndDlg
), PSWIZB_FINISH
);
1987 SendDlgItemMessage(hwndDlg
, IDC_RESTART_PROGRESS
, PBM_SETRANGE
, 0,
1988 MAKELPARAM(0, 300));
1989 SendDlgItemMessage(hwndDlg
, IDC_RESTART_PROGRESS
, PBM_SETPOS
, 0, 0);
1990 SetTimer(hwndDlg
, 1, 50, NULL
);
1994 DestroyWindow(GetParent(hwndDlg
));
2012 ProcessUnattendInf(HINF hUnattendedInf
)
2014 INFCONTEXT InfContext
;
2016 WCHAR szValue
[MAX_PATH
];
2020 if (!SetupFindFirstLineW(hUnattendedInf
,
2022 L
"UnattendSetupEnabled",
2025 DPRINT1("Error: Cant find UnattendSetupEnabled Key! %d\n", GetLastError());
2029 if (!SetupGetStringFieldW(&InfContext
,
2032 sizeof(szValue
) / sizeof(WCHAR
),
2035 DPRINT1("Error: SetupGetStringField failed with %d\n", GetLastError());
2039 if (wcscmp(szValue
, L
"yes") != 0)
2041 DPRINT("Unattend setup was disabled by UnattendSetupEnabled key.\n");
2045 if (!SetupFindFirstLineW(hUnattendedInf
,
2050 DPRINT1("Error: SetupFindFirstLine failed %d\n", GetLastError());
2057 if (!SetupGetStringFieldW(&InfContext
,
2060 sizeof(szName
) / sizeof(WCHAR
),
2063 DPRINT1("Error: SetupGetStringField failed with %d\n", GetLastError());
2067 if (!SetupGetStringFieldW(&InfContext
,
2070 sizeof(szValue
) / sizeof(WCHAR
),
2073 DPRINT1("Error: SetupGetStringField failed with %d\n", GetLastError());
2076 DPRINT1("Name %S Value %S\n", szName
, szValue
);
2077 if (!wcscmp(szName
, L
"FullName"))
2079 if ((sizeof(SetupData
.OwnerName
) / sizeof(TCHAR
)) > LineLength
)
2081 wcscpy(SetupData
.OwnerName
, szValue
);
2084 else if (!wcscmp(szName
, L
"OrgName"))
2086 if ((sizeof(SetupData
.OwnerOrganization
) / sizeof(WCHAR
)) > LineLength
)
2088 wcscpy(SetupData
.OwnerOrganization
, szValue
);
2091 else if (!wcscmp(szName
, L
"ComputerName"))
2093 if ((sizeof(SetupData
.ComputerName
) / sizeof(WCHAR
)) > LineLength
)
2095 wcscpy(SetupData
.ComputerName
, szValue
);
2098 else if (!wcscmp(szName
, L
"AdminPassword"))
2100 if ((sizeof(SetupData
.AdminPassword
) / sizeof(WCHAR
)) > LineLength
)
2102 wcscpy(SetupData
.AdminPassword
, szValue
);
2105 else if (!wcscmp(szName
, L
"TimeZoneIndex"))
2107 SetupData
.TimeZoneIndex
= _wtoi(szValue
);
2109 else if (!wcscmp(szName
, L
"DisableAutoDaylightTimeSet"))
2111 SetupData
.DisableAutoDaylightTimeSet
= _wtoi(szValue
);
2113 else if (!wcscmp(szName
, L
"DisableVmwInst"))
2115 if(!wcscmp(szValue
, L
"yes"))
2116 SetupData
.DisableVmwInst
= 1;
2118 SetupData
.DisableVmwInst
= 0;
2122 while (SetupFindNextLine(&InfContext
, &InfContext
));
2124 if (RegOpenKeyExW(HKEY_LOCAL_MACHINE
,
2125 L
"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\RunOnce",
2128 &hKey
) != ERROR_SUCCESS
)
2130 DPRINT1("Error: failed to open HKLM\\Software\\Microsoft\\Windows\\CurrentVersion\\RunOnce\n");
2135 if (SetupFindFirstLineW(hUnattendedInf
,
2144 if(SetupGetStringFieldW(&InfContext
,
2147 sizeof(szValue
) / sizeof(WCHAR
),
2150 WCHAR szPath
[MAX_PATH
];
2151 swprintf(szName
, L
"%d", i
);
2152 DPRINT("szName %S szValue %S\n", szName
, szValue
);
2154 if (ExpandEnvironmentStringsW(szValue
, szPath
, MAX_PATH
))
2156 DPRINT("value %S\n", szPath
);
2157 if (RegSetValueExW(hKey
,
2161 (const BYTE
*)szPath
,
2162 (wcslen(szPath
) + 1) * sizeof(WCHAR
)) == ERROR_SUCCESS
)
2168 } while(SetupFindNextLine(&InfContext
, &InfContext
));
2176 * GetRosInstallCD should find the path to ros installation medium
2178 * If there are more than one CDDrive in it containing a ReactOS
2179 * installation cd, then it will pick the first one regardless if
2180 * it is really the installation cd
2182 * The best way to implement this is to set the key
2183 * HKLM\Software\Microsoft\Windows NT\CurrentVersion\SourcePath (REG_SZ)
2187 GetRosInstallCD(WCHAR
*pwszPath
, DWORD cchPathMax
)
2189 WCHAR wszDrives
[512];
2193 cchDrives
= GetLogicalDriveStringsW(_countof(wszDrives
) - 1, wszDrives
);
2194 if (cchDrives
== 0 || cchDrives
>= _countof(wszDrives
))
2196 /* buffer too small or failure */
2197 LogItem(SYSSETUP_SEVERITY_INFORMATION
, L
"GetLogicalDriveStringsW failed");
2201 for (pwszDrive
= wszDrives
; pwszDrive
[0]; pwszDrive
+= wcslen(pwszDrive
) + 1)
2203 if (GetDriveTypeW(pwszDrive
) == DRIVE_CDROM
)
2205 WCHAR wszBuf
[MAX_PATH
];
2206 wsprintf(wszBuf
, L
"%sreactos\\system32\\ntoskrnl.exe", pwszDrive
);
2207 LogItem(SYSSETUP_SEVERITY_INFORMATION
, wszBuf
);
2208 if (GetFileAttributesW(wszBuf
) != INVALID_FILE_ATTRIBUTES
)
2210 /* the file exists, so this is the right drive */
2211 wcsncpy(pwszPath
, pwszDrive
, cchPathMax
);
2212 OutputDebugStringW(L
"GetRosInstallCD: ");OutputDebugStringW(pwszPath
);OutputDebugStringW(L
"\n");
2222 ProcessUnattendSetup(VOID
)
2224 WCHAR szPath
[MAX_PATH
];
2225 HINF hUnattendedInf
;
2228 if (!GetRosInstallCD(szPath
, MAX_PATH
))
2230 /* no cd drive found */
2234 dwLength
= wcslen(szPath
);
2235 if (dwLength
+ 21 > MAX_PATH
)
2238 * allocate bigger buffer
2243 wcscat(szPath
, L
"reactos\\unattend.inf");
2245 hUnattendedInf
= SetupOpenInfFileW(szPath
,
2250 if (hUnattendedInf
!= INVALID_HANDLE_VALUE
)
2252 SetupData
.UnattendSetup
= ProcessUnattendInf(hUnattendedInf
);
2253 SetupCloseInfFile(hUnattendedInf
);
2261 PROPSHEETHEADER psh
;
2262 HPROPSHEETPAGE ahpsp
[8];
2263 PROPSHEETPAGE psp
= {0};
2268 /* Clear setup data */
2269 ZeroMemory(&SetupData
, sizeof(SETUPDATA
));
2271 ProcessUnattendSetup();
2273 /* Create the Welcome page */
2274 psp
.dwSize
= sizeof(PROPSHEETPAGE
);
2275 psp
.dwFlags
= PSP_DEFAULT
| PSP_HIDEHEADER
;
2276 psp
.hInstance
= hDllInstance
;
2277 psp
.lParam
= (LPARAM
)&SetupData
;
2278 psp
.pfnDlgProc
= WelcomeDlgProc
;
2279 psp
.pszTemplate
= MAKEINTRESOURCE(IDD_WELCOMEPAGE
);
2280 ahpsp
[nPages
++] = CreatePropertySheetPage(&psp
);
2282 /* Create the Acknowledgements page */
2283 psp
.dwFlags
= PSP_DEFAULT
| PSP_USEHEADERTITLE
| PSP_USEHEADERSUBTITLE
;
2284 psp
.pszHeaderTitle
= MAKEINTRESOURCE(IDS_ACKTITLE
);
2285 psp
.pszHeaderSubTitle
= MAKEINTRESOURCE(IDS_ACKSUBTITLE
);
2286 psp
.pszTemplate
= MAKEINTRESOURCE(IDD_ACKPAGE
);
2287 psp
.pfnDlgProc
= AckPageDlgProc
;
2288 ahpsp
[nPages
++] = CreatePropertySheetPage(&psp
);
2290 /* Create the Locale page */
2291 psp
.dwFlags
= PSP_DEFAULT
| PSP_USEHEADERTITLE
| PSP_USEHEADERSUBTITLE
;
2292 psp
.pszHeaderTitle
= MAKEINTRESOURCE(IDS_LOCALETITLE
);
2293 psp
.pszHeaderSubTitle
= MAKEINTRESOURCE(IDS_LOCALESUBTITLE
);
2294 psp
.pfnDlgProc
= LocalePageDlgProc
;
2295 psp
.pszTemplate
= MAKEINTRESOURCE(IDD_LOCALEPAGE
);
2296 ahpsp
[nPages
++] = CreatePropertySheetPage(&psp
);
2299 /* Create the Owner page */
2300 psp
.dwFlags
= PSP_DEFAULT
| PSP_USEHEADERTITLE
| PSP_USEHEADERSUBTITLE
;
2301 psp
.pszHeaderTitle
= MAKEINTRESOURCE(IDS_OWNERTITLE
);
2302 psp
.pszHeaderSubTitle
= MAKEINTRESOURCE(IDS_OWNERSUBTITLE
);
2303 psp
.pszTemplate
= MAKEINTRESOURCE(IDD_OWNERPAGE
);
2304 psp
.pfnDlgProc
= OwnerPageDlgProc
;
2305 ahpsp
[nPages
++] = CreatePropertySheetPage(&psp
);
2307 /* Create the Computer page */
2308 psp
.dwFlags
= PSP_DEFAULT
| PSP_USEHEADERTITLE
| PSP_USEHEADERSUBTITLE
;
2309 psp
.pszHeaderTitle
= MAKEINTRESOURCE(IDS_COMPUTERTITLE
);
2310 psp
.pszHeaderSubTitle
= MAKEINTRESOURCE(IDS_COMPUTERSUBTITLE
);
2311 psp
.pfnDlgProc
= ComputerPageDlgProc
;
2312 psp
.pszTemplate
= MAKEINTRESOURCE(IDD_COMPUTERPAGE
);
2313 ahpsp
[nPages
++] = CreatePropertySheetPage(&psp
);
2316 /* Create the DateTime page */
2317 psp
.dwFlags
= PSP_DEFAULT
| PSP_USEHEADERTITLE
| PSP_USEHEADERSUBTITLE
;
2318 psp
.pszHeaderTitle
= MAKEINTRESOURCE(IDS_DATETIMETITLE
);
2319 psp
.pszHeaderSubTitle
= MAKEINTRESOURCE(IDS_DATETIMESUBTITLE
);
2320 psp
.pfnDlgProc
= DateTimePageDlgProc
;
2321 psp
.pszTemplate
= MAKEINTRESOURCE(IDD_DATETIMEPAGE
);
2322 ahpsp
[nPages
++] = CreatePropertySheetPage(&psp
);
2325 /* Create the Process page */
2326 psp
.dwFlags
= PSP_DEFAULT
| PSP_USEHEADERTITLE
| PSP_USEHEADERSUBTITLE
;
2327 psp
.pszHeaderTitle
= MAKEINTRESOURCE(IDS_PROCESSTITLE
);
2328 psp
.pszHeaderSubTitle
= MAKEINTRESOURCE(IDS_PROCESSSUBTITLE
);
2329 psp
.pfnDlgProc
= ProcessPageDlgProc
;
2330 psp
.pszTemplate
= MAKEINTRESOURCE(IDD_PROCESSPAGE
);
2331 ahpsp
[nPages
++] = CreatePropertySheetPage(&psp
);
2334 /* Create the Finish page */
2335 psp
.dwFlags
= PSP_DEFAULT
| PSP_HIDEHEADER
;
2336 psp
.pfnDlgProc
= FinishDlgProc
;
2337 psp
.pszTemplate
= MAKEINTRESOURCE(IDD_FINISHPAGE
);
2338 ahpsp
[nPages
++] = CreatePropertySheetPage(&psp
);
2340 /* Create the property sheet */
2341 psh
.dwSize
= sizeof(PROPSHEETHEADER
);
2342 psh
.dwFlags
= PSH_WIZARD97
| PSH_WATERMARK
| PSH_HEADER
| PSH_MODELESS
;
2343 psh
.hInstance
= hDllInstance
;
2344 psh
.hwndParent
= NULL
;
2345 psh
.nPages
= nPages
;
2348 psh
.pszbmWatermark
= MAKEINTRESOURCE(IDB_WATERMARK
);
2349 psh
.pszbmHeader
= MAKEINTRESOURCE(IDB_HEADER
);
2351 /* Create title font */
2352 SetupData
.hTitleFont
= CreateTitleFont();
2354 /* Display the wizard */
2355 hWnd
= (HWND
)PropertySheet(&psh
);
2356 ShowWindow(hWnd
, SW_SHOW
);
2358 while (GetMessage(&msg
, NULL
, 0, 0))
2360 if(!IsDialogMessage(hWnd
, &msg
))
2362 TranslateMessage(&msg
);
2363 DispatchMessage(&msg
);
2367 DeleteObject(SetupData
.hTitleFont
);