advapi32: Add tests for RegQueryValueEx to show that it sets the data
size to 0 when a buffer isn't present and that it sets the type to REG_NONE on Win9x.
This commit is contained in:
parent
ce5c4d38c4
commit
bc590e87a6
|
@ -1142,7 +1142,11 @@ LONG WINAPI RegQueryValueExW( HKEY hkey, LPCWSTR name, LPDWORD reserved, LPDWORD
|
|||
RtlInitUnicodeString( &name_str, name );
|
||||
|
||||
if (data) total_size = min( sizeof(buffer), *count + info_size );
|
||||
else total_size = info_size;
|
||||
else
|
||||
{
|
||||
total_size = info_size;
|
||||
if (count) *count = 0;
|
||||
}
|
||||
|
||||
status = NtQueryValueKey( hkey, &name_str, KeyValuePartialInformation,
|
||||
buffer, total_size, &total_size );
|
||||
|
@ -1224,6 +1228,11 @@ LONG WINAPI RegQueryValueExA( HKEY hkey, LPCSTR name, LPDWORD reserved, LPDWORD
|
|||
if ((data && !count) || reserved) return ERROR_INVALID_PARAMETER;
|
||||
if (!(hkey = get_special_root_hkey( hkey ))) return ERROR_INVALID_HANDLE;
|
||||
|
||||
if (!data && count) *count = 0;
|
||||
|
||||
/* this matches Win9x behaviour - NT sets *type to a random value */
|
||||
if (type) *type = REG_NONE;
|
||||
|
||||
RtlInitAnsiString( &nameA, name );
|
||||
if ((status = RtlAnsiStringToUnicodeString( &NtCurrentTeb()->StaticUnicodeString,
|
||||
&nameA, FALSE )))
|
||||
|
|
|
@ -333,11 +333,25 @@ static void test_query_value_ex(void)
|
|||
DWORD ret;
|
||||
DWORD size;
|
||||
DWORD type;
|
||||
BYTE buffer[10];
|
||||
|
||||
ret = RegQueryValueExA(hkey_main, "TP1_SZ", NULL, &type, NULL, &size);
|
||||
ok(ret == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %ld\n", ret);
|
||||
ok(size == strlen(sTestpath1) + 1, "(%ld,%ld)\n", (DWORD)strlen(sTestpath1) + 1, size);
|
||||
ok(type == REG_SZ, "type %ld is not REG_SZ\n", type);
|
||||
|
||||
type = 0xdeadbeef;
|
||||
size = 0xdeadbeef;
|
||||
ret = RegQueryValueExA(HKEY_CLASSES_ROOT, "Non Existent Value", NULL, &type, NULL, &size);
|
||||
ok(ret == ERROR_FILE_NOT_FOUND, "expected ERROR_FILE_NOT_FOUND, got %ld\n", ret);
|
||||
ok(size == 0, "size should have been set to 0 instead of %ld\n", size);
|
||||
ok(type == (DWORD)HKEY_CLASSES_ROOT /* NT */ || type == 0 /* Win9x */,
|
||||
"type should have been set to 0x80000000 or 0 instead of 0x%lx\n", type);
|
||||
|
||||
size = sizeof(buffer);
|
||||
ret = RegQueryValueExA(HKEY_CLASSES_ROOT, "Non Existent Value", NULL, &type, buffer, &size);
|
||||
ok(ret == ERROR_FILE_NOT_FOUND, "expected ERROR_FILE_NOT_FOUND, got %ld\n", ret);
|
||||
ok(size == sizeof(buffer), "size shouldn't have been changed to %ld\n", size);
|
||||
}
|
||||
|
||||
static void test_get_value(void)
|
||||
|
|
Loading…
Reference in New Issue