From eb1be244ca3bab7d0db03b12e05454616e372d2f Mon Sep 17 00:00:00 2001 From: Johannes Anderwald Date: Sat, 12 Aug 2006 19:32:57 +0000 Subject: [PATCH] * implement unattend switch for intl * makes ReactOS gui setup run unattended (untill VmWare popsup) svn path=/trunk/; revision=23563 --- reactos/dll/cpl/intl/intl.c | 74 +++++++++++++++++++++++++++++++- reactos/dll/cpl/intl/intl.h | 3 ++ reactos/dll/cpl/intl/intl.rbuild | 1 + 3 files changed, 77 insertions(+), 1 deletion(-) diff --git a/reactos/dll/cpl/intl/intl.c b/reactos/dll/cpl/intl/intl.c index 037ab3a01a3..6d6091afc7e 100644 --- a/reactos/dll/cpl/intl/intl.c +++ b/reactos/dll/cpl/intl/intl.c @@ -26,6 +26,8 @@ #include #include #include +#include +#include #include "intl.h" #include "resource.h" @@ -38,7 +40,7 @@ Applet(HWND hwnd, UINT uMsg, LONG wParam, LONG lParam); HINSTANCE hApplet = 0; - +HINF hSetupInf = INVALID_HANDLE_VALUE; /* Applets */ APPLET Applets[NUM_APPLETS] = @@ -58,6 +60,71 @@ InitPropSheetPage(PROPSHEETPAGE *psp, WORD idDlg, DLGPROC DlgProc) psp->pfnDlgProc = DlgProc; } +BOOL +OpenSetupInf() +{ + LPTSTR lpCmdLine; + LPTSTR lpSwitch; + size_t len; + + lpCmdLine = GetCommandLine(); + + lpSwitch = _tcsstr(lpCmdLine, _T("/f:\"")); + + if(!lpSwitch) + { + return FALSE; + } + + len = _tcslen(lpSwitch); + if (len < 5) + { + return FALSE; + } + + if(lpSwitch[len-1] != _T('\"')) + { + return FALSE; + } + + lpSwitch[len-1] = _T('\0'); + + hSetupInf = SetupOpenInfFile(&lpSwitch[4], + NULL, + INF_STYLE_OLDNT, + NULL); + + return (hSetupInf != INVALID_HANDLE_VALUE); +} + +LONG ParseSetupInf() +{ + INFCONTEXT InfContext; + INT LocaleID; + TCHAR szBuffer[30]; + + if (!SetupFindFirstLine(hSetupInf, + _T("Unattend"), + _T("LocaleID"), + &InfContext)) + { + return -1; + } + + if (!SetupGetStringField(&InfContext, + 1, + szBuffer, + sizeof(szBuffer) / sizeof(TCHAR), + NULL)) + { + return -1; + } + LocaleID = _ttoi(szBuffer); + SetNewLocale((LCID)LocaleID); + SetupCloseInfFile(hSetupInf); + + return 0; +} LONG APIENTRY Applet(HWND hwnd, UINT uMsg, LONG wParam, LONG lParam) @@ -66,6 +133,11 @@ Applet(HWND hwnd, UINT uMsg, LONG wParam, LONG lParam) PROPSHEETHEADER psh; TCHAR Caption[256]; + if (OpenSetupInf()) + { + return ParseSetupInf(); + } + LoadString(hApplet, IDS_CPLNAME, Caption, sizeof(Caption) / sizeof(TCHAR)); ZeroMemory(&psh, sizeof(PROPSHEETHEADER)); diff --git a/reactos/dll/cpl/intl/intl.h b/reactos/dll/cpl/intl/intl.h index 39fd7d6f0a9..f557a4593c8 100644 --- a/reactos/dll/cpl/intl/intl.h +++ b/reactos/dll/cpl/intl/intl.h @@ -55,6 +55,9 @@ TimePageProc(HWND hwndDlg, WPARAM wParam, LPARAM lParam); + +void SetNewLocale(LCID lcid); + #endif /* __CPL_INTL_H */ /* EOF */ diff --git a/reactos/dll/cpl/intl/intl.rbuild b/reactos/dll/cpl/intl/intl.rbuild index e7838cfa81d..84f5a7e050a 100644 --- a/reactos/dll/cpl/intl/intl.rbuild +++ b/reactos/dll/cpl/intl/intl.rbuild @@ -11,6 +11,7 @@ user32 comctl32 advapi32 + setupapi currency.c date.c general.c