setupapi: Brace the guid in SetupDiOpenClassRegKeyExW.

This commit is contained in:
Damjan Jovanovic 2006-09-21 16:15:14 +02:00 committed by Alexandre Julliard
parent 9ae4e8d98e
commit e6e96d3ea1
3 changed files with 33 additions and 4 deletions

View File

@ -1413,6 +1413,7 @@ HKEY WINAPI SetupDiOpenClassRegKeyExW(
PVOID Reserved) PVOID Reserved)
{ {
LPWSTR lpGuidString; LPWSTR lpGuidString;
WCHAR bracedGuidString[39];
HKEY hClassesKey; HKEY hClassesKey;
HKEY hClassKey; HKEY hClassKey;
LPCWSTR lpKeyName; LPCWSTR lpKeyName;
@ -1455,19 +1456,22 @@ HKEY WINAPI SetupDiOpenClassRegKeyExW(
RegCloseKey(hClassesKey); RegCloseKey(hClassesKey);
return INVALID_HANDLE_VALUE; return INVALID_HANDLE_VALUE;
} }
bracedGuidString[0] = '{';
memcpy(&bracedGuidString[1], lpGuidString, 36*sizeof(WCHAR));
bracedGuidString[37] = '}';
bracedGuidString[38] = 0;
RpcStringFreeW(&lpGuidString);
if (RegOpenKeyExW(hClassesKey, if (RegOpenKeyExW(hClassesKey,
lpGuidString, bracedGuidString,
0, 0,
KEY_ALL_ACCESS, KEY_ALL_ACCESS,
&hClassKey)) &hClassKey))
{ {
RpcStringFreeW(&lpGuidString);
RegCloseKey(hClassesKey); RegCloseKey(hClassesKey);
return INVALID_HANDLE_VALUE; return INVALID_HANDLE_VALUE;
} }
RpcStringFreeW(&lpGuidString);
RegCloseKey(hClassesKey); RegCloseKey(hClassesKey);
return hClassKey; return hClassKey;

View File

@ -3,7 +3,7 @@ TOPOBJDIR = ../../..
SRCDIR = @srcdir@ SRCDIR = @srcdir@
VPATH = @srcdir@ VPATH = @srcdir@
TESTDLL = setupapi.dll TESTDLL = setupapi.dll
IMPORTS = setupapi kernel32 IMPORTS = setupapi advapi32 kernel32
CTESTS = \ CTESTS = \
devinst.c \ devinst.c \

View File

@ -87,6 +87,7 @@ static void test_SetupDiOpenClassRegKeyExA(void)
/* This is a unique guid for testing purposes */ /* This is a unique guid for testing purposes */
GUID guid = {0x6a55b5a4, 0x3f65, 0x11db, {0xb7,0x04, GUID guid = {0x6a55b5a4, 0x3f65, 0x11db, {0xb7,0x04,
0x00,0x11,0x95,0x5c,0x2b,0xdb}}; 0x00,0x11,0x95,0x5c,0x2b,0xdb}};
static const CHAR guidString[] = "{6a55b5a4-3f65-11db-b704-0011955c2bdb}";
HKEY hkey; HKEY hkey;
/* Check return value for non-existent key */ /* Check return value for non-existent key */
@ -94,6 +95,30 @@ static void test_SetupDiOpenClassRegKeyExA(void)
DIOCR_INSTALLER, NULL, NULL); DIOCR_INSTALLER, NULL, NULL);
ok(hkey == INVALID_HANDLE_VALUE, ok(hkey == INVALID_HANDLE_VALUE,
"returned %p (expected INVALID_HANDLE_VALUE)\n", hkey); "returned %p (expected INVALID_HANDLE_VALUE)\n", hkey);
/* Test it for a key that exists */
hkey = SetupDiOpenClassRegKey(NULL, KEY_ALL_ACCESS);
if (hkey != INVALID_HANDLE_VALUE)
{
HKEY classKey;
if (RegCreateKeyA(hkey, guidString, &classKey) == ERROR_SUCCESS)
{
RegCloseKey(classKey);
SetLastError(0xdeadbeef);
classKey = pSetupDiOpenClassRegKeyExA(&guid, KEY_ALL_ACCESS,
DIOCR_INSTALLER, NULL, NULL);
ok(classKey != INVALID_HANDLE_VALUE,
"opening class registry key failed with error %ld\n",
GetLastError());
if (classKey != INVALID_HANDLE_VALUE)
RegCloseKey(classKey);
RegDeleteKeyA(hkey, guidString);
}
else
trace("failed to create registry key for test\n");
}
else
trace("failed to open classes key\n");
} }
START_TEST(devinst) START_TEST(devinst)