2005-01-20 21:03:13 +01:00
|
|
|
/*
|
|
|
|
* Unit tests for advpack.dll
|
|
|
|
*
|
|
|
|
* Copyright (C) 2005 Robert Reif
|
2005-04-27 11:37:25 +02:00
|
|
|
* Copyright (C) 2005 Sami Aario
|
2005-01-20 21:03:13 +01:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2005-01-20 21:03:13 +01:00
|
|
|
*/
|
|
|
|
|
2005-11-08 13:43:35 +01:00
|
|
|
#include <stdio.h>
|
2005-01-20 21:03:13 +01:00
|
|
|
#include <windows.h>
|
2005-02-14 12:02:46 +01:00
|
|
|
#include <advpub.h>
|
2005-04-27 11:37:25 +02:00
|
|
|
#include <assert.h>
|
2005-01-20 21:03:13 +01:00
|
|
|
#include "wine/test.h"
|
2005-02-14 12:02:46 +01:00
|
|
|
|
2006-04-06 10:48:49 +02:00
|
|
|
/* defines for the TranslateInfString/Ex tests */
|
2006-01-23 17:29:41 +01:00
|
|
|
#define TEST_STRING1 "\\Application Name"
|
2005-11-08 13:43:35 +01:00
|
|
|
#define TEST_STRING2 "%49001%\\Application Name"
|
|
|
|
|
2006-04-06 10:48:49 +02:00
|
|
|
/* defines for the SetPerUserSecValues tests */
|
|
|
|
#define GUID_KEY "SOFTWARE\\Microsoft\\Active Setup\\Installed Components\\guid"
|
|
|
|
#define REG_VAL_EXISTS(key, value) !RegQueryValueEx(key, value, NULL, NULL, NULL, NULL)
|
|
|
|
#define OPEN_GUID_KEY() !RegOpenKey(HKEY_LOCAL_MACHINE, GUID_KEY, &guid)
|
|
|
|
|
2006-02-27 20:50:03 +01:00
|
|
|
static HRESULT (WINAPI *pCloseINFEngine)(HINF);
|
2005-04-27 11:37:25 +02:00
|
|
|
static HRESULT (WINAPI *pDelNode)(LPCSTR,DWORD);
|
2006-02-27 20:49:50 +01:00
|
|
|
static HRESULT (WINAPI *pGetVersionFromFile)(LPSTR,LPDWORD,LPDWORD,BOOL);
|
2006-02-27 20:50:03 +01:00
|
|
|
static HRESULT (WINAPI *pOpenINFEngine)(PCSTR,PCSTR,DWORD,HINF*,PVOID);
|
2006-04-06 10:48:49 +02:00
|
|
|
static HRESULT (WINAPI *pSetPerUserSecValues)(PPERUSERSECTION pPerUser);
|
2005-11-08 13:43:35 +01:00
|
|
|
static HRESULT (WINAPI *pTranslateInfString)(LPSTR,LPSTR,LPSTR,LPSTR,LPSTR,DWORD,LPDWORD,LPVOID);
|
2006-02-27 20:50:03 +01:00
|
|
|
static HRESULT (WINAPI *pTranslateInfStringEx)(HINF,PCSTR,PCSTR,PCSTR,PSTR,DWORD,PDWORD,PVOID);
|
2005-01-20 21:03:13 +01:00
|
|
|
|
2006-02-27 20:50:25 +01:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2006-02-27 20:49:50 +01:00
|
|
|
static BOOL init_function_pointers(void)
|
|
|
|
{
|
|
|
|
HMODULE hAdvPack = LoadLibraryA("advpack.dll");
|
|
|
|
|
|
|
|
if (!hAdvPack)
|
|
|
|
return FALSE;
|
|
|
|
|
2006-02-27 20:50:03 +01:00
|
|
|
pCloseINFEngine = (void*)GetProcAddress(hAdvPack, "CloseINFEngine");
|
2006-02-27 20:49:50 +01:00
|
|
|
pDelNode = (void *)GetProcAddress(hAdvPack, "DelNode");
|
|
|
|
pGetVersionFromFile = (void *)GetProcAddress(hAdvPack, "GetVersionFromFile");
|
2006-02-27 20:50:03 +01:00
|
|
|
pOpenINFEngine = (void*)GetProcAddress(hAdvPack, "OpenINFEngine");
|
2006-04-06 10:48:49 +02:00
|
|
|
pSetPerUserSecValues = (void*)GetProcAddress(hAdvPack, "SetPerUserSecValues");
|
2006-02-27 20:49:50 +01:00
|
|
|
pTranslateInfString = (void *)GetProcAddress(hAdvPack, "TranslateInfString");
|
2006-02-27 20:50:03 +01:00
|
|
|
pTranslateInfStringEx = (void*)GetProcAddress(hAdvPack, "TranslateInfStringEx");
|
2006-02-27 20:49:50 +01:00
|
|
|
|
2006-02-27 20:50:03 +01:00
|
|
|
if (!pCloseINFEngine || !pDelNode || !pGetVersionFromFile ||
|
2006-04-06 10:48:49 +02:00
|
|
|
!pOpenINFEngine || !pSetPerUserSecValues || !pTranslateInfString)
|
2006-02-27 20:49:50 +01:00
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2005-06-20 16:18:03 +02:00
|
|
|
static void version_test(void)
|
2005-01-20 21:03:13 +01:00
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
DWORD major, minor;
|
|
|
|
|
|
|
|
major = minor = 0;
|
2005-02-14 12:02:46 +01:00
|
|
|
hr = pGetVersionFromFile("kernel32.dll", &major, &minor, FALSE);
|
2005-01-20 21:03:13 +01:00
|
|
|
ok (hr == S_OK, "GetVersionFromFileEx(kernel32.dll) failed, returned "
|
|
|
|
"0x%08lx\n", hr);
|
|
|
|
trace("kernel32.dll Language ID: 0x%08lx, Codepage ID: 0x%08lx\n",
|
|
|
|
major, minor);
|
|
|
|
|
|
|
|
major = minor = 0;
|
2005-02-14 12:02:46 +01:00
|
|
|
hr = pGetVersionFromFile("kernel32.dll", &major, &minor, TRUE);
|
2005-01-20 21:03:13 +01:00
|
|
|
ok (hr == S_OK, "GetVersionFromFileEx(kernel32.dll) failed, returned "
|
|
|
|
"0x%08lx\n", hr);
|
|
|
|
trace("kernel32.dll version: %d.%d.%d.%d\n", HIWORD(major), LOWORD(major),
|
|
|
|
HIWORD(minor), LOWORD(minor));
|
2005-11-14 13:27:39 +01:00
|
|
|
|
|
|
|
major = minor = 0;
|
|
|
|
hr = pGetVersionFromFile("advpack.dll", &major, &minor, FALSE);
|
|
|
|
ok (hr == S_OK, "GetVersionFromFileEx(advpack.dll) failed, returned "
|
|
|
|
"0x%08lx\n", hr);
|
|
|
|
trace("advpack.dll Language ID: 0x%08lx, Codepage ID: 0x%08lx\n",
|
|
|
|
major, minor);
|
|
|
|
|
|
|
|
major = minor = 0;
|
|
|
|
hr = pGetVersionFromFile("advpack.dll", &major, &minor, TRUE);
|
|
|
|
ok (hr == S_OK, "GetVersionFromFileEx(advpack.dll) failed, returned "
|
|
|
|
"0x%08lx\n", hr);
|
|
|
|
trace("advpack.dll version: %d.%d.%d.%d\n", HIWORD(major), LOWORD(major),
|
|
|
|
HIWORD(minor), LOWORD(minor));
|
2005-01-20 21:03:13 +01:00
|
|
|
}
|
|
|
|
|
2005-06-20 16:18:03 +02:00
|
|
|
static void delnode_test(void)
|
2005-04-27 11:37:25 +02:00
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
HANDLE hn;
|
|
|
|
CHAR currDir[MAX_PATH];
|
|
|
|
int currDirLen;
|
|
|
|
|
|
|
|
/* Native DelNode apparently does not support relative paths, so we use
|
|
|
|
absolute paths for testing */
|
|
|
|
currDirLen = GetCurrentDirectoryA(sizeof(currDir) / sizeof(CHAR), currDir);
|
|
|
|
assert(currDirLen > 0 && currDirLen < sizeof(currDir) / sizeof(CHAR));
|
|
|
|
|
2005-08-15 12:47:31 +02:00
|
|
|
if(currDir[currDirLen - 1] == '\\')
|
|
|
|
currDir[--currDirLen] = 0;
|
|
|
|
|
2005-04-27 11:37:25 +02:00
|
|
|
/* Simple tests; these should fail. */
|
|
|
|
hr = pDelNode(NULL, 0);
|
|
|
|
ok (hr == E_FAIL, "DelNode called with NULL pathname should return E_FAIL\n");
|
|
|
|
hr = pDelNode("", 0);
|
|
|
|
ok (hr == E_FAIL, "DelNode called with empty pathname should return E_FAIL\n");
|
|
|
|
|
|
|
|
/* Test deletion of a file. */
|
|
|
|
hn = CreateFile("DelNodeTestFile1", GENERIC_WRITE, 0, NULL,
|
|
|
|
CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
|
|
|
|
assert(hn != INVALID_HANDLE_VALUE);
|
|
|
|
CloseHandle(hn);
|
|
|
|
hr = pDelNode(lstrcat(currDir, "\\DelNodeTestFile1"), 0);
|
|
|
|
ok (hr == S_OK, "DelNode failed deleting a single file\n");
|
|
|
|
currDir[currDirLen] = '\0';
|
|
|
|
|
|
|
|
/* Test deletion of an empty directory. */
|
|
|
|
CreateDirectoryA("DelNodeTestDir", NULL);
|
|
|
|
hr = pDelNode(lstrcat(currDir, "\\DelNodeTestDir"), 0);
|
|
|
|
ok (hr == S_OK, "DelNode failed deleting an empty directory\n");
|
|
|
|
currDir[currDirLen] = '\0';
|
|
|
|
|
|
|
|
/* Test deletion of a directory containing one file. */
|
|
|
|
CreateDirectoryA("DelNodeTestDir", NULL);
|
|
|
|
hn = CreateFile("DelNodeTestDir\\DelNodeTestFile1", GENERIC_WRITE, 0, NULL,
|
|
|
|
CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
|
|
|
|
assert(hn != INVALID_HANDLE_VALUE);
|
|
|
|
CloseHandle(hn);
|
|
|
|
hr = pDelNode(lstrcat(currDir, "\\DelNodeTestDir"), 0);
|
|
|
|
ok (hr == S_OK, "DelNode failed deleting a directory containing one file\n");
|
|
|
|
currDir[currDirLen] = '\0';
|
|
|
|
|
|
|
|
/* Test deletion of a directory containing multiple files. */
|
|
|
|
CreateDirectoryA("DelNodeTestDir", NULL);
|
|
|
|
hn = CreateFile("DelNodeTestDir\\DelNodeTestFile1", GENERIC_WRITE, 0, NULL,
|
|
|
|
CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
|
|
|
|
assert(hn != INVALID_HANDLE_VALUE);
|
|
|
|
CloseHandle(hn);
|
|
|
|
hn = CreateFile("DelNodeTestDir\\DelNodeTestFile2", GENERIC_WRITE, 0, NULL,
|
|
|
|
CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
|
|
|
|
assert(hn != INVALID_HANDLE_VALUE);
|
|
|
|
CloseHandle(hn);
|
|
|
|
hn = CreateFile("DelNodeTestDir\\DelNodeTestFile3", GENERIC_WRITE, 0, NULL,
|
|
|
|
CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
|
|
|
|
assert(hn != INVALID_HANDLE_VALUE);
|
|
|
|
CloseHandle(hn);
|
|
|
|
hr = pDelNode(lstrcat(currDir, "\\DelNodeTestDir"), 0);
|
|
|
|
ok (hr == S_OK, "DelNode failed deleting a directory containing multiple files\n");
|
|
|
|
currDir[currDirLen] = '\0';
|
|
|
|
}
|
|
|
|
|
2005-11-08 13:43:35 +01:00
|
|
|
static void append_str(char **str, const char *data)
|
|
|
|
{
|
|
|
|
sprintf(*str, data);
|
|
|
|
*str += strlen(*str);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void create_inf_file()
|
|
|
|
{
|
|
|
|
char data[1024];
|
|
|
|
char *ptr = data;
|
2005-11-10 12:37:03 +01:00
|
|
|
DWORD dwNumberOfBytesWritten;
|
2005-11-08 13:43:35 +01:00
|
|
|
HANDLE hf = CreateFile("c:\\test.inf", GENERIC_WRITE, 0, NULL,
|
|
|
|
CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
|
|
|
|
|
|
|
|
append_str(&ptr, "[Version]\n");
|
|
|
|
append_str(&ptr, "Signature=\"$Chicago$\"\n");
|
|
|
|
append_str(&ptr, "[CustInstDestSection]\n");
|
|
|
|
append_str(&ptr, "49001=ProgramFilesDir\n");
|
|
|
|
append_str(&ptr, "[ProgramFilesDir]\n");
|
|
|
|
append_str(&ptr, "HKLM,\"Software\\Microsoft\\Windows\\CurrentVersion\",");
|
|
|
|
append_str(&ptr, "\"ProgramFilesDir\",,\"%%24%%\\%%LProgramF%%\"\n");
|
|
|
|
append_str(&ptr, "[section]\n");
|
|
|
|
append_str(&ptr, "NotACustomDestination=Version\n");
|
|
|
|
append_str(&ptr, "CustomDestination=CustInstDestSection\n");
|
|
|
|
append_str(&ptr, "[Options.NTx86]\n");
|
|
|
|
append_str(&ptr, "49001=ProgramFilesDir\n");
|
|
|
|
append_str(&ptr, "InstallDir=%%49001%%\\%%DefaultAppPath%%\n");
|
|
|
|
append_str(&ptr, "CustomHDestination=CustInstDestSection\n");
|
|
|
|
append_str(&ptr, "[Strings]\n");
|
|
|
|
append_str(&ptr, "DefaultAppPath=\"Application Name\"\n");
|
|
|
|
append_str(&ptr, "LProgramF=\"Program Files\"\n");
|
|
|
|
|
2005-11-10 12:37:03 +01:00
|
|
|
WriteFile(hf, data, ptr - data, &dwNumberOfBytesWritten, NULL);
|
2005-11-08 13:43:35 +01:00
|
|
|
CloseHandle(hf);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void translateinfstring_test()
|
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
char buffer[MAX_PATH];
|
|
|
|
DWORD dwSize;
|
|
|
|
|
|
|
|
create_inf_file();
|
|
|
|
|
|
|
|
/* pass in a couple invalid parameters */
|
|
|
|
hr = pTranslateInfString(NULL, NULL, NULL, NULL, buffer, MAX_PATH, &dwSize, NULL);
|
|
|
|
ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got 0x%08x\n", (UINT)hr);
|
|
|
|
|
|
|
|
/* try to open an inf file that doesn't exist */
|
|
|
|
hr = pTranslateInfString("c:\\a.inf", "Options.NTx86", "Options.NTx86",
|
|
|
|
"InstallDir", buffer, MAX_PATH, &dwSize, NULL);
|
2005-11-22 12:58:25 +01:00
|
|
|
ok(hr == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND) || hr == E_INVALIDARG ||
|
|
|
|
hr == HRESULT_FROM_WIN32(ERROR_MOD_NOT_FOUND),
|
|
|
|
"Expected E_INVALIDARG, 0x80070002 or 0x8007007e, got 0x%08x\n", (UINT)hr);
|
|
|
|
|
|
|
|
if(hr == HRESULT_FROM_WIN32(ERROR_MOD_NOT_FOUND))
|
|
|
|
{
|
2005-11-23 19:44:20 +01:00
|
|
|
trace("WinNT 3.51 detected. Skipping tests for TranslateInfString()\n");
|
2005-11-22 12:58:25 +01:00
|
|
|
return;
|
|
|
|
}
|
2005-11-08 13:43:35 +01:00
|
|
|
|
|
|
|
/* try a nonexistent section */
|
2005-11-10 12:37:03 +01:00
|
|
|
buffer[0] = 0;
|
2005-11-08 13:43:35 +01:00
|
|
|
hr = pTranslateInfString("c:\\test.inf", "idontexist", "Options.NTx86",
|
|
|
|
"InstallDir", buffer, MAX_PATH, &dwSize, NULL);
|
|
|
|
ok(hr == S_OK, "Expected S_OK, got 0x%08x\n", (UINT)hr);
|
|
|
|
ok(!strcmp(buffer, TEST_STRING2), "Expected %s, got %s\n", TEST_STRING2, buffer);
|
|
|
|
ok(dwSize == 25, "Expected size 25, got %ld\n", dwSize);
|
|
|
|
|
2005-11-10 12:37:03 +01:00
|
|
|
buffer[0] = 0;
|
2005-11-08 13:43:35 +01:00
|
|
|
/* try other nonexistent section */
|
|
|
|
hr = pTranslateInfString("c:\\test.inf", "Options.NTx86", "idontexist",
|
|
|
|
"InstallDir", buffer, MAX_PATH, &dwSize, NULL);
|
2005-11-10 12:37:03 +01:00
|
|
|
ok(hr == SPAPI_E_LINE_NOT_FOUND || hr == E_INVALIDARG,
|
|
|
|
"Expected SPAPI_E_LINE_NOT_FOUND or E_INVALIDARG, got 0x%08x\n", (UINT)hr);
|
2005-11-08 13:43:35 +01:00
|
|
|
|
2005-11-10 12:37:03 +01:00
|
|
|
buffer[0] = 0;
|
2005-11-08 13:43:35 +01:00
|
|
|
/* try nonexistent key */
|
|
|
|
hr = pTranslateInfString("c:\\test.inf", "Options.NTx86", "Options.NTx86",
|
|
|
|
"notvalid", buffer, MAX_PATH, &dwSize, NULL);
|
2005-11-10 12:37:03 +01:00
|
|
|
ok(hr == SPAPI_E_LINE_NOT_FOUND || hr == E_INVALIDARG,
|
|
|
|
"Expected SPAPI_E_LINE_NOT_FOUND or E_INVALIDARG, got 0x%08x\n", (UINT)hr);
|
2005-11-08 13:43:35 +01:00
|
|
|
|
2005-11-10 12:37:03 +01:00
|
|
|
buffer[0] = 0;
|
2005-11-08 13:43:35 +01:00
|
|
|
/* test the behavior of pszInstallSection */
|
|
|
|
hr = pTranslateInfString("c:\\test.inf", "section", "Options.NTx86",
|
|
|
|
"InstallDir", buffer, MAX_PATH, &dwSize, NULL);
|
2005-11-10 12:37:03 +01:00
|
|
|
ok(hr == ERROR_SUCCESS || hr == E_FAIL,
|
|
|
|
"Expected ERROR_SUCCESS or E_FAIL, got 0x%08x\n", (UINT)hr);
|
2005-11-08 13:43:35 +01:00
|
|
|
|
2005-11-10 12:37:03 +01:00
|
|
|
if(hr == ERROR_SUCCESS)
|
2005-11-08 13:43:35 +01:00
|
|
|
{
|
2006-02-27 20:50:25 +01:00
|
|
|
ok(!strcmp(buffer, PROG_FILES), "Expected '%s', got '%s'\n", PROG_FILES, buffer);
|
|
|
|
ok(dwSize == PROG_FILES_LEN, "Expected size %ld, got %ld\n", PROG_FILES_LEN, dwSize);
|
2005-11-08 13:43:35 +01:00
|
|
|
}
|
|
|
|
|
2005-11-10 12:37:03 +01:00
|
|
|
buffer[0] = 0;
|
2005-11-08 13:43:35 +01:00
|
|
|
/* try without a pszInstallSection */
|
|
|
|
hr = pTranslateInfString("c:\\test.inf", NULL, "Options.NTx86",
|
|
|
|
"InstallDir", buffer, MAX_PATH, &dwSize, NULL);
|
|
|
|
ok(hr == S_OK, "Expected S_OK, got 0x%08x\n", (UINT)hr);
|
2006-02-21 04:40:59 +01:00
|
|
|
todo_wine
|
|
|
|
{
|
|
|
|
ok(!strcmp(buffer, TEST_STRING2), "Expected %s, got %s\n", TEST_STRING2, buffer);
|
|
|
|
ok(dwSize == 25, "Expected size 25, got %ld\n", dwSize);
|
|
|
|
}
|
2005-11-08 13:43:35 +01:00
|
|
|
|
2005-11-10 12:37:03 +01:00
|
|
|
DeleteFile("c:\\a.inf");
|
2005-11-08 13:43:35 +01:00
|
|
|
DeleteFile("c:\\test.inf");
|
|
|
|
}
|
|
|
|
|
2006-02-27 20:50:03 +01:00
|
|
|
static void translateinfstringex_test(void)
|
|
|
|
{
|
|
|
|
HINF hinf;
|
|
|
|
HRESULT hr;
|
|
|
|
char buffer[MAX_PATH];
|
|
|
|
DWORD size = MAX_PATH;
|
|
|
|
|
|
|
|
create_inf_file();
|
|
|
|
|
|
|
|
/* need to see if there are any flags */
|
|
|
|
|
|
|
|
/* try a NULL filename */
|
|
|
|
hr = pOpenINFEngine(NULL, "Options.NTx86", 0, &hinf, NULL);
|
|
|
|
ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got %ld\n", hr);
|
|
|
|
|
|
|
|
/* try an empty filename */
|
|
|
|
hr = pOpenINFEngine("", "Options.NTx86", 0, &hinf, NULL);
|
|
|
|
ok(hr == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND),
|
|
|
|
"Expected HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND), got %ld\n", hr);
|
|
|
|
|
|
|
|
/* try a NULL hinf */
|
|
|
|
hr = pOpenINFEngine("c:\\test.inf", "Options.NTx86", 0, NULL, NULL);
|
|
|
|
ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got %ld\n", hr);
|
|
|
|
|
|
|
|
/* open the INF without the Install section specified */
|
|
|
|
hr = pOpenINFEngine("c:\\test.inf", NULL, 0, &hinf, NULL);
|
|
|
|
ok(hr == S_OK, "Expected S_OK, got %ld\n", hr);
|
|
|
|
|
|
|
|
/* try a NULL hinf */
|
|
|
|
hr = pTranslateInfStringEx(NULL, "c:\\test.inf", "Options.NTx86", "InstallDir",
|
|
|
|
buffer, size, &size, NULL);
|
|
|
|
ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got %ld\n", hr);
|
|
|
|
|
|
|
|
/* try a NULL filename */
|
|
|
|
hr = pTranslateInfStringEx(hinf, NULL, "Options.NTx86", "InstallDir",
|
|
|
|
buffer, size, &size, NULL);
|
|
|
|
ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got %ld\n", hr);
|
|
|
|
|
|
|
|
/* try an empty filename */
|
|
|
|
size = MAX_PATH;
|
|
|
|
hr = pTranslateInfStringEx(hinf, "", "Options.NTx86", "InstallDir",
|
|
|
|
buffer, size, &size, NULL);
|
|
|
|
ok(hr == S_OK, "Expected S_OK, got %08x\n", (UINT)hr);
|
|
|
|
todo_wine
|
|
|
|
{
|
|
|
|
ok(!strcmp(buffer, TEST_STRING2), "Expected %s, got %s\n", TEST_STRING2, buffer);
|
|
|
|
ok(size == 25, "Expected size 25, got %ld\n", size);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* try a NULL translate section */
|
|
|
|
hr = pTranslateInfStringEx(hinf, "c:\\test.inf", NULL, "InstallDir",
|
|
|
|
buffer, size, &size, NULL);
|
|
|
|
ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got %ld\n", hr);
|
|
|
|
|
|
|
|
/* try an empty translate section */
|
|
|
|
hr = pTranslateInfStringEx(hinf, "c:\\test.inf", "", "InstallDir",
|
|
|
|
buffer, size, &size, NULL);
|
|
|
|
ok(hr == SPAPI_E_LINE_NOT_FOUND, "Expected SPAPI_E_LINE_NOT_FOUND, got %ld\n", hr);
|
|
|
|
|
|
|
|
/* try a NULL translate key */
|
|
|
|
hr = pTranslateInfStringEx(hinf, "c:\\test.inf", "Options.NTx86", NULL,
|
|
|
|
buffer, size, &size, NULL);
|
|
|
|
ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got %ld\n", hr);
|
|
|
|
|
|
|
|
/* try an empty translate key */
|
|
|
|
hr = pTranslateInfStringEx(hinf, "c:\\test.inf", "Options.NTx86", "",
|
|
|
|
buffer, size, &size, NULL);
|
|
|
|
ok(hr == SPAPI_E_LINE_NOT_FOUND, "Expected SPAPI_E_LINE_NOT_FOUND, got %ld\n", hr);
|
|
|
|
|
|
|
|
/* successfully translate the string */
|
|
|
|
size = MAX_PATH;
|
|
|
|
hr = pTranslateInfStringEx(hinf, "c:\\test.inf", "Options.NTx86", "InstallDir",
|
|
|
|
buffer, size, &size, NULL);
|
|
|
|
ok(hr == S_OK, "Expected S_OK, got %ld\n", hr);
|
|
|
|
todo_wine
|
|
|
|
{
|
|
|
|
ok(!strcmp(buffer, TEST_STRING2), "Expected %s, got %s\n", TEST_STRING2, buffer);
|
|
|
|
ok(size == 25, "Expected size 25, got %ld\n", size);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* try a NULL hinf */
|
|
|
|
hr = pCloseINFEngine(NULL);
|
|
|
|
ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got %ld\n", hr);
|
|
|
|
|
|
|
|
/* successfully close the hinf */
|
|
|
|
hr = pCloseINFEngine(hinf);
|
|
|
|
ok(hr == S_OK, "Expected S_OK, got %ld\n", hr);
|
|
|
|
|
|
|
|
/* open the inf with the install section */
|
|
|
|
hr = pOpenINFEngine("c:\\test.inf", "section", 0, &hinf, NULL);
|
|
|
|
ok(hr == S_OK, "Expected S_OK, got %ld\n", hr);
|
|
|
|
|
|
|
|
/* translate the string with the install section specified */
|
|
|
|
size = MAX_PATH;
|
|
|
|
hr = pTranslateInfStringEx(hinf, "c:\\test.inf", "Options.NTx86", "InstallDir",
|
|
|
|
buffer, size, &size, NULL);
|
|
|
|
ok(hr == S_OK, "Expected S_OK, got %ld\n", hr);
|
2006-02-27 20:50:25 +01:00
|
|
|
ok(!strcmp(buffer, PROG_FILES), "Expected %s, got %s\n", PROG_FILES, buffer);
|
|
|
|
ok(size == PROG_FILES_LEN, "Expected size %ld, got %ld\n", PROG_FILES_LEN, size);
|
2006-02-27 20:50:03 +01:00
|
|
|
|
|
|
|
/* close the INF again */
|
|
|
|
hr = pCloseINFEngine(hinf);
|
|
|
|
ok(hr == S_OK, "Expected S_OK, got %ld\n", hr);
|
|
|
|
|
|
|
|
DeleteFileA("c:\\test.inf");
|
|
|
|
}
|
|
|
|
|
2006-04-06 10:48:49 +02:00
|
|
|
static BOOL check_reg_str(HKEY hkey, LPSTR name, LPSTR value)
|
|
|
|
{
|
|
|
|
DWORD size = MAX_PATH;
|
|
|
|
char check[MAX_PATH];
|
|
|
|
|
|
|
|
if (RegQueryValueEx(hkey, name, NULL, NULL, (LPBYTE)check, &size))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
return !lstrcmp(check, value);
|
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL check_reg_dword(HKEY hkey, LPSTR name, DWORD value)
|
|
|
|
{
|
|
|
|
DWORD size = sizeof(DWORD);
|
|
|
|
DWORD check;
|
|
|
|
|
|
|
|
if (RegQueryValueEx(hkey, name, NULL, NULL, (LPBYTE)&check, &size))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
return (check == value);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void setperusersecvalues_test()
|
|
|
|
{
|
|
|
|
PERUSERSECTION peruser;
|
|
|
|
HRESULT hr;
|
|
|
|
HKEY guid;
|
|
|
|
|
|
|
|
lstrcpy(peruser.szDispName, "displayname");
|
|
|
|
lstrcpy(peruser.szLocale, "locale");
|
|
|
|
lstrcpy(peruser.szStub, "stub");
|
|
|
|
lstrcpy(peruser.szVersion, "1,1,1,1");
|
|
|
|
lstrcpy(peruser.szCompID, "compid");
|
|
|
|
peruser.dwIsInstalled = 1;
|
|
|
|
peruser.bRollback = FALSE;
|
|
|
|
|
2006-04-07 15:30:21 +02:00
|
|
|
/* try a NULL pPerUser */
|
|
|
|
hr = pSetPerUserSecValues(NULL);
|
|
|
|
todo_wine
|
2006-04-08 08:03:30 +02:00
|
|
|
ok(hr == S_OK, "Expected S_OK, got %ld\n", hr);
|
2006-04-07 15:30:21 +02:00
|
|
|
ok(!OPEN_GUID_KEY(), "Expected guid key to not exist\n");
|
|
|
|
|
|
|
|
/* at the very least, szGUID must be valid */
|
|
|
|
peruser.szGUID[0] = '\0';
|
|
|
|
hr = pSetPerUserSecValues(&peruser);
|
2006-04-08 08:03:30 +02:00
|
|
|
ok(hr == S_OK, "Expected S_OK, got %ld\n", hr);
|
2006-04-07 15:30:21 +02:00
|
|
|
ok(!OPEN_GUID_KEY(), "Expected guid key to not exist\n");
|
|
|
|
|
2006-04-06 10:48:49 +02:00
|
|
|
/* set initial values */
|
2006-04-07 15:30:21 +02:00
|
|
|
lstrcpy(peruser.szGUID, "guid");
|
2006-04-06 10:48:49 +02:00
|
|
|
hr = pSetPerUserSecValues(&peruser);
|
2006-04-08 08:03:30 +02:00
|
|
|
ok(hr == S_OK, "Expected S_OK, got %ld\n", hr);
|
|
|
|
ok(OPEN_GUID_KEY(), "Expected guid key to exist\n");
|
|
|
|
ok(check_reg_str(guid, NULL, "displayname"), "Expected displayname\n");
|
|
|
|
ok(check_reg_str(guid, "ComponentID", "compid"), "Expected compid\n");
|
|
|
|
ok(check_reg_str(guid, "Locale", "locale"), "Expected locale\n");
|
|
|
|
ok(check_reg_str(guid, "StubPath", "stub"), "Expected stub\n");
|
|
|
|
ok(check_reg_str(guid, "Version", "1,1,1,1"), "Expected 1,1,1,1\n");
|
|
|
|
ok(check_reg_dword(guid, "IsInstalled", 1), "Expected 1\n");
|
2006-04-06 10:48:49 +02:00
|
|
|
ok(!REG_VAL_EXISTS(guid, "OldDisplayName"), "Expected OldDisplayName to not exist\n");
|
|
|
|
ok(!REG_VAL_EXISTS(guid, "OldLocale"), "Expected OldLocale to not exist\n");
|
|
|
|
ok(!REG_VAL_EXISTS(guid, "OldStubPath"), "Expected OldStubPath to not exist\n");
|
|
|
|
ok(!REG_VAL_EXISTS(guid, "OldVersion"), "Expected OldVersion to not exist\n");
|
|
|
|
ok(!REG_VAL_EXISTS(guid, "RealStubPath"), "Expected RealStubPath to not exist\n");
|
|
|
|
|
|
|
|
/* raise the version, but bRollback is FALSE, so vals not saved */
|
|
|
|
lstrcpy(peruser.szVersion, "2,1,1,1");
|
|
|
|
hr = pSetPerUserSecValues(&peruser);
|
2006-04-08 08:03:30 +02:00
|
|
|
ok(hr == S_OK, "Expected S_OK, got %ld\n", hr);
|
|
|
|
ok(check_reg_str(guid, NULL, "displayname"), "Expected displayname\n");
|
|
|
|
ok(check_reg_str(guid, "ComponentID", "compid"), "Expected compid\n");
|
|
|
|
ok(check_reg_str(guid, "Locale", "locale"), "Expected locale\n");
|
|
|
|
ok(check_reg_str(guid, "StubPath", "stub"), "Expected stub\n");
|
|
|
|
ok(check_reg_str(guid, "Version", "2,1,1,1"), "Expected 2,1,1,1\n");
|
|
|
|
ok(check_reg_dword(guid, "IsInstalled", 1), "Expected 1\n");
|
2006-04-06 10:48:49 +02:00
|
|
|
ok(!REG_VAL_EXISTS(guid, "OldDisplayName"), "Expected OldDisplayName to not exist\n");
|
|
|
|
ok(!REG_VAL_EXISTS(guid, "OldLocale"), "Expected OldLocale to not exist\n");
|
|
|
|
ok(!REG_VAL_EXISTS(guid, "OldStubPath"), "Expected OldStubPath to not exist\n");
|
|
|
|
ok(!REG_VAL_EXISTS(guid, "OldVersion"), "Expected OldVersion to not exist\n");
|
|
|
|
ok(!REG_VAL_EXISTS(guid, "RealStubPath"), "Expected RealStubPath to not exist\n");
|
|
|
|
|
|
|
|
/* raise the version again, bRollback is TRUE so vals are saved */
|
2006-04-08 08:03:30 +02:00
|
|
|
peruser.bRollback = TRUE;
|
2006-04-06 10:48:49 +02:00
|
|
|
lstrcpy(peruser.szVersion, "3,1,1,1");
|
|
|
|
hr = pSetPerUserSecValues(&peruser);
|
2006-04-08 08:03:30 +02:00
|
|
|
ok(hr == S_OK, "Expected S_OK, got %ld\n", hr);
|
|
|
|
ok(check_reg_str(guid, NULL, "displayname"), "Expected displayname\n");
|
|
|
|
ok(check_reg_str(guid, "ComponentID", "compid"), "Expected compid\n");
|
|
|
|
ok(check_reg_str(guid, "Locale", "locale"), "Expected locale\n");
|
|
|
|
ok(check_reg_dword(guid, "IsInstalled", 1), "Expected 1\n");
|
|
|
|
ok(check_reg_str(guid, "Version", "3,1,1,1"), "Expected 3,1,1,1\n");
|
2006-04-06 10:48:49 +02:00
|
|
|
todo_wine
|
|
|
|
{
|
|
|
|
ok(check_reg_str(guid, "OldDisplayName", "displayname"), "Expected displayname\n");
|
|
|
|
ok(check_reg_str(guid, "OldLocale", "locale"), "Expected locale\n");
|
|
|
|
ok(check_reg_str(guid, "RealStubPath", "stub"), "Expected stub\n");
|
|
|
|
ok(check_reg_str(guid, "OldStubPath", "stub"), "Expected stub\n");
|
|
|
|
ok(check_reg_str(guid, "OldVersion", "2,1,1,1"), "Expected 2,1,1,1\n");
|
|
|
|
ok(check_reg_str(guid, "StubPath",
|
|
|
|
"rundll32.exe advpack.dll,UserInstStubWrapper guid"),
|
|
|
|
"Expected real stub\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
RegDeleteKey(HKEY_LOCAL_MACHINE, GUID_KEY);
|
|
|
|
}
|
|
|
|
|
2005-01-20 21:03:13 +01:00
|
|
|
START_TEST(advpack)
|
|
|
|
{
|
2006-02-27 20:49:50 +01:00
|
|
|
if (!init_function_pointers())
|
2005-02-14 12:02:46 +01:00
|
|
|
return;
|
|
|
|
|
2006-02-27 20:50:25 +01:00
|
|
|
get_progfiles_dir();
|
|
|
|
|
2005-01-20 21:03:13 +01:00
|
|
|
version_test();
|
2005-04-27 11:37:25 +02:00
|
|
|
delnode_test();
|
2006-04-06 10:48:49 +02:00
|
|
|
setperusersecvalues_test();
|
2005-11-08 13:43:35 +01:00
|
|
|
translateinfstring_test();
|
2006-02-27 20:50:03 +01:00
|
|
|
translateinfstringex_test();
|
2005-01-20 21:03:13 +01:00
|
|
|
}
|