advpack: Factor out loading the program files directory.
This commit is contained in:
parent
7787ca6134
commit
1f3028563d
@ -35,6 +35,22 @@ static HRESULT (WINAPI *pOpenINFEngine)(PCSTR,PCSTR,DWORD,HINF*,PVOID);
|
|||||||
static HRESULT (WINAPI *pTranslateInfString)(LPSTR,LPSTR,LPSTR,LPSTR,LPSTR,DWORD,LPDWORD,LPVOID);
|
static HRESULT (WINAPI *pTranslateInfString)(LPSTR,LPSTR,LPSTR,LPSTR,LPSTR,DWORD,LPDWORD,LPVOID);
|
||||||
static HRESULT (WINAPI *pTranslateInfStringEx)(HINF,PCSTR,PCSTR,PCSTR,PSTR,DWORD,PDWORD,PVOID);
|
static HRESULT (WINAPI *pTranslateInfStringEx)(HINF,PCSTR,PCSTR,PCSTR,PSTR,DWORD,PDWORD,PVOID);
|
||||||
|
|
||||||
|
static CHAR PROG_FILES[MAX_PATH];
|
||||||
|
static DWORD PROG_FILES_LEN;
|
||||||
|
|
||||||
|
static void get_progfiles_dir(void)
|
||||||
|
{
|
||||||
|
HKEY hkey;
|
||||||
|
DWORD size = MAX_PATH;
|
||||||
|
|
||||||
|
RegOpenKeyA(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Windows\\CurrentVersion", &hkey);
|
||||||
|
RegQueryValueExA(hkey, "ProgramFilesDir", NULL, NULL, (LPBYTE)PROG_FILES, &size);
|
||||||
|
RegCloseKey(hkey);
|
||||||
|
|
||||||
|
lstrcatA(PROG_FILES, TEST_STRING1);
|
||||||
|
PROG_FILES_LEN = lstrlenA(PROG_FILES) + 1;
|
||||||
|
}
|
||||||
|
|
||||||
static BOOL init_function_pointers(void)
|
static BOOL init_function_pointers(void)
|
||||||
{
|
{
|
||||||
HMODULE hAdvPack = LoadLibraryA("advpack.dll");
|
HMODULE hAdvPack = LoadLibraryA("advpack.dll");
|
||||||
@ -247,20 +263,8 @@ static void translateinfstring_test()
|
|||||||
|
|
||||||
if(hr == ERROR_SUCCESS)
|
if(hr == ERROR_SUCCESS)
|
||||||
{
|
{
|
||||||
HKEY key;
|
ok(!strcmp(buffer, PROG_FILES), "Expected '%s', got '%s'\n", PROG_FILES, buffer);
|
||||||
DWORD len = MAX_PATH;
|
ok(dwSize == PROG_FILES_LEN, "Expected size %ld, got %ld\n", PROG_FILES_LEN, dwSize);
|
||||||
char cmpbuffer[MAX_PATH];
|
|
||||||
LONG res = RegOpenKeyA(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Windows\\CurrentVersion", &key);
|
|
||||||
if(res == ERROR_SUCCESS) {
|
|
||||||
res = RegQueryValueExA(key, "ProgramFilesDir", NULL, NULL, (LPBYTE)cmpbuffer, &len);
|
|
||||||
if(res == ERROR_SUCCESS) {
|
|
||||||
strcat(cmpbuffer, TEST_STRING1);
|
|
||||||
ok(!strcmp(buffer, cmpbuffer), "Expected '%s', got '%s'\n", cmpbuffer, buffer);
|
|
||||||
ok(dwSize == (strlen(cmpbuffer)+1), "Expected size %d, got %ld\n",
|
|
||||||
strlen(cmpbuffer)+1, dwSize);
|
|
||||||
}
|
|
||||||
RegCloseKey(key);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
buffer[0] = 0;
|
buffer[0] = 0;
|
||||||
@ -281,18 +285,12 @@ static void translateinfstring_test()
|
|||||||
static void translateinfstringex_test(void)
|
static void translateinfstringex_test(void)
|
||||||
{
|
{
|
||||||
HINF hinf;
|
HINF hinf;
|
||||||
HKEY hkey;
|
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
char buffer[MAX_PATH];
|
char buffer[MAX_PATH];
|
||||||
char progfiles[MAX_PATH];
|
|
||||||
DWORD size = MAX_PATH;
|
DWORD size = MAX_PATH;
|
||||||
|
|
||||||
create_inf_file();
|
create_inf_file();
|
||||||
|
|
||||||
RegOpenKeyA(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Windows\\CurrentVersion", &hkey);
|
|
||||||
RegQueryValueExA(hkey, "ProgramFilesDir", NULL, NULL, (LPBYTE)progfiles, &size);
|
|
||||||
lstrcatA(progfiles, TEST_STRING1);
|
|
||||||
|
|
||||||
/* need to see if there are any flags */
|
/* need to see if there are any flags */
|
||||||
|
|
||||||
/* try a NULL filename */
|
/* try a NULL filename */
|
||||||
@ -381,9 +379,8 @@ static void translateinfstringex_test(void)
|
|||||||
hr = pTranslateInfStringEx(hinf, "c:\\test.inf", "Options.NTx86", "InstallDir",
|
hr = pTranslateInfStringEx(hinf, "c:\\test.inf", "Options.NTx86", "InstallDir",
|
||||||
buffer, size, &size, NULL);
|
buffer, size, &size, NULL);
|
||||||
ok(hr == S_OK, "Expected S_OK, got %ld\n", hr);
|
ok(hr == S_OK, "Expected S_OK, got %ld\n", hr);
|
||||||
ok(!strcmp(buffer, progfiles), "Expected %s, got %s\n", progfiles, buffer);
|
ok(!strcmp(buffer, PROG_FILES), "Expected %s, got %s\n", PROG_FILES, buffer);
|
||||||
ok(size == lstrlenA(progfiles) + 1, "Expected size %i, got %ld\n",
|
ok(size == PROG_FILES_LEN, "Expected size %ld, got %ld\n", PROG_FILES_LEN, size);
|
||||||
lstrlenA(progfiles) + 1, size);
|
|
||||||
|
|
||||||
/* close the INF again */
|
/* close the INF again */
|
||||||
hr = pCloseINFEngine(hinf);
|
hr = pCloseINFEngine(hinf);
|
||||||
@ -397,6 +394,8 @@ START_TEST(advpack)
|
|||||||
if (!init_function_pointers())
|
if (!init_function_pointers())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
get_progfiles_dir();
|
||||||
|
|
||||||
version_test();
|
version_test();
|
||||||
delnode_test();
|
delnode_test();
|
||||||
translateinfstring_test();
|
translateinfstring_test();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user