HINSTANCE hInstance;
BOOL isUnattend;
+LONG LoadGenentry(HINF hinf,PCTSTR name,PGENENTRY gen,PINFCONTEXT context);
+
/* FUNCTIONS ****************************************************************/
static VOID
if (hTxtsetupSif != INVALID_HANDLE_VALUE)
{
// get language list
- Count = SetupGetLineCount(hTxtsetupSif, _T("Language"));
- if (Count > 0)
+ SetupData.LangCount = SetupGetLineCount(hTxtsetupSif, _T("Language"));
+ if (SetupData.LangCount > 0)
{
- SetupData.pLanguages = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(LANG) * Count);
+ SetupData.pLanguages = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(LANG) * SetupData.LangCount);
if (SetupData.pLanguages != NULL)
{
- SetupData.LangCount = Count;
Count = 0;
if (SetupFindFirstLine(hTxtsetupSif, _T("Language"), NULL, &InfContext))
{
&LineLength);
++Count;
}
- while (SetupFindNextLine(&InfContext, &InfContext) && Count < SetupData.LangCount);
+ while (SetupFindNextLine(&InfContext, &InfContext) && Count < SetupData.LangCount);
}
}
}
// get keyboard layout list
- Count = SetupGetLineCount(hTxtsetupSif, _T("KeyboardLayout"));
- if (Count > 0)
+ SetupData.KbLayoutCount = SetupGetLineCount(hTxtsetupSif, _T("KeyboardLayout"));
+ if (SetupData.KbLayoutCount > 0)
{
- SetupData.pKbLayouts = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(KBLAYOUT) * Count);
+ SetupData.pKbLayouts = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(KBLAYOUT) * SetupData.KbLayoutCount);
if (SetupData.pKbLayouts != NULL)
{
- SetupData.KbLayoutCount = Count;
Count = 0;
if (SetupFindFirstLine(hTxtsetupSif, _T("KeyboardLayout"), NULL, &InfContext))
{
&LineLength);
++Count;
}
- while (SetupFindNextLine(&InfContext, &InfContext) && Count < SetupData.LangCount);
+ while (SetupFindNextLine(&InfContext, &InfContext) && Count < SetupData.KbLayoutCount);
}
}
}
}
// get computers list
- Count = SetupGetLineCount(hTxtsetupSif, _T("Computer"));
- if (Count > 0)
- {
- SetupData.pComputers = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(GENENTRY) * Count);
- if (SetupData.pComputers != NULL)
- {
- SetupData.CompCount = Count;
- Count = 0;
- if (SetupFindFirstLine(hTxtsetupSif, _T("Computer"), NULL, &InfContext))
- {
- do
- {
- SetupGetStringField(&InfContext,
- 0,
- SetupData.pComputers[Count].Id,
- sizeof(SetupData.pComputers[Count].Id) / sizeof(TCHAR),
- &LineLength);
-
- SetupGetStringField(&InfContext,
- 1,
- SetupData.pComputers[Count].Value,
- sizeof(SetupData.pComputers[Count].Value) / sizeof(TCHAR),
- &LineLength);
- ++Count;
- }
- while (SetupFindNextLine(&InfContext, &InfContext) && Count < SetupData.CompCount);
- }
- }
- }
+ SetupData.CompCount = LoadGenentry(hTxtsetupSif,_T("Computer"),SetupData.pComputers,&InfContext);
// get display list
- Count = SetupGetLineCount(hTxtsetupSif, _T("Display"));
- if (Count > 0)
- {
- SetupData.pDisplays = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(GENENTRY) * Count);
- if (SetupData.pDisplays != NULL)
- {
- SetupData.DispCount = Count;
- Count = 0;
-
- if (SetupFindFirstLine(hTxtsetupSif, _T("Display"), NULL, &InfContext))
- {
- do
- {
- SetupGetStringField(&InfContext,
- 0,
- SetupData.pDisplays[Count].Id,
- sizeof(SetupData.pDisplays[Count].Id) / sizeof(TCHAR),
- &LineLength);
-
- SetupGetStringField(&InfContext,
- 1,
- SetupData.pDisplays[Count].Value,
- sizeof(SetupData.pDisplays[Count].Value) / sizeof(TCHAR),
- &LineLength);
- ++Count;
- }
- while (SetupFindNextLine(&InfContext, &InfContext) && Count < SetupData.DispCount);
- }
- }
- }
+ SetupData.DispCount = LoadGenentry(hTxtsetupSif,_T("Display"),SetupData.pDisplays,&InfContext);
// get keyboard list
- Count = SetupGetLineCount(hTxtsetupSif, _T("Keyboard"));
- if (Count > 0)
- {
- SetupData.pKeyboards = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(GENENTRY) * Count);
- if (SetupData.pKeyboards != NULL)
- {
- SetupData.KeybCount = Count;
- Count = 0;
-
- if (SetupFindFirstLine(hTxtsetupSif, _T("Keyboard"), NULL, &InfContext))
- {
- do
- {
- SetupGetStringField(&InfContext,
- 0,
- SetupData.pKeyboards[Count].Id,
- sizeof(SetupData.pKeyboards[Count].Id) / sizeof(TCHAR),
- &LineLength);
-
- SetupGetStringField(&InfContext,
- 1,
- SetupData.pKeyboards[Count].Value,
- sizeof(SetupData.pKeyboards[Count].Value) / sizeof(TCHAR),
- &LineLength);
- ++Count;
- }
- while (SetupFindNextLine(&InfContext, &InfContext) && Count < SetupData.KeybCount);
- }
- }
- }
+ SetupData.KeybCount = LoadGenentry(hTxtsetupSif, _T("Keyboard"),SetupData.pKeyboards,&InfContext);
// get install directory
if (SetupFindFirstLine(hTxtsetupSif, _T("SetupData"), _T("DefaultPath"), &InfContext))
}
}
+LONG LoadGenentry(HINF hinf,PCTSTR name,PGENENTRY gen,PINFCONTEXT context)
+{
+ LONG TotalCount;
+
+ TotalCount = SetupGetLineCount(hinf, name);
+ if (TotalCount > 0)
+ {
+ gen = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(GENENTRY) * TotalCount);
+ if (gen != NULL)
+ {
+ if (SetupFindFirstLine(hinf, name, NULL, context))
+ {
+ LONG Count = 0;
+ do
+ {
+ SetupGetStringField(context,
+ 0,
+ gen[Count].Id,
+ sizeof(gen[Count].Id) / sizeof(TCHAR),
+ NULL);
+
+ SetupGetStringField(context,
+ 1,
+ gen[Count].Value,
+ sizeof(gen[Count].Value) / sizeof(TCHAR),
+ NULL);
+ Count++;
+ }
+ while (SetupFindNextLine(context, context) && Count < TotalCount);
+ }
+ }
+ }
+
+ return TotalCount;
+}
+
BOOL isUnattendSetup()
{
WCHAR szPath[MAX_PATH];