Author: janderwald
Date: Thu Aug 30 00:13:27 2007
New Revision: 28654
URL:
http://svn.reactos.org/svn/reactos?rev=28654&view=rev
Log:
- close unattend inf in case of errors
- correctly convert provided LCID (with base 16)
- verify provided LCID with installed languages
- thanks to Colin_Fink
Modified:
trunk/reactos/dll/cpl/intl/generalp.c
trunk/reactos/dll/cpl/intl/intl.c
trunk/reactos/dll/cpl/intl/intl.h
Modified: trunk/reactos/dll/cpl/intl/generalp.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/cpl/intl/generalp.c?re…
==============================================================================
--- trunk/reactos/dll/cpl/intl/generalp.c (original)
+++ trunk/reactos/dll/cpl/intl/generalp.c Thu Aug 30 00:13:27 2007
@@ -173,6 +173,34 @@
RegCloseKey(langKey);
}
+DWORD
+VerifyUnattendLCID(HWND hwndDlg)
+{
+ LRESULT lCount, lIndex, lResult;
+ lCount = SendMessage(hList, CB_GETCOUNT, (WPARAM)0, (LPARAM)0);
+ if (lCount == CB_ERR)
+ {
+ return 0;
+ }
+
+ for (lIndex = 0; lIndex < lCount; lIndex++)
+ {
+ lResult = SendMessage(hList, CB_GETITEMDATA, (WPARAM)lIndex, (LPARAM)0);
+ if (lResult == CB_ERR)
+ {
+ continue;
+ }
+
+ if (lResult == (LCID)UnattendLCID)
+ {
+ SendMessage(hList, CB_SETCURSEL, (WPARAM)lIndex, (LPARAM)0);
+ PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
+ return 1;
+ }
+ }
+ return 0;
+}
+
/* Property page dialog callback */
INT_PTR CALLBACK
@@ -185,6 +213,15 @@
{
case WM_INITDIALOG:
CreateLanguagesList(GetDlgItem(hwndDlg, IDC_LANGUAGELIST));
+ if (IsUnattendedSetupEnabled)
+ {
+ if (VerifyUnattendLCID(hwndDlg))
+ {
+ SetNewLocale(UnattendLCID);
+ PostQuitMessage(0);
+ }
+ return TRUE;
+ }
break;
case WM_COMMAND:
switch (LOWORD(wParam))
Modified: trunk/reactos/dll/cpl/intl/intl.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/cpl/intl/intl.c?rev=28…
==============================================================================
--- trunk/reactos/dll/cpl/intl/intl.c (original)
+++ trunk/reactos/dll/cpl/intl/intl.c Thu Aug 30 00:13:27 2007
@@ -41,6 +41,9 @@
HINSTANCE hApplet = 0;
HINF hSetupInf = INVALID_HANDLE_VALUE;
+DWORD IsUnattendedSetupEnabled = 0;
+DWORD UnattendLCID = 0;
+
/* Applets */
APPLET Applets[NUM_APPLETS] =
@@ -97,10 +100,10 @@
return (hSetupInf != INVALID_HANDLE_VALUE);
}
-LONG ParseSetupInf()
+VOID
+ParseSetupInf()
{
INFCONTEXT InfContext;
- INT LocaleID;
TCHAR szBuffer[30];
if (!SetupFindFirstLine(hSetupInf,
@@ -108,7 +111,8 @@
_T("LocaleID"),
&InfContext))
{
- return -1;
+ SetupCloseInfFile(hSetupInf);
+ return;
}
if (!SetupGetStringField(&InfContext,
@@ -117,13 +121,13 @@
sizeof(szBuffer) / sizeof(TCHAR),
NULL))
{
- return -1;
- }
- LocaleID = _ttoi(szBuffer);
- SetNewLocale((LCID)LocaleID);
+ SetupCloseInfFile(hSetupInf);
+ return;
+ }
+
+ UnattendLCID = _tcstoul(szBuffer, NULL, 16);
+ IsUnattendedSetupEnabled = 1;
SetupCloseInfFile(hSetupInf);
-
- return 0;
}
static LONG APIENTRY
@@ -135,7 +139,7 @@
if (OpenSetupInf())
{
- return ParseSetupInf();
+ ParseSetupInf();
}
LoadString(hApplet, IDS_CPLNAME, Caption, sizeof(Caption) / sizeof(TCHAR));
Modified: trunk/reactos/dll/cpl/intl/intl.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/cpl/intl/intl.h?rev=28…
==============================================================================
--- trunk/reactos/dll/cpl/intl/intl.h (original)
+++ trunk/reactos/dll/cpl/intl/intl.h Thu Aug 30 00:13:27 2007
@@ -11,7 +11,8 @@
} APPLET, *PAPPLET;
extern HINSTANCE hApplet;
-
+extern DWORD IsUnattendedSetupEnabled;
+extern DWORD UnattendLCID;
/* currency.c */
INT_PTR CALLBACK