Commit bc590e87 authored by Robert Shearman's avatar Robert Shearman Committed by Alexandre Julliard

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.
parent ce5c4d38
......@@ -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)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment