3 * Copyright (C) 2004 ReactOS Team
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 * COPYRIGHT: See COPYING in the top level directory
21 * PROJECT: ReactOS system libraries
22 * PURPOSE: System setup
23 * FILE: lib/syssetup/wizard.c
24 * PROGRAMER: Eric Kohl
27 /* INCLUDES *****************************************************************/
36 #include <syssetup/syssetup.h>
43 /* GLOBALS ******************************************************************/
45 static SETUPDATA SetupData
;
48 /* FUNCTIONS ****************************************************************/
52 RunVMWInstall(HWND hWnd
)
54 PROCESS_INFORMATION ProcInfo
;
58 WCHAR InstallName
[] = L
"vmwinst.exe";
60 si
.cb
= sizeof(STARTUPINFO
);
62 if(CreateProcess(NULL
, InstallName
, NULL
, NULL
, TRUE
, NORMAL_PRIORITY_CLASS
,
63 NULL
, NULL
, &si
, &ProcInfo
))
65 EnableWindow(hWnd
, FALSE
);
68 while (PeekMessage(&msg
, NULL
, 0, 0, PM_REMOVE
))
70 if (msg
.message
== WM_QUIT
)
72 TranslateMessage(&msg
);
73 DispatchMessage(&msg
);
76 ret
= MsgWaitForMultipleObjects(1, &ProcInfo
.hProcess
, FALSE
, INFINITE
, QS_ALLEVENTS
| QS_ALLINPUT
);
77 if (ret
== WAIT_OBJECT_0
)
81 EnableWindow(hWnd
, TRUE
);
83 CloseHandle(ProcInfo
.hThread
);
84 CloseHandle(ProcInfo
.hProcess
);
92 CenterWindow(HWND hWnd
)
98 hWndParent
= GetParent(hWnd
);
99 if (hWndParent
== NULL
)
100 hWndParent
= GetDesktopWindow();
102 GetWindowRect(hWndParent
, &rcParent
);
103 GetWindowRect(hWnd
, &rcWindow
);
107 ((rcParent
.right
- rcParent
.left
) - (rcWindow
.right
- rcWindow
.left
)) / 2,
108 ((rcParent
.bottom
- rcParent
.top
) - (rcWindow
.bottom
- rcWindow
.top
)) / 2,
116 CreateTitleFont(VOID
)
118 NONCLIENTMETRICS ncm
;
124 ncm
.cbSize
= sizeof(NONCLIENTMETRICS
);
125 SystemParametersInfo(SPI_GETNONCLIENTMETRICS
, 0, &ncm
, 0);
127 LogFont
= ncm
.lfMessageFont
;
128 LogFont
.lfWeight
= FW_BOLD
;
129 _tcscpy(LogFont
.lfFaceName
, _T("MS Shell Dlg"));
133 LogFont
.lfHeight
= 0 - GetDeviceCaps (hdc
, LOGPIXELSY
) * FontSize
/ 72;
134 hFont
= CreateFontIndirect(&LogFont
);
135 ReleaseDC(NULL
, hdc
);
141 static INT_PTR CALLBACK
142 GplDlgProc(HWND hwndDlg
,
147 HRSRC GplTextResource
;
157 GplTextResource
= FindResource(hDllInstance
, MAKEINTRESOURCE(IDR_GPL
), _T("RT_TEXT"));
158 if (NULL
== GplTextResource
)
162 Size
= SizeofResource(hDllInstance
, GplTextResource
);
167 GplText
= HeapAlloc(GetProcessHeap(), 0, Size
+ 1);
172 GplTextMem
= LoadResource(hDllInstance
, GplTextResource
);
173 if (NULL
== GplTextMem
)
175 HeapFree(GetProcessHeap(), 0, GplText
);
178 GplTextLocked
= LockResource(GplTextMem
);
179 if (NULL
== GplTextLocked
)
181 HeapFree(GetProcessHeap(), 0, GplText
);
184 memcpy(GplText
, GplTextLocked
, Size
);
185 GplText
[Size
] = '\0';
186 SendMessageA(GetDlgItem(hwndDlg
, IDC_GPL_TEXT
), WM_SETTEXT
, 0, (LPARAM
) GplText
);
187 HeapFree(GetProcessHeap(), 0, GplText
);
188 SetFocus(GetDlgItem(hwndDlg
, IDOK
));
192 EndDialog(hwndDlg
, IDCANCEL
);
196 if (HIWORD(wParam
) == BN_CLICKED
&& IDOK
== LOWORD(wParam
))
198 EndDialog(hwndDlg
, IDOK
);
210 static INT_PTR CALLBACK
211 WelcomeDlgProc(HWND hwndDlg
,
220 PSETUPDATA SetupData
;
224 /* Get pointer to the global setup data */
225 SetupData
= (PSETUPDATA
)((LPPROPSHEETPAGE
)lParam
)->lParam
;
227 hwndControl
= GetParent(hwndDlg
);
229 /* Center the wizard window */
230 CenterWindow (hwndControl
);
232 /* Hide the system menu */
233 dwStyle
= GetWindowLong(hwndControl
, GWL_STYLE
);
234 SetWindowLong(hwndControl
, GWL_STYLE
, dwStyle
& ~WS_SYSMENU
);
236 /* Hide and disable the 'Cancel' button */
237 hwndControl
= GetDlgItem(GetParent(hwndDlg
), IDCANCEL
);
238 ShowWindow (hwndControl
, SW_HIDE
);
239 EnableWindow (hwndControl
, FALSE
);
242 SendDlgItemMessage(hwndDlg
,
245 (WPARAM
)SetupData
->hTitleFont
,
253 LPNMHDR lpnm
= (LPNMHDR
)lParam
;
258 /* Enable the Next button */
259 PropSheet_SetWizButtons(GetParent(hwndDlg
), PSWIZB_NEXT
);
276 static INT_PTR CALLBACK
277 AckPageDlgProc(HWND hwndDlg
,
284 PWCHAR End
, CurrentProject
;
285 INT ProjectsSize
, ProjectsCount
;
295 Projects
= HeapAlloc(GetProcessHeap(), 0, ProjectsSize
* sizeof(WCHAR
));
296 if (NULL
== Projects
)
300 ProjectsCount
= LoadString(hDllInstance
, IDS_ACKPROJECTS
, Projects
, ProjectsSize
);
301 if (0 == ProjectsCount
)
303 HeapFree(GetProcessHeap(), 0, Projects
);
306 if (ProjectsCount
< ProjectsSize
- 1)
310 HeapFree(GetProcessHeap(), 0, Projects
);
314 CurrentProject
= Projects
;
315 while (L
'\0' != *CurrentProject
)
317 End
= wcschr(CurrentProject
, L
'\n');
322 ListBox_AddString(GetDlgItem(hwndDlg
, IDC_PROJECTS
), CurrentProject
);
325 CurrentProject
= End
+ 1;
329 CurrentProject
+= wcslen(CurrentProject
);
332 HeapFree(GetProcessHeap(), 0, Projects
);
337 if (HIWORD(wParam
) == BN_CLICKED
&& IDC_VIEWGPL
== LOWORD(wParam
))
339 DialogBox(hDllInstance
, MAKEINTRESOURCE(IDD_GPL
), NULL
, GplDlgProc
);
345 lpnm
= (LPNMHDR
)lParam
;
350 /* Enable the Back and Next buttons */
351 PropSheet_SetWizButtons(GetParent(hwndDlg
), PSWIZB_BACK
| PSWIZB_NEXT
);
368 static INT_PTR CALLBACK
369 OwnerPageDlgProc(HWND hwndDlg
,
375 TCHAR OwnerOrganization
[51];
383 SendDlgItemMessage(hwndDlg
, IDC_OWNERNAME
, EM_LIMITTEXT
, 50, 0);
384 SendDlgItemMessage(hwndDlg
, IDC_OWNERORGANIZATION
, EM_LIMITTEXT
, 50, 0);
386 /* Set focus to owner name */
387 SetFocus(GetDlgItem(hwndDlg
, IDC_OWNERNAME
));
394 lpnm
= (LPNMHDR
)lParam
;
399 /* Enable the Back and Next buttons */
400 PropSheet_SetWizButtons(GetParent(hwndDlg
), PSWIZB_BACK
| PSWIZB_NEXT
);
405 if (GetDlgItemText(hwndDlg
, IDC_OWNERNAME
, OwnerName
, 50) == 0)
408 _T("Setup cannot continue until you enter your name."),
410 MB_ICONERROR
| MB_OK
);
411 SetWindowLong(hwndDlg
, DWL_MSGRESULT
, -1);
415 OwnerOrganization
[0] = 0;
416 GetDlgItemTextW(hwndDlg
, IDC_OWNERORGANIZATION
, OwnerOrganization
, 50);
418 RegOpenKeyEx(HKEY_LOCAL_MACHINE
,
419 _T("Software\\Microsoft\\Windows NT\\CurrentVersion"),
423 /* FIXME: check error code */
426 _T("RegisteredOwner"),
430 (_tcslen(OwnerName
) + 1) * sizeof(TCHAR
));
431 /* FIXME: check error code */
434 _T("RegisteredOrganization"),
437 (LPBYTE
)OwnerOrganization
,
438 (_tcslen(OwnerOrganization
) + 1) * sizeof(TCHAR
));
439 /* FIXME: check error code */
458 static INT_PTR CALLBACK
459 ComputerPageDlgProc(HWND hwndDlg
,
464 TCHAR ComputerName
[MAX_COMPUTERNAME_LENGTH
+ 1];
474 /* Retrieve current computer name */
475 Length
= MAX_COMPUTERNAME_LENGTH
+ 1;
476 GetComputerName(ComputerName
, &Length
);
478 /* Display current computer name */
479 SetDlgItemText(hwndDlg
, IDC_COMPUTERNAME
, ComputerName
);
481 /* Set text limits */
482 SendDlgItemMessage(hwndDlg
, IDC_COMPUTERNAME
, EM_LIMITTEXT
, 64, 0);
483 SendDlgItemMessage(hwndDlg
, IDC_ADMINPASSWORD1
, EM_LIMITTEXT
, 14, 0);
484 SendDlgItemMessage(hwndDlg
, IDC_ADMINPASSWORD2
, EM_LIMITTEXT
, 14, 0);
486 /* Set focus to computer name */
487 SetFocus(GetDlgItem(hwndDlg
, IDC_COMPUTERNAME
));
494 lpnm
= (LPNMHDR
)lParam
;
499 /* Enable the Back and Next buttons */
500 PropSheet_SetWizButtons(GetParent(hwndDlg
), PSWIZB_BACK
| PSWIZB_NEXT
);
504 if (GetDlgItemText(hwndDlg
, IDC_COMPUTERNAME
, ComputerName
, 64) == 0)
507 _T("Setup cannot continue until you enter the name of your computer."),
509 MB_ICONERROR
| MB_OK
);
510 SetWindowLong(hwndDlg
, DWL_MSGRESULT
, -1);
514 /* FIXME: check computer name for invalid characters */
516 if (!SetComputerName(ComputerName
))
519 _T("Setup failed to set the computer name."),
521 MB_ICONERROR
| MB_OK
);
522 SetWindowLong(hwndDlg
, DWL_MSGRESULT
, -1);
525 /* Try to also set DNS hostname */
526 SetComputerNameEx(ComputerNamePhysicalDnsHostname
, ComputerName
);
528 /* Check admin passwords */
529 GetDlgItemText(hwndDlg
, IDC_ADMINPASSWORD1
, Password1
, 15);
530 GetDlgItemText(hwndDlg
, IDC_ADMINPASSWORD2
, Password2
, 15);
531 if (_tcscmp(Password1
, Password2
))
534 _T("The passwords you entered do not match. Please enter "\
535 "the desired password again."),
537 MB_ICONERROR
| MB_OK
);
538 SetWindowLong(hwndDlg
, DWL_MSGRESULT
, -1);
542 /* FIXME: check password for invalid characters */
544 /* FIXME: Set admin password */
562 SetKeyboardLayoutName(HWND hwnd
)
565 TCHAR szLayoutPath
[256];
566 TCHAR szLocaleName
[32];
570 if (RegOpenKeyEx(HKEY_LOCAL_MACHINE
,
571 _T("SYSTEM\\CurrentControlSet\\Control\\NLS\\Locale"),
577 dwValueSize
= 16 * sizeof(TCHAR
);
578 if (RegQueryValueEx(hKey
,
589 _tcscpy(szLayoutPath
,
590 _T("SYSTEM\\CurrentControlSet\\Control\\KeyboardLayouts\\"));
591 _tcscat(szLayoutPath
,
594 if (RegOpenKeyEx(HKEY_LOCAL_MACHINE
,
601 dwValueSize
= 32 * sizeof(TCHAR
);
602 if (RegQueryValueEx(hKey
,
619 RunInputLocalePage(HWND hwnd
)
621 PROPSHEETPAGE psp
= {0};
622 PROPSHEETHEADER psh
= {0};
624 // TCHAR Caption[256];
626 hDll
= LoadLibrary(_T("intl.cpl"));
630 psp
.dwSize
= sizeof(PROPSHEETPAGE
);
631 psp
.dwFlags
= PSP_DEFAULT
;
632 psp
.hInstance
= hDll
;
633 psp
.pszTemplate
= MAKEINTRESOURCE(105); /* IDD_LOCALEPAGE from intl.cpl */
634 psp
.pfnDlgProc
= GetProcAddress(hDll
, "LocalePageProc");
636 // LoadString(hDll, IDS_CPLNAME, Caption, sizeof(Caption) / sizeof(TCHAR));
638 psh
.dwSize
= sizeof(PROPSHEETHEADER
);
639 psh
.dwFlags
= PSH_PROPSHEETPAGE
| PSH_PROPTITLE
;
640 // psh.hwndParent = hwnd;
641 // psh.hInstance = hDll;
642 // psh.hIcon = LoadIcon(hApplet, MAKEINTRESOURCE(IDC_CPLICON));
643 psh
.pszCaption
= _T("Title"); //Caption;
654 static INT_PTR CALLBACK
655 LocalePageDlgProc(HWND hwndDlg
,
660 PSETUPDATA SetupData
;
662 /* Retrieve pointer to the global setup data */
663 SetupData
= (PSETUPDATA
)GetWindowLongPtr (hwndDlg
, GWL_USERDATA
);
669 /* Save pointer to the global setup data */
670 SetupData
= (PSETUPDATA
)((LPPROPSHEETPAGE
)lParam
)->lParam
;
671 SetWindowLongPtr(hwndDlg
, GWL_USERDATA
, (DWORD_PTR
)SetupData
);
674 SetKeyboardLayoutName(GetDlgItem(hwndDlg
, IDC_LAYOUTTEXT
));
680 if (HIWORD(wParam
) == BN_CLICKED
)
682 switch (LOWORD(wParam
))
684 case IDC_CUSTOMLOCALE
:
686 RunInputLocalePage(hwndDlg
);
687 /* FIXME: Update input locale name */
691 case IDC_CUSTOMLAYOUT
:
693 // RunKeyboardLayoutControlPanel(hwndDlg);
702 LPNMHDR lpnm
= (LPNMHDR
)lParam
;
707 /* Enable the Back and Next buttons */
708 PropSheet_SetWizButtons(GetParent(hwndDlg
), PSWIZB_BACK
| PSWIZB_NEXT
);
728 static PTIMEZONE_ENTRY
729 GetLargerTimeZoneEntry(PSETUPDATA SetupData
, DWORD Index
)
731 PTIMEZONE_ENTRY Entry
;
733 Entry
= SetupData
->TimeZoneListHead
;
734 while (Entry
!= NULL
)
736 if (Entry
->Index
>= Index
)
747 CreateTimeZoneList(PSETUPDATA SetupData
)
749 TCHAR szKeyName
[256];
757 PTIMEZONE_ENTRY Entry
;
758 PTIMEZONE_ENTRY Current
;
760 if (RegOpenKeyEx(HKEY_LOCAL_MACHINE
,
761 _T("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Time Zones"),
770 dwNameSize
= 256 * sizeof(TCHAR
);
771 lError
= RegEnumKeyEx(hZonesKey
,
779 if (lError
!= ERROR_SUCCESS
&& lError
!= ERROR_MORE_DATA
)
782 if (RegOpenKeyEx(hZonesKey
,
789 Entry
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(TIMEZONE_ENTRY
));
792 RegCloseKey(hZoneKey
);
796 dwValueSize
= 64 * sizeof(TCHAR
);
797 if (RegQueryValueEx(hZoneKey
,
801 (LPBYTE
)&Entry
->Description
,
804 RegCloseKey(hZoneKey
);
808 dwValueSize
= 32 * sizeof(TCHAR
);
809 if (RegQueryValueEx(hZoneKey
,
813 (LPBYTE
)&Entry
->StandardName
,
816 RegCloseKey(hZoneKey
);
820 dwValueSize
= 32 * sizeof(WCHAR
);
821 if (RegQueryValueEx(hZoneKey
,
825 (LPBYTE
)&Entry
->DaylightName
,
828 RegCloseKey(hZoneKey
);
832 dwValueSize
= sizeof(DWORD
);
833 if (RegQueryValueEx(hZoneKey
,
837 (LPBYTE
)&Entry
->Index
,
840 RegCloseKey(hZoneKey
);
844 dwValueSize
= sizeof(TZ_INFO
);
845 if (RegQueryValueEx(hZoneKey
,
849 (LPBYTE
)&Entry
->TimezoneInfo
,
852 RegCloseKey(hZoneKey
);
856 RegCloseKey(hZoneKey
);
858 if (SetupData
->TimeZoneListHead
== NULL
&&
859 SetupData
->TimeZoneListTail
== NULL
)
863 SetupData
->TimeZoneListHead
= Entry
;
864 SetupData
->TimeZoneListTail
= Entry
;
868 Current
= GetLargerTimeZoneEntry(SetupData
, Entry
->Index
);
871 if (Current
== SetupData
->TimeZoneListHead
)
873 /* Prepend to head */
875 Entry
->Next
= SetupData
->TimeZoneListHead
;
876 SetupData
->TimeZoneListHead
->Prev
= Entry
;
877 SetupData
->TimeZoneListHead
= Entry
;
881 /* Insert before current */
882 Entry
->Prev
= Current
->Prev
;
883 Entry
->Next
= Current
;
884 Current
->Prev
->Next
= Entry
;
885 Current
->Prev
= Entry
;
891 Entry
->Prev
= SetupData
->TimeZoneListTail
;
893 SetupData
->TimeZoneListTail
->Next
= Entry
;
894 SetupData
->TimeZoneListTail
= Entry
;
901 RegCloseKey(hZonesKey
);
906 DestroyTimeZoneList(PSETUPDATA SetupData
)
908 PTIMEZONE_ENTRY Entry
;
910 while (SetupData
->TimeZoneListHead
!= NULL
)
912 Entry
= SetupData
->TimeZoneListHead
;
914 SetupData
->TimeZoneListHead
= Entry
->Next
;
915 if (SetupData
->TimeZoneListHead
!= NULL
)
917 SetupData
->TimeZoneListHead
->Prev
= NULL
;
920 HeapFree(GetProcessHeap(), 0, Entry
);
923 SetupData
->TimeZoneListTail
= NULL
;
928 GetTimeZoneListIndex(LPDWORD lpIndex
)
930 TCHAR szLanguageIdString
[9];
939 if (RegOpenKeyEx(HKEY_LOCAL_MACHINE
,
940 _T("SYSTEM\\CurrentControlSet\\Control\\NLS\\Language"),
946 dwValueSize
= 9 * sizeof(TCHAR
);
947 if (RegQueryValueEx(hKey
,
951 (LPBYTE
)szLanguageIdString
,
960 if (RegOpenKeyEx(HKEY_LOCAL_MACHINE
,
961 _T("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Time Zones"),
968 if (RegQueryValueEx(hKey
,
979 Buffer
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, dwValueSize
);
986 if (RegQueryValueEx(hKey
,
993 HeapFree(GetProcessHeap(), 0, Buffer
);
1003 Length
= _tcslen(Ptr
);
1004 if (_tcsicmp(Ptr
, szLanguageIdString
) == 0)
1007 Ptr
= Ptr
+ Length
+ 1;
1011 Length
= _tcslen(Ptr
);
1015 *lpIndex
= _tcstoul(Ptr
, &End
, 10);
1016 HeapFree(GetProcessHeap(), 0, Buffer
);
1020 Ptr
= Ptr
+ Length
+ 1;
1023 HeapFree(GetProcessHeap(), 0, Buffer
);
1031 ShowTimeZoneList(HWND hwnd
, PSETUPDATA SetupData
)
1033 PTIMEZONE_ENTRY Entry
;
1035 DWORD dwEntryIndex
= 0;
1039 GetTimeZoneListIndex(&dwEntryIndex
);
1041 dwEntryIndex
= 85; /* GMT time zone */
1043 Entry
= SetupData
->TimeZoneListHead
;
1044 while (Entry
!= NULL
)
1046 dwCount
= SendMessage(hwnd
,
1049 (LPARAM
)Entry
->Description
);
1051 if (dwEntryIndex
!= 0 && dwEntryIndex
== Entry
->Index
)
1054 Entry
= Entry
->Next
;
1065 SetLocalTimeZone(HWND hwnd
, PSETUPDATA SetupData
)
1067 TIME_ZONE_INFORMATION TimeZoneInformation
;
1068 PTIMEZONE_ENTRY Entry
;
1072 dwIndex
= SendMessage(hwnd
,
1078 Entry
= SetupData
->TimeZoneListHead
;
1085 Entry
= Entry
->Next
;
1088 _tcscpy(TimeZoneInformation
.StandardName
,
1089 Entry
->StandardName
);
1090 _tcscpy(TimeZoneInformation
.DaylightName
,
1091 Entry
->DaylightName
);
1093 TimeZoneInformation
.Bias
= Entry
->TimezoneInfo
.Bias
;
1094 TimeZoneInformation
.StandardBias
= Entry
->TimezoneInfo
.StandardBias
;
1095 TimeZoneInformation
.DaylightBias
= Entry
->TimezoneInfo
.DaylightBias
;
1097 memcpy(&TimeZoneInformation
.StandardDate
,
1098 &Entry
->TimezoneInfo
.StandardDate
,
1099 sizeof(SYSTEMTIME
));
1100 memcpy(&TimeZoneInformation
.DaylightDate
,
1101 &Entry
->TimezoneInfo
.DaylightDate
,
1102 sizeof(SYSTEMTIME
));
1104 /* Set time zone information */
1105 SetTimeZoneInformation(&TimeZoneInformation
);
1110 GetLocalSystemTime(HWND hwnd
, PSETUPDATA SetupData
)
1115 if (DateTime_GetSystemTime(GetDlgItem(hwnd
, IDC_DATEPICKER
), &Date
) != GDT_VALID
)
1120 if (DateTime_GetSystemTime(GetDlgItem(hwnd
, IDC_TIMEPICKER
), &Time
) != GDT_VALID
)
1125 SetupData
->SystemTime
.wYear
= Date
.wYear
;
1126 SetupData
->SystemTime
.wMonth
= Date
.wMonth
;
1127 SetupData
->SystemTime
.wDayOfWeek
= Date
.wDayOfWeek
;
1128 SetupData
->SystemTime
.wDay
= Date
.wDay
;
1129 SetupData
->SystemTime
.wHour
= Time
.wHour
;
1130 SetupData
->SystemTime
.wMinute
= Time
.wMinute
;
1131 SetupData
->SystemTime
.wSecond
= Time
.wSecond
;
1132 SetupData
->SystemTime
.wMilliseconds
= Time
.wMilliseconds
;
1139 SetAutoDaylightInfo(HWND hwnd
)
1144 if (SendMessage(hwnd
, BM_GETCHECK
, 0, 0) == BST_UNCHECKED
)
1146 if (RegOpenKeyEx(HKEY_LOCAL_MACHINE
,
1147 _T("SYSTEM\\CurrentControlSet\\Control\\TimeZoneInformation"),
1154 _T("DisableAutoDaylightTimeSet"),
1165 SetSystemLocalTime(HWND hwnd
, PSETUPDATA SetupData
)
1169 TOKEN_PRIVILEGES priv
, previouspriv
;
1173 * enable the SeSystemtimePrivilege privilege
1176 if(OpenProcessToken(GetCurrentProcess(),
1177 TOKEN_ADJUST_PRIVILEGES
| TOKEN_QUERY
,
1180 priv
.PrivilegeCount
= 1;
1181 priv
.Privileges
[0].Attributes
= SE_PRIVILEGE_ENABLED
;
1183 if(LookupPrivilegeValue(NULL
,
1185 &priv
.Privileges
[0].Luid
))
1187 if(AdjustTokenPrivileges(hToken
,
1190 sizeof(previouspriv
),
1193 GetLastError() == ERROR_SUCCESS
)
1196 * we successfully enabled it, we're permitted to change the system time
1198 Ret
= SetLocalTime(&SetupData
->SystemTime
);
1201 * for the sake of security, restore the previous status again
1203 if(previouspriv
.PrivilegeCount
> 0)
1205 AdjustTokenPrivileges(hToken
,
1214 CloseHandle(hToken
);
1221 static INT_PTR CALLBACK
1222 DateTimePageDlgProc(HWND hwndDlg
,
1227 PSETUPDATA SetupData
;
1229 /* Retrieve pointer to the global setup data */
1230 SetupData
= (PSETUPDATA
)GetWindowLongPtr (hwndDlg
, GWL_USERDATA
);
1236 /* Save pointer to the global setup data */
1237 SetupData
= (PSETUPDATA
)((LPPROPSHEETPAGE
)lParam
)->lParam
;
1238 SetWindowLongPtr(hwndDlg
, GWL_USERDATA
, (DWORD_PTR
)SetupData
);
1240 CreateTimeZoneList(SetupData
);
1242 ShowTimeZoneList(GetDlgItem(hwndDlg
, IDC_TIMEZONELIST
),
1245 SendDlgItemMessage(hwndDlg
, IDC_AUTODAYLIGHT
, BM_SETCHECK
, (WPARAM
)BST_CHECKED
, 0);
1252 LPNMHDR lpnm
= (LPNMHDR
)lParam
;
1257 /* Enable the Back and Next buttons */
1258 PropSheet_SetWizButtons(GetParent(hwndDlg
), PSWIZB_BACK
| PSWIZB_NEXT
);
1263 GetLocalSystemTime(hwndDlg
, SetupData
);
1264 SetLocalTimeZone(GetDlgItem(hwndDlg
, IDC_TIMEZONELIST
),
1266 SetAutoDaylightInfo(GetDlgItem(hwndDlg
, IDC_AUTODAYLIGHT
));
1267 if(!SetSystemLocalTime(hwndDlg
, SetupData
))
1270 _T("Setup was unable to set the local time."),
1271 _T("ReactOS Setup"),
1272 MB_ICONWARNING
| MB_OK
);
1284 DestroyTimeZoneList(SetupData
);
1295 static INT_PTR CALLBACK
1296 ProcessPageDlgProc(HWND hwndDlg
,
1301 PSETUPDATA SetupData
;
1303 /* Retrieve pointer to the global setup data */
1304 SetupData
= (PSETUPDATA
)GetWindowLongPtr (hwndDlg
, GWL_USERDATA
);
1310 /* Save pointer to the global setup data */
1311 SetupData
= (PSETUPDATA
)((LPPROPSHEETPAGE
)lParam
)->lParam
;
1312 SetWindowLongPtr(hwndDlg
, GWL_USERDATA
, (DWORD_PTR
)SetupData
);
1321 hWndProgress
= GetDlgItem(hwndDlg
, IDC_PROCESSPROGRESS
);
1322 Position
= SendMessage(hWndProgress
, PBM_GETPOS
, 0, 0);
1325 KillTimer(hwndDlg
, 1);
1327 /* Enable the Back and Next buttons */
1328 PropSheet_SetWizButtons(GetParent(hwndDlg
), PSWIZB_NEXT
);
1329 PropSheet_PressButton(GetParent(hwndDlg
), PSBTN_NEXT
);
1336 KillTimer(hwndDlg
, 1);
1337 RunVMWInstall(GetParent(hwndDlg
));
1338 SetTimer(hwndDlg
, 1, 50, NULL
);
1341 SendMessage(hWndProgress
, PBM_SETPOS
, Position
+ 1, 0);
1348 LPNMHDR lpnm
= (LPNMHDR
)lParam
;
1353 /* Disable the Back and Next buttons */
1354 PropSheet_SetWizButtons(GetParent(hwndDlg
), 0);
1356 SendDlgItemMessage(hwndDlg
, IDC_PROCESSPROGRESS
, PBM_SETRANGE
, 0,
1358 SetTimer(hwndDlg
, 1, 50, NULL
);
1379 static INT_PTR CALLBACK
1380 FinishDlgProc(HWND hwndDlg
,
1390 PSETUPDATA SetupData
;
1392 /* Get pointer to the global setup data */
1393 SetupData
= (PSETUPDATA
)((LPPROPSHEETPAGE
)lParam
)->lParam
;
1395 /* Set title font */
1396 SendDlgItemMessage(hwndDlg
,
1399 (WPARAM
)SetupData
->hTitleFont
,
1409 hWndProgress
= GetDlgItem(hwndDlg
, IDC_RESTART_PROGRESS
);
1410 Position
= SendMessage(hWndProgress
, PBM_GETPOS
, 0, 0);
1411 if (Position
== 300)
1413 KillTimer(hwndDlg
, 1);
1414 PropSheet_PressButton(GetParent(hwndDlg
), PSBTN_FINISH
);
1418 SendMessage(hWndProgress
, PBM_SETPOS
, Position
+ 1, 0);
1425 LPNMHDR lpnm
= (LPNMHDR
)lParam
;
1430 /* Enable the correct buttons on for the active page */
1431 PropSheet_SetWizButtons(GetParent(hwndDlg
), PSWIZB_BACK
| PSWIZB_FINISH
);
1433 SendDlgItemMessage(hwndDlg
, IDC_RESTART_PROGRESS
, PBM_SETRANGE
, 0,
1434 MAKELPARAM(0, 300));
1435 SendDlgItemMessage(hwndDlg
, IDC_RESTART_PROGRESS
, PBM_SETPOS
, 0, 0);
1436 SetTimer(hwndDlg
, 1, 50, NULL
);
1440 /* Handle a Back button click, if necessary */
1441 KillTimer(hwndDlg
, 1);
1443 /* Skip the progress page */
1444 PropSheet_SetCurSelByID(GetParent(hwndDlg
), IDD_DATETIMEPAGE
);
1445 SetWindowLong(hwndDlg
, DWL_MSGRESULT
, -1);
1449 /* Handle a Finish button click, if necessary */
1469 PROPSHEETHEADER psh
;
1470 HPROPSHEETPAGE ahpsp
[8];
1471 PROPSHEETPAGE psp
= {0};
1474 /* Clear setup data */
1475 ZeroMemory(&SetupData
, sizeof(SETUPDATA
));
1477 /* Create the Welcome page */
1478 psp
.dwSize
= sizeof(PROPSHEETPAGE
);
1479 psp
.dwFlags
= PSP_DEFAULT
| PSP_HIDEHEADER
;
1480 psp
.hInstance
= hDllInstance
;
1481 psp
.lParam
= (LPARAM
)&SetupData
;
1482 psp
.pfnDlgProc
= WelcomeDlgProc
;
1483 psp
.pszTemplate
= MAKEINTRESOURCE(IDD_WELCOMEPAGE
);
1484 ahpsp
[nPages
++] = CreatePropertySheetPage(&psp
);
1486 /* Create the Acknowledgements page */
1487 psp
.dwFlags
= PSP_DEFAULT
| PSP_USEHEADERTITLE
| PSP_USEHEADERSUBTITLE
;
1488 psp
.pszHeaderTitle
= MAKEINTRESOURCE(IDS_ACKTITLE
);
1489 psp
.pszHeaderSubTitle
= MAKEINTRESOURCE(IDS_ACKSUBTITLE
);
1490 psp
.pszTemplate
= MAKEINTRESOURCE(IDD_ACKPAGE
);
1491 psp
.pfnDlgProc
= AckPageDlgProc
;
1492 ahpsp
[nPages
++] = CreatePropertySheetPage(&psp
);
1494 /* Create the Owner page */
1495 psp
.dwFlags
= PSP_DEFAULT
| PSP_USEHEADERTITLE
| PSP_USEHEADERSUBTITLE
;
1496 psp
.pszHeaderTitle
= MAKEINTRESOURCE(IDS_OWNERTITLE
);
1497 psp
.pszHeaderSubTitle
= MAKEINTRESOURCE(IDS_OWNERSUBTITLE
);
1498 psp
.pszTemplate
= MAKEINTRESOURCE(IDD_OWNERPAGE
);
1499 psp
.pfnDlgProc
= OwnerPageDlgProc
;
1500 ahpsp
[nPages
++] = CreatePropertySheetPage(&psp
);
1502 /* Create the Computer page */
1503 psp
.dwFlags
= PSP_DEFAULT
| PSP_USEHEADERTITLE
| PSP_USEHEADERSUBTITLE
;
1504 psp
.pszHeaderTitle
= MAKEINTRESOURCE(IDS_COMPUTERTITLE
);
1505 psp
.pszHeaderSubTitle
= MAKEINTRESOURCE(IDS_COMPUTERSUBTITLE
);
1506 psp
.pfnDlgProc
= ComputerPageDlgProc
;
1507 psp
.pszTemplate
= MAKEINTRESOURCE(IDD_COMPUTERPAGE
);
1508 ahpsp
[nPages
++] = CreatePropertySheetPage(&psp
);
1511 /* Create the Locale page */
1512 psp
.dwFlags
= PSP_DEFAULT
| PSP_USEHEADERTITLE
| PSP_USEHEADERSUBTITLE
;
1513 psp
.pszHeaderTitle
= MAKEINTRESOURCE(IDS_LOCALETITLE
);
1514 psp
.pszHeaderSubTitle
= MAKEINTRESOURCE(IDS_LOCALESUBTITLE
);
1515 psp
.pfnDlgProc
= LocalePageDlgProc
;
1516 psp
.pszTemplate
= MAKEINTRESOURCE(IDD_LOCALEPAGE
);
1517 ahpsp
[nPages
++] = CreatePropertySheetPage(&psp
);
1520 /* Create the DateTime page */
1521 psp
.dwFlags
= PSP_DEFAULT
| PSP_USEHEADERTITLE
| PSP_USEHEADERSUBTITLE
;
1522 psp
.pszHeaderTitle
= MAKEINTRESOURCE(IDS_DATETIMETITLE
);
1523 psp
.pszHeaderSubTitle
= MAKEINTRESOURCE(IDS_DATETIMESUBTITLE
);
1524 psp
.pfnDlgProc
= DateTimePageDlgProc
;
1525 psp
.pszTemplate
= MAKEINTRESOURCE(IDD_DATETIMEPAGE
);
1526 ahpsp
[nPages
++] = CreatePropertySheetPage(&psp
);
1529 /* Create the Process page */
1530 psp
.dwFlags
= PSP_DEFAULT
| PSP_USEHEADERTITLE
| PSP_USEHEADERSUBTITLE
;
1531 psp
.pszHeaderTitle
= MAKEINTRESOURCE(IDS_PROCESSTITLE
);
1532 psp
.pszHeaderSubTitle
= MAKEINTRESOURCE(IDS_PROCESSSUBTITLE
);
1533 psp
.pfnDlgProc
= ProcessPageDlgProc
;
1534 psp
.pszTemplate
= MAKEINTRESOURCE(IDD_PROCESSPAGE
);
1535 ahpsp
[nPages
++] = CreatePropertySheetPage(&psp
);
1538 /* Create the Finish page */
1539 psp
.dwFlags
= PSP_DEFAULT
| PSP_HIDEHEADER
;
1540 psp
.pfnDlgProc
= FinishDlgProc
;
1541 psp
.pszTemplate
= MAKEINTRESOURCE(IDD_FINISHPAGE
);
1542 ahpsp
[nPages
++] = CreatePropertySheetPage(&psp
);
1544 /* Create the property sheet */
1545 psh
.dwSize
= sizeof(PROPSHEETHEADER
);
1546 psh
.dwFlags
= PSH_WIZARD97
| PSH_WATERMARK
| PSH_HEADER
;
1547 psh
.hInstance
= hDllInstance
;
1548 psh
.hwndParent
= NULL
;
1549 psh
.nPages
= nPages
;
1552 psh
.pszbmWatermark
= MAKEINTRESOURCE(IDB_WATERMARK
);
1553 psh
.pszbmHeader
= MAKEINTRESOURCE(IDB_HEADER
);
1555 /* Create title font */
1556 SetupData
.hTitleFont
= CreateTitleFont();
1558 /* Display the wizard */
1559 PropertySheet(&psh
);
1561 DeleteObject(SetupData
.hTitleFont
);