2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS Userinit Logon Application
4 * FILE: base/system/userinit/livecd.c
5 * PROGRAMMERS: Eric Kohl
15 InitImageInfo(PIMGINFO ImgInfo
)
19 ZeroMemory(ImgInfo
, sizeof(*ImgInfo
));
21 ImgInfo
->hBitmap
= LoadImage(hInstance
,
22 MAKEINTRESOURCE(IDB_ROSLOGO
),
28 if (ImgInfo
->hBitmap
!= NULL
)
30 GetObject(ImgInfo
->hBitmap
, sizeof(BITMAP
), &bitmap
);
32 ImgInfo
->cxSource
= bitmap
.bmWidth
;
33 ImgInfo
->cySource
= bitmap
.bmHeight
;
41 HKEY ControlKey
= NULL
;
42 LPWSTR SystemStartOptions
= NULL
;
43 LPWSTR CurrentOption
, NextOption
; /* Pointers into SystemStartOptions */
47 TRACE("IsLiveCD()\n");
49 rc
= RegOpenKeyEx(HKEY_LOCAL_MACHINE
,
50 REGSTR_PATH_CURRENT_CONTROL_SET
,
54 if (rc
!= ERROR_SUCCESS
)
56 WARN("RegOpenKeyEx() failed with error %lu\n", rc
);
60 rc
= ReadRegSzKey(ControlKey
, L
"SystemStartOptions", &SystemStartOptions
);
61 if (rc
!= ERROR_SUCCESS
)
63 WARN("ReadRegSzKey() failed with error %lu\n", rc
);
67 /* Check for CONSOLE switch in SystemStartOptions */
68 CurrentOption
= SystemStartOptions
;
71 NextOption
= wcschr(CurrentOption
, L
' ');
74 if (_wcsicmp(CurrentOption
, L
"MININT") == 0)
76 TRACE("Found 'MININT' boot option\n");
80 CurrentOption
= NextOption
? NextOption
+ 1 : NULL
;
84 if (ControlKey
!= NULL
)
85 RegCloseKey(ControlKey
);
86 HeapFree(GetProcessHeap(), 0, SystemStartOptions
);
88 TRACE("IsLiveCD() returning %d\n", ret
);
95 LocalesEnumProc(LPTSTR lpLocale
)
100 BOOL bNoShow
= FALSE
;
102 lcid
= wcstoul(lpLocale
, NULL
, 16);
104 /* Display only languages with installed support */
105 if (!IsValidLocale(lcid
, LCID_INSTALLED
))
108 if (lcid
== MAKELCID(MAKELANGID(LANG_SPANISH
, SUBLANG_SPANISH
), SORT_DEFAULT
) ||
109 lcid
== MAKELCID(MAKELANGID(LANG_SPANISH
, SUBLANG_SPANISH_MODERN
), SORT_DEFAULT
))
113 LoadStringW(hInstance
, IDS_SPAIN
, lang
, 255);
123 GetLocaleInfoW(lcid
, LOCALE_SLANGUAGE
, lang
, sizeof(lang
)/sizeof(WCHAR
));
126 if (bNoShow
== FALSE
)
128 index
= SendMessageW(hList
,
144 CreateLanguagesList(HWND hwnd
)
150 EnumSystemLocalesW(LocalesEnumProc
, LCID_SUPPORTED
);
152 /* Select current locale */
153 /* or should it be System and not user? */
154 GetLocaleInfoW(GetUserDefaultLCID(), LOCALE_SLANGUAGE
, langSel
, sizeof(langSel
)/sizeof(WCHAR
));
165 InitializeDefaultUserLocale(
176 struct {LCTYPE LCType
; PWSTR pValue
;} LocaleData
[] = {
178 {LOCALE_SDECIMAL
, L
"sDecimal"},
179 {LOCALE_STHOUSAND
, L
"sThousand"},
180 {LOCALE_SNEGATIVESIGN
, L
"sNegativeSign"},
181 {LOCALE_SPOSITIVESIGN
, L
"sPositiveSign"},
182 {LOCALE_SGROUPING
, L
"sGrouping"},
183 {LOCALE_SLIST
, L
"sList"},
184 {LOCALE_SNATIVEDIGITS
, L
"sNativeDigits"},
185 {LOCALE_INEGNUMBER
, L
"iNegNumber"},
186 {LOCALE_IDIGITS
, L
"iDigits"},
187 {LOCALE_ILZERO
, L
"iLZero"},
188 {LOCALE_IMEASURE
, L
"iMeasure"},
189 {LOCALE_IDIGITSUBSTITUTION
, L
"NumShape"},
192 {LOCALE_SCURRENCY
, L
"sCurrency"},
193 {LOCALE_SMONDECIMALSEP
, L
"sMonDecimalSep"},
194 {LOCALE_SMONTHOUSANDSEP
, L
"sMonThousandSep"},
195 {LOCALE_SMONGROUPING
, L
"sMonGrouping"},
196 {LOCALE_ICURRENCY
, L
"iCurrency"},
197 {LOCALE_INEGCURR
, L
"iNegCurr"},
198 {LOCALE_ICURRDIGITS
, L
"iCurrDigits"},
201 {LOCALE_STIMEFORMAT
, L
"sTimeFormat"},
202 {LOCALE_STIME
, L
"sTime"},
203 {LOCALE_S1159
, L
"s1159"},
204 {LOCALE_S2359
, L
"s2359"},
205 {LOCALE_ITIME
, L
"iTime"},
206 {LOCALE_ITIMEMARKPOSN
, L
"iTimePrefix"},
207 {LOCALE_ITLZERO
, L
"iTLZero"},
210 {LOCALE_SLONGDATE
, L
"sLongDate"},
211 {LOCALE_SSHORTDATE
, L
"sShortDate"},
212 {LOCALE_SDATE
, L
"sDate"},
213 {LOCALE_IFIRSTDAYOFWEEK
, L
"iFirstDayOfWeek"},
214 {LOCALE_IFIRSTWEEKOFYEAR
, L
"iFirstWeekOfYear"},
215 {LOCALE_IDATE
, L
"iDate"},
216 {LOCALE_ICALENDARTYPE
, L
"iCalendarType"},
219 {LOCALE_SCOUNTRY
, L
"sCountry"},
220 {LOCALE_SLANGUAGE
, L
"sLanguage"},
221 {LOCALE_ICOUNTRY
, L
"iCountry"},
224 ret
= RegOpenKeyExW(HKEY_USERS
,
225 L
".DEFAULT\\Control Panel\\International",
227 KEY_READ
| KEY_WRITE
,
229 if (ret
!= ERROR_SUCCESS
)
234 if (pNewLcid
== NULL
)
236 dwSize
= 9 * sizeof(WCHAR
);
237 ret
= RegQueryValueExW(hLocaleKey
,
243 if (ret
!= ERROR_SUCCESS
)
246 lcid
= (LCID
)wcstoul(szBuffer
, &ptr
, 16);
254 swprintf(szBuffer
, L
"%08lx", lcid
);
255 RegSetValueExW(hLocaleKey
,
260 (wcslen(szBuffer
) + 1) * sizeof(WCHAR
));
264 while (LocaleData
[i
].pValue
!= NULL
)
266 if (GetLocaleInfo(lcid
,
267 LocaleData
[i
].LCType
| LOCALE_NOUSEROVERRIDE
,
269 sizeof(szBuffer
) / sizeof(WCHAR
)))
271 RegSetValueExW(hLocaleKey
,
272 LocaleData
[i
].pValue
,
276 (wcslen(szBuffer
) + 1) * sizeof(WCHAR
));
283 RegCloseKey(hLocaleKey
);
288 CenterWindow(HWND hWnd
)
294 hWndParent
= GetParent(hWnd
);
295 if (hWndParent
== NULL
)
296 hWndParent
= GetDesktopWindow();
298 GetWindowRect(hWndParent
, &rcParent
);
299 GetWindowRect(hWnd
, &rcWindow
);
303 ((rcParent
.right
- rcParent
.left
) - (rcWindow
.right
- rcWindow
.left
)) / 2,
304 ((rcParent
.bottom
- rcParent
.top
) - (rcWindow
.bottom
- rcWindow
.top
)) / 2,
314 LPDRAWITEMSTRUCT lpDrawItem
,
321 if (lpDrawItem
->CtlID
== uCtlID
)
323 /* position image in centre of dialog */
324 left
= (lpDrawItem
->rcItem
.right
- pState
->ImageInfo
.cxSource
) / 2;
326 hdcMem
= CreateCompatibleDC(lpDrawItem
->hDC
);
329 SelectObject(hdcMem
, pState
->ImageInfo
.hBitmap
);
330 BitBlt(lpDrawItem
->hDC
,
332 lpDrawItem
->rcItem
.top
,
333 lpDrawItem
->rcItem
.right
- lpDrawItem
->rcItem
.left
,
334 lpDrawItem
->rcItem
.bottom
- lpDrawItem
->rcItem
.top
,
356 /* Retrieve pointer to the state */
357 pState
= (PSTATE
)GetWindowLongPtr (hwndDlg
, GWL_USERDATA
);
362 /* Save pointer to the global state */
363 pState
= (PSTATE
)lParam
;
364 SetWindowLongPtr(hwndDlg
, GWL_USERDATA
, (DWORD_PTR
)pState
);
366 /* Center the dialog window */
367 CenterWindow (hwndDlg
);
368 CreateLanguagesList(GetDlgItem(hwndDlg
, IDC_LANGUAGELIST
));
370 EnableWindow(GetDlgItem(hwndDlg
, IDCANCEL
), FALSE
);
374 OnDrawItem((LPDRAWITEMSTRUCT
)lParam
,
380 if (HIWORD(wParam
) == BN_CLICKED
)
382 switch (LOWORD(wParam
))
389 iCurSel
= SendDlgItemMessageW(hwndDlg
,
394 if (iCurSel
== CB_ERR
)
397 NewLcid
= SendDlgItemMessageW(hwndDlg
,
402 if (NewLcid
== (LCID
)CB_ERR
)
405 NtSetDefaultLocale(TRUE
, NewLcid
);
406 InitializeDefaultUserLocale(&NewLcid
);
409 pState
->NextPage
= STARTPAGE
;
410 EndDialog(hwndDlg
, 0);
438 /* Retrieve pointer to the state */
439 pState
= (PSTATE
)GetWindowLongPtr (hwndDlg
, GWL_USERDATA
);
444 /* Save pointer to the state */
445 pState
= (PSTATE
)lParam
;
446 SetWindowLongPtr(hwndDlg
, GWL_USERDATA
, (DWORD_PTR
)pState
);
448 /* Center the dialog window */
449 CenterWindow(hwndDlg
);
451 EnableWindow(GetDlgItem(hwndDlg
, IDCANCEL
), FALSE
);
455 OnDrawItem((LPDRAWITEMSTRUCT
)lParam
,
461 if (HIWORD(wParam
) == BN_CLICKED
)
463 switch (LOWORD(wParam
))
466 pState
->NextPage
= DONE
;
468 EndDialog(hwndDlg
, 0);
472 pState
->NextPage
= DONE
;
473 pState
->Run
= INSTALLER
;
474 EndDialog(hwndDlg
, 0);
478 pState
->NextPage
= LOCALEPAGE
;
479 EndDialog(hwndDlg
, 0);
500 InitImageInfo(&pState
->ImageInfo
);
502 while (pState
->NextPage
!= DONE
)
504 switch (pState
->NextPage
)
507 DialogBoxParam(hInstance
,
508 MAKEINTRESOURCE(IDD_LOCALEPAGE
),
515 DialogBoxParam(hInstance
,
516 MAKEINTRESOURCE(IDD_STARTPAGE
),
527 DeleteObject(pState
->ImageInfo
.hBitmap
);