2 * Unit tests for registry functions
4 * Copyright (c) 2002 Alexandre Julliard
5 * Copyright (c) 2010 André Hentschel
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
25 #include "wine/test.h"
35 #define IS_HKCR(hk) ((UINT_PTR)hk > 0 && ((UINT_PTR)hk & 3) == 2)
37 static HKEY hkey_main
;
40 static const char * sTestpath1
= "%LONGSYSTEMVAR%\\subdir1";
41 static const char * sTestpath2
= "%FOO%\\subdir1";
42 static const DWORD ptr_size
= 8 * sizeof(void*);
44 static DWORD (WINAPI
*pRegGetValueA
)(HKEY
,LPCSTR
,LPCSTR
,DWORD
,LPDWORD
,PVOID
,LPDWORD
);
45 static LONG (WINAPI
*pRegCopyTreeA
)(HKEY
,const char *,HKEY
);
46 static LONG (WINAPI
*pRegDeleteTreeA
)(HKEY
,const char *);
47 static DWORD (WINAPI
*pRegDeleteKeyExA
)(HKEY
,LPCSTR
,REGSAM
,DWORD
);
48 static BOOL (WINAPI
*pIsWow64Process
)(HANDLE
,PBOOL
);
49 static NTSTATUS (WINAPI
* pNtDeleteKey
)(HANDLE
);
50 static NTSTATUS (WINAPI
* pRtlFormatCurrentUserKeyPath
)(UNICODE_STRING
*);
51 static NTSTATUS (WINAPI
* pRtlFreeUnicodeString
)(PUNICODE_STRING
);
52 static LONG (WINAPI
*pRegDeleteKeyValueA
)(HKEY
,LPCSTR
,LPCSTR
);
53 static LONG (WINAPI
*pRegSetKeyValueW
)(HKEY
,LPCWSTR
,LPCWSTR
,DWORD
,const void*,DWORD
);
54 static LONG (WINAPI
*pRegLoadMUIStringA
)(HKEY
,LPCSTR
,LPSTR
,DWORD
,LPDWORD
,DWORD
,LPCSTR
);
55 static LONG (WINAPI
*pRegLoadMUIStringW
)(HKEY
,LPCWSTR
,LPWSTR
,DWORD
,LPDWORD
,DWORD
,LPCWSTR
);
57 static BOOL limited_user
;
60 /* Debugging functions from wine/libs/wine/debug.c */
62 /* allocate some tmp string space */
63 /* FIXME: this is not 100% thread-safe */
64 static char *get_temp_buffer( int size
)
66 static char *list
[32];
71 idx
= ++pos
% ARRAY_SIZE(list
);
73 ret
= HeapReAlloc( GetProcessHeap(), 0, list
[idx
], size
);
75 ret
= HeapAlloc( GetProcessHeap(), 0, size
);
76 if (ret
) list
[idx
] = ret
;
80 static const char *wine_debugstr_an( const char *str
, int n
)
82 static const char hex
[16] = "0123456789abcdef";
86 if (!((ULONG_PTR
)str
>> 16))
88 if (!str
) return "(null)";
89 res
= get_temp_buffer( 6 );
90 sprintf( res
, "#%04x", LOWORD(str
) );
93 if (n
== -1) n
= strlen(str
);
95 size
= 10 + min( 300, n
* 4 );
96 dst
= res
= get_temp_buffer( size
);
98 while (n
-- > 0 && dst
<= res
+ size
- 9)
100 unsigned char c
= *str
++;
103 case '\n': *dst
++ = '\\'; *dst
++ = 'n'; break;
104 case '\r': *dst
++ = '\\'; *dst
++ = 'r'; break;
105 case '\t': *dst
++ = '\\'; *dst
++ = 't'; break;
106 case '"': *dst
++ = '\\'; *dst
++ = '"'; break;
107 case '\\': *dst
++ = '\\'; *dst
++ = '\\'; break;
109 if (c
>= ' ' && c
<= 126)
115 *dst
++ = hex
[(c
>> 4) & 0x0f];
116 *dst
++ = hex
[c
& 0x0f];
131 #define ADVAPI32_GET_PROC(func) \
132 p ## func = (void*)GetProcAddress(hadvapi32, #func)
134 static void InitFunctionPtrs(void)
136 HMODULE hntdll
= GetModuleHandleA("ntdll.dll");
137 HMODULE hkernel32
= GetModuleHandleA("kernel32.dll");
138 HMODULE hadvapi32
= GetModuleHandleA("advapi32.dll");
140 /* This function was introduced with Windows 2003 SP1 */
141 ADVAPI32_GET_PROC(RegGetValueA
);
142 ADVAPI32_GET_PROC(RegCopyTreeA
);
143 ADVAPI32_GET_PROC(RegDeleteTreeA
);
144 ADVAPI32_GET_PROC(RegDeleteKeyExA
);
145 ADVAPI32_GET_PROC(RegDeleteKeyValueA
);
146 ADVAPI32_GET_PROC(RegSetKeyValueW
);
147 ADVAPI32_GET_PROC(RegLoadMUIStringA
);
148 ADVAPI32_GET_PROC(RegLoadMUIStringW
);
150 pIsWow64Process
= (void *)GetProcAddress( hkernel32
, "IsWow64Process" );
151 pRtlFormatCurrentUserKeyPath
= (void *)GetProcAddress( hntdll
, "RtlFormatCurrentUserKeyPath" );
152 pRtlFreeUnicodeString
= (void *)GetProcAddress(hntdll
, "RtlFreeUnicodeString");
153 pNtDeleteKey
= (void *)GetProcAddress( hntdll
, "NtDeleteKey" );
156 /* delete key and all its subkeys */
157 static DWORD
delete_key( HKEY hkey
)
162 if ((ret
= RegOpenKeyExA( hkey
, "", 0, KEY_ENUMERATE_SUB_KEYS
, &hkey
))) return ret
;
163 while (!(ret
= RegEnumKeyA(hkey
, 0, name
, sizeof(name
))))
166 if (!(ret
= RegOpenKeyExA( hkey
, name
, 0, KEY_ENUMERATE_SUB_KEYS
, &tmp
)))
168 ret
= delete_key( tmp
);
173 if (ret
!= ERROR_NO_MORE_ITEMS
) return ret
;
174 RegDeleteKeyA( hkey
, "" );
179 static void setup_main_key(void)
183 if (!RegOpenKeyA( HKEY_CURRENT_USER
, "Software\\Wine\\Test", &hkey_main
)) delete_key( hkey_main
);
185 ret
= RegCreateKeyA( HKEY_CURRENT_USER
, "Software\\Wine\\Test", &hkey_main
);
186 ok(ret
== ERROR_SUCCESS
, "expected ERROR_SUCCESS, got %d\n", ret
);
189 static void check_user_privs(void)
192 HKEY hkey
= (HKEY
)0xdeadbeef;
194 ret
= RegOpenKeyExA( HKEY_LOCAL_MACHINE
, "Software", 0, KEY_READ
|KEY_WRITE
, &hkey
);
195 ok(ret
== ERROR_SUCCESS
|| ret
== ERROR_ACCESS_DENIED
, "expected success or access denied, got %i\n", ret
);
196 if (ret
== ERROR_SUCCESS
)
198 ok(hkey
!= NULL
, "RegOpenKeyExA succeeded but returned NULL hkey\n");
203 ok(hkey
== NULL
, "RegOpenKeyExA failed but returned hkey %p\n", hkey
);
205 trace("running as limited user\n");
209 #define lok ok_(__FILE__, line)
210 #define test_hkey_main_Value_A(name, string, full_byte_len) _test_hkey_main_Value_A(__LINE__, name, string, full_byte_len)
211 static void _test_hkey_main_Value_A(int line
, LPCSTR name
, LPCSTR string
,
214 DWORD ret
, type
, cbData
;
220 /* When successful RegQueryValueExA() leaves GLE as is,
221 * so we must reset it to detect unimplemented functions.
223 SetLastError(0xdeadbeef);
224 ret
= RegQueryValueExA(hkey_main
, name
, NULL
, &type
, NULL
, &cbData
);
225 GLE
= GetLastError();
226 lok(ret
== ERROR_SUCCESS
, "RegQueryValueExA/1 failed: %d, GLE=%d\n", ret
, GLE
);
227 /* It is wrong for the Ansi version to not be implemented */
228 ok(GLE
== 0xdeadbeef, "RegQueryValueExA set GLE = %u\n", GLE
);
229 if(GLE
== ERROR_CALL_NOT_IMPLEMENTED
) return;
231 str_byte_len
= (string
? lstrlenA(string
) : 0) + 1;
232 lok(type
== REG_SZ
, "RegQueryValueExA/1 returned type %d\n", type
);
233 lok(cbData
== full_byte_len
, "cbData=%d instead of %d or %d\n", cbData
, full_byte_len
, str_byte_len
);
235 value
= HeapAlloc(GetProcessHeap(), 0, cbData
+1);
236 memset(value
, 0xbd, cbData
+1);
238 ret
= RegQueryValueExA(hkey_main
, name
, NULL
, &type
, value
, &cbData
);
239 GLE
= GetLastError();
240 lok(ret
== ERROR_SUCCESS
, "RegQueryValueExA/2 failed: %d, GLE=%d\n", ret
, GLE
);
243 /* When cbData == 0, RegQueryValueExA() should not modify the buffer */
244 lok(*value
== 0xbd, "RegQueryValueExA overflowed: cbData=%u *value=%02x\n", cbData
, *value
);
248 lok(memcmp(value
, string
, cbData
) == 0, "RegQueryValueExA/2 failed: %s/%d != %s/%d\n",
249 wine_debugstr_an((char*)value
, cbData
), cbData
,
250 wine_debugstr_an(string
, full_byte_len
), full_byte_len
);
251 lok(*(value
+cbData
) == 0xbd, "RegQueryValueExA/2 overflowed at offset %u: %02x != bd\n", cbData
, *(value
+cbData
));
253 HeapFree(GetProcessHeap(), 0, value
);
256 #define test_hkey_main_Value_W(name, string, full_byte_len) _test_hkey_main_Value_W(__LINE__, name, string, full_byte_len)
257 static void _test_hkey_main_Value_W(int line
, LPCWSTR name
, LPCWSTR string
,
260 DWORD ret
, type
, cbData
;
265 /* When successful RegQueryValueExW() leaves GLE as is,
266 * so we must reset it to detect unimplemented functions.
268 SetLastError(0xdeadbeef);
269 ret
= RegQueryValueExW(hkey_main
, name
, NULL
, &type
, NULL
, &cbData
);
270 GLE
= GetLastError();
271 lok(ret
== ERROR_SUCCESS
, "RegQueryValueExW/1 failed: %d, GLE=%d\n", ret
, GLE
);
272 if(GLE
== ERROR_CALL_NOT_IMPLEMENTED
)
274 win_skip("RegQueryValueExW() is not implemented\n");
278 lok(type
== REG_SZ
, "RegQueryValueExW/1 returned type %d\n", type
);
279 lok(cbData
== full_byte_len
,
280 "cbData=%d instead of %d\n", cbData
, full_byte_len
);
282 /* Give enough space to overflow by one WCHAR */
283 value
= HeapAlloc(GetProcessHeap(), 0, cbData
+2);
284 memset(value
, 0xbd, cbData
+2);
286 ret
= RegQueryValueExW(hkey_main
, name
, NULL
, &type
, value
, &cbData
);
287 GLE
= GetLastError();
288 lok(ret
== ERROR_SUCCESS
, "RegQueryValueExW/2 failed: %d, GLE=%d\n", ret
, GLE
);
291 lok(memcmp(value
, string
, cbData
) == 0, "RegQueryValueExW failed: %s/%d != %s/%d\n",
292 wine_dbgstr_wn((WCHAR
*)value
, cbData
/ sizeof(WCHAR
)), cbData
,
293 wine_dbgstr_wn(string
, full_byte_len
/ sizeof(WCHAR
)), full_byte_len
);
295 /* This implies that when cbData == 0, RegQueryValueExW() should not modify the buffer */
296 lok(*(value
+cbData
) == 0xbd, "RegQueryValueExW/2 overflowed at %u: %02x != bd\n", cbData
, *(value
+cbData
));
297 lok(*(value
+cbData
+1) == 0xbd, "RegQueryValueExW/2 overflowed at %u+1: %02x != bd\n", cbData
, *(value
+cbData
+1));
298 HeapFree(GetProcessHeap(), 0, value
);
301 static void test_set_value(void)
305 static const WCHAR name1W
[] = {'C','l','e','a','n','S','i','n','g','l','e','S','t','r','i','n','g', 0};
306 static const WCHAR name2W
[] = {'S','o','m','e','I','n','t','r','a','Z','e','r','o','e','d','S','t','r','i','n','g', 0};
307 static const WCHAR emptyW
[] = {0};
308 static const WCHAR string1W
[] = {'T','h','i','s','N','e','v','e','r','B','r','e','a','k','s', 0};
309 static const WCHAR string2W
[] = {'T','h','i','s', 0 ,'B','r','e','a','k','s', 0 , 0 ,'A', 0 , 0 , 0 , 'L','o','t', 0 , 0 , 0 , 0, 0};
310 static const WCHAR substring2W
[] = {'T','h','i','s',0};
312 static const char name1A
[] = "CleanSingleString";
313 static const char name2A
[] = "SomeIntraZeroedString";
314 static const char emptyA
[] = "";
315 static const char string1A
[] = "ThisNeverBreaks";
316 static const char string2A
[] = "This\0Breaks\0\0A\0\0\0Lot\0\0\0\0";
317 static const char substring2A
[] = "This";
321 /* Crashes on NT4, Windows 2000 and XP SP1 */
322 ret
= RegSetValueA(hkey_main
, NULL
, REG_SZ
, NULL
, 0);
323 ok(ret
== ERROR_INVALID_PARAMETER
, "RegSetValueA should have failed with ERROR_INVALID_PARAMETER instead of %d\n", ret
);
326 ret
= RegSetValueA(hkey_main
, NULL
, REG_SZ
, string1A
, sizeof(string1A
));
327 ok(ret
== ERROR_SUCCESS
, "RegSetValueA failed: %d, GLE=%d\n", ret
, GetLastError());
328 test_hkey_main_Value_A(NULL
, string1A
, sizeof(string1A
));
329 test_hkey_main_Value_W(NULL
, string1W
, sizeof(string1W
));
331 /* RegSetValueA ignores the size passed in */
332 ret
= RegSetValueA(hkey_main
, NULL
, REG_SZ
, string1A
, 4);
333 ok(ret
== ERROR_SUCCESS
, "RegSetValueA failed: %d, GLE=%d\n", ret
, GetLastError());
334 test_hkey_main_Value_A(NULL
, string1A
, sizeof(string1A
));
335 test_hkey_main_Value_W(NULL
, string1W
, sizeof(string1W
));
337 /* stops at first null */
338 ret
= RegSetValueA(hkey_main
, NULL
, REG_SZ
, string2A
, sizeof(string2A
));
339 ok(ret
== ERROR_SUCCESS
, "RegSetValueA failed: %d, GLE=%d\n", ret
, GetLastError());
340 test_hkey_main_Value_A(NULL
, substring2A
, sizeof(substring2A
));
341 test_hkey_main_Value_W(NULL
, substring2W
, sizeof(substring2W
));
343 /* only REG_SZ is supported on NT*/
344 ret
= RegSetValueA(hkey_main
, NULL
, REG_BINARY
, string2A
, sizeof(string2A
));
345 ok(ret
== ERROR_INVALID_PARAMETER
, "got %d (expected ERROR_INVALID_PARAMETER)\n", ret
);
347 ret
= RegSetValueA(hkey_main
, NULL
, REG_EXPAND_SZ
, string2A
, sizeof(string2A
));
348 ok(ret
== ERROR_INVALID_PARAMETER
, "got %d (expected ERROR_INVALID_PARAMETER)\n", ret
);
350 ret
= RegSetValueA(hkey_main
, NULL
, REG_MULTI_SZ
, string2A
, sizeof(string2A
));
351 ok(ret
== ERROR_INVALID_PARAMETER
, "got %d (expected ERROR_INVALID_PARAMETER)\n", ret
);
353 /* Test RegSetValueExA with a 'zero-byte' string (as Office 2003 does).
354 * Surprisingly enough we're supposed to get zero bytes out of it.
356 ret
= RegSetValueExA(hkey_main
, name1A
, 0, REG_SZ
, (const BYTE
*)emptyA
, 0);
357 ok(ret
== ERROR_SUCCESS
, "RegSetValueExA failed: %d, GLE=%d\n", ret
, GetLastError());
358 test_hkey_main_Value_A(name1A
, NULL
, 0);
359 test_hkey_main_Value_W(name1W
, NULL
, 0);
361 /* test RegSetValueExA with an empty string */
362 ret
= RegSetValueExA(hkey_main
, name1A
, 0, REG_SZ
, (const BYTE
*)emptyA
, sizeof(emptyA
));
363 ok(ret
== ERROR_SUCCESS
, "RegSetValueExA failed: %d, GLE=%d\n", ret
, GetLastError());
364 test_hkey_main_Value_A(name1A
, emptyA
, sizeof(emptyA
));
365 test_hkey_main_Value_W(name1W
, emptyW
, sizeof(emptyW
));
367 /* test RegSetValueExA with off-by-one size */
368 ret
= RegSetValueExA(hkey_main
, name1A
, 0, REG_SZ
, (const BYTE
*)string1A
, sizeof(string1A
)-sizeof(string1A
[0]));
369 ok(ret
== ERROR_SUCCESS
, "RegSetValueExA failed: %d, GLE=%d\n", ret
, GetLastError());
370 test_hkey_main_Value_A(name1A
, string1A
, sizeof(string1A
));
371 test_hkey_main_Value_W(name1W
, string1W
, sizeof(string1W
));
373 /* test RegSetValueExA with normal string */
374 ret
= RegSetValueExA(hkey_main
, name1A
, 0, REG_SZ
, (const BYTE
*)string1A
, sizeof(string1A
));
375 ok(ret
== ERROR_SUCCESS
, "RegSetValueExA failed: %d, GLE=%d\n", ret
, GetLastError());
376 test_hkey_main_Value_A(name1A
, string1A
, sizeof(string1A
));
377 test_hkey_main_Value_W(name1W
, string1W
, sizeof(string1W
));
379 /* test RegSetValueExA with intrazeroed string */
380 ret
= RegSetValueExA(hkey_main
, name2A
, 0, REG_SZ
, (const BYTE
*)string2A
, sizeof(string2A
));
381 ok(ret
== ERROR_SUCCESS
, "RegSetValueExA failed: %d, GLE=%d\n", ret
, GetLastError());
382 test_hkey_main_Value_A(name2A
, string2A
, sizeof(string2A
));
383 test_hkey_main_Value_W(name2W
, string2W
, sizeof(string2W
));
387 /* Crashes on NT4, Windows 2000 and XP SP1 */
388 ret
= RegSetValueW(hkey_main
, NULL
, REG_SZ
, NULL
, 0);
389 ok(ret
== ERROR_INVALID_PARAMETER
, "RegSetValueW should have failed with ERROR_INVALID_PARAMETER instead of %d\n", ret
);
391 RegSetValueExA(hkey_main
, name2A
, 0, REG_SZ
, (const BYTE
*)1, 1);
392 RegSetValueExA(hkey_main
, name2A
, 0, REG_DWORD
, (const BYTE
*)1, 1);
395 ret
= RegSetValueW(hkey_main
, NULL
, REG_SZ
, string1W
, sizeof(string1W
));
396 ok(ret
== ERROR_SUCCESS
, "RegSetValueW failed: %d, GLE=%d\n", ret
, GetLastError());
397 test_hkey_main_Value_A(NULL
, string1A
, sizeof(string1A
));
398 test_hkey_main_Value_W(NULL
, string1W
, sizeof(string1W
));
400 ret
= RegSetValueW(hkey_main
, name1W
, REG_SZ
, string1W
, sizeof(string1W
));
401 ok(ret
== ERROR_SUCCESS
, "RegSetValueW failed: %d, GLE=%d\n", ret
, GetLastError());
402 test_hkey_main_Value_A(name1A
, string1A
, sizeof(string1A
));
403 test_hkey_main_Value_W(name1W
, string1W
, sizeof(string1W
));
405 /* RegSetValueW ignores the size passed in */
406 ret
= RegSetValueW(hkey_main
, NULL
, REG_SZ
, string1W
, 4 * sizeof(string1W
[0]));
407 ok(ret
== ERROR_SUCCESS
, "RegSetValueW failed: %d, GLE=%d\n", ret
, GetLastError());
408 test_hkey_main_Value_A(NULL
, string1A
, sizeof(string1A
));
409 test_hkey_main_Value_W(NULL
, string1W
, sizeof(string1W
));
411 /* stops at first null */
412 ret
= RegSetValueW(hkey_main
, NULL
, REG_SZ
, string2W
, sizeof(string2W
));
413 ok(ret
== ERROR_SUCCESS
, "RegSetValueW failed: %d, GLE=%d\n", ret
, GetLastError());
414 test_hkey_main_Value_A(NULL
, substring2A
, sizeof(substring2A
));
415 test_hkey_main_Value_W(NULL
, substring2W
, sizeof(substring2W
));
417 /* only REG_SZ is supported */
418 ret
= RegSetValueW(hkey_main
, NULL
, REG_BINARY
, string2W
, sizeof(string2W
));
419 ok(ret
== ERROR_INVALID_PARAMETER
, "RegSetValueW should have returned ERROR_INVALID_PARAMETER instead of %d\n", ret
);
420 ret
= RegSetValueW(hkey_main
, NULL
, REG_EXPAND_SZ
, string2W
, sizeof(string2W
));
421 ok(ret
== ERROR_INVALID_PARAMETER
, "RegSetValueW should have returned ERROR_INVALID_PARAMETER instead of %d\n", ret
);
422 ret
= RegSetValueW(hkey_main
, NULL
, REG_MULTI_SZ
, string2W
, sizeof(string2W
));
423 ok(ret
== ERROR_INVALID_PARAMETER
, "RegSetValueW should have returned ERROR_INVALID_PARAMETER instead of %d\n", ret
);
425 /* test RegSetValueExW with off-by-one size */
426 ret
= RegSetValueExW(hkey_main
, name1W
, 0, REG_SZ
, (const BYTE
*)string1W
, sizeof(string1W
)-sizeof(string1W
[0]));
427 ok(ret
== ERROR_SUCCESS
, "RegSetValueExW failed: %d, GLE=%d\n", ret
, GetLastError());
428 test_hkey_main_Value_A(name1A
, string1A
, sizeof(string1A
));
429 test_hkey_main_Value_W(name1W
, string1W
, sizeof(string1W
));
431 /* test RegSetValueExW with normal string */
432 ret
= RegSetValueExW(hkey_main
, name1W
, 0, REG_SZ
, (const BYTE
*)string1W
, sizeof(string1W
));
433 ok(ret
== ERROR_SUCCESS
, "RegSetValueExW failed: %d, GLE=%d\n", ret
, GetLastError());
434 test_hkey_main_Value_A(name1A
, string1A
, sizeof(string1A
));
435 test_hkey_main_Value_W(name1W
, string1W
, sizeof(string1W
));
437 /* test RegSetValueExW with intrazeroed string */
438 ret
= RegSetValueExW(hkey_main
, name2W
, 0, REG_SZ
, (const BYTE
*)string2W
, sizeof(string2W
));
439 ok(ret
== ERROR_SUCCESS
, "RegSetValueExW failed: %d, GLE=%d\n", ret
, GetLastError());
440 test_hkey_main_Value_A(name2A
, string2A
, sizeof(string2A
));
441 test_hkey_main_Value_W(name2W
, string2W
, sizeof(string2W
));
443 /* test RegSetValueExW with data = 1 */
444 ret
= RegSetValueExW(hkey_main
, name2W
, 0, REG_SZ
, (const BYTE
*)1, 1);
445 ok(ret
== ERROR_NOACCESS
, "RegSetValueExW should have failed with ERROR_NOACCESS: %d, GLE=%d\n", ret
, GetLastError());
446 ret
= RegSetValueExW(hkey_main
, name2W
, 0, REG_DWORD
, (const BYTE
*)1, 1);
447 ok(ret
== ERROR_NOACCESS
, "RegSetValueExW should have failed with ERROR_NOACCESS: %d, GLE=%d\n", ret
, GetLastError());
449 if (pRegGetValueA
) /* avoid a crash on Windows 2000 */
451 ret
= RegSetValueExW(hkey_main
, NULL
, 0, REG_SZ
, NULL
, 4);
452 ok(ret
== ERROR_NOACCESS
, "RegSetValueExW should have failed with ERROR_NOACCESS: %d, GLE=%d\n", ret
, GetLastError());
454 ret
= RegSetValueExW(hkey_main
, NULL
, 0, REG_SZ
, NULL
, 0);
455 ok(ret
== ERROR_SUCCESS
, "got %d\n", ret
);
457 ret
= RegSetValueExW(hkey_main
, NULL
, 0, REG_DWORD
, NULL
, 4);
458 ok(ret
== ERROR_NOACCESS
, "RegSetValueExW should have failed with ERROR_NOACCESS: %d, GLE=%d\n", ret
, GetLastError());
460 ret
= RegSetValueExW(hkey_main
, NULL
, 0, REG_DWORD
, NULL
, 0);
461 ok(ret
== ERROR_SUCCESS
, "got %d\n", ret
);
465 if (!pRegSetKeyValueW
)
466 win_skip("RegSetKeyValue() is not supported.\n");
469 static const WCHAR subkeyW
[] = {'s','u','b','k','e','y',0};
473 ret
= pRegSetKeyValueW(hkey_main
, NULL
, name1W
, REG_SZ
, (const BYTE
*)string2W
, sizeof(string2W
));
474 ok(ret
== ERROR_SUCCESS
, "got %d\n", ret
);
475 test_hkey_main_Value_A(name1A
, string2A
, sizeof(string2A
));
476 test_hkey_main_Value_W(name1W
, string2W
, sizeof(string2W
));
478 ret
= pRegSetKeyValueW(hkey_main
, subkeyW
, name1W
, REG_SZ
, string1W
, sizeof(string1W
));
479 ok(ret
== ERROR_SUCCESS
, "got %d\n", ret
);
481 ret
= RegOpenKeyExW(hkey_main
, subkeyW
, 0, KEY_QUERY_VALUE
, &subkey
);
482 ok(ret
== ERROR_SUCCESS
, "got %d\n", ret
);
484 ret
= RegQueryValueExW(subkey
, name1W
, 0, &type
, NULL
, &len
);
485 ok(ret
== ERROR_SUCCESS
, "got %d\n", ret
);
486 ok(len
== sizeof(string1W
), "got %d\n", len
);
487 ok(type
== REG_SZ
, "got type %d\n", type
);
489 ret
= pRegSetKeyValueW(hkey_main
, subkeyW
, name1W
, REG_SZ
, NULL
, 0);
490 ok(ret
== ERROR_SUCCESS
, "got %d\n", ret
);
492 ret
= pRegSetKeyValueW(hkey_main
, subkeyW
, name1W
, REG_SZ
, NULL
, 4);
493 ok(ret
== ERROR_NOACCESS
, "got %d\n", ret
);
495 ret
= pRegSetKeyValueW(hkey_main
, subkeyW
, name1W
, REG_DWORD
, NULL
, 4);
496 ok(ret
== ERROR_NOACCESS
, "got %d\n", ret
);
502 static void create_test_entries(void)
504 static const DWORD qw
[2] = { 0x12345678, 0x87654321 };
506 SetEnvironmentVariableA("LONGSYSTEMVAR", "bar");
507 SetEnvironmentVariableA("FOO", "ImARatherLongButIndeedNeededString");
509 ok(!RegSetValueExA(hkey_main
,"TP1_EXP_SZ",0,REG_EXPAND_SZ
, (const BYTE
*)sTestpath1
, strlen(sTestpath1
)+1),
510 "RegSetValueExA failed\n");
511 ok(!RegSetValueExA(hkey_main
,"TP1_SZ",0,REG_SZ
, (const BYTE
*)sTestpath1
, strlen(sTestpath1
)+1),
512 "RegSetValueExA failed\n");
513 ok(!RegSetValueExA(hkey_main
,"TP1_ZB_SZ",0,REG_SZ
, (const BYTE
*)"", 0),
514 "RegSetValueExA failed\n");
515 ok(!RegSetValueExA(hkey_main
,"TP2_EXP_SZ",0,REG_EXPAND_SZ
, (const BYTE
*)sTestpath2
, strlen(sTestpath2
)+1),
516 "RegSetValueExA failed\n");
517 ok(!RegSetValueExA(hkey_main
,"DWORD",0,REG_DWORD
, (const BYTE
*)qw
, 4),
518 "RegSetValueExA failed\n");
519 ok(!RegSetValueExA(hkey_main
,"BIN32",0,REG_BINARY
, (const BYTE
*)qw
, 4),
520 "RegSetValueExA failed\n");
521 ok(!RegSetValueExA(hkey_main
,"BIN64",0,REG_BINARY
, (const BYTE
*)qw
, 8),
522 "RegSetValueExA failed\n");
525 static void test_enum_value(void)
529 char value
[20], data
[20];
530 WCHAR valueW
[20], dataW
[20];
531 DWORD val_count
, data_count
, type
;
532 static const WCHAR foobarW
[] = {'f','o','o','b','a','r',0};
533 static const WCHAR testW
[] = {'T','e','s','t',0};
534 static const WCHAR xxxW
[] = {'x','x','x','x','x','x','x','x',0};
536 /* create the working key for new 'Test' value */
537 res
= RegCreateKeyA( hkey_main
, "TestKey", &test_key
);
538 ok( res
== ERROR_SUCCESS
, "expected ERROR_SUCCESS, got %d\n", res
);
540 /* check NULL data with zero length */
541 res
= RegSetValueExA( test_key
, "Test", 0, REG_SZ
, NULL
, 0 );
542 if (GetVersion() & 0x80000000)
543 ok( res
== ERROR_INVALID_PARAMETER
, "RegSetValueExA returned %d\n", res
);
545 ok( !res
, "RegSetValueExA returned %d\n", res
);
546 res
= RegSetValueExA( test_key
, "Test", 0, REG_EXPAND_SZ
, NULL
, 0 );
547 ok( ERROR_SUCCESS
== res
|| ERROR_INVALID_PARAMETER
== res
, "RegSetValueExA returned %d\n", res
);
548 res
= RegSetValueExA( test_key
, "Test", 0, REG_BINARY
, NULL
, 0 );
549 ok( ERROR_SUCCESS
== res
|| ERROR_INVALID_PARAMETER
== res
, "RegSetValueExA returned %d\n", res
);
551 /* test reading the value and data without setting them */
555 strcpy( value
, "xxxxxxxxxx" );
556 strcpy( data
, "xxxxxxxxxx" );
557 res
= RegEnumValueA( test_key
, 0, value
, &val_count
, NULL
, &type
, (LPBYTE
)data
, &data_count
);
558 ok( res
== ERROR_SUCCESS
, "expected ERROR_SUCCESS, got %d\n", res
);
559 ok( val_count
== 4, "val_count set to %d instead of 4\n", val_count
);
560 ok( data_count
== 0, "data_count set to %d instead of 0\n", data_count
);
561 ok( type
== REG_BINARY
, "type %d is not REG_BINARY\n", type
);
562 ok( !strcmp( value
, "Test" ), "value is '%s' instead of Test\n", value
);
563 ok( !strcmp( data
, "xxxxxxxxxx" ), "data is '%s' instead of xxxxxxxxxx\n", data
);
568 memcpy( valueW
, xxxW
, sizeof(xxxW
) );
569 memcpy( dataW
, xxxW
, sizeof(xxxW
) );
570 res
= RegEnumValueW( test_key
, 0, valueW
, &val_count
, NULL
, &type
, (BYTE
*)dataW
, &data_count
);
571 ok( res
== ERROR_SUCCESS
, "expected ERROR_SUCCESS, got %d\n", res
);
572 ok( val_count
== 4, "val_count set to %d instead of 4\n", val_count
);
573 ok( data_count
== 0, "data_count set to %d instead of 0\n", data_count
);
574 ok( type
== REG_BINARY
, "type %d is not REG_BINARY\n", type
);
575 ok( !memcmp( valueW
, testW
, sizeof(testW
) ), "value is not 'Test'\n" );
576 ok( !memcmp( dataW
, xxxW
, sizeof(xxxW
) ), "data is not 'xxxxxxxxxx'\n" );
578 res
= RegSetValueExA( test_key
, "Test", 0, REG_SZ
, (const BYTE
*)"foobar", 7 );
579 ok( res
== 0, "RegSetValueExA failed error %d\n", res
);
581 /* overflow both name and data */
585 strcpy( value
, "xxxxxxxxxx" );
586 strcpy( data
, "xxxxxxxxxx" );
587 res
= RegEnumValueA( test_key
, 0, value
, &val_count
, NULL
, &type
, (LPBYTE
)data
, &data_count
);
588 ok( res
== ERROR_MORE_DATA
, "expected ERROR_MORE_DATA, got %d\n", res
);
589 ok( val_count
== 2, "val_count set to %d\n", val_count
);
590 ok( data_count
== 7 || broken( data_count
== 8 ), "data_count set to %d instead of 7\n", data_count
);
591 ok( type
== REG_SZ
, "type %d is not REG_SZ\n", type
);
592 ok( !strcmp( value
, "xxxxxxxxxx" ), "value set to '%s'\n", value
);
593 ok( !strcmp( data
, "xxxxxxxxxx" ), "data set to '%s'\n", data
);
599 strcpy( value
, "xxxxxxxxxx" );
600 strcpy( data
, "xxxxxxxxxx" );
601 res
= RegEnumValueA( test_key
, 0, value
, &val_count
, NULL
, &type
, (LPBYTE
)data
, &data_count
);
602 ok( res
== ERROR_MORE_DATA
, "expected ERROR_MORE_DATA, got %d\n", res
);
603 ok( val_count
== 3, "val_count set to %d\n", val_count
);
604 ok( data_count
== 7 || broken( data_count
== 8 ), "data_count set to %d instead of 7\n", data_count
);
605 ok( type
== REG_SZ
, "type %d is not REG_SZ\n", type
);
606 /* v5.1.2600.0 (XP Home and Professional) does not touch value or data in this case */
607 ok( !strcmp( value
, "Te" ) || !strcmp( value
, "xxxxxxxxxx" ),
608 "value set to '%s' instead of 'Te' or 'xxxxxxxxxx'\n", value
);
609 ok( !strcmp( data
, "foobar" ) || !strcmp( data
, "xxxxxxx" ) || broken( !strcmp( data
, "xxxxxxxx" ) && data_count
== 8 ),
610 "data set to '%s' instead of 'foobar' or 'xxxxxxx'\n", data
);
612 /* overflow empty name */
616 strcpy( value
, "xxxxxxxxxx" );
617 strcpy( data
, "xxxxxxxxxx" );
618 res
= RegEnumValueA( test_key
, 0, value
, &val_count
, NULL
, &type
, (LPBYTE
)data
, &data_count
);
619 ok( res
== ERROR_MORE_DATA
, "expected ERROR_MORE_DATA, got %d\n", res
);
620 ok( val_count
== 0, "val_count set to %d\n", val_count
);
621 ok( data_count
== 7 || broken( data_count
== 8 ), "data_count set to %d instead of 7\n", data_count
);
622 ok( type
== REG_SZ
, "type %d is not REG_SZ\n", type
);
623 ok( !strcmp( value
, "xxxxxxxxxx" ), "value set to '%s'\n", value
);
624 /* v5.1.2600.0 (XP Home and Professional) does not touch data in this case */
625 ok( !strcmp( data
, "foobar" ) || !strcmp( data
, "xxxxxxx" ) || broken( !strcmp( data
, "xxxxxxxx" ) && data_count
== 8 ),
626 "data set to '%s' instead of 'foobar' or 'xxxxxxx'\n", data
);
632 strcpy( value
, "xxxxxxxxxx" );
633 strcpy( data
, "xxxxxxxxxx" );
634 res
= RegEnumValueA( test_key
, 0, value
, &val_count
, NULL
, &type
, (LPBYTE
)data
, &data_count
);
635 ok( res
== ERROR_MORE_DATA
, "expected ERROR_MORE_DATA, got %d\n", res
);
636 ok( val_count
== 20, "val_count set to %d\n", val_count
);
637 ok( data_count
== 7, "data_count set to %d instead of 7\n", data_count
);
638 ok( type
== REG_SZ
, "type %d is not REG_SZ\n", type
);
639 ok( !strcmp( value
, "xxxxxxxxxx" ), "value set to '%s'\n", value
);
640 ok( !strcmp( data
, "xxxxxxxxxx" ), "data set to '%s'\n", data
);
646 strcpy( value
, "xxxxxxxxxx" );
647 strcpy( data
, "xxxxxxxxxx" );
648 res
= RegEnumValueA( test_key
, 0, value
, &val_count
, NULL
, &type
, (LPBYTE
)data
, &data_count
);
649 ok( res
== ERROR_SUCCESS
, "expected ERROR_SUCCESS, got %d\n", res
);
650 ok( val_count
== 4, "val_count set to %d instead of 4\n", val_count
);
651 ok( data_count
== 7, "data_count set to %d instead of 7\n", data_count
);
652 ok( type
== REG_SZ
, "type %d is not REG_SZ\n", type
);
653 ok( !strcmp( value
, "Test" ), "value is '%s' instead of Test\n", value
);
654 ok( !strcmp( data
, "foobar" ), "data is '%s' instead of foobar\n", data
);
656 if (pRegGetValueA
) /* avoid a crash on Windows 2000 */
658 /* no value and no val_count parameter */
661 strcpy( data
, "xxxxxxxxxx" );
662 res
= RegEnumValueA( test_key
, 0, NULL
, NULL
, NULL
, &type
, (BYTE
*)data
, &data_count
);
663 ok( res
== ERROR_INVALID_PARAMETER
, "expected ERROR_INVALID_PARAMETER, got %d\n", res
);
665 /* no value parameter */
669 strcpy( data
, "xxxxxxxxxx" );
670 res
= RegEnumValueA( test_key
, 0, NULL
, &val_count
, NULL
, &type
, (BYTE
*)data
, &data_count
);
671 ok( res
== ERROR_INVALID_PARAMETER
, "expected ERROR_INVALID_PARAMETER, got %d\n", res
);
673 /* no val_count parameter */
676 strcpy( value
, "xxxxxxxxxx" );
677 strcpy( data
, "xxxxxxxxxx" );
678 res
= RegEnumValueA( test_key
, 0, value
, NULL
, NULL
, &type
, (BYTE
*)data
, &data_count
);
679 ok( res
== ERROR_INVALID_PARAMETER
, "expected ERROR_INVALID_PARAMETER, got %d\n", res
);
684 SetLastError(0xdeadbeef);
685 res
= RegSetValueExW( test_key
, testW
, 0, REG_SZ
, (const BYTE
*)foobarW
, 7*sizeof(WCHAR
) );
686 if (res
==0 && GetLastError()==ERROR_CALL_NOT_IMPLEMENTED
)
688 win_skip("RegSetValueExW is not implemented\n");
691 ok( res
== 0, "RegSetValueExW failed error %d\n", res
);
693 /* overflow both name and data */
697 memcpy( valueW
, xxxW
, sizeof(xxxW
) );
698 memcpy( dataW
, xxxW
, sizeof(xxxW
) );
699 res
= RegEnumValueW( test_key
, 0, valueW
, &val_count
, NULL
, &type
, (BYTE
*)dataW
, &data_count
);
700 ok( res
== ERROR_MORE_DATA
, "expected ERROR_MORE_DATA, got %d\n", res
);
701 ok( val_count
== 2, "val_count set to %d\n", val_count
);
702 ok( data_count
== 7*sizeof(WCHAR
), "data_count set to %d instead of 7*sizeof(WCHAR)\n", data_count
);
703 ok( type
== REG_SZ
, "type %d is not REG_SZ\n", type
);
704 ok( !memcmp( valueW
, xxxW
, sizeof(xxxW
) ), "value modified\n" );
705 ok( !memcmp( dataW
, xxxW
, sizeof(xxxW
) ), "data modified\n" );
711 memcpy( valueW
, xxxW
, sizeof(xxxW
) );
712 memcpy( dataW
, xxxW
, sizeof(xxxW
) );
713 res
= RegEnumValueW( test_key
, 0, valueW
, &val_count
, NULL
, &type
, (BYTE
*)dataW
, &data_count
);
714 ok( res
== ERROR_MORE_DATA
, "expected ERROR_MORE_DATA, got %d\n", res
);
715 ok( val_count
== 3, "val_count set to %d\n", val_count
);
716 ok( data_count
== 7*sizeof(WCHAR
), "data_count set to %d instead of 7*sizeof(WCHAR)\n", data_count
);
717 ok( type
== REG_SZ
, "type %d is not REG_SZ\n", type
);
718 ok( !memcmp( valueW
, xxxW
, sizeof(xxxW
) ), "value modified\n" );
719 ok( !memcmp( dataW
, xxxW
, sizeof(xxxW
) ), "data modified\n" );
725 memcpy( valueW
, xxxW
, sizeof(xxxW
) );
726 memcpy( dataW
, xxxW
, sizeof(xxxW
) );
727 res
= RegEnumValueW( test_key
, 0, valueW
, &val_count
, NULL
, &type
, (BYTE
*)dataW
, &data_count
);
728 ok( res
== ERROR_MORE_DATA
, "expected ERROR_MORE_DATA, got %d\n", res
);
729 ok( val_count
== 4, "val_count set to %d instead of 4\n", val_count
);
730 ok( data_count
== 7*sizeof(WCHAR
), "data_count set to %d instead of 7*sizeof(WCHAR)\n", data_count
);
731 ok( type
== REG_SZ
, "type %d is not REG_SZ\n", type
);
732 ok( !memcmp( valueW
, testW
, sizeof(testW
) ), "value is not 'Test'\n" );
733 ok( !memcmp( dataW
, xxxW
, sizeof(xxxW
) ), "data modified\n" );
739 memcpy( valueW
, xxxW
, sizeof(xxxW
) );
740 memcpy( dataW
, xxxW
, sizeof(xxxW
) );
741 res
= RegEnumValueW( test_key
, 0, valueW
, &val_count
, NULL
, &type
, (BYTE
*)dataW
, &data_count
);
742 ok( res
== ERROR_SUCCESS
, "expected ERROR_SUCCESS, got %d\n", res
);
743 ok( val_count
== 4, "val_count set to %d instead of 4\n", val_count
);
744 ok( data_count
== 7*sizeof(WCHAR
), "data_count set to %d instead of 7*sizeof(WCHAR)\n", data_count
);
745 ok( type
== REG_SZ
, "type %d is not REG_SZ\n", type
);
746 ok( !memcmp( valueW
, testW
, sizeof(testW
) ), "value is not 'Test'\n" );
747 ok( !memcmp( dataW
, foobarW
, sizeof(foobarW
) ), "data is not 'foobar'\n" );
749 if (pRegGetValueA
) /* avoid a crash on Windows 2000 */
751 /* no valueW and no val_count parameter */
754 memcpy( dataW
, xxxW
, sizeof(xxxW
) );
755 res
= RegEnumValueW( test_key
, 0, NULL
, NULL
, NULL
, &type
, (BYTE
*)dataW
, &data_count
);
756 ok( res
== ERROR_INVALID_PARAMETER
, "expected ERROR_INVALID_PARAMETER, got %d\n", res
);
758 /* no valueW parameter */
762 memcpy( dataW
, xxxW
, sizeof(xxxW
) );
763 res
= RegEnumValueW( test_key
, 0, NULL
, &val_count
, NULL
, &type
, (BYTE
*)dataW
, &data_count
);
764 ok( res
== ERROR_INVALID_PARAMETER
, "expected ERROR_INVALID_PARAMETER, got %d\n", res
);
766 /* no val_count parameter */
769 memcpy( valueW
, xxxW
, sizeof(xxxW
) );
770 memcpy( dataW
, xxxW
, sizeof(xxxW
) );
771 res
= RegEnumValueW( test_key
, 0, valueW
, NULL
, NULL
, &type
, (BYTE
*)dataW
, &data_count
);
772 ok( res
== ERROR_INVALID_PARAMETER
, "expected ERROR_INVALID_PARAMETER, got %d\n", res
);
776 RegDeleteKeyA(test_key
, "");
777 RegCloseKey(test_key
);
780 static void test_query_value_ex(void)
782 DWORD ret
, size
, type
;
785 size
= sizeof(buffer
);
786 ret
= RegQueryValueExA(hkey_main
, "TP1_SZ", NULL
, &type
, NULL
, &size
);
787 ok(ret
== ERROR_SUCCESS
, "expected ERROR_SUCCESS, got %d\n", ret
);
788 ok(size
== strlen(sTestpath1
) + 1, "(%d,%d)\n", (DWORD
)strlen(sTestpath1
) + 1, size
);
789 ok(type
== REG_SZ
, "type %d is not REG_SZ\n", type
);
793 ret
= RegQueryValueExA(HKEY_CLASSES_ROOT
, "Nonexistent Value", NULL
, &type
, NULL
, &size
);
794 ok(ret
== ERROR_FILE_NOT_FOUND
, "expected ERROR_FILE_NOT_FOUND, got %d\n", ret
);
795 ok(size
== 0, "size should have been set to 0 instead of %d\n", size
);
797 size
= sizeof(buffer
);
798 ret
= RegQueryValueExA(HKEY_CLASSES_ROOT
, "Nonexistent Value", NULL
, &type
, buffer
, &size
);
799 ok(ret
== ERROR_FILE_NOT_FOUND
, "expected ERROR_FILE_NOT_FOUND, got %d\n", ret
);
800 ok(size
== sizeof(buffer
), "size shouldn't have been changed to %d\n", size
);
803 ret
= RegQueryValueExA(hkey_main
, "BIN32", NULL
, &size
, buffer
, &size
);
804 ok(ret
== ERROR_SUCCESS
, "expected ERROR_SUCCESS, got %d\n", ret
);
807 static void test_get_value(void)
814 CHAR expanded
[] = "bar\\subdir1";
815 CHAR expanded2
[] = "ImARatherLongButIndeedNeededString\\subdir1";
819 win_skip("RegGetValue not available on this platform\n");
823 /* Invalid parameter */
824 ret
= pRegGetValueA(hkey_main
, NULL
, "DWORD", RRF_RT_REG_DWORD
, &type
, &dw
, NULL
);
825 ok(ret
== ERROR_INVALID_PARAMETER
, "ret=%d\n", ret
);
827 /* Query REG_DWORD using RRF_RT_REG_DWORD (ok) */
828 size
= type
= dw
= 0xdeadbeef;
829 ret
= pRegGetValueA(hkey_main
, NULL
, "DWORD", RRF_RT_REG_DWORD
, &type
, &dw
, &size
);
830 ok(ret
== ERROR_SUCCESS
, "ret=%d\n", ret
);
831 ok(size
== 4, "size=%d\n", size
);
832 ok(type
== REG_DWORD
, "type=%d\n", type
);
833 ok(dw
== 0x12345678, "dw=%d\n", dw
);
835 /* Query by subkey-name */
836 ret
= pRegGetValueA(HKEY_CURRENT_USER
, "Software\\Wine\\Test", "DWORD", RRF_RT_REG_DWORD
, NULL
, NULL
, NULL
);
837 ok(ret
== ERROR_SUCCESS
, "ret=%d\n", ret
);
839 /* Query REG_DWORD using RRF_RT_REG_BINARY (restricted) */
840 size
= type
= dw
= 0xdeadbeef;
841 ret
= pRegGetValueA(hkey_main
, NULL
, "DWORD", RRF_RT_REG_BINARY
, &type
, &dw
, &size
);
842 ok(ret
== ERROR_UNSUPPORTED_TYPE
, "ret=%d\n", ret
);
843 /* Although the function failed all values are retrieved */
844 ok(size
== 4, "size=%d\n", size
);
845 ok(type
== REG_DWORD
, "type=%d\n", type
);
846 ok(dw
== 0x12345678, "dw=%d\n", dw
);
848 /* Test RRF_ZEROONFAILURE */
849 type
= dw
= 0xdeadbeef; size
= 4;
850 ret
= pRegGetValueA(hkey_main
, NULL
, "DWORD", RRF_RT_REG_SZ
|RRF_ZEROONFAILURE
, &type
, &dw
, &size
);
851 ok(ret
== ERROR_UNSUPPORTED_TYPE
, "ret=%d\n", ret
);
852 /* Again all values are retrieved ... */
853 ok(size
== 4, "size=%d\n", size
);
854 ok(type
== REG_DWORD
, "type=%d\n", type
);
855 /* ... except the buffer, which is zeroed out */
856 ok(dw
== 0, "dw=%d\n", dw
);
858 /* Test RRF_ZEROONFAILURE with a NULL buffer... */
859 type
= size
= 0xbadbeef;
860 ret
= pRegGetValueA(hkey_main
, NULL
, "DWORD", RRF_RT_REG_SZ
|RRF_ZEROONFAILURE
, &type
, NULL
, &size
);
861 ok(ret
== ERROR_UNSUPPORTED_TYPE
, "ret=%d\n", ret
);
862 ok(size
== 4, "size=%d\n", size
);
863 ok(type
== REG_DWORD
, "type=%d\n", type
);
865 /* Query REG_DWORD using RRF_RT_DWORD (ok) */
866 size
= type
= dw
= 0xdeadbeef;
867 ret
= pRegGetValueA(hkey_main
, NULL
, "DWORD", RRF_RT_DWORD
, &type
, &dw
, &size
);
868 ok(ret
== ERROR_SUCCESS
, "ret=%d\n", ret
);
869 ok(size
== 4, "size=%d\n", size
);
870 ok(type
== REG_DWORD
, "type=%d\n", type
);
871 ok(dw
== 0x12345678, "dw=%d\n", dw
);
873 /* Query 32-bit REG_BINARY using RRF_RT_DWORD (ok) */
874 size
= type
= dw
= 0xdeadbeef;
875 ret
= pRegGetValueA(hkey_main
, NULL
, "BIN32", RRF_RT_DWORD
, &type
, &dw
, &size
);
876 ok(ret
== ERROR_SUCCESS
, "ret=%d\n", ret
);
877 ok(size
== 4, "size=%d\n", size
);
878 ok(type
== REG_BINARY
, "type=%d\n", type
);
879 ok(dw
== 0x12345678, "dw=%d\n", dw
);
881 /* Query 64-bit REG_BINARY using RRF_RT_DWORD (type mismatch) */
882 qw
[0] = qw
[1] = size
= type
= 0xdeadbeef;
883 ret
= pRegGetValueA(hkey_main
, NULL
, "BIN64", RRF_RT_DWORD
, &type
, qw
, &size
);
884 ok(ret
== ERROR_DATATYPE_MISMATCH
, "ret=%d\n", ret
);
885 ok(size
== 8, "size=%d\n", size
);
886 ok(type
== REG_BINARY
, "type=%d\n", type
);
887 ok(qw
[0] == 0x12345678 &&
888 qw
[1] == 0x87654321, "qw={%d,%d}\n", qw
[0], qw
[1]);
890 /* Query 64-bit REG_BINARY using 32-bit buffer (buffer too small) */
891 type
= dw
= 0xdeadbeef; size
= 4;
892 ret
= pRegGetValueA(hkey_main
, NULL
, "BIN64", RRF_RT_REG_BINARY
, &type
, &dw
, &size
);
893 ok(ret
== ERROR_MORE_DATA
, "ret=%d\n", ret
);
894 ok(dw
== 0xdeadbeef, "dw=%d\n", dw
);
895 ok(size
== 8, "size=%d\n", size
);
897 /* Query 64-bit REG_BINARY using RRF_RT_QWORD (ok) */
898 qw
[0] = qw
[1] = size
= type
= 0xdeadbeef;
899 ret
= pRegGetValueA(hkey_main
, NULL
, "BIN64", RRF_RT_QWORD
, &type
, qw
, &size
);
900 ok(ret
== ERROR_SUCCESS
, "ret=%d\n", ret
);
901 ok(size
== 8, "size=%d\n", size
);
902 ok(type
== REG_BINARY
, "type=%d\n", type
);
903 ok(qw
[0] == 0x12345678 &&
904 qw
[1] == 0x87654321, "qw={%d,%d}\n", qw
[0], qw
[1]);
906 /* Query REG_SZ using RRF_RT_REG_SZ (ok) */
907 buf
[0] = 0; type
= 0xdeadbeef; size
= sizeof(buf
);
908 ret
= pRegGetValueA(hkey_main
, NULL
, "TP1_SZ", RRF_RT_REG_SZ
, &type
, buf
, &size
);
909 ok(ret
== ERROR_SUCCESS
, "ret=%d\n", ret
);
910 ok(size
== strlen(sTestpath1
)+1, "strlen(sTestpath1)=%d size=%d\n", lstrlenA(sTestpath1
), size
);
911 ok(type
== REG_SZ
, "type=%d\n", type
);
912 ok(!strcmp(sTestpath1
, buf
), "sTestpath=\"%s\" buf=\"%s\"\n", sTestpath1
, buf
);
914 /* Query REG_SZ using RRF_RT_REG_SZ and no buffer (ok) */
915 type
= 0xdeadbeef; size
= 0;
916 ret
= pRegGetValueA(hkey_main
, NULL
, "TP1_SZ", RRF_RT_REG_SZ
, &type
, NULL
, &size
);
917 ok(ret
== ERROR_SUCCESS
, "ret=%d\n", ret
);
918 /* v5.2.3790.1830 (2003 SP1) returns sTestpath1 length + 2 here. */
919 ok(size
== strlen(sTestpath1
)+1 || broken(size
== strlen(sTestpath1
)+2),
920 "strlen(sTestpath1)=%d size=%d\n", lstrlenA(sTestpath1
), size
);
921 ok(type
== REG_SZ
, "type=%d\n", type
);
923 /* Query REG_SZ using RRF_RT_REG_SZ on a zero-byte value (ok) */
924 strcpy(buf
, sTestpath1
);
927 ret
= pRegGetValueA(hkey_main
, NULL
, "TP1_ZB_SZ", RRF_RT_REG_SZ
, &type
, buf
, &size
);
928 ok(ret
== ERROR_SUCCESS
, "ret=%d\n", ret
);
929 /* v5.2.3790.1830 (2003 SP1) returns sTestpath1 length + 2 here. */
931 size
== 1, /* win2k3 */
933 ok(type
== REG_SZ
, "type=%d\n", type
);
934 ok(!strcmp(sTestpath1
, buf
) ||
936 "Expected \"%s\" or \"\", got \"%s\"\n", sTestpath1
, buf
);
938 /* Query REG_SZ using RRF_RT_REG_SZ|RRF_NOEXPAND (ok) */
939 buf
[0] = 0; type
= 0xdeadbeef; size
= sizeof(buf
);
940 ret
= pRegGetValueA(hkey_main
, NULL
, "TP1_SZ", RRF_RT_REG_SZ
|RRF_NOEXPAND
, &type
, buf
, &size
);
941 ok(ret
== ERROR_SUCCESS
, "ret=%d\n", ret
);
942 ok(size
== strlen(sTestpath1
)+1, "strlen(sTestpath1)=%d size=%d\n", lstrlenA(sTestpath1
), size
);
943 ok(type
== REG_SZ
, "type=%d\n", type
);
944 ok(!strcmp(sTestpath1
, buf
), "sTestpath=\"%s\" buf=\"%s\"\n", sTestpath1
, buf
);
946 /* Query REG_EXPAND_SZ using RRF_RT_REG_SZ and no buffer (ok, expands) */
948 ret
= pRegGetValueA(hkey_main
, NULL
, "TP2_EXP_SZ", RRF_RT_REG_SZ
, NULL
, NULL
, &size
);
949 ok(ret
== ERROR_SUCCESS
, "ret=%d\n", ret
);
950 ok((size
== strlen(expanded2
)+1) || /* win2k3 SP1 */
951 (size
== strlen(expanded2
)+2) || /* win2k3 SP2 */
952 (size
== strlen(sTestpath2
)+1),
953 "strlen(expanded2)=%d, strlen(sTestpath2)=%d, size=%d\n", lstrlenA(expanded2
), lstrlenA(sTestpath2
), size
);
955 /* Query REG_EXPAND_SZ using RRF_RT_REG_SZ (ok, expands) */
956 buf
[0] = 0; type
= 0xdeadbeef; size
= sizeof(buf
);
957 ret
= pRegGetValueA(hkey_main
, NULL
, "TP1_EXP_SZ", RRF_RT_REG_SZ
, &type
, buf
, &size
);
958 ok(ret
== ERROR_SUCCESS
, "ret=%d\n", ret
);
959 /* At least v5.2.3790.1830 (2003 SP1) returns the unexpanded sTestpath1 length + 1 here. */
960 ok(size
== strlen(expanded
)+1 || broken(size
== strlen(sTestpath1
)+1),
961 "strlen(expanded)=%d, strlen(sTestpath1)=%d, size=%d\n", lstrlenA(expanded
), lstrlenA(sTestpath1
), size
);
962 ok(type
== REG_SZ
, "type=%d\n", type
);
963 ok(!strcmp(expanded
, buf
), "expanded=\"%s\" buf=\"%s\"\n", expanded
, buf
);
965 /* Query REG_EXPAND_SZ using RRF_RT_REG_SZ (ok, expands a lot) */
966 buf
[0] = 0; type
= 0xdeadbeef; size
= sizeof(buf
);
967 ret
= pRegGetValueA(hkey_main
, NULL
, "TP2_EXP_SZ", RRF_RT_REG_SZ
, &type
, buf
, &size
);
968 ok(ret
== ERROR_SUCCESS
, "ret=%d\n", ret
);
969 /* At least v5.2.3790.1830 (2003 SP1) returns the unexpanded sTestpath2 length + 1 here. */
970 ok(size
== strlen(expanded2
)+1 || broken(size
== strlen(sTestpath2
)+1),
971 "strlen(expanded2)=%d, strlen(sTestpath1)=%d, size=%d\n", lstrlenA(expanded2
), lstrlenA(sTestpath2
), size
);
972 ok(type
== REG_SZ
, "type=%d\n", type
);
973 ok(!strcmp(expanded2
, buf
), "expanded2=\"%s\" buf=\"%s\"\n", expanded2
, buf
);
975 /* Query REG_EXPAND_SZ using RRF_RT_REG_EXPAND_SZ|RRF_NOEXPAND (ok, doesn't expand) */
976 buf
[0] = 0; type
= 0xdeadbeef; size
= sizeof(buf
);
977 ret
= pRegGetValueA(hkey_main
, NULL
, "TP1_EXP_SZ", RRF_RT_REG_EXPAND_SZ
|RRF_NOEXPAND
, &type
, buf
, &size
);
978 ok(ret
== ERROR_SUCCESS
, "ret=%d\n", ret
);
979 ok(size
== strlen(sTestpath1
)+1, "strlen(sTestpath1)=%d size=%d\n", lstrlenA(sTestpath1
), size
);
980 ok(type
== REG_EXPAND_SZ
, "type=%d\n", type
);
981 ok(!strcmp(sTestpath1
, buf
), "sTestpath=\"%s\" buf=\"%s\"\n", sTestpath1
, buf
);
983 /* Query REG_EXPAND_SZ using RRF_RT_REG_EXPAND_SZ|RRF_NOEXPAND and no buffer (ok, doesn't expand) */
985 ret
= pRegGetValueA(hkey_main
, NULL
, "TP1_EXP_SZ", RRF_RT_REG_EXPAND_SZ
|RRF_NOEXPAND
, NULL
, NULL
, &size
);
986 ok(ret
== ERROR_SUCCESS
, "ret=%d\n", ret
);
987 /* v5.2.3790.1830 (2003 SP1) returns sTestpath1 length + 2 here. */
988 ok(size
== strlen(sTestpath1
)+1 || broken(size
== strlen(sTestpath1
)+2),
989 "strlen(sTestpath1)=%d size=%d\n", lstrlenA(sTestpath1
), size
);
991 /* Query REG_EXPAND_SZ using RRF_RT_REG_SZ|RRF_NOEXPAND (type mismatch) */
992 ret
= pRegGetValueA(hkey_main
, NULL
, "TP1_EXP_SZ", RRF_RT_REG_SZ
|RRF_NOEXPAND
, NULL
, NULL
, NULL
);
993 ok(ret
== ERROR_UNSUPPORTED_TYPE
, "ret=%d\n", ret
);
995 /* Query REG_EXPAND_SZ using RRF_RT_REG_EXPAND_SZ (not allowed without RRF_NOEXPAND) */
996 ret
= pRegGetValueA(hkey_main
, NULL
, "TP1_EXP_SZ", RRF_RT_REG_EXPAND_SZ
, NULL
, NULL
, NULL
);
997 /* before win8: ERROR_INVALID_PARAMETER, win8: ERROR_UNSUPPORTED_TYPE */
998 ok(ret
== ERROR_INVALID_PARAMETER
|| ret
== ERROR_UNSUPPORTED_TYPE
, "ret=%d\n", ret
);
1000 /* Query REG_EXPAND_SZ using RRF_RT_ANY */
1001 buf
[0] = 0; type
= 0xdeadbeef; size
= sizeof(buf
);
1002 ret
= pRegGetValueA(hkey_main
, NULL
, "TP1_EXP_SZ", RRF_RT_ANY
, &type
, buf
, &size
);
1003 ok(ret
== ERROR_SUCCESS
, "ret=%d\n", ret
);
1004 /* At least v5.2.3790.1830 (2003 SP1) returns the unexpanded sTestpath1 length + 1 here. */
1005 ok(size
== strlen(expanded
)+1 || broken(size
== strlen(sTestpath1
)+1),
1006 "strlen(expanded)=%d, strlen(sTestpath1)=%d, size=%d\n", lstrlenA(expanded
), lstrlenA(sTestpath1
), size
);
1007 ok(type
== REG_SZ
, "type=%d\n", type
);
1008 ok(!strcmp(expanded
, buf
), "expanded=\"%s\" buf=\"%s\"\n", expanded
, buf
);
1011 static void test_reg_open_key(void)
1014 HKEY hkResult
= NULL
;
1015 HKEY hkPreserve
= NULL
;
1016 HKEY hkRoot64
= NULL
;
1017 HKEY hkRoot32
= NULL
;
1019 SID_IDENTIFIER_AUTHORITY sid_authority
= {SECURITY_WORLD_SID_AUTHORITY
};
1021 EXPLICIT_ACCESSA access
;
1023 SECURITY_DESCRIPTOR
*sd
;
1025 /* successful open */
1026 ret
= RegOpenKeyA(HKEY_CURRENT_USER
, "Software\\Wine\\Test", &hkResult
);
1027 ok(ret
== ERROR_SUCCESS
, "expected ERROR_SUCCESS, got %d\n", ret
);
1028 ok(hkResult
!= NULL
, "expected hkResult != NULL\n");
1029 hkPreserve
= hkResult
;
1031 /* open same key twice */
1032 ret
= RegOpenKeyA(HKEY_CURRENT_USER
, "Software\\Wine\\Test", &hkResult
);
1033 ok(ret
== ERROR_SUCCESS
, "expected ERROR_SUCCESS, got %d\n", ret
);
1034 ok(hkResult
!= hkPreserve
, "expected hkResult != hkPreserve\n");
1035 ok(hkResult
!= NULL
, "hkResult != NULL\n");
1036 RegCloseKey(hkResult
);
1038 /* trailing slashes */
1039 ret
= RegOpenKeyA(HKEY_CURRENT_USER
, "Software\\Wine\\Test\\\\", &hkResult
);
1040 ok(ret
== ERROR_SUCCESS
, "expected ERROR_SUCCESS, got %d\n", ret
);
1041 RegCloseKey(hkResult
);
1043 /* open nonexistent key
1044 * check that hkResult is set to NULL
1046 hkResult
= hkPreserve
;
1047 ret
= RegOpenKeyA(HKEY_CURRENT_USER
, "Software\\Wine\\Nonexistent", &hkResult
);
1048 ok(ret
== ERROR_FILE_NOT_FOUND
, "expected ERROR_FILE_NOT_FOUND, got %d\n", ret
);
1049 ok(hkResult
== NULL
, "expected hkResult == NULL\n");
1051 /* open the same nonexistent key again to make sure the key wasn't created */
1052 hkResult
= hkPreserve
;
1053 ret
= RegOpenKeyA(HKEY_CURRENT_USER
, "Software\\Wine\\Nonexistent", &hkResult
);
1054 ok(ret
== ERROR_FILE_NOT_FOUND
, "expected ERROR_FILE_NOT_FOUND, got %d\n", ret
);
1055 ok(hkResult
== NULL
, "expected hkResult == NULL\n");
1057 /* send in NULL lpSubKey
1058 * check that hkResult receives the value of hKey
1060 hkResult
= hkPreserve
;
1061 ret
= RegOpenKeyA(HKEY_CURRENT_USER
, NULL
, &hkResult
);
1062 ok(ret
== ERROR_SUCCESS
, "expected ERROR_SUCCESS, got %d\n", ret
);
1063 ok(hkResult
== HKEY_CURRENT_USER
, "expected hkResult == HKEY_CURRENT_USER\n");
1065 /* send empty-string in lpSubKey */
1066 hkResult
= hkPreserve
;
1067 ret
= RegOpenKeyA(HKEY_CURRENT_USER
, "", &hkResult
);
1068 ok(ret
== ERROR_SUCCESS
, "expected ERROR_SUCCESS, got %d\n", ret
);
1069 ok(hkResult
== HKEY_CURRENT_USER
, "expected hkResult == HKEY_CURRENT_USER\n");
1071 /* send in NULL lpSubKey and NULL hKey
1072 * hkResult is set to NULL
1074 hkResult
= hkPreserve
;
1075 ret
= RegOpenKeyA(NULL
, NULL
, &hkResult
);
1076 ok(ret
== ERROR_SUCCESS
, "expected ERROR_SUCCESS, got %d\n", ret
);
1077 ok(hkResult
== NULL
, "expected hkResult == NULL\n");
1079 /* only send NULL hKey
1080 * the value of hkResult remains unchanged
1082 hkResult
= hkPreserve
;
1083 ret
= RegOpenKeyA(NULL
, "Software\\Wine\\Test", &hkResult
);
1084 ok(ret
== ERROR_INVALID_HANDLE
|| ret
== ERROR_BADKEY
, /* Windows 95 returns BADKEY */
1085 "expected ERROR_INVALID_HANDLE or ERROR_BADKEY, got %d\n", ret
);
1086 ok(hkResult
== hkPreserve
, "expected hkResult == hkPreserve\n");
1088 /* send in NULL hkResult */
1089 ret
= RegOpenKeyA(HKEY_CURRENT_USER
, "Software\\Wine\\Test", NULL
);
1090 ok(ret
== ERROR_INVALID_PARAMETER
, "expected ERROR_INVALID_PARAMETER, got %d\n", ret
);
1092 ret
= RegOpenKeyA(HKEY_CURRENT_USER
, NULL
, NULL
);
1093 ok(ret
== ERROR_INVALID_PARAMETER
, "expected ERROR_INVALID_PARAMETER, got %d\n", ret
);
1095 ret
= RegOpenKeyA(NULL
, NULL
, NULL
);
1096 ok(ret
== ERROR_INVALID_PARAMETER
, "expected ERROR_INVALID_PARAMETER, got %d\n", ret
);
1098 /* beginning backslash character */
1099 ret
= RegOpenKeyA(HKEY_CURRENT_USER
, "\\Software\\Wine\\Test", &hkResult
);
1100 ok(ret
== ERROR_BAD_PATHNAME
|| /* NT/2k/XP */
1101 broken(ret
== ERROR_SUCCESS
), /* wow64 */
1102 "expected ERROR_BAD_PATHNAME or ERROR_FILE_NOT_FOUND, got %d\n", ret
);
1103 if (!ret
) RegCloseKey(hkResult
);
1106 ret
= RegOpenKeyExA(HKEY_CLASSES_ROOT
, "\\clsid", 0, KEY_QUERY_VALUE
, &hkResult
);
1107 ok(ret
== ERROR_SUCCESS
|| /* 2k/XP */
1108 ret
== ERROR_BAD_PATHNAME
, /* NT */
1109 "expected ERROR_SUCCESS, ERROR_BAD_PATHNAME or ERROR_FILE_NOT_FOUND, got %d\n", ret
);
1110 RegCloseKey(hkResult
);
1112 /* NULL or empty subkey of special root */
1114 ret
= RegOpenKeyExA(HKEY_CLASSES_ROOT
, NULL
, 0, KEY_QUERY_VALUE
, &hkResult
);
1115 ok(ret
== ERROR_SUCCESS
, "expected ERROR_SUCCESS, got %d\n", ret
);
1116 ok(hkResult
== HKEY_CLASSES_ROOT
, "expected hkResult == HKEY_CLASSES_ROOT\n");
1119 ret
= RegOpenKeyExA(HKEY_CLASSES_ROOT
, "", 0, KEY_QUERY_VALUE
, &hkResult
);
1120 ok(ret
== ERROR_SUCCESS
, "expected ERROR_SUCCESS, got %d\n", ret
);
1121 ok(hkResult
== HKEY_CLASSES_ROOT
, "expected hkResult == HKEY_CLASSES_ROOT\n");
1124 ret
= RegOpenKeyExA(HKEY_CLASSES_ROOT
, "\\", 0, KEY_QUERY_VALUE
, &hkResult
);
1125 ok(ret
== ERROR_SUCCESS
, "expected ERROR_SUCCESS, got %d\n", ret
);
1126 ok(hkResult
!= HKEY_CLASSES_ROOT
, "expected hkResult to be a new key\n");
1127 ok(!RegCloseKey(hkResult
), "got invalid hkey\n");
1129 /* empty subkey of existing handle */
1130 hkResult
= hkPreserve
;
1131 ret
= RegOpenKeyExA(hkPreserve
, "", 0, KEY_QUERY_VALUE
, &hkResult
);
1132 ok(ret
== ERROR_SUCCESS
, "expected ERROR_SUCCESS, got %d\n", ret
);
1133 ok(hkResult
!= hkPreserve
, "expected hkResult != hkPreserve\n");
1134 ok(!RegCloseKey(hkResult
), "got invalid hkey\n");
1136 /* NULL subkey of existing handle */
1137 hkResult
= hkPreserve
;
1138 ret
= RegOpenKeyExA(hkPreserve
, NULL
, 0, KEY_QUERY_VALUE
, &hkResult
);
1139 ok(ret
== ERROR_SUCCESS
, "expected ERROR_SUCCESS, got %d\n", ret
);
1140 ok(hkResult
!= hkPreserve
, "expected hkResult != hkPreserve\n");
1141 ok(!RegCloseKey(hkResult
), "got invalid hkey\n");
1143 /* empty subkey of NULL */
1144 hkResult
= hkPreserve
;
1145 ret
= RegOpenKeyExA(NULL
, "", 0, KEY_QUERY_VALUE
, &hkResult
);
1146 ok(ret
== ERROR_INVALID_HANDLE
, "expected ERROR_INVALID_HANDLE, got %d\n", ret
);
1147 ok(hkResult
== hkPreserve
, "expected hkResult == hkPreserve\n");
1149 RegCloseKey(hkPreserve
);
1153 ret
= RegOpenKeyExA(HKEY_LOCAL_MACHINE
, "Software", 0, KEY_READ
|KEY_WOW64_32KEY
, &hkResult
);
1154 ok((ret
== ERROR_SUCCESS
&& hkResult
!= NULL
) || broken(ret
== ERROR_ACCESS_DENIED
/* NT4, win2k */),
1155 "RegOpenKeyEx with KEY_WOW64_32KEY failed (err=%u)\n", ret
);
1156 RegCloseKey(hkResult
);
1159 ret
= RegOpenKeyExA(HKEY_LOCAL_MACHINE
, "Software", 0, KEY_READ
|KEY_WOW64_64KEY
, &hkResult
);
1160 ok((ret
== ERROR_SUCCESS
&& hkResult
!= NULL
) || broken(ret
== ERROR_ACCESS_DENIED
/* NT4, win2k */),
1161 "RegOpenKeyEx with KEY_WOW64_64KEY failed (err=%u)\n", ret
);
1162 RegCloseKey(hkResult
);
1164 /* check special HKEYs on 64bit
1165 * only the lower 4 bytes of the supplied key are used
1169 /* HKEY_CURRENT_USER */
1170 ret
= RegOpenKeyA(UlongToHandle(HandleToUlong(HKEY_CURRENT_USER
)), "Software", &hkResult
);
1171 ok(ret
== ERROR_SUCCESS
, "expected ERROR_SUCCESS, got %d\n", ret
);
1172 ok(hkResult
!= NULL
, "expected hkResult != NULL\n");
1173 RegCloseKey(hkResult
);
1175 ret
= RegOpenKeyA((HKEY
)(HandleToUlong(HKEY_CURRENT_USER
) | (ULONG64
)1 << 32), "Software", &hkResult
);
1176 ok(ret
== ERROR_SUCCESS
, "expected ERROR_SUCCESS, got %d\n", ret
);
1177 ok(hkResult
!= NULL
, "expected hkResult != NULL\n");
1178 RegCloseKey(hkResult
);
1180 ret
= RegOpenKeyA((HKEY
)(HandleToUlong(HKEY_CURRENT_USER
) | (ULONG64
)0xdeadbeef << 32), "Software", &hkResult
);
1181 ok(ret
== ERROR_SUCCESS
, "expected ERROR_SUCCESS, got %d\n", ret
);
1182 ok(hkResult
!= NULL
, "expected hkResult != NULL\n");
1183 RegCloseKey(hkResult
);
1185 ret
= RegOpenKeyA((HKEY
)(HandleToUlong(HKEY_CURRENT_USER
) | (ULONG64
)0xffffffff << 32), "Software", &hkResult
);
1186 ok(ret
== ERROR_SUCCESS
, "expected ERROR_SUCCESS, got %d\n", ret
);
1187 ok(hkResult
!= NULL
, "expected hkResult != NULL\n");
1188 RegCloseKey(hkResult
);
1190 /* HKEY_LOCAL_MACHINE */
1191 ret
= RegOpenKeyA((HKEY
)(HandleToUlong(HKEY_LOCAL_MACHINE
) | (ULONG64
)0xdeadbeef << 32), "Software", &hkResult
);
1192 ok(ret
== ERROR_SUCCESS
, "expected ERROR_SUCCESS, got %d\n", ret
);
1193 ok(hkResult
!= NULL
, "expected hkResult != NULL\n");
1194 RegCloseKey(hkResult
);
1197 /* Try using WOW64 flags when opening a key with a DACL set to verify that
1198 * the registry access check is performed correctly. Redirection isn't
1199 * being tested, so the tests don't care about whether the process is
1200 * running under WOW64. */
1201 if (!pIsWow64Process
)
1203 win_skip("WOW64 flags are not recognized\n");
1207 ret
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, "Software\\Wine", 0, NULL
, 0,
1208 KEY_WOW64_32KEY
| KEY_ALL_ACCESS
, NULL
, &hkRoot32
, NULL
);
1210 ok(ret
== ERROR_ACCESS_DENIED
&& hkRoot32
== NULL
,
1211 "RegCreateKeyEx with KEY_WOW64_32KEY failed (err=%u)\n", ret
);
1213 ok(ret
== ERROR_SUCCESS
&& hkRoot32
!= NULL
,
1214 "RegCreateKeyEx with KEY_WOW64_32KEY failed (err=%u)\n", ret
);
1216 ret
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, "Software\\Wine", 0, NULL
, 0,
1217 KEY_WOW64_64KEY
| KEY_ALL_ACCESS
, NULL
, &hkRoot64
, NULL
);
1219 ok(ret
== ERROR_ACCESS_DENIED
&& hkRoot64
== NULL
,
1220 "RegCreateKeyEx with KEY_WOW64_64KEY failed (err=%u)\n", ret
);
1222 ok(ret
== ERROR_SUCCESS
&& hkRoot64
!= NULL
,
1223 "RegCreateKeyEx with KEY_WOW64_64KEY failed (err=%u)\n", ret
);
1225 bRet
= AllocateAndInitializeSid(&sid_authority
, 1, SECURITY_WORLD_RID
,
1226 0, 0, 0, 0, 0, 0, 0, &world_sid
);
1228 "Expected AllocateAndInitializeSid to return TRUE, got %d, last error %u\n", bRet
, GetLastError());
1230 access
.grfAccessPermissions
= GENERIC_ALL
| STANDARD_RIGHTS_ALL
;
1231 access
.grfAccessMode
= SET_ACCESS
;
1232 access
.grfInheritance
= SUB_CONTAINERS_AND_OBJECTS_INHERIT
;
1233 access
.Trustee
.pMultipleTrustee
= NULL
;
1234 access
.Trustee
.MultipleTrusteeOperation
= NO_MULTIPLE_TRUSTEE
;
1235 access
.Trustee
.TrusteeForm
= TRUSTEE_IS_SID
;
1236 access
.Trustee
.TrusteeType
= TRUSTEE_IS_WELL_KNOWN_GROUP
;
1237 access
.Trustee
.ptstrName
= (char *)world_sid
;
1239 ret
= SetEntriesInAclA(1, &access
, NULL
, &key_acl
);
1240 ok(ret
== ERROR_SUCCESS
,
1241 "Expected SetEntriesInAclA to return ERROR_SUCCESS, got %u, last error %u\n", ret
, GetLastError());
1243 sd
= HeapAlloc(GetProcessHeap(), 0, SECURITY_DESCRIPTOR_MIN_LENGTH
);
1244 bRet
= InitializeSecurityDescriptor(sd
, SECURITY_DESCRIPTOR_REVISION
);
1246 "Expected InitializeSecurityDescriptor to return TRUE, got %d, last error %u\n", bRet
, GetLastError());
1248 bRet
= SetSecurityDescriptorDacl(sd
, TRUE
, key_acl
, FALSE
);
1250 "Expected SetSecurityDescriptorDacl to return TRUE, got %d, last error %u\n", bRet
, GetLastError());
1254 skip("not enough privileges to modify HKLM\n");
1260 error
= RegSetKeySecurity(hkRoot64
, DACL_SECURITY_INFORMATION
, sd
);
1261 ok(error
== ERROR_SUCCESS
,
1262 "Expected RegSetKeySecurity to return success, got error %u\n", error
);
1264 error
= RegSetKeySecurity(hkRoot32
, DACL_SECURITY_INFORMATION
, sd
);
1265 ok(error
== ERROR_SUCCESS
,
1266 "Expected RegSetKeySecurity to return success, got error %u\n", error
);
1269 ret
= RegOpenKeyExA(HKEY_LOCAL_MACHINE
, "Software\\Wine", 0, KEY_WOW64_64KEY
| KEY_READ
, &hkResult
);
1270 ok(ret
== ERROR_SUCCESS
&& hkResult
!= NULL
,
1271 "RegOpenKeyEx with KEY_WOW64_64KEY failed (err=%u)\n", ret
);
1272 RegCloseKey(hkResult
);
1275 ret
= RegOpenKeyExA(HKEY_LOCAL_MACHINE
, "Software\\Wine", 0, KEY_WOW64_32KEY
| KEY_READ
, &hkResult
);
1276 ok(ret
== ERROR_SUCCESS
&& hkResult
!= NULL
,
1277 "RegOpenKeyEx with KEY_WOW64_32KEY failed (err=%u)\n", ret
);
1278 RegCloseKey(hkResult
);
1281 HeapFree(GetProcessHeap(), 0, sd
);
1284 RegDeleteKeyA(hkRoot64
, "");
1285 RegCloseKey(hkRoot64
);
1286 RegDeleteKeyA(hkRoot32
, "");
1287 RegCloseKey(hkRoot32
);
1290 static void test_reg_create_key(void)
1294 HKEY hkRoot64
= NULL
;
1295 HKEY hkRoot32
= NULL
;
1298 SID_IDENTIFIER_AUTHORITY sid_authority
= {SECURITY_WORLD_SID_AUTHORITY
};
1300 EXPLICIT_ACCESSA access
;
1302 SECURITY_DESCRIPTOR
*sd
;
1304 ret
= RegCreateKeyExA(hkey_main
, "Subkey1", 0, NULL
, 0, KEY_NOTIFY
, NULL
, &hkey1
, NULL
);
1305 ok(!ret
, "RegCreateKeyExA failed with error %d\n", ret
);
1306 /* should succeed: all versions of Windows ignore the access rights
1307 * to the parent handle */
1308 ret
= RegCreateKeyExA(hkey1
, "Subkey2", 0, NULL
, 0, KEY_SET_VALUE
, NULL
, &hkey2
, NULL
);
1309 ok(!ret
, "RegCreateKeyExA failed with error %d\n", ret
);
1312 RegDeleteKeyA(hkey2
, "");
1313 RegDeleteKeyA(hkey1
, "");
1317 /* test creation of volatile keys */
1318 ret
= RegCreateKeyExA(hkey_main
, "Volatile", 0, NULL
, REG_OPTION_VOLATILE
, KEY_ALL_ACCESS
, NULL
, &hkey1
, NULL
);
1319 ok(!ret
, "RegCreateKeyExA failed with error %d\n", ret
);
1320 ret
= RegCreateKeyExA(hkey1
, "Subkey2", 0, NULL
, 0, KEY_ALL_ACCESS
, NULL
, &hkey2
, NULL
);
1321 ok(ret
== ERROR_CHILD_MUST_BE_VOLATILE
, "RegCreateKeyExA failed with error %d\n", ret
);
1322 if (!ret
) RegCloseKey( hkey2
);
1323 ret
= RegCreateKeyExA(hkey1
, "Subkey2", 0, NULL
, REG_OPTION_VOLATILE
, KEY_ALL_ACCESS
, NULL
, &hkey2
, NULL
);
1324 ok(!ret
, "RegCreateKeyExA failed with error %d\n", ret
);
1326 /* should succeed if the key already exists */
1327 ret
= RegCreateKeyExA(hkey1
, "Subkey2", 0, NULL
, 0, KEY_ALL_ACCESS
, NULL
, &hkey2
, NULL
);
1328 ok(!ret
, "RegCreateKeyExA failed with error %d\n", ret
);
1331 RegDeleteKeyA(hkey2
, "");
1332 RegDeleteKeyA(hkey1
, "");
1336 /* beginning backslash character */
1337 ret
= RegCreateKeyExA(hkey_main
, "\\Subkey3", 0, NULL
, 0, KEY_NOTIFY
, NULL
, &hkey1
, NULL
);
1338 if (!(GetVersion() & 0x80000000))
1339 ok(ret
== ERROR_BAD_PATHNAME
, "expected ERROR_BAD_PATHNAME, got %d\n", ret
);
1341 ok(!ret
, "RegCreateKeyExA failed with error %d\n", ret
);
1342 RegDeleteKeyA(hkey1
, "");
1346 /* trailing backslash characters */
1347 ret
= RegCreateKeyExA(hkey_main
, "Subkey4\\\\", 0, NULL
, 0, KEY_NOTIFY
, NULL
, &hkey1
, NULL
);
1348 ok(ret
== ERROR_SUCCESS
, "RegCreateKeyExA failed with error %d\n", ret
);
1349 RegDeleteKeyA(hkey1
, "");
1352 /* WOW64 flags - open an existing key */
1354 ret
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, "Software", 0, NULL
, 0, KEY_READ
|KEY_WOW64_32KEY
, NULL
, &hkey1
, NULL
);
1355 ok((ret
== ERROR_SUCCESS
&& hkey1
!= NULL
) || broken(ret
== ERROR_ACCESS_DENIED
/* NT4, win2k */),
1356 "RegOpenKeyEx with KEY_WOW64_32KEY failed (err=%u)\n", ret
);
1360 ret
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, "Software", 0, NULL
, 0, KEY_READ
|KEY_WOW64_64KEY
, NULL
, &hkey1
, NULL
);
1361 ok((ret
== ERROR_SUCCESS
&& hkey1
!= NULL
) || broken(ret
== ERROR_ACCESS_DENIED
/* NT4, win2k */),
1362 "RegOpenKeyEx with KEY_WOW64_64KEY failed (err=%u)\n", ret
);
1365 /* Try using WOW64 flags when opening a key with a DACL set to verify that
1366 * the registry access check is performed correctly. Redirection isn't
1367 * being tested, so the tests don't care about whether the process is
1368 * running under WOW64. */
1369 if (!pIsWow64Process
)
1371 win_skip("WOW64 flags are not recognized\n");
1375 ret
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, "Software\\Wine", 0, NULL
, 0,
1376 KEY_WOW64_32KEY
| KEY_ALL_ACCESS
, NULL
, &hkRoot32
, NULL
);
1378 ok(ret
== ERROR_ACCESS_DENIED
&& hkRoot32
== NULL
,
1379 "RegCreateKeyEx with KEY_WOW64_32KEY failed (err=%d)\n", ret
);
1381 ok(ret
== ERROR_SUCCESS
&& hkRoot32
!= NULL
,
1382 "RegCreateKeyEx with KEY_WOW64_32KEY failed (err=%d)\n", ret
);
1384 ret
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, "Software\\Wine", 0, NULL
, 0,
1385 KEY_WOW64_64KEY
| KEY_ALL_ACCESS
, NULL
, &hkRoot64
, NULL
);
1387 ok(ret
== ERROR_ACCESS_DENIED
&& hkRoot64
== NULL
,
1388 "RegCreateKeyEx with KEY_WOW64_64KEY failed (err=%d)\n", ret
);
1390 ok(ret
== ERROR_SUCCESS
&& hkRoot64
!= NULL
,
1391 "RegCreateKeyEx with KEY_WOW64_64KEY failed (err=%d)\n", ret
);
1393 bRet
= AllocateAndInitializeSid(&sid_authority
, 1, SECURITY_WORLD_RID
,
1394 0, 0, 0, 0, 0, 0, 0, &world_sid
);
1396 "Expected AllocateAndInitializeSid to return TRUE, got %d, last error %u\n", bRet
, GetLastError());
1398 access
.grfAccessPermissions
= GENERIC_ALL
| STANDARD_RIGHTS_ALL
;
1399 access
.grfAccessMode
= SET_ACCESS
;
1400 access
.grfInheritance
= SUB_CONTAINERS_AND_OBJECTS_INHERIT
;
1401 access
.Trustee
.pMultipleTrustee
= NULL
;
1402 access
.Trustee
.MultipleTrusteeOperation
= NO_MULTIPLE_TRUSTEE
;
1403 access
.Trustee
.TrusteeForm
= TRUSTEE_IS_SID
;
1404 access
.Trustee
.TrusteeType
= TRUSTEE_IS_WELL_KNOWN_GROUP
;
1405 access
.Trustee
.ptstrName
= (char *)world_sid
;
1407 dwRet
= SetEntriesInAclA(1, &access
, NULL
, &key_acl
);
1408 ok(dwRet
== ERROR_SUCCESS
,
1409 "Expected SetEntriesInAclA to return ERROR_SUCCESS, got %u, last error %u\n", dwRet
, GetLastError());
1411 sd
= HeapAlloc(GetProcessHeap(), 0, SECURITY_DESCRIPTOR_MIN_LENGTH
);
1412 bRet
= InitializeSecurityDescriptor(sd
, SECURITY_DESCRIPTOR_REVISION
);
1414 "Expected InitializeSecurityDescriptor to return TRUE, got %d, last error %u\n", bRet
, GetLastError());
1416 bRet
= SetSecurityDescriptorDacl(sd
, TRUE
, key_acl
, FALSE
);
1418 "Expected SetSecurityDescriptorDacl to return TRUE, got %d, last error %u\n", bRet
, GetLastError());
1422 skip("not enough privileges to modify HKLM\n");
1426 ret
= RegSetKeySecurity(hkRoot64
, DACL_SECURITY_INFORMATION
, sd
);
1427 ok(ret
== ERROR_SUCCESS
,
1428 "Expected RegSetKeySecurity to return success, got error %u\n", ret
);
1430 ret
= RegSetKeySecurity(hkRoot32
, DACL_SECURITY_INFORMATION
, sd
);
1431 ok(ret
== ERROR_SUCCESS
,
1432 "Expected RegSetKeySecurity to return success, got error %u\n", ret
);
1435 ret
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, "Software\\Wine", 0, NULL
, 0,
1436 KEY_WOW64_64KEY
| KEY_READ
, NULL
, &hkey1
, NULL
);
1437 ok(ret
== ERROR_SUCCESS
&& hkey1
!= NULL
,
1438 "RegOpenKeyEx with KEY_WOW64_64KEY failed (err=%u)\n", ret
);
1442 ret
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, "Software\\Wine", 0, NULL
, 0,
1443 KEY_WOW64_32KEY
| KEY_READ
, NULL
, &hkey1
, NULL
);
1444 ok(ret
== ERROR_SUCCESS
&& hkey1
!= NULL
,
1445 "RegOpenKeyEx with KEY_WOW64_32KEY failed (err=%u)\n", ret
);
1449 HeapFree(GetProcessHeap(), 0, sd
);
1452 RegDeleteKeyA(hkRoot64
, "");
1453 RegCloseKey(hkRoot64
);
1454 RegDeleteKeyA(hkRoot32
, "");
1455 RegCloseKey(hkRoot32
);
1458 static void test_reg_close_key(void)
1463 /* successfully close key
1464 * hkHandle remains changed after call to RegCloseKey
1466 ret
= RegOpenKeyA(HKEY_CURRENT_USER
, "Software\\Wine\\Test", &hkHandle
);
1467 ok(ret
== ERROR_SUCCESS
, "expected ERROR_SUCCESS, got %d\n", ret
);
1468 ret
= RegCloseKey(hkHandle
);
1469 ok(ret
== ERROR_SUCCESS
, "expected ERROR_SUCCESS, got %d\n", ret
);
1471 /* try to close the key twice */
1472 ret
= RegCloseKey(hkHandle
); /* Windows 95 doesn't mind. */
1473 ok(ret
== ERROR_INVALID_HANDLE
|| ret
== ERROR_SUCCESS
,
1474 "expected ERROR_INVALID_HANDLE or ERROR_SUCCESS, got %d\n", ret
);
1476 /* try to close a NULL handle */
1477 ret
= RegCloseKey(NULL
);
1478 ok(ret
== ERROR_INVALID_HANDLE
|| ret
== ERROR_BADKEY
, /* Windows 95 returns BADKEY */
1479 "expected ERROR_INVALID_HANDLE or ERROR_BADKEY, got %d\n", ret
);
1481 /* Check to see if we didn't potentially close our main handle, which could happen on win98 as
1482 * win98 doesn't give a new handle when the same key is opened.
1483 * Not re-opening will make some next tests fail.
1485 if (hkey_main
== hkHandle
)
1487 trace("The main handle is most likely closed, so re-opening\n");
1488 RegOpenKeyA( HKEY_CURRENT_USER
, "Software\\Wine\\Test", &hkey_main
);
1492 static void test_reg_delete_key(void)
1497 ret
= RegDeleteKeyA(hkey_main
, NULL
);
1499 /* There is a bug in NT4 and W2K that doesn't check if the subkey is NULL. If
1500 * there are also no subkeys available it will delete the key pointed to by hkey_main.
1501 * Not re-creating will make some next tests fail.
1503 if (ret
== ERROR_SUCCESS
)
1505 trace("We are probably running on NT4 or W2K as the main key is deleted,"
1506 " re-creating the main key\n");
1510 ok(ret
== ERROR_INVALID_PARAMETER
||
1511 ret
== ERROR_ACCESS_DENIED
||
1512 ret
== ERROR_BADKEY
, /* Win95 */
1515 ret
= RegCreateKeyA(hkey_main
, "deleteme", &key
);
1516 ok(ret
== ERROR_SUCCESS
, "Could not create key, got %d\n", ret
);
1517 ret
= RegDeleteKeyA(key
, "");
1518 ok(ret
== ERROR_SUCCESS
, "RegDeleteKeyA failed, got %d\n", ret
);
1520 ret
= RegOpenKeyA(hkey_main
, "deleteme", &key
);
1521 ok(ret
== ERROR_FILE_NOT_FOUND
, "Key was not deleted, got %d\n", ret
);
1525 static BOOL
set_privileges(LPCSTR privilege
, BOOL set
)
1527 TOKEN_PRIVILEGES tp
;
1531 if (!OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES
, &hToken
))
1534 if(!LookupPrivilegeValueA(NULL
, privilege
, &luid
))
1536 CloseHandle(hToken
);
1540 tp
.PrivilegeCount
= 1;
1541 tp
.Privileges
[0].Luid
= luid
;
1544 tp
.Privileges
[0].Attributes
= SE_PRIVILEGE_ENABLED
;
1546 tp
.Privileges
[0].Attributes
= 0;
1548 AdjustTokenPrivileges(hToken
, FALSE
, &tp
, sizeof(TOKEN_PRIVILEGES
), NULL
, NULL
);
1549 if (GetLastError() != ERROR_SUCCESS
)
1551 CloseHandle(hToken
);
1555 CloseHandle(hToken
);
1559 static void test_reg_save_key(void)
1563 if (!set_privileges(SE_BACKUP_NAME
, TRUE
) ||
1564 !set_privileges(SE_RESTORE_NAME
, FALSE
))
1566 win_skip("Failed to set SE_BACKUP_NAME privileges, skipping tests\n");
1570 ret
= RegSaveKeyA(hkey_main
, "saved_key", NULL
);
1571 ok(ret
== ERROR_SUCCESS
, "expected ERROR_SUCCESS, got %d\n", ret
);
1573 set_privileges(SE_BACKUP_NAME
, FALSE
);
1576 static void test_reg_load_key(void)
1581 if (!set_privileges(SE_RESTORE_NAME
, TRUE
) ||
1582 !set_privileges(SE_BACKUP_NAME
, FALSE
))
1584 win_skip("Failed to set SE_RESTORE_NAME privileges, skipping tests\n");
1588 ret
= RegLoadKeyA(HKEY_LOCAL_MACHINE
, "Test", "saved_key");
1589 ok(ret
== ERROR_SUCCESS
, "expected ERROR_SUCCESS, got %d\n", ret
);
1591 set_privileges(SE_RESTORE_NAME
, FALSE
);
1593 ret
= RegOpenKeyA(HKEY_LOCAL_MACHINE
, "Test", &hkHandle
);
1594 ok(ret
== ERROR_SUCCESS
, "expected ERROR_SUCCESS, got %d\n", ret
);
1596 RegCloseKey(hkHandle
);
1599 static void test_reg_unload_key(void)
1603 if (!set_privileges(SE_RESTORE_NAME
, TRUE
) ||
1604 !set_privileges(SE_BACKUP_NAME
, FALSE
))
1606 win_skip("Failed to set SE_RESTORE_NAME privileges, skipping tests\n");
1610 ret
= RegUnLoadKeyA(HKEY_LOCAL_MACHINE
, "Test");
1611 ok(ret
== ERROR_SUCCESS
, "expected ERROR_SUCCESS, got %d\n", ret
);
1613 set_privileges(SE_RESTORE_NAME
, FALSE
);
1615 DeleteFileA("saved_key");
1616 DeleteFileA("saved_key.LOG");
1619 /* tests that show that RegConnectRegistry and
1620 OpenSCManager accept computer names without the
1621 \\ prefix (what MSDN says). */
1622 static void test_regconnectregistry( void)
1624 CHAR compName
[MAX_COMPUTERNAME_LENGTH
+ 1];
1625 CHAR netwName
[MAX_COMPUTERNAME_LENGTH
+ 3]; /* 2 chars for double backslash */
1626 DWORD len
= sizeof(compName
) ;
1632 SetLastError(0xdeadbeef);
1633 ret
= GetComputerNameA(compName
, &len
);
1634 ok( ret
, "GetComputerName failed err = %d\n", GetLastError());
1637 lstrcpyA(netwName
, "\\\\");
1638 lstrcpynA(netwName
+2, compName
, MAX_COMPUTERNAME_LENGTH
+ 1);
1640 retl
= RegConnectRegistryA( compName
, HKEY_LOCAL_MACHINE
, &hkey
);
1642 retl
== ERROR_DLL_INIT_FAILED
||
1643 retl
== ERROR_BAD_NETPATH
, /* some win2k */
1644 "RegConnectRegistryA failed err = %d\n", retl
);
1645 if( !retl
) RegCloseKey( hkey
);
1647 retl
= RegConnectRegistryA( netwName
, HKEY_LOCAL_MACHINE
, &hkey
);
1649 retl
== ERROR_DLL_INIT_FAILED
||
1650 retl
== ERROR_BAD_NETPATH
, /* some win2k */
1651 "RegConnectRegistryA failed err = %d\n", retl
);
1652 if( !retl
) RegCloseKey( hkey
);
1654 SetLastError(0xdeadbeef);
1655 schnd
= OpenSCManagerA( compName
, NULL
, GENERIC_READ
);
1656 if (GetLastError() == ERROR_CALL_NOT_IMPLEMENTED
)
1658 win_skip("OpenSCManagerA is not implemented\n");
1662 ok( schnd
!= NULL
, "OpenSCManagerA failed err = %d\n", GetLastError());
1663 CloseServiceHandle( schnd
);
1665 SetLastError(0xdeadbeef);
1666 schnd
= OpenSCManagerA( netwName
, NULL
, GENERIC_READ
);
1667 ok( schnd
!= NULL
, "OpenSCManagerA failed err = %d\n", GetLastError());
1668 CloseServiceHandle( schnd
);
1672 static void test_reg_query_value(void)
1679 static const WCHAR expected
[] = {'d','a','t','a',0};
1681 ret
= RegCreateKeyA(hkey_main
, "subkey", &subkey
);
1682 ok(ret
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", ret
);
1684 ret
= RegSetValueA(subkey
, NULL
, REG_SZ
, "data", 4);
1685 ok(ret
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", ret
);
1687 /* try an invalid hkey */
1688 SetLastError(0xdeadbeef);
1690 ret
= RegQueryValueA((HKEY
)0xcafebabe, "subkey", val
, &size
);
1691 ok(ret
== ERROR_INVALID_HANDLE
||
1692 ret
== ERROR_BADKEY
|| /* Windows 98 returns BADKEY */
1693 ret
== ERROR_ACCESS_DENIED
, /* non-admin winxp */
1694 "Expected ERROR_INVALID_HANDLE or ERROR_BADKEY, got %d\n", ret
);
1695 ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
1697 /* try a NULL hkey */
1698 SetLastError(0xdeadbeef);
1700 ret
= RegQueryValueA(NULL
, "subkey", val
, &size
);
1701 ok(ret
== ERROR_INVALID_HANDLE
|| ret
== ERROR_BADKEY
, /* Windows 98 returns BADKEY */
1702 "Expected ERROR_INVALID_HANDLE or ERROR_BADKEY, got %d\n", ret
);
1703 ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
1705 /* try a NULL value */
1707 ret
= RegQueryValueA(hkey_main
, "subkey", NULL
, &size
);
1708 ok(ret
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", ret
);
1709 ok(size
== 5, "Expected 5, got %d\n", size
);
1711 /* try a NULL size */
1712 SetLastError(0xdeadbeef);
1714 ret
= RegQueryValueA(hkey_main
, "subkey", val
, NULL
);
1715 ok(ret
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %d\n", ret
);
1716 ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
1717 ok(!val
[0], "Expected val to be untouched, got %s\n", val
);
1719 /* try a NULL value and size */
1720 ret
= RegQueryValueA(hkey_main
, "subkey", NULL
, NULL
);
1721 ok(ret
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", ret
);
1723 /* try a size too small */
1724 SetLastError(0xdeadbeef);
1727 ret
= RegQueryValueA(hkey_main
, "subkey", val
, &size
);
1728 ok(ret
== ERROR_MORE_DATA
, "Expected ERROR_MORE_DATA, got %d\n", ret
);
1729 ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
1730 ok(!val
[0], "Expected val to be untouched, got %s\n", val
);
1731 ok(size
== 5, "Expected 5, got %d\n", size
);
1733 /* successfully read the value using 'subkey' */
1735 ret
= RegQueryValueA(hkey_main
, "subkey", val
, &size
);
1736 ok(ret
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", ret
);
1737 ok(!lstrcmpA(val
, "data"), "Expected 'data', got '%s'\n", val
);
1738 ok(size
== 5, "Expected 5, got %d\n", size
);
1740 /* successfully read the value using the subkey key */
1742 ret
= RegQueryValueA(subkey
, NULL
, val
, &size
);
1743 ok(ret
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", ret
);
1744 ok(!lstrcmpA(val
, "data"), "Expected 'data', got '%s'\n", val
);
1745 ok(size
== 5, "Expected 5, got %d\n", size
);
1747 /* unicode - try size too small */
1748 SetLastError(0xdeadbeef);
1751 ret
= RegQueryValueW(subkey
, NULL
, valW
, &size
);
1752 if (GetLastError() == ERROR_CALL_NOT_IMPLEMENTED
)
1754 win_skip("RegQueryValueW is not implemented\n");
1757 ok(ret
== ERROR_MORE_DATA
, "Expected ERROR_MORE_DATA, got %d\n", ret
);
1758 ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
1759 ok(!valW
[0], "Expected valW to be untouched\n");
1760 ok(size
== sizeof(expected
), "Got wrong size: %d\n", size
);
1762 /* unicode - try size in WCHARS */
1763 SetLastError(0xdeadbeef);
1764 size
= ARRAY_SIZE(valW
);
1765 ret
= RegQueryValueW(subkey
, NULL
, valW
, &size
);
1766 ok(ret
== ERROR_MORE_DATA
, "Expected ERROR_MORE_DATA, got %d\n", ret
);
1767 ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
1768 ok(!valW
[0], "Expected valW to be untouched\n");
1769 ok(size
== sizeof(expected
), "Got wrong size: %d\n", size
);
1771 /* unicode - successfully read the value */
1772 size
= sizeof(valW
);
1773 ret
= RegQueryValueW(subkey
, NULL
, valW
, &size
);
1774 ok(ret
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", ret
);
1775 ok(!lstrcmpW(valW
, expected
), "Got wrong value\n");
1776 ok(size
== sizeof(expected
), "Got wrong size: %d\n", size
);
1778 /* unicode - set the value without a NULL terminator */
1779 ret
= RegSetValueW(subkey
, NULL
, REG_SZ
, expected
, sizeof(expected
)-sizeof(WCHAR
));
1780 ok(ret
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", ret
);
1782 /* unicode - read the unterminated value, value is terminated for us */
1783 memset(valW
, 'a', sizeof(valW
));
1784 size
= sizeof(valW
);
1785 ret
= RegQueryValueW(subkey
, NULL
, valW
, &size
);
1786 ok(ret
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", ret
);
1787 ok(!lstrcmpW(valW
, expected
), "Got wrong value\n");
1788 ok(size
== sizeof(expected
), "Got wrong size: %d\n", size
);
1791 RegDeleteKeyA(subkey
, "");
1792 RegCloseKey(subkey
);
1795 static void test_reg_query_info(void)
1800 char classbuffer
[32];
1801 WCHAR classbufferW
[32];
1802 char expectbuffer
[32];
1803 WCHAR expectbufferW
[32];
1804 char subkey_class
[] = "subkey class";
1805 WCHAR subkey_classW
[] = {'s','u','b','k','e','y',' ','c','l','a','s','s',0};
1806 char subsubkey_class
[] = "subsubkey class";
1808 DWORD subkeys
, maxsubkeylen
, maxclasslen
;
1809 DWORD values
, maxvaluenamelen
, maxvaluelen
;
1813 ret
= RegCreateKeyExA(hkey_main
, "subkey", 0, subkey_class
, 0, KEY_ALL_ACCESS
, NULL
, &subkey
, NULL
);
1814 ok(ret
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", ret
);
1816 /* all parameters NULL */
1817 ret
= RegQueryInfoKeyA(NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
);
1818 ok(ret
== ERROR_INVALID_HANDLE
, "ret = %d\n", ret
);
1820 ret
= RegQueryInfoKeyW(NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
);
1821 ok(ret
== ERROR_INVALID_HANDLE
, "ret = %d\n", ret
);
1823 /* not requesting any information */
1824 ret
= RegQueryInfoKeyA(subkey
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
);
1825 ok(ret
== ERROR_SUCCESS
, "ret = %d\n", ret
);
1827 ret
= RegQueryInfoKeyW(subkey
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
);
1828 ok(ret
== ERROR_SUCCESS
, "ret = %d\n", ret
);
1830 /* class without length is invalid */
1831 memset(classbuffer
, 0x55, sizeof(classbuffer
));
1832 ret
= RegQueryInfoKeyA(subkey
, classbuffer
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
);
1833 ok(ret
== ERROR_INVALID_PARAMETER
, "ret = %d\n", ret
);
1834 ok(classbuffer
[0] == 0x55, "classbuffer[0] = 0x%x\n", classbuffer
[0]);
1836 memset(classbufferW
, 0x55, sizeof(classbufferW
));
1837 ret
= RegQueryInfoKeyW(subkey
, classbufferW
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
);
1838 ok(ret
== ERROR_INVALID_PARAMETER
, "ret = %d\n", ret
);
1839 ok(classbufferW
[0] == 0x5555, "classbufferW[0] = 0x%x\n", classbufferW
[0]);
1842 sdlen
= classlen
=0;
1843 ret
= RegQueryInfoKeyA(subkey
, NULL
, &classlen
, NULL
, &subkeys
, &maxsubkeylen
, &maxclasslen
, &values
, &maxvaluenamelen
, &maxvaluelen
, &sdlen
, &lastwrite
);
1844 ok(ret
== ERROR_SUCCESS
, "ret = %d\n", ret
);
1845 ok(classlen
== strlen(subkey_class
), "classlen = %u\n", classlen
);
1846 ok(subkeys
== 0, "subkeys = %u\n", subkeys
);
1847 ok(maxsubkeylen
== 0, "maxsubkeylen = %u\n", maxsubkeylen
);
1848 ok(maxclasslen
== 0, "maxclasslen = %u\n", maxclasslen
);
1849 ok(values
== 0, "values = %u\n", values
);
1850 ok(maxvaluenamelen
== 0, "maxvaluenamelen = %u\n", maxvaluenamelen
);
1851 ok(maxvaluelen
== 0, "maxvaluelen = %u\n", maxvaluelen
);
1852 todo_wine
ok(sdlen
!= 0, "sdlen = %u\n", sdlen
);
1853 ok(lastwrite
.dwLowDateTime
!= 0, "lastwrite.dwLowDateTime = %u\n", lastwrite
.dwLowDateTime
);
1854 ok(lastwrite
.dwHighDateTime
!= 0, "lastwrite.dwHighDateTime = %u\n", lastwrite
.dwHighDateTime
);
1856 sdlen
= classlen
= 0;
1857 ret
= RegQueryInfoKeyW(subkey
, NULL
, &classlen
, NULL
, &subkeys
, &maxsubkeylen
, &maxclasslen
, &values
, &maxvaluenamelen
, &maxvaluelen
, &sdlen
, &lastwrite
);
1858 ok(ret
== ERROR_SUCCESS
, "ret = %d\n", ret
);
1859 ok(classlen
== strlen(subkey_class
), "classlen = %u\n", classlen
);
1860 ok(subkeys
== 0, "subkeys = %u\n", subkeys
);
1861 ok(maxsubkeylen
== 0, "maxsubkeylen = %u\n", maxsubkeylen
);
1862 ok(maxclasslen
== 0, "maxclasslen = %u\n", maxclasslen
);
1863 ok(values
== 0, "values = %u\n", values
);
1864 ok(maxvaluenamelen
== 0, "maxvaluenamelen = %u\n", maxvaluenamelen
);
1865 ok(maxvaluelen
== 0, "maxvaluelen = %u\n", maxvaluelen
);
1866 todo_wine
ok(sdlen
!= 0, "sdlen = %u\n", sdlen
);
1867 ok(lastwrite
.dwLowDateTime
!= 0, "lastwrite.dwLowDateTime = %u\n", lastwrite
.dwLowDateTime
);
1868 ok(lastwrite
.dwHighDateTime
!= 0, "lastwrite.dwHighDateTime = %u\n", lastwrite
.dwHighDateTime
);
1870 ret
= RegCreateKeyExA(subkey
, "subsubkey", 0, subsubkey_class
, 0, KEY_ALL_ACCESS
, NULL
, &subsubkey
, NULL
);
1871 ok(ret
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", ret
);
1873 ret
= RegSetValueExA(subkey
, NULL
, 0, REG_SZ
, (const BYTE
*)"data", 5);
1874 ok(ret
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", ret
);
1876 /* with subkey & default value */
1877 sdlen
= classlen
= 0;
1878 ret
= RegQueryInfoKeyA(subkey
, NULL
, &classlen
, NULL
, &subkeys
, &maxsubkeylen
, &maxclasslen
, &values
, &maxvaluenamelen
, &maxvaluelen
, &sdlen
, &lastwrite
);
1879 ok(ret
== ERROR_SUCCESS
, "ret = %d\n", ret
);
1880 ok(classlen
== strlen(subkey_class
), "classlen = %u\n", classlen
);
1881 ok(subkeys
== 1, "subkeys = %u\n", subkeys
);
1882 ok(maxsubkeylen
== strlen("subsubkey"), "maxsubkeylen = %u\n", maxsubkeylen
);
1883 ok(maxclasslen
== strlen(subsubkey_class
), "maxclasslen = %u\n", maxclasslen
);
1884 ok(values
== 1, "values = %u\n", values
);
1885 ok(maxvaluenamelen
== 0, "maxvaluenamelen = %u\n", maxvaluenamelen
);
1886 ok(maxvaluelen
== sizeof("data") * sizeof(WCHAR
), "maxvaluelen = %u\n", maxvaluelen
);
1887 todo_wine
ok(sdlen
!= 0, "sdlen = %u\n", sdlen
);
1888 ok(lastwrite
.dwLowDateTime
!= 0, "lastwrite.dwLowDateTime = %u\n", lastwrite
.dwLowDateTime
);
1889 ok(lastwrite
.dwHighDateTime
!= 0, "lastwrite.dwHighDateTime = %u\n", lastwrite
.dwHighDateTime
);
1891 sdlen
= classlen
= 0;
1892 ret
= RegQueryInfoKeyW(subkey
, NULL
, &classlen
, NULL
, &subkeys
, &maxsubkeylen
, &maxclasslen
, &values
, &maxvaluenamelen
, &maxvaluelen
, &sdlen
, &lastwrite
);
1893 ok(ret
== ERROR_SUCCESS
, "ret = %d\n", ret
);
1894 ok(classlen
== strlen(subkey_class
), "classlen = %u\n", classlen
);
1895 ok(subkeys
== 1, "subkeys = %u\n", subkeys
);
1896 ok(maxsubkeylen
== strlen("subsubkey"), "maxsubkeylen = %u\n", maxsubkeylen
);
1897 ok(maxclasslen
== strlen(subsubkey_class
), "maxclasslen = %u\n", maxclasslen
);
1898 ok(values
== 1, "values = %u\n", values
);
1899 ok(maxvaluenamelen
== 0, "maxvaluenamelen = %u\n", maxvaluenamelen
);
1900 ok(maxvaluelen
== sizeof("data") * sizeof(WCHAR
), "maxvaluelen = %u\n", maxvaluelen
);
1901 todo_wine
ok(sdlen
!= 0, "sdlen = %u\n", sdlen
);
1902 ok(lastwrite
.dwLowDateTime
!= 0, "lastwrite.dwLowDateTime = %u\n", lastwrite
.dwLowDateTime
);
1903 ok(lastwrite
.dwHighDateTime
!= 0, "lastwrite.dwHighDateTime = %u\n", lastwrite
.dwHighDateTime
);
1905 ret
= RegSetValueExA(subkey
, "value one", 0, REG_SZ
, (const BYTE
*)"first value data", 17);
1906 ok(ret
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", ret
);
1908 ret
= RegSetValueExA(subkey
, "value 2", 0, REG_SZ
, (const BYTE
*)"second value data", 18);
1909 ok(ret
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", ret
);
1911 /* with named value */
1913 ret
= RegQueryInfoKeyA(subkey
, NULL
, &classlen
, NULL
, &subkeys
, &maxsubkeylen
, &maxclasslen
, &values
, &maxvaluenamelen
, &maxvaluelen
, &sdlen
, &lastwrite
);
1914 ok(ret
== ERROR_SUCCESS
, "ret = %d\n", ret
);
1915 ok(values
== 3, "values = %u\n", values
);
1916 ok(maxvaluenamelen
== strlen("value one"), "maxvaluenamelen = %u\n", maxvaluenamelen
);
1917 ok(maxvaluelen
== sizeof("second value data") * sizeof(WCHAR
), "maxvaluelen = %u\n", maxvaluelen
);
1920 ret
= RegQueryInfoKeyW(subkey
, NULL
, &classlen
, NULL
, &subkeys
, &maxsubkeylen
, &maxclasslen
, &values
, &maxvaluenamelen
, &maxvaluelen
, &sdlen
, &lastwrite
);
1921 ok(ret
== ERROR_SUCCESS
, "ret = %d\n", ret
);
1922 ok(values
== 3, "values = %u\n", values
);
1923 ok(maxvaluenamelen
== strlen("value one"), "maxvaluenamelen = %u\n", maxvaluenamelen
);
1924 ok(maxvaluelen
== sizeof("second value data") * sizeof(WCHAR
), "maxvaluelen = %u\n", maxvaluelen
);
1926 /* class name with zero size buffer */
1927 memset(classbuffer
, 0x55, sizeof(classbuffer
));
1929 ret
= RegQueryInfoKeyA(subkey
, classbuffer
, &classlen
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
);
1930 ok(ret
== ERROR_SUCCESS
, "ret = %d\n", ret
);
1931 ok(classlen
== strlen(subkey_class
) /* win2k */ ||
1932 classlen
== 0, "classlen = %u\n", classlen
);
1933 memset(expectbuffer
, 0x55, sizeof(expectbuffer
));
1934 ok(!memcmp(classbuffer
, expectbuffer
, sizeof(classbuffer
)), "classbuffer was modified\n");
1936 memset(classbufferW
, 0x55, sizeof(classbufferW
));
1938 ret
= RegQueryInfoKeyW(subkey
, classbufferW
, &classlen
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
);
1939 ok(ret
== ERROR_SUCCESS
, "ret = %d\n", ret
);
1940 ok(classlen
== strlen(subkey_class
) /* win2k */ ||
1941 classlen
== 0, "classlen = %u\n", classlen
);
1942 memset(expectbufferW
, 0x55, sizeof(expectbufferW
));
1943 ok(!memcmp(classbufferW
, expectbufferW
, sizeof(classbufferW
)), "classbufferW was modified\n");
1945 /* class name with one char buffer */
1946 memset(classbuffer
, 0x55, sizeof(classbuffer
));
1948 ret
= RegQueryInfoKeyA(subkey
, classbuffer
, &classlen
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
);
1949 ok(ret
== ERROR_MORE_DATA
, "ret = %d\n", ret
);
1950 ok(classlen
== 0, "classlen = %u\n", classlen
);
1951 memset(expectbuffer
, 0x55, sizeof(expectbuffer
));
1952 expectbuffer
[0] = 0;
1953 ok(!memcmp(classbuffer
, expectbuffer
, sizeof(classbuffer
)), "classbuffer was modified\n");
1955 memset(classbufferW
, 0x55, sizeof(classbufferW
));
1957 ret
= RegQueryInfoKeyW(subkey
, classbufferW
, &classlen
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
);
1958 /* failure-code changed to ERROR_MORE_DATA in recent win10 */
1959 ok((ret
== ERROR_INSUFFICIENT_BUFFER
) || (ret
== ERROR_MORE_DATA
), "ret = %d\n", ret
);
1960 ok(classlen
== 0 /* win8 */ ||
1961 classlen
== strlen(subkey_class
), "classlen = %u\n", classlen
);
1962 memset(expectbufferW
, 0x55, sizeof(expectbufferW
));
1963 ok(!memcmp(classbufferW
, expectbufferW
, sizeof(classbufferW
)), "classbufferW was modified\n");
1965 /* class name with buffer one char too small */
1966 memset(classbuffer
, 0x55, sizeof(classbuffer
));
1967 classlen
= sizeof(subkey_class
) - 1;
1968 ret
= RegQueryInfoKeyA(subkey
, classbuffer
, &classlen
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
);
1969 ok(ret
== ERROR_MORE_DATA
, "ret = %d\n", ret
);
1970 ok(classlen
== sizeof(subkey_class
) - 2, "classlen = %u\n", classlen
);
1971 memset(expectbuffer
, 0x55, sizeof(expectbuffer
));
1972 strcpy(expectbuffer
, subkey_class
);
1973 expectbuffer
[sizeof(subkey_class
) - 2] = 0;
1974 expectbuffer
[sizeof(subkey_class
) - 1] = 0x55;
1975 ok(!memcmp(classbuffer
, expectbuffer
, sizeof(classbuffer
)),
1976 "classbuffer = %.*s, expected %s\n",
1977 (int)sizeof(classbuffer
), classbuffer
, expectbuffer
);
1979 memset(classbufferW
, 0x55, sizeof(classbufferW
));
1980 classlen
= sizeof(subkey_class
) - 1;
1981 ret
= RegQueryInfoKeyW(subkey
, classbufferW
, &classlen
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
);
1982 ok(ret
== ERROR_INSUFFICIENT_BUFFER
, "ret = %d\n", ret
);
1983 ok(classlen
== sizeof(subkey_class
) - 2 /* win8 */ ||
1984 classlen
== strlen(subkey_class
), "classlen = %u\n", classlen
);
1985 memset(expectbufferW
, 0x55, sizeof(expectbufferW
));
1986 ok(!memcmp(classbufferW
, expectbufferW
, sizeof(classbufferW
)), "classbufferW was modified\n");
1988 /* class name with large enough buffer */
1989 memset(classbuffer
, 0x55, sizeof(classbuffer
));
1990 classlen
= sizeof(subkey_class
);
1991 ret
= RegQueryInfoKeyA(subkey
, classbuffer
, &classlen
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
);
1992 ok(ret
== ERROR_SUCCESS
, "ret = %d\n", ret
);
1993 ok(classlen
== sizeof(subkey_class
) - 1, "classlen = %u\n", classlen
);
1994 memset(expectbuffer
, 0x55, sizeof(expectbuffer
));
1995 strcpy(expectbuffer
, subkey_class
);
1996 ok(!memcmp(classbuffer
, expectbuffer
, sizeof(classbuffer
)),
1997 "classbuffer = \"%.*s\", expected %s\n",
1998 (int)sizeof(classbuffer
), classbuffer
, expectbuffer
);
2000 memset(classbuffer
, 0x55, sizeof(classbuffer
));
2001 classlen
= 0xdeadbeef;
2002 ret
= RegQueryInfoKeyA(subkey
, classbuffer
, &classlen
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
);
2003 ok(ret
== ERROR_SUCCESS
, "ret = %d\n", ret
);
2004 ok(classlen
== sizeof(subkey_class
) - 1, "classlen = %u\n", classlen
);
2005 memset(expectbuffer
, 0x55, sizeof(expectbuffer
));
2006 strcpy(expectbuffer
, subkey_class
);
2007 ok(!memcmp(classbuffer
, expectbuffer
, sizeof(classbuffer
)),
2008 "classbuffer = \"%.*s\", expected %s\n",
2009 (int)sizeof(classbuffer
), classbuffer
, expectbuffer
);
2011 memset(classbufferW
, 0x55, sizeof(classbufferW
));
2012 classlen
= sizeof(subkey_class
);
2013 ret
= RegQueryInfoKeyW(subkey
, classbufferW
, &classlen
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
);
2014 ok(ret
== ERROR_SUCCESS
, "ret = %d\n", ret
);
2015 ok(classlen
== sizeof(subkey_class
) - 1, "classlen = %u\n", classlen
);
2016 memset(expectbufferW
, 0x55, sizeof(expectbufferW
));
2017 lstrcpyW(expectbufferW
, subkey_classW
);
2018 ok(!memcmp(classbufferW
, expectbufferW
, sizeof(classbufferW
)),
2019 "classbufferW = %s, expected %s\n",
2020 wine_dbgstr_wn(classbufferW
, ARRAY_SIZE(classbufferW
)), wine_dbgstr_w(expectbufferW
));
2022 memset(classbufferW
, 0x55, sizeof(classbufferW
));
2023 classlen
= 0xdeadbeef;
2024 ret
= RegQueryInfoKeyW(subkey
, classbufferW
, &classlen
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
);
2025 ok(ret
== ERROR_SUCCESS
, "ret = %d\n", ret
);
2026 ok(classlen
== sizeof(subkey_class
) - 1, "classlen = %u\n", classlen
);
2027 memset(expectbufferW
, 0x55, sizeof(expectbufferW
));
2028 lstrcpyW(expectbufferW
, subkey_classW
);
2029 ok(!memcmp(classbufferW
, expectbufferW
, sizeof(classbufferW
)),
2030 "classbufferW = %s, expected %s\n",
2031 wine_dbgstr_wn(classbufferW
, ARRAY_SIZE(classbufferW
)), wine_dbgstr_w(expectbufferW
));
2033 RegDeleteKeyA(subsubkey
, "");
2034 RegCloseKey(subsubkey
);
2035 RegDeleteKeyA(subkey
, "");
2036 RegCloseKey(subkey
);
2039 static void test_string_termination(void)
2043 static const char string
[] = "FullString";
2046 DWORD insize
, outsize
, nsize
;
2048 ret
= RegCreateKeyA(hkey_main
, "string_termination", &subkey
);
2049 ok(ret
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", ret
);
2051 /* Off-by-one RegSetValueExA -> adds a trailing '\0'! */
2052 insize
=sizeof(string
)-1;
2053 ret
= RegSetValueExA(subkey
, "stringtest", 0, REG_SZ
, (BYTE
*)string
, insize
);
2054 ok(ret
== ERROR_SUCCESS
, "RegSetValueExA failed: %d\n", ret
);
2056 ret
= RegQueryValueExA(subkey
, "stringtest", NULL
, NULL
, buffer
, &outsize
);
2057 ok(ret
== ERROR_MORE_DATA
, "RegQueryValueExA returned: %d\n", ret
);
2059 /* Off-by-two RegSetValueExA -> no trailing '\0' */
2060 insize
=sizeof(string
)-2;
2061 ret
= RegSetValueExA(subkey
, "stringtest", 0, REG_SZ
, (BYTE
*)string
, insize
);
2062 ok(ret
== ERROR_SUCCESS
, "RegSetValueExA failed: %d\n", ret
);
2064 ret
= RegQueryValueExA(subkey
, "stringtest", NULL
, NULL
, NULL
, &outsize
);
2065 ok(ret
== ERROR_SUCCESS
, "RegQueryValueExA failed: %d\n", ret
);
2066 ok(outsize
== insize
, "wrong size %u != %u\n", outsize
, insize
);
2068 /* RegQueryValueExA may return a string with no trailing '\0' */
2070 memset(buffer
, 0xbd, sizeof(buffer
));
2071 ret
= RegQueryValueExA(subkey
, "stringtest", NULL
, NULL
, buffer
, &outsize
);
2072 ok(ret
== ERROR_SUCCESS
, "RegQueryValueExA failed: %d\n", ret
);
2073 ok(outsize
== insize
, "wrong size: %u != %u\n", outsize
, insize
);
2074 ok(memcmp(buffer
, string
, outsize
) == 0, "bad string: %s/%u != %s\n",
2075 wine_debugstr_an((char*)buffer
, outsize
), outsize
, string
);
2076 ok(buffer
[insize
] == 0xbd, "buffer overflow at %u %02x\n", insize
, buffer
[insize
]);
2078 /* RegQueryValueExA adds a trailing '\0' if there is room */
2080 memset(buffer
, 0xbd, sizeof(buffer
));
2081 ret
= RegQueryValueExA(subkey
, "stringtest", NULL
, NULL
, buffer
, &outsize
);
2082 ok(ret
== ERROR_SUCCESS
, "RegQueryValueExA failed: %d\n", ret
);
2083 ok(outsize
== insize
, "wrong size: %u != %u\n", outsize
, insize
);
2084 ok(memcmp(buffer
, string
, outsize
) == 0, "bad string: %s/%u != %s\n",
2085 wine_debugstr_an((char*)buffer
, outsize
), outsize
, string
);
2086 ok(buffer
[insize
] == 0, "buffer overflow at %u %02x\n", insize
, buffer
[insize
]);
2088 /* RegEnumValueA may return a string with no trailing '\0' */
2090 memset(buffer
, 0xbd, sizeof(buffer
));
2092 ret
= RegEnumValueA(subkey
, 0, name
, &nsize
, NULL
, NULL
, buffer
, &outsize
);
2093 ok(ret
== ERROR_SUCCESS
, "RegEnumValueA failed: %d\n", ret
);
2094 ok(strcmp(name
, "stringtest") == 0, "wrong name: %s\n", name
);
2095 ok(outsize
== insize
, "wrong size: %u != %u\n", outsize
, insize
);
2096 ok(memcmp(buffer
, string
, outsize
) == 0, "bad string: %s/%u != %s\n",
2097 wine_debugstr_an((char*)buffer
, outsize
), outsize
, string
);
2098 ok(buffer
[insize
] == 0xbd, "buffer overflow at %u %02x\n", insize
, buffer
[insize
]);
2100 /* RegEnumValueA adds a trailing '\0' if there is room */
2102 memset(buffer
, 0xbd, sizeof(buffer
));
2104 ret
= RegEnumValueA(subkey
, 0, name
, &nsize
, NULL
, NULL
, buffer
, &outsize
);
2105 ok(ret
== ERROR_SUCCESS
, "RegEnumValueA failed: %d\n", ret
);
2106 ok(strcmp(name
, "stringtest") == 0, "wrong name: %s\n", name
);
2107 ok(outsize
== insize
, "wrong size: %u != %u\n", outsize
, insize
);
2108 ok(memcmp(buffer
, string
, outsize
) == 0, "bad string: %s/%u != %s\n",
2109 wine_debugstr_an((char*)buffer
, outsize
), outsize
, string
);
2110 ok(buffer
[insize
] == 0, "buffer overflow at %u %02x\n", insize
, buffer
[insize
]);
2112 RegDeleteKeyA(subkey
, "");
2113 RegCloseKey(subkey
);
2116 static void test_reg_copy_tree(void)
2118 HKEY src
, dst
, subkey
;
2119 CHAR buffer
[MAX_PATH
];
2125 win_skip("Skipping RegCopyTreeA tests, function not present\n");
2129 ret
= RegCreateKeyA(hkey_main
, "src", &src
);
2130 ok(ret
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", ret
);
2131 ret
= RegCreateKeyA(hkey_main
, "dst", &dst
);
2132 ok(ret
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", ret
);
2134 /* Copy nonexistent subkey */
2135 ret
= pRegCopyTreeA(src
, "nonexistent_subkey", dst
);
2136 ok(ret
== ERROR_FILE_NOT_FOUND
, "Expected ERROR_FILE_NOT_FOUND, got %d\n", ret
);
2138 /* Create test keys and values */
2139 ret
= RegSetValueA(src
, NULL
, REG_SZ
, "data", 4);
2140 ok(ret
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", ret
);
2141 ret
= RegSetValueExA(src
, "value", 0, REG_SZ
, (const BYTE
*)"data2", 5);
2142 ok(ret
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", ret
);
2144 ret
= RegCreateKeyA(src
, "subkey2", &subkey
);
2145 ok(ret
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", ret
);
2146 ret
= RegSetValueA(subkey
, NULL
, REG_SZ
, "data3", 5);
2147 ok(ret
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", ret
);
2148 ret
= RegSetValueExA(subkey
, "value", 0, REG_SZ
, (const BYTE
*)"data4", 5);
2149 ok(ret
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", ret
);
2150 ret
= RegCloseKey(subkey
);
2151 ok(ret
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", ret
);
2153 ret
= RegCreateKeyA(src
, "subkey3", &subkey
);
2154 ok(ret
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", ret
);
2155 ret
= RegCloseKey(subkey
);
2156 ok(ret
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", ret
);
2159 ret
= pRegCopyTreeA(src
, "subkey2", dst
);
2160 ok(ret
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", ret
);
2163 ret
= RegQueryValueA(dst
, NULL
, buffer
, &size
);
2164 ok(ret
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", ret
);
2165 ok(!strcmp(buffer
, "data3"), "Expected 'data3', got '%s'\n", buffer
);
2168 ret
= RegQueryValueExA(dst
, "value", NULL
, &type
, (BYTE
*)buffer
, &dwsize
);
2169 ok(ret
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", ret
);
2170 ok(type
== REG_SZ
, "Expected REG_SZ, got %u\n", type
);
2171 ok(!strcmp(buffer
, "data4"), "Expected 'data4', got '%s'\n", buffer
);
2173 /* Copy full tree */
2174 ret
= pRegCopyTreeA(src
, NULL
, dst
);
2175 ok(ret
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", ret
);
2178 ret
= RegQueryValueA(dst
, NULL
, buffer
, &size
);
2179 ok(ret
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", ret
);
2180 ok(!strcmp(buffer
, "data"), "Expected 'data', got '%s'\n", buffer
);
2183 ret
= RegQueryValueExA(dst
, "value", NULL
, &type
, (BYTE
*)buffer
, &dwsize
);
2184 ok(ret
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", ret
);
2185 ok(type
== REG_SZ
, "Expected REG_SZ, got %u\n", type
);
2186 ok(!strcmp(buffer
, "data2"), "Expected 'data2', got '%s'\n", buffer
);
2188 ret
= RegOpenKeyA(dst
, "subkey2", &subkey
);
2189 ok(ret
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", ret
);
2191 ret
= RegQueryValueA(subkey
, NULL
, buffer
, &size
);
2192 ok(ret
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", ret
);
2193 ok(!strcmp(buffer
, "data3"), "Expected 'data3', got '%s'\n", buffer
);
2195 ret
= RegQueryValueExA(subkey
, "value", NULL
, &type
, (BYTE
*)buffer
, &dwsize
);
2196 ok(ret
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", ret
);
2197 ok(type
== REG_SZ
, "Expected REG_SZ, got %u\n", type
);
2198 ok(!strcmp(buffer
, "data4"), "Expected 'data4', got '%s'\n", buffer
);
2199 ret
= RegCloseKey(subkey
);
2200 ok(ret
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", ret
);
2202 ret
= RegOpenKeyA(dst
, "subkey3", &subkey
);
2203 ok(ret
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", ret
);
2204 ret
= RegCloseKey(subkey
);
2205 ok(ret
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", ret
);
2211 static void test_reg_delete_tree(void)
2213 CHAR buffer
[MAX_PATH
];
2214 HKEY subkey
, subkey2
;
2218 if(!pRegDeleteTreeA
) {
2219 win_skip("Skipping RegDeleteTreeA tests, function not present\n");
2223 ret
= RegCreateKeyA(hkey_main
, "subkey", &subkey
);
2224 ok(ret
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", ret
);
2225 ret
= RegCreateKeyA(subkey
, "subkey2", &subkey2
);
2226 ok(ret
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", ret
);
2227 ret
= RegSetValueA(subkey
, NULL
, REG_SZ
, "data", 4);
2228 ok(ret
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", ret
);
2229 ret
= RegSetValueA(subkey2
, NULL
, REG_SZ
, "data2", 5);
2230 ok(ret
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", ret
);
2231 ret
= RegCloseKey(subkey2
);
2232 ok(ret
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", ret
);
2234 ret
= pRegDeleteTreeA(subkey
, "subkey2");
2235 ok(ret
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", ret
);
2236 ok(RegOpenKeyA(subkey
, "subkey2", &subkey2
),
2237 "subkey2 was not deleted\n");
2239 ok(!RegQueryValueA(subkey
, NULL
, buffer
, &size
),
2240 "Default value of subkey no longer present\n");
2242 ret
= RegCreateKeyA(subkey
, "subkey2", &subkey2
);
2243 ok(ret
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", ret
);
2244 ret
= RegCloseKey(subkey2
);
2245 ok(ret
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", ret
);
2246 ret
= pRegDeleteTreeA(hkey_main
, "subkey\\subkey2");
2247 ok(ret
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", ret
);
2248 ok(RegOpenKeyA(subkey
, "subkey2", &subkey2
),
2249 "subkey2 was not deleted\n");
2250 ok(!RegQueryValueA(subkey
, NULL
, buffer
, &size
),
2251 "Default value of subkey no longer present\n");
2253 ret
= RegCreateKeyA(subkey
, "subkey2", &subkey2
);
2254 ok(ret
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", ret
);
2255 ret
= RegCloseKey(subkey2
);
2256 ok(ret
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", ret
);
2257 ret
= RegCreateKeyA(subkey
, "subkey3", &subkey2
);
2258 ok(ret
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", ret
);
2259 ret
= RegCloseKey(subkey2
);
2260 ok(ret
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", ret
);
2261 ret
= RegSetValueA(subkey
, NULL
, REG_SZ
, "data", 4);
2262 ok(ret
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", ret
);
2263 ret
= RegSetValueExA(subkey
, "value", 0, REG_SZ
, (const BYTE
*)"data2", 5);
2264 ok(ret
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", ret
);
2265 ret
= pRegDeleteTreeA(subkey
, NULL
);
2266 ok(ret
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", ret
);
2267 ok(!RegOpenKeyA(hkey_main
, "subkey", &subkey
),
2268 "subkey was deleted\n");
2269 ok(RegOpenKeyA(subkey
, "subkey2", &subkey2
),
2270 "subkey2 was not deleted\n");
2271 ok(RegOpenKeyA(subkey
, "subkey3", &subkey2
),
2272 "subkey3 was not deleted\n");
2274 ret
= RegQueryValueA(subkey
, NULL
, buffer
, &size
);
2275 ok(ret
== ERROR_SUCCESS
,
2276 "Default value of subkey is not present\n");
2277 ok(!buffer
[0], "Expected length 0 got length %u(%s)\n", lstrlenA(buffer
), buffer
);
2279 ok(RegQueryValueExA(subkey
, "value", NULL
, &type
, (BYTE
*)buffer
, &dwsize
),
2280 "Value is still present\n");
2281 ret
= RegCloseKey(subkey
);
2282 ok(ret
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", ret
);
2284 ret
= RegOpenKeyA(hkey_main
, "subkey", &subkey
);
2285 ok(ret
== ERROR_SUCCESS
, "subkey was deleted\n");
2286 ret
= pRegDeleteTreeA(subkey
, "");
2287 ok(ret
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", ret
);
2288 ret
= RegCloseKey(subkey
);
2289 ok(ret
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", ret
);
2291 ret
= RegOpenKeyA(hkey_main
, "subkey", &subkey
);
2292 ok(ret
== ERROR_SUCCESS
, "subkey was deleted\n");
2293 ret
= RegCloseKey(subkey
);
2294 ok(ret
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", ret
);
2296 ret
= pRegDeleteTreeA(hkey_main
, "not-here");
2297 ok(ret
== ERROR_FILE_NOT_FOUND
,
2298 "Expected ERROR_FILE_NOT_FOUND, got %d\n", ret
);
2301 static void test_rw_order(void)
2305 static const char keyname
[] = "test_rw_order";
2307 DWORD values
, value_len
, value_name_max_len
;
2310 RegDeleteKeyA(HKEY_CURRENT_USER
, keyname
);
2311 ret
= RegCreateKeyA(HKEY_CURRENT_USER
, keyname
, &hKey
);
2312 if(ret
!= ERROR_SUCCESS
) {
2313 skip("Couldn't create key. Skipping.\n");
2317 ok(!RegSetValueExA(hKey
, "A", 0, REG_DWORD
, (LPBYTE
)&dw
, sizeof(dw
)),
2318 "RegSetValueExA for value \"A\" failed\n");
2319 ok(!RegSetValueExA(hKey
, "C", 0, REG_DWORD
, (LPBYTE
)&dw
, sizeof(dw
)),
2320 "RegSetValueExA for value \"C\" failed\n");
2321 ok(!RegSetValueExA(hKey
, "D", 0, REG_DWORD
, (LPBYTE
)&dw
, sizeof(dw
)),
2322 "RegSetValueExA for value \"D\" failed\n");
2323 ok(!RegSetValueExA(hKey
, "B", 0, REG_DWORD
, (LPBYTE
)&dw
, sizeof(dw
)),
2324 "RegSetValueExA for value \"B\" failed\n");
2326 ok(!RegQueryInfoKeyA(hKey
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, &values
,
2327 &value_name_max_len
, NULL
, NULL
, NULL
), "RegQueryInfoKeyA failed\n");
2328 ok(values
== 4, "Expected 4 values, got %u\n", values
);
2330 /* Value enumeration preserves RegSetValueEx call order */
2332 ok(!RegEnumValueA(hKey
, 0, value_buf
, &value_len
, NULL
, NULL
, NULL
, NULL
), "RegEnumValueA failed\n");
2333 ok(strcmp(value_buf
, "A") == 0, "Expected name \"A\", got %s\n", value_buf
);
2335 ok(!RegEnumValueA(hKey
, 1, value_buf
, &value_len
, NULL
, NULL
, NULL
, NULL
), "RegEnumValueA failed\n");
2336 todo_wine
ok(strcmp(value_buf
, "C") == 0, "Expected name \"C\", got %s\n", value_buf
);
2338 ok(!RegEnumValueA(hKey
, 2, value_buf
, &value_len
, NULL
, NULL
, NULL
, NULL
), "RegEnumValueA failed\n");
2339 todo_wine
ok(strcmp(value_buf
, "D") == 0, "Expected name \"D\", got %s\n", value_buf
);
2341 ok(!RegEnumValueA(hKey
, 3, value_buf
, &value_len
, NULL
, NULL
, NULL
, NULL
), "RegEnumValueA failed\n");
2342 todo_wine
ok(strcmp(value_buf
, "B") == 0, "Expected name \"B\", got %s\n", value_buf
);
2344 ok(!RegDeleteKeyA(HKEY_CURRENT_USER
, keyname
), "Failed to delete key\n");
2347 static void test_symlinks(void)
2349 static const WCHAR targetW
[] = {'\\','S','o','f','t','w','a','r','e','\\','W','i','n','e',
2350 '\\','T','e','s','t','\\','t','a','r','g','e','t',0};
2352 UNICODE_STRING target_str
;
2356 DWORD target_len
, type
, len
, dw
, err
;
2358 if (!pRtlFormatCurrentUserKeyPath
|| !pNtDeleteKey
)
2360 win_skip( "Can't perform symlink tests\n" );
2364 pRtlFormatCurrentUserKeyPath( &target_str
);
2366 target_len
= target_str
.Length
+ sizeof(targetW
);
2367 target
= HeapAlloc( GetProcessHeap(), 0, target_len
);
2368 memcpy( target
, target_str
.Buffer
, target_str
.Length
);
2369 memcpy( target
+ target_str
.Length
/sizeof(WCHAR
), targetW
, sizeof(targetW
) );
2371 err
= RegCreateKeyExA( hkey_main
, "link", 0, NULL
, REG_OPTION_CREATE_LINK
,
2372 KEY_ALL_ACCESS
, NULL
, &link
, NULL
);
2373 ok( err
== ERROR_SUCCESS
, "RegCreateKeyEx failed: %u\n", err
);
2375 /* REG_SZ is not allowed */
2376 err
= RegSetValueExA( link
, "SymbolicLinkValue", 0, REG_SZ
, (BYTE
*)"foobar", sizeof("foobar") );
2377 ok( err
== ERROR_ACCESS_DENIED
, "RegSetValueEx wrong error %u\n", err
);
2378 err
= RegSetValueExA( link
, "SymbolicLinkValue", 0, REG_LINK
,
2379 (BYTE
*)target
, target_len
- sizeof(WCHAR
) );
2380 ok( err
== ERROR_SUCCESS
, "RegSetValueEx failed error %u\n", err
);
2381 /* other values are not allowed */
2382 err
= RegSetValueExA( link
, "link", 0, REG_LINK
, (BYTE
*)target
, target_len
- sizeof(WCHAR
) );
2383 ok( err
== ERROR_ACCESS_DENIED
, "RegSetValueEx wrong error %u\n", err
);
2385 /* try opening the target through the link */
2387 err
= RegOpenKeyA( hkey_main
, "link", &key
);
2388 ok( err
== ERROR_FILE_NOT_FOUND
, "RegOpenKey wrong error %u\n", err
);
2390 err
= RegCreateKeyExA( hkey_main
, "target", 0, NULL
, 0, KEY_ALL_ACCESS
, NULL
, &key
, NULL
);
2391 ok( err
== ERROR_SUCCESS
, "RegCreateKeyEx failed error %u\n", err
);
2394 err
= RegSetValueExA( key
, "value", 0, REG_DWORD
, (BYTE
*)&dw
, sizeof(dw
) );
2395 ok( err
== ERROR_SUCCESS
, "RegSetValueEx failed error %u\n", err
);
2398 err
= RegOpenKeyA( hkey_main
, "link", &key
);
2399 ok( err
== ERROR_SUCCESS
, "RegOpenKey failed error %u\n", err
);
2401 len
= sizeof(buffer
);
2402 err
= RegQueryValueExA( key
, "value", NULL
, &type
, buffer
, &len
);
2403 ok( err
== ERROR_SUCCESS
, "RegOpenKey failed error %u\n", err
);
2404 ok( len
== sizeof(DWORD
), "wrong len %u\n", len
);
2406 len
= sizeof(buffer
);
2407 err
= RegQueryValueExA( key
, "SymbolicLinkValue", NULL
, &type
, buffer
, &len
);
2408 ok( err
== ERROR_FILE_NOT_FOUND
, "RegQueryValueEx wrong error %u\n", err
);
2410 /* REG_LINK can be created in non-link keys */
2411 err
= RegSetValueExA( key
, "SymbolicLinkValue", 0, REG_LINK
,
2412 (BYTE
*)target
, target_len
- sizeof(WCHAR
) );
2413 ok( err
== ERROR_SUCCESS
, "RegSetValueEx failed error %u\n", err
);
2414 len
= sizeof(buffer
);
2415 err
= RegQueryValueExA( key
, "SymbolicLinkValue", NULL
, &type
, buffer
, &len
);
2416 ok( err
== ERROR_SUCCESS
, "RegQueryValueEx failed error %u\n", err
);
2417 ok( len
== target_len
- sizeof(WCHAR
), "wrong len %u\n", len
);
2418 err
= RegDeleteValueA( key
, "SymbolicLinkValue" );
2419 ok( err
== ERROR_SUCCESS
, "RegDeleteValue failed error %u\n", err
);
2423 err
= RegCreateKeyExA( hkey_main
, "link", 0, NULL
, 0, KEY_ALL_ACCESS
, NULL
, &key
, NULL
);
2424 ok( err
== ERROR_SUCCESS
, "RegCreateKeyEx failed error %u\n", err
);
2426 len
= sizeof(buffer
);
2427 err
= RegQueryValueExA( key
, "value", NULL
, &type
, buffer
, &len
);
2428 ok( err
== ERROR_SUCCESS
, "RegQueryValueEx failed error %u\n", err
);
2429 ok( len
== sizeof(DWORD
), "wrong len %u\n", len
);
2431 err
= RegQueryValueExA( key
, "SymbolicLinkValue", NULL
, &type
, buffer
, &len
);
2432 ok( err
== ERROR_FILE_NOT_FOUND
, "RegQueryValueEx wrong error %u\n", err
);
2435 /* now open the symlink itself */
2437 err
= RegOpenKeyExA( hkey_main
, "link", REG_OPTION_OPEN_LINK
, KEY_ALL_ACCESS
, &key
);
2438 ok( err
== ERROR_SUCCESS
, "RegOpenKeyEx failed error %u\n", err
);
2439 len
= sizeof(buffer
);
2440 err
= RegQueryValueExA( key
, "SymbolicLinkValue", NULL
, &type
, buffer
, &len
);
2441 ok( err
== ERROR_SUCCESS
, "RegQueryValueEx failed error %u\n", err
);
2442 ok( len
== target_len
- sizeof(WCHAR
), "wrong len %u\n", len
);
2445 err
= RegCreateKeyExA( hkey_main
, "link", 0, NULL
, REG_OPTION_OPEN_LINK
,
2446 KEY_ALL_ACCESS
, NULL
, &key
, NULL
);
2447 ok( err
== ERROR_SUCCESS
, "RegCreateKeyEx failed error %u\n", err
);
2448 len
= sizeof(buffer
);
2449 err
= RegQueryValueExA( key
, "SymbolicLinkValue", NULL
, &type
, buffer
, &len
);
2450 ok( err
== ERROR_SUCCESS
, "RegQueryValueEx failed error %u\n", err
);
2451 ok( len
== target_len
- sizeof(WCHAR
), "wrong len %u\n", len
);
2454 err
= RegCreateKeyExA( hkey_main
, "link", 0, NULL
, REG_OPTION_CREATE_LINK
,
2455 KEY_ALL_ACCESS
, NULL
, &key
, NULL
);
2456 ok( err
== ERROR_ALREADY_EXISTS
, "RegCreateKeyEx wrong error %u\n", err
);
2458 err
= RegCreateKeyExA( hkey_main
, "link", 0, NULL
, REG_OPTION_CREATE_LINK
| REG_OPTION_OPEN_LINK
,
2459 KEY_ALL_ACCESS
, NULL
, &key
, NULL
);
2460 ok( err
== ERROR_ALREADY_EXISTS
, "RegCreateKeyEx wrong error %u\n", err
);
2462 err
= RegDeleteKeyA( hkey_main
, "target" );
2463 ok( err
== ERROR_SUCCESS
, "RegDeleteKey failed error %u\n", err
);
2465 err
= RegDeleteKeyA( hkey_main
, "link" );
2466 ok( err
== ERROR_FILE_NOT_FOUND
, "RegDeleteKey wrong error %u\n", err
);
2468 status
= pNtDeleteKey( link
);
2469 ok( !status
, "NtDeleteKey failed: 0x%08x\n", status
);
2470 RegCloseKey( link
);
2472 HeapFree( GetProcessHeap(), 0, target
);
2473 pRtlFreeUnicodeString( &target_str
);
2476 static DWORD
get_key_value( HKEY root
, const char *name
, DWORD flags
)
2479 DWORD err
, type
, dw
, len
= sizeof(dw
);
2481 err
= RegCreateKeyExA( root
, name
, 0, NULL
, 0, flags
| KEY_ALL_ACCESS
, NULL
, &key
, NULL
);
2482 if (err
== ERROR_FILE_NOT_FOUND
) return 0;
2483 ok( err
== ERROR_SUCCESS
, "%08x: RegCreateKeyEx failed: %u\n", flags
, err
);
2485 err
= RegQueryValueExA( key
, "value", NULL
, &type
, (BYTE
*)&dw
, &len
);
2486 if (err
== ERROR_FILE_NOT_FOUND
)
2489 ok( err
== ERROR_SUCCESS
, "%08x: RegQueryValueEx failed: %u\n", flags
, err
);
2494 static void _check_key_value( int line
, HANDLE root
, const char *name
, DWORD flags
, DWORD expect
)
2496 DWORD dw
= get_key_value( root
, name
, flags
);
2497 ok_(__FILE__
,line
)( dw
== expect
, "%08x: wrong value %u/%u\n", flags
, dw
, expect
);
2499 #define check_key_value(root,name,flags,expect) _check_key_value( __LINE__, root, name, flags, expect )
2501 static void test_redirection(void)
2503 DWORD err
, type
, dw
, len
;
2504 HKEY key
, root32
, root64
, key32
, key64
, native
, op_key
;
2505 BOOL is_vista
= FALSE
;
2506 REGSAM opposite
= (sizeof(void*) == 8 ? KEY_WOW64_32KEY
: KEY_WOW64_64KEY
);
2511 if (!pIsWow64Process
|| !pIsWow64Process( GetCurrentProcess(), &is_wow64
) || !is_wow64
)
2513 skip( "Not on Wow64, no redirection\n" );
2520 skip("not enough privileges to modify HKLM\n");
2524 err
= RegCreateKeyExA( HKEY_LOCAL_MACHINE
, "Software\\Wine", 0, NULL
, 0,
2525 KEY_WOW64_64KEY
| KEY_ALL_ACCESS
, NULL
, &root64
, NULL
);
2526 ok( err
== ERROR_SUCCESS
, "RegCreateKeyExA failed: %u\n", err
);
2528 err
= RegCreateKeyExA( HKEY_LOCAL_MACHINE
, "Software\\Wine", 0, NULL
, 0,
2529 KEY_WOW64_32KEY
| KEY_ALL_ACCESS
, NULL
, &root32
, NULL
);
2530 ok( err
== ERROR_SUCCESS
, "RegCreateKeyExA failed: %u\n", err
);
2532 err
= RegCreateKeyExA( HKEY_LOCAL_MACHINE
, "Software\\Wine\\Winetest", 0, NULL
, 0,
2533 KEY_WOW64_64KEY
| KEY_ALL_ACCESS
, NULL
, &key64
, NULL
);
2534 ok( err
== ERROR_SUCCESS
, "RegCreateKeyExA failed: %u\n", err
);
2536 err
= RegCreateKeyExA( HKEY_LOCAL_MACHINE
, "Software\\Wine\\Winetest", 0, NULL
, 0,
2537 KEY_WOW64_32KEY
| KEY_ALL_ACCESS
, NULL
, &key32
, NULL
);
2538 ok( err
== ERROR_SUCCESS
, "RegCreateKeyExA failed: %u\n", err
);
2541 err
= RegSetValueExA( key64
, "value", 0, REG_DWORD
, (BYTE
*)&dw
, sizeof(dw
) );
2542 ok( err
== ERROR_SUCCESS
, "RegSetValueExA failed: %u\n", err
);
2545 err
= RegSetValueExA( key32
, "value", 0, REG_DWORD
, (BYTE
*)&dw
, sizeof(dw
) );
2546 ok( err
== ERROR_SUCCESS
, "RegSetValueExA failed: %u\n", err
);
2550 err
= RegQueryValueExA( key32
, "value", NULL
, &type
, (BYTE
*)&dw
, &len
);
2551 ok( err
== ERROR_SUCCESS
, "RegQueryValueExA failed: %u\n", err
);
2552 ok( dw
== 32, "wrong value %u\n", dw
);
2556 err
= RegQueryValueExA( key64
, "value", NULL
, &type
, (BYTE
*)&dw
, &len
);
2557 ok( err
== ERROR_SUCCESS
, "RegQueryValueExA failed: %u\n", err
);
2558 ok( dw
== 64, "wrong value %u\n", dw
);
2560 err
= RegCreateKeyExA( HKEY_LOCAL_MACHINE
, "Software", 0, NULL
, 0,
2561 KEY_ALL_ACCESS
, NULL
, &key
, NULL
);
2562 ok( err
== ERROR_SUCCESS
, "RegCreateKeyExA failed: %u\n", err
);
2566 /* the Vista mechanism allows opening Wow6432Node from a 32-bit key too */
2567 /* the new (and simpler) Win7 mechanism doesn't */
2568 if (get_key_value( key
, "Wow6432Node\\Wine\\Winetest", 0 ) == 32)
2570 trace( "using Vista-style Wow6432Node handling\n" );
2573 check_key_value( key
, "Wine\\Winetest", 0, 32 );
2574 check_key_value( key
, "Wine\\Winetest", KEY_WOW64_64KEY
, is_vista
? 64 : 32 );
2575 check_key_value( key
, "Wine\\Winetest", KEY_WOW64_32KEY
, 32 );
2576 check_key_value( key
, "Wow6432Node\\Wine\\Winetest", 0, is_vista
? 32 : 0 );
2577 check_key_value( key
, "Wow6432Node\\Wine\\Winetest", KEY_WOW64_64KEY
, is_vista
? 64 : 0 );
2578 check_key_value( key
, "Wow6432Node\\Wine\\Winetest", KEY_WOW64_32KEY
, is_vista
? 32 : 0 );
2582 if (get_key_value( HKEY_LOCAL_MACHINE
, "Software\\Wow6432Node\\Wine\\Winetest", KEY_WOW64_64KEY
) == 64)
2584 trace( "using Vista-style Wow6432Node handling\n" );
2587 check_key_value( key
, "Wine\\Winetest", 0, 64 );
2588 check_key_value( key
, "Wow6432Node\\Wine\\Winetest", 0, 32 );
2594 err
= RegCreateKeyExA( HKEY_LOCAL_MACHINE
, "Software", 0, NULL
, 0,
2595 KEY_WOW64_64KEY
| KEY_ALL_ACCESS
, NULL
, &key
, NULL
);
2596 ok( err
== ERROR_SUCCESS
, "RegCreateKeyExA failed: %u\n", err
);
2597 dw
= get_key_value( key
, "Wine\\Winetest", 0 );
2598 ok( dw
== 64 || broken(dw
== 32) /* xp64 */, "wrong value %u\n", dw
);
2599 check_key_value( key
, "Wine\\Winetest", KEY_WOW64_64KEY
, 64 );
2600 check_key_value( key
, "Wine\\Winetest", KEY_WOW64_32KEY
, 32 );
2601 check_key_value( key
, "Wow6432Node\\Wine\\Winetest", 0, 32 );
2602 dw
= get_key_value( key
, "Wow6432Node\\Wine\\Winetest", KEY_WOW64_64KEY
);
2603 ok( dw
== 32 || broken(dw
== 64) /* xp64 */, "wrong value %u\n", dw
);
2604 check_key_value( key
, "Wow6432Node\\Wine\\Winetest", KEY_WOW64_32KEY
, 32 );
2607 err
= RegCreateKeyExA( HKEY_LOCAL_MACHINE
, "Software", 0, NULL
, 0,
2608 KEY_WOW64_32KEY
| KEY_ALL_ACCESS
, NULL
, &key
, NULL
);
2609 ok( err
== ERROR_SUCCESS
, "RegCreateKeyExA failed: %u\n", err
);
2610 check_key_value( key
, "Wine\\Winetest", 0, 32 );
2611 check_key_value( key
, "Wine\\Winetest", KEY_WOW64_64KEY
, is_vista
? 64 : 32 );
2612 check_key_value( key
, "Wine\\Winetest", KEY_WOW64_32KEY
, 32 );
2613 check_key_value( key
, "Wow6432Node\\Wine\\Winetest", 0, is_vista
? 32 : 0 );
2614 check_key_value( key
, "Wow6432Node\\Wine\\Winetest", KEY_WOW64_64KEY
, is_vista
? 64 : 0 );
2615 check_key_value( key
, "Wow6432Node\\Wine\\Winetest", KEY_WOW64_32KEY
, is_vista
? 32 : 0 );
2620 err
= RegCreateKeyExA( HKEY_LOCAL_MACHINE
, "Software", 0, NULL
, 0,
2621 KEY_WOW64_64KEY
| KEY_ALL_ACCESS
, NULL
, &key
, NULL
);
2622 ok( err
== ERROR_SUCCESS
, "RegCreateKeyExA failed: %u\n", err
);
2623 check_key_value( key
, "Wine\\Winetest", 0, 64 );
2624 check_key_value( key
, "Wine\\Winetest", KEY_WOW64_64KEY
, 64 );
2625 dw
= get_key_value( key
, "Wine\\Winetest", KEY_WOW64_32KEY
);
2626 todo_wine
ok( dw
== 32, "wrong value %u\n", dw
);
2627 check_key_value( key
, "Wow6432Node\\Wine\\Winetest", 0, 32 );
2630 err
= RegCreateKeyExA( HKEY_LOCAL_MACHINE
, "Software", 0, NULL
, 0,
2631 KEY_WOW64_32KEY
| KEY_ALL_ACCESS
, NULL
, &key
, NULL
);
2632 ok( err
== ERROR_SUCCESS
, "RegCreateKeyExA failed: %u\n", err
);
2633 check_key_value( key
, "Wine\\Winetest", 0, 32 );
2634 dw
= get_key_value( key
, "Wine\\Winetest", KEY_WOW64_64KEY
);
2635 ok( dw
== 32 || broken(dw
== 64) /* vista */, "wrong value %u\n", dw
);
2636 check_key_value( key
, "Wine\\Winetest", KEY_WOW64_32KEY
, 32 );
2640 check_key_value( HKEY_LOCAL_MACHINE
, "Software\\Wine\\Winetest", 0, ptr_size
);
2641 check_key_value( HKEY_LOCAL_MACHINE
, "Software\\Wow6432Node\\Wine\\Winetest", 0, 32 );
2644 /* KEY_WOW64 flags have no effect on 64-bit */
2645 check_key_value( HKEY_LOCAL_MACHINE
, "Software\\Wine\\Winetest", KEY_WOW64_64KEY
, 64 );
2646 check_key_value( HKEY_LOCAL_MACHINE
, "Software\\Wine\\Winetest", KEY_WOW64_32KEY
, 32 );
2647 check_key_value( HKEY_LOCAL_MACHINE
, "Software\\Wow6432Node\\Wine\\Winetest", KEY_WOW64_64KEY
, is_vista
? 64 : 32 );
2648 check_key_value( HKEY_LOCAL_MACHINE
, "Software\\Wow6432Node\\Wine\\Winetest", KEY_WOW64_32KEY
, 32 );
2652 check_key_value( HKEY_LOCAL_MACHINE
, "Software\\Wine\\Winetest", KEY_WOW64_64KEY
, 64 );
2653 check_key_value( HKEY_LOCAL_MACHINE
, "Software\\Wine\\Winetest", KEY_WOW64_32KEY
, 32 );
2654 check_key_value( HKEY_LOCAL_MACHINE
, "Software\\Wow6432Node\\Wine\\Winetest", KEY_WOW64_64KEY
, is_vista
? 64 : 32 );
2655 check_key_value( HKEY_LOCAL_MACHINE
, "Software\\Wow6432Node\\Wine\\Winetest", KEY_WOW64_32KEY
, 32 );
2658 err
= RegCreateKeyExA( HKEY_LOCAL_MACHINE
, "Software\\Wow6432Node", 0, NULL
, 0,
2659 KEY_ALL_ACCESS
, NULL
, &key
, NULL
);
2660 ok( err
== ERROR_SUCCESS
, "RegCreateKeyExA failed: %u\n", err
);
2661 check_key_value( key
, "Wine\\Winetest", 0, 32 );
2662 check_key_value( key
, "Wine\\Winetest", KEY_WOW64_64KEY
, is_vista
? 64 : 32 );
2663 check_key_value( key
, "Wine\\Winetest", KEY_WOW64_32KEY
, 32 );
2668 err
= RegCreateKeyExA( HKEY_LOCAL_MACHINE
, "Software\\Wow6432Node", 0, NULL
, 0,
2669 KEY_WOW64_64KEY
| KEY_ALL_ACCESS
, NULL
, &key
, NULL
);
2670 ok( err
== ERROR_SUCCESS
, "RegCreateKeyExA failed: %u\n", err
);
2671 dw
= get_key_value( key
, "Wine\\Winetest", 0 );
2672 ok( dw
== (is_vista
? 64 : 32) || broken(dw
== 32) /* xp64 */, "wrong value %u\n", dw
);
2673 check_key_value( key
, "Wine\\Winetest", KEY_WOW64_64KEY
, is_vista
? 64 : 32 );
2674 check_key_value( key
, "Wine\\Winetest", KEY_WOW64_32KEY
, 32 );
2677 err
= RegCreateKeyExA( HKEY_LOCAL_MACHINE
, "Software\\Wow6432Node", 0, NULL
, 0,
2678 KEY_WOW64_32KEY
| KEY_ALL_ACCESS
, NULL
, &key
, NULL
);
2679 ok( err
== ERROR_SUCCESS
, "RegCreateKeyExA failed: %u\n", err
);
2680 check_key_value( key
, "Wine\\Winetest", 0, 32 );
2681 check_key_value( key
, "Wine\\Winetest", KEY_WOW64_64KEY
, is_vista
? 64 : 32 );
2682 check_key_value( key
, "Wine\\Winetest", KEY_WOW64_32KEY
, 32 );
2686 err
= RegCreateKeyExA( HKEY_LOCAL_MACHINE
, "Software\\Wow6432Node\\Wine", 0, NULL
, 0,
2687 KEY_ALL_ACCESS
, NULL
, &key
, NULL
);
2688 ok( err
== ERROR_SUCCESS
, "RegCreateKeyExA failed: %u\n", err
);
2689 check_key_value( key
, "Winetest", 0, 32 );
2690 check_key_value( key
, "Winetest", KEY_WOW64_64KEY
, is_vista
? 64 : 32 );
2691 check_key_value( key
, "Winetest", KEY_WOW64_32KEY
, 32 );
2696 err
= RegCreateKeyExA( HKEY_LOCAL_MACHINE
, "Software\\Wow6432Node\\Wine", 0, NULL
, 0,
2697 KEY_WOW64_64KEY
| KEY_ALL_ACCESS
, NULL
, &key
, NULL
);
2698 ok( err
== ERROR_SUCCESS
, "RegCreateKeyExA failed: %u\n", err
);
2699 dw
= get_key_value( key
, "Winetest", 0 );
2700 ok( dw
== 32 || (is_vista
&& dw
== 64), "wrong value %u\n", dw
);
2701 check_key_value( key
, "Winetest", KEY_WOW64_64KEY
, is_vista
? 64 : 32 );
2702 check_key_value( key
, "Winetest", KEY_WOW64_32KEY
, 32 );
2705 err
= RegCreateKeyExA( HKEY_LOCAL_MACHINE
, "Software\\Wow6432Node\\Wine", 0, NULL
, 0,
2706 KEY_WOW64_32KEY
| KEY_ALL_ACCESS
, NULL
, &key
, NULL
);
2707 ok( err
== ERROR_SUCCESS
, "RegCreateKeyExA failed: %u\n", err
);
2708 check_key_value( key
, "Winetest", 0, 32 );
2709 check_key_value( key
, "Winetest", KEY_WOW64_64KEY
, is_vista
? 64 : 32 );
2710 check_key_value( key
, "Winetest", KEY_WOW64_32KEY
, 32 );
2714 err
= RegCreateKeyExA( HKEY_LOCAL_MACHINE
, "Software\\Wine", 0, NULL
, 0,
2715 KEY_ALL_ACCESS
, NULL
, &key
, NULL
);
2716 ok( err
== ERROR_SUCCESS
, "RegCreateKeyExA failed: %u\n", err
);
2717 check_key_value( key
, "Winetest", 0, ptr_size
);
2718 check_key_value( key
, "Winetest", KEY_WOW64_64KEY
, is_vista
? 64 : ptr_size
);
2719 dw
= get_key_value( key
, "Winetest", KEY_WOW64_32KEY
);
2720 todo_wine_if (ptr_size
!= 32)
2721 ok( dw
== 32, "wrong value %u\n", dw
);
2726 err
= RegCreateKeyExA( HKEY_LOCAL_MACHINE
, "Software\\Wine", 0, NULL
, 0,
2727 KEY_WOW64_64KEY
| KEY_ALL_ACCESS
, NULL
, &key
, NULL
);
2728 ok( err
== ERROR_SUCCESS
, "RegCreateKeyExA failed: %u\n", err
);
2729 dw
= get_key_value( key
, "Winetest", 0 );
2730 ok( dw
== 64 || broken(dw
== 32) /* xp64 */, "wrong value %u\n", dw
);
2731 check_key_value( key
, "Winetest", KEY_WOW64_64KEY
, 64 );
2732 dw
= get_key_value( key
, "Winetest", KEY_WOW64_32KEY
);
2733 todo_wine
ok( dw
== 32, "wrong value %u\n", dw
);
2736 err
= RegCreateKeyExA( HKEY_LOCAL_MACHINE
, "Software\\Wine", 0, NULL
, 0,
2737 KEY_WOW64_32KEY
| KEY_ALL_ACCESS
, NULL
, &key
, NULL
);
2738 ok( err
== ERROR_SUCCESS
, "RegCreateKeyExA failed: %u\n", err
);
2739 check_key_value( key
, "Winetest", 0, 32 );
2740 check_key_value( key
, "Winetest", KEY_WOW64_64KEY
, is_vista
? 64 : 32 );
2741 check_key_value( key
, "Winetest", KEY_WOW64_32KEY
, 32 );
2745 if (pRegDeleteKeyExA
)
2747 err
= pRegDeleteKeyExA( key32
, "", KEY_WOW64_32KEY
, 0 );
2748 ok( err
== ERROR_SUCCESS
, "RegDeleteKey failed: %u\n", err
);
2749 err
= pRegDeleteKeyExA( key64
, "", KEY_WOW64_64KEY
, 0 );
2750 ok( err
== ERROR_SUCCESS
, "RegDeleteKey failed: %u\n", err
);
2751 pRegDeleteKeyExA( key64
, "", KEY_WOW64_64KEY
, 0 );
2752 pRegDeleteKeyExA( root64
, "", KEY_WOW64_64KEY
, 0 );
2756 err
= RegDeleteKeyA( key32
, "" );
2757 ok( err
== ERROR_SUCCESS
, "RegDeleteKey failed: %u\n", err
);
2758 err
= RegDeleteKeyA( key64
, "" );
2759 ok( err
== ERROR_SUCCESS
, "RegDeleteKey failed: %u\n", err
);
2760 RegDeleteKeyA( key64
, "" );
2761 RegDeleteKeyA( root64
, "" );
2763 RegCloseKey( key32
);
2764 RegCloseKey( key64
);
2765 RegCloseKey( root32
);
2766 RegCloseKey( root64
);
2768 /* open key in native bit mode */
2769 err
= RegOpenKeyExA(HKEY_CLASSES_ROOT
, "Interface", 0, KEY_ALL_ACCESS
, &native
);
2770 ok(err
== ERROR_SUCCESS
, "got %i\n", err
);
2772 pRegDeleteKeyExA(native
, "AWineTest", 0, 0);
2774 /* write subkey in opposite bit mode */
2775 err
= RegOpenKeyExA(HKEY_CLASSES_ROOT
, "Interface", 0, KEY_ALL_ACCESS
| opposite
, &op_key
);
2776 ok(err
== ERROR_SUCCESS
, "got %i\n", err
);
2778 err
= RegCreateKeyExA(op_key
, "AWineTest", 0, NULL
, 0, KEY_ALL_ACCESS
| opposite
,
2780 ok(err
== ERROR_SUCCESS
|| err
== ERROR_ACCESS_DENIED
, "got %i\n", err
);
2781 if(err
!= ERROR_SUCCESS
){
2782 win_skip("Can't write to registry\n");
2783 RegCloseKey(op_key
);
2784 RegCloseKey(native
);
2789 /* verify subkey is not present in native mode */
2790 err
= RegOpenKeyExA(native
, "AWineTest", 0, KEY_ALL_ACCESS
, &key
);
2791 ok(err
== ERROR_FILE_NOT_FOUND
||
2792 broken(err
== ERROR_SUCCESS
), /* before Win7, HKCR is reflected instead of redirected */
2795 err
= pRegDeleteKeyExA(op_key
, "AWineTest", opposite
, 0);
2796 ok(err
== ERROR_SUCCESS
, "got %i\n", err
);
2798 RegCloseKey(op_key
);
2799 RegCloseKey(native
);
2802 static void test_classesroot(void)
2804 HKEY hkey
, hklm
, hkcr
, hkeysub1
, hklmsub1
, hkcrsub1
, hklmsub2
, hkcrsub2
;
2806 DWORD type
= REG_SZ
;
2807 static CHAR buffer
[8];
2810 /* create a key in the user's classes */
2811 if (!RegOpenKeyA( HKEY_CURRENT_USER
, "Software\\Classes\\WineTestCls", &hkey
))
2814 RegCloseKey( hkey
);
2816 res
= RegCreateKeyExA( HKEY_CURRENT_USER
, "Software\\Classes\\WineTestCls", 0, NULL
, 0,
2817 KEY_QUERY_VALUE
|KEY_SET_VALUE
, NULL
, &hkey
, NULL
);
2818 if (res
== ERROR_ACCESS_DENIED
)
2820 skip("not enough privileges to add a user class\n");
2823 ok(!IS_HKCR(hkey
), "hkcr mask set in %p\n", hkey
);
2825 /* try to open that key in hkcr */
2826 res
= RegOpenKeyExA( HKEY_CLASSES_ROOT
, "WineTestCls", 0,
2827 KEY_QUERY_VALUE
|KEY_SET_VALUE
, &hkcr
);
2828 todo_wine
ok(res
== ERROR_SUCCESS
||
2829 broken(res
== ERROR_FILE_NOT_FOUND
/* WinNT */),
2830 "test key not found in hkcr: %d\n", res
);
2833 skip("HKCR key merging not supported\n");
2835 RegCloseKey( hkey
);
2839 todo_wine
ok(IS_HKCR(hkcr
), "hkcr mask not set in %p\n", hkcr
);
2841 /* set a value in user's classes */
2842 res
= RegSetValueExA(hkey
, "val1", 0, REG_SZ
, (const BYTE
*)"user", sizeof("user"));
2843 ok(res
== ERROR_SUCCESS
, "RegSetValueExA failed: %d, GLE=%x\n", res
, GetLastError());
2845 /* try to find the value in hkcr */
2846 res
= RegQueryValueExA(hkcr
, "val1", NULL
, &type
, (LPBYTE
)buffer
, &size
);
2847 ok(res
== ERROR_SUCCESS
, "RegQueryValueExA failed: %d\n", res
);
2848 ok(!strcmp( buffer
, "user" ), "value set to '%s'\n", buffer
);
2850 /* modify the value in hkcr */
2851 res
= RegSetValueExA(hkcr
, "val1", 0, REG_SZ
, (const BYTE
*)"hkcr", sizeof("hkcr"));
2852 ok(res
== ERROR_SUCCESS
, "RegSetValueExA failed: %d, GLE=%x\n", res
, GetLastError());
2854 /* check if the value is also modified in user's classes */
2855 res
= RegQueryValueExA(hkey
, "val1", NULL
, &type
, (LPBYTE
)buffer
, &size
);
2856 ok(res
== ERROR_SUCCESS
, "RegQueryValueExA failed: %d, GLE=%x\n", res
, GetLastError());
2857 ok(!strcmp( buffer
, "hkcr" ), "value set to '%s'\n", buffer
);
2859 /* set a value in hkcr */
2860 res
= RegSetValueExA(hkcr
, "val0", 0, REG_SZ
, (const BYTE
*)"hkcr", sizeof("hkcr"));
2861 ok(res
== ERROR_SUCCESS
, "RegSetValueExA failed: %d, GLE=%x\n", res
, GetLastError());
2863 /* try to find the value in user's classes */
2864 res
= RegQueryValueExA(hkey
, "val0", NULL
, &type
, (LPBYTE
)buffer
, &size
);
2865 ok(res
== ERROR_SUCCESS
, "RegQueryValueExA failed: %d\n", res
);
2866 ok(!strcmp( buffer
, "hkcr" ), "value set to '%s'\n", buffer
);
2868 /* modify the value in user's classes */
2869 res
= RegSetValueExA(hkey
, "val0", 0, REG_SZ
, (const BYTE
*)"user", sizeof("user"));
2870 ok(res
== ERROR_SUCCESS
, "RegSetValueExA failed: %d, GLE=%x\n", res
, GetLastError());
2872 /* check if the value is also modified in hkcr */
2873 res
= RegQueryValueExA(hkcr
, "val0", NULL
, &type
, (LPBYTE
)buffer
, &size
);
2874 ok(res
== ERROR_SUCCESS
, "RegQueryValueExA failed: %d, GLE=%x\n", res
, GetLastError());
2875 ok(!strcmp( buffer
, "user" ), "value set to '%s'\n", buffer
);
2880 RegCloseKey( hkey
);
2881 RegCloseKey( hkcr
);
2883 /* create a key in the hklm classes */
2884 if (!RegOpenKeyA( HKEY_LOCAL_MACHINE
, "Software\\Classes\\WineTestCls", &hklm
))
2887 RegCloseKey( hklm
);
2889 res
= RegCreateKeyExA( HKEY_LOCAL_MACHINE
, "Software\\Classes\\WineTestCls", 0, NULL
, REG_OPTION_NON_VOLATILE
,
2890 KEY_ALL_ACCESS
, NULL
, &hklm
, NULL
);
2891 if (res
== ERROR_ACCESS_DENIED
)
2893 skip("not enough privileges to add a system class\n");
2896 ok(!IS_HKCR(hklm
), "hkcr mask set in %p\n", hklm
);
2898 /* try to open that key in hkcr */
2899 res
= RegOpenKeyExA( HKEY_CLASSES_ROOT
, "WineTestCls", 0,
2900 KEY_QUERY_VALUE
|KEY_SET_VALUE
, &hkcr
);
2901 ok(res
== ERROR_SUCCESS
,
2902 "test key not found in hkcr: %d\n", res
);
2903 ok(IS_HKCR(hkcr
), "hkcr mask not set in %p\n", hkcr
);
2907 RegCloseKey( hklm
);
2911 /* set a value in hklm classes */
2912 res
= RegSetValueExA(hklm
, "val2", 0, REG_SZ
, (const BYTE
*)"hklm", sizeof("hklm"));
2913 ok(res
== ERROR_SUCCESS
, "RegSetValueExA failed: %d, GLE=%x\n", res
, GetLastError());
2915 /* try to find the value in hkcr */
2916 res
= RegQueryValueExA(hkcr
, "val2", NULL
, &type
, (LPBYTE
)buffer
, &size
);
2917 ok(res
== ERROR_SUCCESS
, "RegQueryValueExA failed: %d\n", res
);
2918 ok(!strcmp( buffer
, "hklm" ), "value set to '%s'\n", buffer
);
2920 /* modify the value in hkcr */
2921 res
= RegSetValueExA(hkcr
, "val2", 0, REG_SZ
, (const BYTE
*)"hkcr", sizeof("hkcr"));
2922 ok(res
== ERROR_SUCCESS
, "RegSetValueExA failed: %d, GLE=%x\n", res
, GetLastError());
2924 /* check that the value is modified in hklm classes */
2925 res
= RegQueryValueExA(hklm
, "val2", NULL
, &type
, (LPBYTE
)buffer
, &size
);
2926 ok(res
== ERROR_SUCCESS
, "RegQueryValueExA failed: %d, GLE=%x\n", res
, GetLastError());
2927 ok(!strcmp( buffer
, "hkcr" ), "value set to '%s'\n", buffer
);
2929 if (RegCreateKeyExA( HKEY_CURRENT_USER
, "Software\\Classes\\WineTestCls", 0, NULL
, 0,
2930 KEY_QUERY_VALUE
|KEY_SET_VALUE
, NULL
, &hkey
, NULL
)) return;
2931 ok(!IS_HKCR(hkey
), "hkcr mask set in %p\n", hkey
);
2933 /* try to open that key in hkcr */
2934 res
= RegOpenKeyExA( HKEY_CLASSES_ROOT
, "WineTestCls", 0,
2935 KEY_QUERY_VALUE
|KEY_SET_VALUE
, &hkcr
);
2936 ok(res
== ERROR_SUCCESS
,
2937 "test key not found in hkcr: %d\n", res
);
2938 ok(IS_HKCR(hkcr
), "hkcr mask not set in %p\n", hkcr
);
2940 /* set a value in user's classes */
2941 res
= RegSetValueExA(hkey
, "val2", 0, REG_SZ
, (const BYTE
*)"user", sizeof("user"));
2942 ok(res
== ERROR_SUCCESS
, "RegSetValueExA failed: %d, GLE=%x\n", res
, GetLastError());
2944 /* try to find the value in hkcr */
2945 res
= RegQueryValueExA(hkcr
, "val2", NULL
, &type
, (LPBYTE
)buffer
, &size
);
2946 ok(res
== ERROR_SUCCESS
, "RegQueryValueExA failed: %d\n", res
);
2947 ok(!strcmp( buffer
, "user" ), "value set to '%s'\n", buffer
);
2949 /* modify the value in hklm */
2950 res
= RegSetValueExA(hklm
, "val2", 0, REG_SZ
, (const BYTE
*)"hklm", sizeof("hklm"));
2951 ok(res
== ERROR_SUCCESS
, "RegSetValueExA failed: %d, GLE=%x\n", res
, GetLastError());
2953 /* check that the value is not overwritten in hkcr or user's classes */
2954 res
= RegQueryValueExA(hkcr
, "val2", NULL
, &type
, (LPBYTE
)buffer
, &size
);
2955 ok(res
== ERROR_SUCCESS
, "RegQueryValueExA failed: %d\n", res
);
2956 ok(!strcmp( buffer
, "user" ), "value set to '%s'\n", buffer
);
2957 res
= RegQueryValueExA(hkey
, "val2", NULL
, &type
, (LPBYTE
)buffer
, &size
);
2958 ok(res
== ERROR_SUCCESS
, "RegQueryValueExA failed: %d, GLE=%x\n", res
, GetLastError());
2959 ok(!strcmp( buffer
, "user" ), "value set to '%s'\n", buffer
);
2961 /* modify the value in hkcr */
2962 res
= RegSetValueExA(hkcr
, "val2", 0, REG_SZ
, (const BYTE
*)"hkcr", sizeof("hkcr"));
2963 ok(res
== ERROR_SUCCESS
, "RegSetValueExA failed: %d, GLE=%x\n", res
, GetLastError());
2965 /* check that the value is overwritten in hklm and user's classes */
2966 res
= RegQueryValueExA(hkcr
, "val2", NULL
, &type
, (LPBYTE
)buffer
, &size
);
2967 ok(res
== ERROR_SUCCESS
, "RegQueryValueExA failed: %d\n", res
);
2968 ok(!strcmp( buffer
, "hkcr" ), "value set to '%s'\n", buffer
);
2969 res
= RegQueryValueExA(hkey
, "val2", NULL
, &type
, (LPBYTE
)buffer
, &size
);
2970 ok(res
== ERROR_SUCCESS
, "RegQueryValueExA failed: %d, GLE=%x\n", res
, GetLastError());
2971 ok(!strcmp( buffer
, "hkcr" ), "value set to '%s'\n", buffer
);
2973 /* create a subkey in hklm */
2974 if (RegCreateKeyExA( hklm
, "subkey1", 0, NULL
, 0,
2975 KEY_QUERY_VALUE
|KEY_SET_VALUE
, NULL
, &hklmsub1
, NULL
)) return;
2976 ok(!IS_HKCR(hklmsub1
), "hkcr mask set in %p\n", hklmsub1
);
2977 /* try to open that subkey in hkcr */
2978 res
= RegOpenKeyExA( hkcr
, "subkey1", 0, KEY_QUERY_VALUE
|KEY_SET_VALUE
, &hkcrsub1
);
2979 ok(res
== ERROR_SUCCESS
, "test key not found in hkcr: %d\n", res
);
2980 ok(IS_HKCR(hkcrsub1
), "hkcr mask not set in %p\n", hkcrsub1
);
2982 /* set a value in hklm classes */
2983 res
= RegSetValueExA(hklmsub1
, "subval1", 0, REG_SZ
, (const BYTE
*)"hklm", sizeof("hklm"));
2984 ok(res
== ERROR_SUCCESS
, "RegSetValueExA failed: %d, GLE=%x\n", res
, GetLastError());
2986 /* try to find the value in hkcr */
2987 res
= RegQueryValueExA(hkcrsub1
, "subval1", NULL
, &type
, (LPBYTE
)buffer
, &size
);
2988 ok(res
== ERROR_SUCCESS
, "RegQueryValueExA failed: %d\n", res
);
2989 ok(!strcmp( buffer
, "hklm" ), "value set to '%s'\n", buffer
);
2991 /* modify the value in hkcr */
2992 res
= RegSetValueExA(hkcrsub1
, "subval1", 0, REG_SZ
, (const BYTE
*)"hkcr", sizeof("hkcr"));
2993 ok(res
== ERROR_SUCCESS
, "RegSetValueExA failed: %d, GLE=%x\n", res
, GetLastError());
2995 /* check that the value is modified in hklm classes */
2996 res
= RegQueryValueExA(hklmsub1
, "subval1", NULL
, &type
, (LPBYTE
)buffer
, &size
);
2997 ok(res
== ERROR_SUCCESS
, "RegQueryValueExA failed: %d, GLE=%x\n", res
, GetLastError());
2998 ok(!strcmp( buffer
, "hkcr" ), "value set to '%s'\n", buffer
);
3000 /* create a subkey in user's classes */
3001 if (RegCreateKeyExA( hkey
, "subkey1", 0, NULL
, 0,
3002 KEY_QUERY_VALUE
|KEY_SET_VALUE
, NULL
, &hkeysub1
, NULL
)) return;
3003 ok(!IS_HKCR(hkeysub1
), "hkcr mask set in %p\n", hkeysub1
);
3005 /* set a value in user's classes */
3006 res
= RegSetValueExA(hkeysub1
, "subval1", 0, REG_SZ
, (const BYTE
*)"user", sizeof("user"));
3007 ok(res
== ERROR_SUCCESS
, "RegSetValueExA failed: %d, GLE=%x\n", res
, GetLastError());
3009 /* try to find the value in hkcr */
3010 res
= RegQueryValueExA(hkcrsub1
, "subval1", NULL
, &type
, (LPBYTE
)buffer
, &size
);
3011 ok(res
== ERROR_SUCCESS
, "RegQueryValueExA failed: %d\n", res
);
3012 ok(!strcmp( buffer
, "user" ), "value set to '%s'\n", buffer
);
3014 /* modify the value in hklm */
3015 res
= RegSetValueExA(hklmsub1
, "subval1", 0, REG_SZ
, (const BYTE
*)"hklm", sizeof("hklm"));
3016 ok(res
== ERROR_SUCCESS
, "RegSetValueExA failed: %d, GLE=%x\n", res
, GetLastError());
3018 /* check that the value is not overwritten in hkcr or user's classes */
3019 res
= RegQueryValueExA(hkcrsub1
, "subval1", NULL
, &type
, (LPBYTE
)buffer
, &size
);
3020 ok(res
== ERROR_SUCCESS
, "RegQueryValueExA failed: %d\n", res
);
3021 ok(!strcmp( buffer
, "user" ), "value set to '%s'\n", buffer
);
3022 res
= RegQueryValueExA(hkeysub1
, "subval1", NULL
, &type
, (LPBYTE
)buffer
, &size
);
3023 ok(res
== ERROR_SUCCESS
, "RegQueryValueExA failed: %d, GLE=%x\n", res
, GetLastError());
3024 ok(!strcmp( buffer
, "user" ), "value set to '%s'\n", buffer
);
3026 /* modify the value in hkcr */
3027 res
= RegSetValueExA(hkcrsub1
, "subval1", 0, REG_SZ
, (const BYTE
*)"hkcr", sizeof("hkcr"));
3028 ok(res
== ERROR_SUCCESS
, "RegSetValueExA failed: %d, GLE=%x\n", res
, GetLastError());
3030 /* check that the value is not overwritten in hklm, but in user's classes */
3031 res
= RegQueryValueExA(hklmsub1
, "subval1", NULL
, &type
, (LPBYTE
)buffer
, &size
);
3032 ok(res
== ERROR_SUCCESS
, "RegQueryValueExA failed: %d\n", res
);
3033 ok(!strcmp( buffer
, "hklm" ), "value set to '%s'\n", buffer
);
3034 res
= RegQueryValueExA(hkeysub1
, "subval1", NULL
, &type
, (LPBYTE
)buffer
, &size
);
3035 ok(res
== ERROR_SUCCESS
, "RegQueryValueExA failed: %d, GLE=%x\n", res
, GetLastError());
3036 ok(!strcmp( buffer
, "hkcr" ), "value set to '%s'\n", buffer
);
3038 /* new subkey in hkcr */
3039 if (RegCreateKeyExA( hkcr
, "subkey2", 0, NULL
, 0,
3040 KEY_QUERY_VALUE
|KEY_SET_VALUE
, NULL
, &hkcrsub2
, NULL
)) return;
3041 ok(IS_HKCR(hkcrsub2
), "hkcr mask not set in %p\n", hkcrsub2
);
3042 res
= RegSetValueExA(hkcrsub2
, "subval1", 0, REG_SZ
, (const BYTE
*)"hkcr", sizeof("hkcr"));
3043 ok(res
== ERROR_SUCCESS
, "RegSetValueExA failed: %d, GLE=%x\n", res
, GetLastError());
3045 /* try to open that new subkey in user's classes and hklm */
3046 res
= RegOpenKeyExA( hkey
, "subkey2", 0, KEY_QUERY_VALUE
|KEY_SET_VALUE
, &hklmsub2
);
3047 ok(res
!= ERROR_SUCCESS
, "test key found in user's classes: %d\n", res
);
3049 res
= RegOpenKeyExA( hklm
, "subkey2", 0, KEY_QUERY_VALUE
|KEY_SET_VALUE
, &hklmsub2
);
3050 ok(res
== ERROR_SUCCESS
, "test key not found in hklm: %d\n", res
);
3051 ok(!IS_HKCR(hklmsub2
), "hkcr mask set in %p\n", hklmsub2
);
3053 /* check that the value is present in hklm */
3054 res
= RegQueryValueExA(hklmsub2
, "subval1", NULL
, &type
, (LPBYTE
)buffer
, &size
);
3055 ok(res
== ERROR_SUCCESS
, "RegQueryValueExA failed: %d\n", res
);
3056 ok(!strcmp( buffer
, "hkcr" ), "value set to '%s'\n", buffer
);
3059 RegCloseKey( hkeysub1
);
3060 RegCloseKey( hklmsub1
);
3062 /* delete subkey1 from hkcr (should point at user's classes) */
3063 res
= RegDeleteKeyA(hkcr
, "subkey1");
3064 ok(res
== ERROR_SUCCESS
, "RegDeleteKey failed: %d\n", res
);
3066 /* confirm key was removed in hkey but not hklm */
3067 res
= RegOpenKeyExA(hkey
, "subkey1", 0, KEY_READ
, &hkeysub1
);
3068 ok(res
== ERROR_FILE_NOT_FOUND
, "test key found in user's classes: %d\n", res
);
3069 res
= RegOpenKeyExA(hklm
, "subkey1", 0, KEY_READ
, &hklmsub1
);
3070 ok(res
== ERROR_SUCCESS
, "test key not found in hklm: %d\n", res
);
3071 ok(!IS_HKCR(hklmsub1
), "hkcr mask set in %p\n", hklmsub1
);
3073 /* delete subkey1 from hkcr again (which should now point at hklm) */
3074 res
= RegDeleteKeyA(hkcr
, "subkey1");
3075 ok(res
== ERROR_SUCCESS
, "RegDeleteKey failed: %d\n", res
);
3077 /* confirm hkey was removed in hklm */
3078 RegCloseKey( hklmsub1
);
3079 res
= RegOpenKeyExA(hklm
, "subkey1", 0, KEY_READ
, &hklmsub1
);
3080 ok(res
== ERROR_FILE_NOT_FOUND
, "test key found in hklm: %d\n", res
);
3086 delete_key( hkeysub1
);
3087 delete_key( hklmsub1
);
3088 delete_key( hkcrsub1
);
3089 delete_key( hklmsub2
);
3090 delete_key( hkcrsub2
);
3091 RegCloseKey( hkey
);
3092 RegCloseKey( hklm
);
3093 RegCloseKey( hkcr
);
3094 RegCloseKey( hkeysub1
);
3095 RegCloseKey( hklmsub1
);
3096 RegCloseKey( hkcrsub1
);
3097 RegCloseKey( hklmsub2
);
3098 RegCloseKey( hkcrsub2
);
3101 static void test_classesroot_enum(void)
3103 HKEY hkcu
=0, hklm
=0, hkcr
=0, hkcusub
[2]={0}, hklmsub
[2]={0};
3105 static CHAR buffer
[2];
3108 /* prepare initial testing env in HKCU */
3109 if (!RegOpenKeyA( HKEY_CURRENT_USER
, "Software\\Classes\\WineTestCls", &hkcu
))
3112 RegCloseKey( hkcu
);
3114 res
= RegCreateKeyExA( HKEY_CURRENT_USER
, "Software\\Classes\\WineTestCls", 0, NULL
, 0,
3115 KEY_SET_VALUE
|KEY_ENUMERATE_SUB_KEYS
, NULL
, &hkcu
, NULL
);
3117 if (res
!= ERROR_SUCCESS
)
3119 skip("failed to add a user class\n");
3123 res
= RegOpenKeyA( HKEY_CLASSES_ROOT
, "WineTestCls", &hkcr
);
3124 todo_wine
ok(res
== ERROR_SUCCESS
||
3125 broken(res
== ERROR_FILE_NOT_FOUND
/* WinNT */),
3126 "test key not found in hkcr: %d\n", res
);
3129 skip("HKCR key merging not supported\n");
3131 RegCloseKey( hkcu
);
3135 res
= RegSetValueExA( hkcu
, "X", 0, REG_SZ
, (const BYTE
*) "AA", 3 );
3136 ok(res
== ERROR_SUCCESS
, "RegSetValueExA failed: %d\n", res
);
3137 res
= RegSetValueExA( hkcu
, "Y", 0, REG_SZ
, (const BYTE
*) "B", 2 );
3138 ok(res
== ERROR_SUCCESS
, "RegSetValueExA failed: %d\n", res
);
3139 res
= RegCreateKeyA( hkcu
, "A", &hkcusub
[0] );
3140 ok(res
== ERROR_SUCCESS
, "RegCreateKeyA failed: %d\n", res
);
3141 res
= RegCreateKeyA( hkcu
, "B", &hkcusub
[1] );
3142 ok(res
== ERROR_SUCCESS
, "RegCreateKeyA failed: %d\n", res
);
3144 /* test on values in HKCU */
3145 size
= sizeof(buffer
);
3146 res
= RegEnumValueA( hkcr
, 0, buffer
, &size
, NULL
, NULL
, NULL
, NULL
);
3147 ok(res
== ERROR_SUCCESS
, "RegEnumValueA failed: %d\n", res
);
3148 ok(!strcmp( buffer
, "X" ), "expected 'X', got '%s'\n", buffer
);
3149 size
= sizeof(buffer
);
3150 res
= RegEnumValueA( hkcr
, 1, buffer
, &size
, NULL
, NULL
, NULL
, NULL
);
3151 ok(res
== ERROR_SUCCESS
, "RegEnumValueA failed: %d\n", res
);
3152 ok(!strcmp( buffer
, "Y" ), "expected 'Y', got '%s'\n", buffer
);
3153 size
= sizeof(buffer
);
3154 res
= RegEnumValueA( hkcr
, 2, buffer
, &size
, NULL
, NULL
, NULL
, NULL
);
3155 ok(res
== ERROR_NO_MORE_ITEMS
, "expected ERROR_NO_MORE_ITEMS, got %d\n", res
);
3157 res
= RegEnumKeyA( hkcr
, 0, buffer
, size
);
3158 ok(res
== ERROR_SUCCESS
, "RegEnumKey failed: %d\n", res
);
3159 ok(!strcmp( buffer
, "A" ), "expected 'A', got '%s'\n", buffer
);
3160 res
= RegEnumKeyA( hkcr
, 1, buffer
, size
);
3161 ok(res
== ERROR_SUCCESS
, "RegEnumKey failed: %d\n", res
);
3162 ok(!strcmp( buffer
, "B" ), "expected 'B', got '%s'\n", buffer
);
3163 res
= RegEnumKeyA( hkcr
, 2, buffer
, size
);
3164 ok(res
== ERROR_NO_MORE_ITEMS
, "expected ERROR_NO_MORE_ITEMS, got %d\n", res
);
3166 /* prepare test env in HKLM */
3167 if (!RegOpenKeyA( HKEY_LOCAL_MACHINE
, "Software\\Classes\\WineTestCls", &hklm
))
3170 RegCloseKey( hklm
);
3173 res
= RegCreateKeyExA( HKEY_LOCAL_MACHINE
, "Software\\Classes\\WineTestCls", 0, NULL
, 0,
3174 KEY_SET_VALUE
|KEY_ENUMERATE_SUB_KEYS
, NULL
, &hklm
, NULL
);
3176 if (res
== ERROR_ACCESS_DENIED
)
3178 RegCloseKey( hkcusub
[0] );
3179 RegCloseKey( hkcusub
[1] );
3181 RegCloseKey( hkcu
);
3182 RegCloseKey( hkcr
);
3183 skip("not enough privileges to add a system class\n");
3187 res
= RegSetValueExA( hklm
, "X", 0, REG_SZ
, (const BYTE
*) "AB", 3 );
3188 ok(res
== ERROR_SUCCESS
, "RegSetValueExA failed: %d\n", res
);
3189 res
= RegSetValueExA( hklm
, "Z", 0, REG_SZ
, (const BYTE
*) "C", 2 );
3190 ok(res
== ERROR_SUCCESS
, "RegSetValueExA failed: %d\n", res
);
3191 res
= RegCreateKeyA( hklm
, "A", &hklmsub
[0] );
3192 ok(res
== ERROR_SUCCESS
, "RegCreateKeyA failed: %d\n", res
);
3193 res
= RegCreateKeyA( hklm
, "C", &hklmsub
[1] );
3194 ok(res
== ERROR_SUCCESS
, "RegCreateKeyA failed: %d\n", res
);
3196 /* test on values/keys in both HKCU and HKLM */
3197 size
= sizeof(buffer
);
3198 res
= RegEnumValueA( hkcr
, 0, buffer
, &size
, NULL
, NULL
, NULL
, NULL
);
3199 ok(res
== ERROR_SUCCESS
, "RegEnumValueA failed: %d\n", res
);
3200 ok(!strcmp( buffer
, "X" ), "expected 'X', got '%s'\n", buffer
);
3201 size
= sizeof(buffer
);
3202 res
= RegEnumValueA( hkcr
, 1, buffer
, &size
, NULL
, NULL
, NULL
, NULL
);
3203 ok(res
== ERROR_SUCCESS
, "RegEnumValueA failed: %d\n", res
);
3204 ok(!strcmp( buffer
, "Y" ), "expected 'Y', got '%s'\n", buffer
);
3205 size
= sizeof(buffer
);
3206 res
= RegEnumValueA( hkcr
, 2, buffer
, &size
, NULL
, NULL
, NULL
, NULL
);
3207 ok(res
== ERROR_SUCCESS
, "RegEnumValueA failed: %d\n", res
);
3208 ok(!strcmp( buffer
, "Z" ), "expected 'Z', got '%s'\n", buffer
);
3209 size
= sizeof(buffer
);
3210 res
= RegEnumValueA( hkcr
, 3, buffer
, &size
, NULL
, NULL
, NULL
, NULL
);
3211 ok(res
== ERROR_NO_MORE_ITEMS
, "expected ERROR_NO_MORE_ITEMS, got %d\n", res
);
3213 res
= RegEnumKeyA( hkcr
, 0, buffer
, size
);
3214 ok(res
== ERROR_SUCCESS
, "RegEnumKey failed: %d\n", res
);
3215 ok(!strcmp( buffer
, "A" ), "expected 'A', got '%s'\n", buffer
);
3216 res
= RegEnumKeyA( hkcr
, 1, buffer
, size
);
3217 ok(res
== ERROR_SUCCESS
, "RegEnumKey failed: %d\n", res
);
3218 ok(!strcmp( buffer
, "B" ), "expected 'B', got '%s'\n", buffer
);
3219 res
= RegEnumKeyA( hkcr
, 2, buffer
, size
);
3220 ok(res
== ERROR_SUCCESS
, "RegEnumKey failed: %d\n", res
);
3221 ok(!strcmp( buffer
, "C" ), "expected 'C', got '%s'\n", buffer
);
3222 res
= RegEnumKeyA( hkcr
, 3, buffer
, size
);
3223 ok(res
== ERROR_NO_MORE_ITEMS
, "expected ERROR_NO_MORE_ITEMS, got %d\n", res
);
3225 /* delete values/keys from HKCU to test only on HKLM */
3226 RegCloseKey( hkcusub
[0] );
3227 RegCloseKey( hkcusub
[1] );
3229 RegCloseKey( hkcu
);
3231 size
= sizeof(buffer
);
3232 res
= RegEnumValueA( hkcr
, 0, buffer
, &size
, NULL
, NULL
, NULL
, NULL
);
3233 ok(res
== ERROR_KEY_DELETED
||
3234 res
== ERROR_NO_SYSTEM_RESOURCES
, /* Windows XP */
3235 "expected ERROR_KEY_DELETED, got %d\n", res
);
3236 size
= sizeof(buffer
);
3237 res
= RegEnumKeyA( hkcr
, 0, buffer
, size
);
3238 ok(res
== ERROR_KEY_DELETED
||
3239 res
== ERROR_NO_SYSTEM_RESOURCES
, /* Windows XP */
3240 "expected ERROR_KEY_DELETED, got %d\n", res
);
3242 /* reopen HKCR handle */
3243 RegCloseKey( hkcr
);
3244 res
= RegOpenKeyA( HKEY_CLASSES_ROOT
, "WineTestCls", &hkcr
);
3245 ok(res
== ERROR_SUCCESS
, "test key not found in hkcr: %d\n", res
);
3246 if (res
) goto cleanup
;
3248 /* test on values/keys in HKLM */
3249 size
= sizeof(buffer
);
3250 res
= RegEnumValueA( hkcr
, 0, buffer
, &size
, NULL
, NULL
, NULL
, NULL
);
3251 ok(res
== ERROR_SUCCESS
, "RegEnumValueA failed: %d\n", res
);
3252 ok(!strcmp( buffer
, "X" ), "expected 'X', got '%s'\n", buffer
);
3253 size
= sizeof(buffer
);
3254 res
= RegEnumValueA( hkcr
, 1, buffer
, &size
, NULL
, NULL
, NULL
, NULL
);
3255 ok(res
== ERROR_SUCCESS
, "RegEnumValueA failed: %d\n", res
);
3256 ok(!strcmp( buffer
, "Z" ), "expected 'Z', got '%s'\n", buffer
);
3257 size
= sizeof(buffer
);
3258 res
= RegEnumValueA( hkcr
, 2, buffer
, &size
, NULL
, NULL
, NULL
, NULL
);
3259 ok(res
== ERROR_NO_MORE_ITEMS
, "expected ERROR_NO_MORE_ITEMS, got %d\n", res
);
3261 res
= RegEnumKeyA( hkcr
, 0, buffer
, size
);
3262 ok(res
== ERROR_SUCCESS
, "RegEnumKey failed: %d\n", res
);
3263 ok(!strcmp( buffer
, "A" ), "expected 'A', got '%s'\n", buffer
);
3264 res
= RegEnumKeyA( hkcr
, 1, buffer
, size
);
3265 ok(res
== ERROR_SUCCESS
, "RegEnumKey failed: %d\n", res
);
3266 ok(!strcmp( buffer
, "C" ), "expected 'C', got '%s'\n", buffer
);
3267 res
= RegEnumKeyA( hkcr
, 2, buffer
, size
);
3268 ok(res
== ERROR_NO_MORE_ITEMS
, "expected ERROR_NO_MORE_ITEMS, got %d\n", res
);
3271 RegCloseKey( hklmsub
[0] );
3272 RegCloseKey( hklmsub
[1] );
3274 RegCloseKey( hklm
);
3275 RegCloseKey( hkcr
);
3278 static void test_classesroot_mask(void)
3283 res
= RegOpenKeyA( HKEY_CLASSES_ROOT
, "CLSID", &hkey
);
3284 ok(res
== ERROR_SUCCESS
, "RegOpenKeyA failed: %d\n", res
);
3285 todo_wine
ok(IS_HKCR(hkey
) || broken(!IS_HKCR(hkey
)) /* WinNT */,
3286 "hkcr mask not set in %p\n", hkey
);
3287 RegCloseKey( hkey
);
3289 res
= RegOpenKeyA( HKEY_CURRENT_USER
, "Software", &hkey
);
3290 ok(res
== ERROR_SUCCESS
, "RegOpenKeyA failed: %d\n", res
);
3291 ok(!IS_HKCR(hkey
), "hkcr mask set in %p\n", hkey
);
3292 RegCloseKey( hkey
);
3294 res
= RegOpenKeyA( HKEY_LOCAL_MACHINE
, "Software", &hkey
);
3295 ok(res
== ERROR_SUCCESS
, "RegOpenKeyA failed: %d\n", res
);
3296 ok(!IS_HKCR(hkey
), "hkcr mask set in %p\n", hkey
);
3297 RegCloseKey( hkey
);
3299 res
= RegOpenKeyA( HKEY_USERS
, ".Default", &hkey
);
3300 ok(res
== ERROR_SUCCESS
, "RegOpenKeyA failed: %d\n", res
);
3301 ok(!IS_HKCR(hkey
), "hkcr mask set in %p\n", hkey
);
3302 RegCloseKey( hkey
);
3304 res
= RegOpenKeyA( HKEY_CURRENT_CONFIG
, "Software", &hkey
);
3305 ok(res
== ERROR_SUCCESS
, "RegOpenKeyA failed: %d\n", res
);
3306 ok(!IS_HKCR(hkey
), "hkcr mask set in %p\n", hkey
);
3307 RegCloseKey( hkey
);
3310 static void test_deleted_key(void)
3314 DWORD val_count
, type
;
3317 /* Open the test key, then delete it while it's open */
3318 RegOpenKeyA( HKEY_CURRENT_USER
, "Software\\Wine\\Test", &hkey
);
3320 delete_key( hkey_main
);
3322 val_count
= sizeof(value
);
3324 res
= RegEnumValueA( hkey
, 0, value
, &val_count
, NULL
, &type
, 0, 0 );
3325 ok(res
== ERROR_KEY_DELETED
, "expect ERROR_KEY_DELETED, got %i\n", res
);
3327 res
= RegEnumKeyA( hkey
, 0, value
, sizeof(value
) );
3328 ok(res
== ERROR_KEY_DELETED
, "expect ERROR_KEY_DELETED, got %i\n", res
);
3330 val_count
= sizeof(value
);
3332 res
= RegQueryValueExA( hkey
, "test", NULL
, &type
, (BYTE
*)value
, &val_count
);
3333 ok(res
== ERROR_KEY_DELETED
, "expect ERROR_KEY_DELETED, got %i\n", res
);
3335 res
= RegSetValueExA( hkey
, "test", 0, REG_SZ
, (const BYTE
*)"value", 6);
3336 ok(res
== ERROR_KEY_DELETED
, "expect ERROR_KEY_DELETED, got %i\n", res
);
3338 res
= RegOpenKeyA( hkey
, "test", &hkey2
);
3339 ok(res
== ERROR_KEY_DELETED
, "expect ERROR_KEY_DELETED, got %i\n", res
);
3341 RegCloseKey( hkey2
);
3343 res
= RegCreateKeyA( hkey
, "test", &hkey2
);
3344 ok(res
== ERROR_KEY_DELETED
, "expect ERROR_KEY_DELETED, got %i\n", res
);
3346 RegCloseKey( hkey2
);
3348 res
= RegFlushKey( hkey
);
3349 ok(res
== ERROR_KEY_DELETED
, "expect ERROR_KEY_DELETED, got %i\n", res
);
3351 RegCloseKey( hkey
);
3356 static void test_delete_value(void)
3361 res
= RegSetValueExA( hkey_main
, "test", 0, REG_SZ
, (const BYTE
*)"value", 6 );
3362 ok(res
== ERROR_SUCCESS
, "expect ERROR_SUCCESS, got %i\n", res
);
3364 res
= RegQueryValueExA( hkey_main
, "test", NULL
, NULL
, NULL
, NULL
);
3365 ok(res
== ERROR_SUCCESS
, "expect ERROR_SUCCESS, got %i\n", res
);
3367 res
= RegDeleteValueA( hkey_main
, "test" );
3368 ok(res
== ERROR_SUCCESS
, "expect ERROR_SUCCESS, got %i\n", res
);
3370 res
= RegQueryValueExA( hkey_main
, "test", NULL
, NULL
, NULL
, NULL
);
3371 ok(res
== ERROR_FILE_NOT_FOUND
, "expect ERROR_FILE_NOT_FOUND, got %i\n", res
);
3373 res
= RegDeleteValueA( hkey_main
, "test" );
3374 ok(res
== ERROR_FILE_NOT_FOUND
, "expect ERROR_FILE_NOT_FOUND, got %i\n", res
);
3376 memset(longname
, 'a', 400);
3378 res
= RegDeleteValueA( hkey_main
, longname
);
3379 ok(res
== ERROR_FILE_NOT_FOUND
|| broken(res
== ERROR_MORE_DATA
), /* nt4, win2k */
3380 "expect ERROR_FILE_NOT_FOUND, got %i\n", res
);
3382 /* Default registry value */
3383 res
= RegSetValueExA(hkey_main
, "", 0, REG_SZ
, (const BYTE
*)"value", 6);
3384 ok(res
== ERROR_SUCCESS
, "expected ERROR_SUCCESS, got %d\n", res
);
3386 res
= RegQueryValueExA(hkey_main
, "", NULL
, NULL
, NULL
, NULL
);
3387 ok(res
== ERROR_SUCCESS
, "expected ERROR_SUCCESS, got %d\n", res
);
3389 res
= RegDeleteValueA(hkey_main
, "" );
3390 ok(res
== ERROR_SUCCESS
, "expected ERROR_SUCCESS, got %d\n", res
);
3392 res
= RegQueryValueExA(hkey_main
, "", NULL
, NULL
, NULL
, NULL
);
3393 ok(res
== ERROR_FILE_NOT_FOUND
, "expected ERROR_FILE_NOT_FOUND, got %d\n", res
);
3396 static void test_delete_key_value(void)
3401 if (!pRegDeleteKeyValueA
)
3403 win_skip("RegDeleteKeyValue is not available.\n");
3407 ret
= pRegDeleteKeyValueA(NULL
, NULL
, NULL
);
3408 ok(ret
== ERROR_INVALID_HANDLE
, "got %d\n", ret
);
3410 ret
= pRegDeleteKeyValueA(hkey_main
, NULL
, NULL
);
3411 ok(ret
== ERROR_FILE_NOT_FOUND
, "got %d\n", ret
);
3413 ret
= RegSetValueExA(hkey_main
, "test", 0, REG_SZ
, (const BYTE
*)"value", 6);
3414 ok(ret
== ERROR_SUCCESS
, "got %d\n", ret
);
3416 ret
= RegQueryValueExA(hkey_main
, "test", NULL
, NULL
, NULL
, NULL
);
3417 ok(ret
== ERROR_SUCCESS
, "got %d\n", ret
);
3419 /* NULL subkey name means delete from open key */
3420 ret
= pRegDeleteKeyValueA(hkey_main
, NULL
, "test");
3421 ok(ret
== ERROR_SUCCESS
, "got %d\n", ret
);
3423 ret
= RegQueryValueExA(hkey_main
, "test", NULL
, NULL
, NULL
, NULL
);
3424 ok(ret
== ERROR_FILE_NOT_FOUND
, "got %d\n", ret
);
3426 /* now with real subkey */
3427 ret
= RegCreateKeyExA(hkey_main
, "Subkey1", 0, NULL
, 0, KEY_WRITE
|KEY_READ
, NULL
, &subkey
, NULL
);
3428 ok(!ret
, "failed with error %d\n", ret
);
3430 ret
= RegSetValueExA(subkey
, "test", 0, REG_SZ
, (const BYTE
*)"value", 6);
3431 ok(ret
== ERROR_SUCCESS
, "got %d\n", ret
);
3433 ret
= RegQueryValueExA(subkey
, "test", NULL
, NULL
, NULL
, NULL
);
3434 ok(ret
== ERROR_SUCCESS
, "got %d\n", ret
);
3436 ret
= pRegDeleteKeyValueA(hkey_main
, "Subkey1", "test");
3437 ok(ret
== ERROR_SUCCESS
, "got %d\n", ret
);
3439 ret
= RegQueryValueExA(subkey
, "test", NULL
, NULL
, NULL
, NULL
);
3440 ok(ret
== ERROR_FILE_NOT_FOUND
, "got %d\n", ret
);
3442 /* Default registry value */
3443 ret
= RegSetValueExA(subkey
, "", 0, REG_SZ
, (const BYTE
*)"value", 6);
3444 ok(ret
== ERROR_SUCCESS
, "expected ERROR_SUCCESS, got %d\n", ret
);
3446 ret
= RegQueryValueExA(subkey
, "", NULL
, NULL
, NULL
, NULL
);
3447 ok(ret
== ERROR_SUCCESS
, "expected ERROR_SUCCESS, got %d\n", ret
);
3449 ret
= pRegDeleteKeyValueA(hkey_main
, "Subkey1", "" );
3450 ok(ret
== ERROR_SUCCESS
, "expected ERROR_SUCCESS, got %d\n", ret
);
3452 ret
= RegQueryValueExA(subkey
, "", NULL
, NULL
, NULL
, NULL
);
3453 ok(ret
== ERROR_FILE_NOT_FOUND
, "expected ERROR_FILE_NOT_FOUND, got %d\n", ret
);
3455 RegDeleteKeyA(subkey
, "");
3456 RegCloseKey(subkey
);
3459 static void test_RegOpenCurrentUser(void)
3464 key
= HKEY_CURRENT_USER
;
3465 ret
= RegOpenCurrentUser(KEY_READ
, &key
);
3466 ok(!ret
, "got %d, error %d\n", ret
, GetLastError());
3467 ok(key
!= HKEY_CURRENT_USER
, "got %p\n", key
);
3471 struct notify_data
{
3477 static DWORD WINAPI
notify_change_thread(void *arg
)
3479 struct notify_data
*data
= arg
;
3482 ret
= RegNotifyChangeKeyValue(data
->key
, TRUE
,
3483 REG_NOTIFY_CHANGE_NAME
|data
->flags
, data
->event
, TRUE
);
3484 ok(ret
== ERROR_SUCCESS
, "expected ERROR_SUCCESS, got %d\n", ret
);
3488 static void test_RegNotifyChangeKeyValue(void)
3490 struct notify_data data
;
3491 HKEY key
, subkey
, subsubkey
;
3497 event
= CreateEventW(NULL
, FALSE
, TRUE
, NULL
);
3498 ok(event
!= NULL
, "CreateEvent failed, error %u\n", GetLastError());
3499 ret
= RegCreateKeyA(hkey_main
, "TestKey", &key
);
3500 ok(ret
== ERROR_SUCCESS
, "expected ERROR_SUCCESS, got %d\n", ret
);
3502 ret
= RegNotifyChangeKeyValue(key
, TRUE
, REG_NOTIFY_CHANGE_NAME
|REG_NOTIFY_CHANGE_LAST_SET
, event
, TRUE
);
3503 ok(ret
== ERROR_SUCCESS
, "expected ERROR_SUCCESS, got %d\n", ret
);
3504 dwret
= WaitForSingleObject(event
, 0);
3505 ok(dwret
== WAIT_TIMEOUT
, "expected WAIT_TIMEOUT, got %u\n", dwret
);
3507 ret
= RegCreateKeyA(key
, "SubKey", &subkey
);
3508 ok(ret
== ERROR_SUCCESS
, "expected ERROR_SUCCESS, got %d\n", ret
);
3509 dwret
= WaitForSingleObject(event
, 0);
3510 ok(dwret
== WAIT_OBJECT_0
, "expected WAIT_OBJECT_0, got %u\n", dwret
);
3512 /* watching deeper keys */
3513 ret
= RegNotifyChangeKeyValue(key
, TRUE
, REG_NOTIFY_CHANGE_NAME
|REG_NOTIFY_CHANGE_LAST_SET
, event
, TRUE
);
3514 ok(ret
== ERROR_SUCCESS
, "expected ERROR_SUCCESS, got %d\n", ret
);
3515 dwret
= WaitForSingleObject(event
, 0);
3516 ok(dwret
== WAIT_TIMEOUT
, "expected WAIT_TIMEOUT, got %u\n", dwret
);
3518 ret
= RegCreateKeyA(subkey
, "SubKey", &subsubkey
);
3519 ok(ret
== ERROR_SUCCESS
, "expected ERROR_SUCCESS, got %d\n", ret
);
3520 dwret
= WaitForSingleObject(event
, 0);
3521 ok(dwret
== WAIT_OBJECT_0
, "expected WAIT_OBJECT_0, got %u\n", dwret
);
3523 /* watching deeper values */
3524 ret
= RegNotifyChangeKeyValue(key
, TRUE
, REG_NOTIFY_CHANGE_NAME
|REG_NOTIFY_CHANGE_LAST_SET
, event
, TRUE
);
3525 ok(ret
== ERROR_SUCCESS
, "expected ERROR_SUCCESS, got %d\n", ret
);
3526 dwret
= WaitForSingleObject(event
, 0);
3527 ok(dwret
== WAIT_TIMEOUT
, "expected WAIT_TIMEOUT, got %u\n", dwret
);
3529 ret
= RegSetValueA(subsubkey
, NULL
, REG_SZ
, "SubSubKeyValue", 0);
3530 ok(ret
== ERROR_SUCCESS
, "expected ERROR_SUCCESS, got %d\n", ret
);
3531 dwret
= WaitForSingleObject(event
, 0);
3532 ok(dwret
== WAIT_OBJECT_0
, "expected WAIT_OBJECT_0, got %u\n", dwret
);
3534 /* don't watch deeper values */
3536 ret
= RegOpenKeyA(hkey_main
, "TestKey", &key
);
3537 ok(ret
== ERROR_SUCCESS
, "expected ERROR_SUCCESS, got %d\n", ret
);
3539 ret
= RegNotifyChangeKeyValue(key
, FALSE
, REG_NOTIFY_CHANGE_NAME
|REG_NOTIFY_CHANGE_LAST_SET
, event
, TRUE
);
3540 ok(ret
== ERROR_SUCCESS
, "expected ERROR_SUCCESS, got %d\n", ret
);
3541 dwret
= WaitForSingleObject(event
, 0);
3542 ok(dwret
== WAIT_TIMEOUT
, "expected WAIT_TIMEOUT, got %u\n", dwret
);
3544 ret
= RegSetValueA(subsubkey
, NULL
, REG_SZ
, "SubSubKeyValueNEW", 0);
3545 ok(ret
== ERROR_SUCCESS
, "expected ERROR_SUCCESS, got %d\n", ret
);
3546 dwret
= WaitForSingleObject(event
, 0);
3547 ok(dwret
== WAIT_TIMEOUT
, "expected WAIT_TIMEOUT, got %u\n", dwret
);
3549 RegDeleteKeyA(subkey
, "SubKey");
3550 RegDeleteKeyA(key
, "SubKey");
3551 RegCloseKey(subsubkey
);
3552 RegCloseKey(subkey
);
3555 /* test same thread with REG_NOTIFY_THREAD_AGNOSTIC */
3556 ret
= RegOpenKeyA(hkey_main
, "TestKey", &key
);
3557 ok(ret
== ERROR_SUCCESS
, "expected ERROR_SUCCESS, got %d\n", ret
);
3558 ret
= RegNotifyChangeKeyValue(key
, TRUE
, REG_NOTIFY_CHANGE_NAME
|REG_NOTIFY_THREAD_AGNOSTIC
,
3560 if (ret
== ERROR_INVALID_PARAMETER
)
3562 win_skip("REG_NOTIFY_THREAD_AGNOSTIC is not supported\n");
3568 ret
= RegCreateKeyA(key
, "SubKey", &subkey
);
3569 ok(ret
== ERROR_SUCCESS
, "expected ERROR_SUCCESS, got %d\n", ret
);
3570 dwret
= WaitForSingleObject(event
, 0);
3571 ok(dwret
== WAIT_OBJECT_0
, "expected WAIT_OBJECT_0, got %u\n", dwret
);
3573 RegDeleteKeyA(key
, "SubKey");
3574 RegCloseKey(subkey
);
3577 /* test different thread without REG_NOTIFY_THREAD_AGNOSTIC */
3578 ret
= RegOpenKeyA(hkey_main
, "TestKey", &key
);
3579 ok(ret
== ERROR_SUCCESS
, "expected ERROR_SUCCESS, got %d\n", ret
);
3584 thread
= CreateThread(NULL
, 0, notify_change_thread
, &data
, 0, NULL
);
3585 WaitForSingleObject(thread
, INFINITE
);
3586 CloseHandle(thread
);
3588 /* the thread exiting causes event to signal on Windows
3589 this is worked around on Windows using REG_NOTIFY_THREAD_AGNOSTIC
3590 Wine already behaves as if the flag is set */
3591 dwret
= WaitForSingleObject(event
, 0);
3593 ok(dwret
== WAIT_OBJECT_0
, "expected WAIT_OBJECT_0, got %u\n", dwret
);
3596 /* test different thread with REG_NOTIFY_THREAD_AGNOSTIC */
3597 ret
= RegOpenKeyA(hkey_main
, "TestKey", &key
);
3598 ok(ret
== ERROR_SUCCESS
, "expected ERROR_SUCCESS, got %d\n", ret
);
3600 data
.flags
= REG_NOTIFY_THREAD_AGNOSTIC
;
3601 thread
= CreateThread(NULL
, 0, notify_change_thread
, &data
, 0, NULL
);
3602 WaitForSingleObject(thread
, INFINITE
);
3603 CloseHandle(thread
);
3605 dwret
= WaitForSingleObject(event
, 0);
3606 ok(dwret
== WAIT_TIMEOUT
, "expected WAIT_TIMEOUT, got %u\n", dwret
);
3608 ret
= RegCreateKeyA(key
, "SubKey", &subkey
);
3609 ok(ret
== ERROR_SUCCESS
, "expected ERROR_SUCCESS, got %d\n", ret
);
3611 dwret
= WaitForSingleObject(event
, 0);
3612 ok(dwret
== WAIT_OBJECT_0
, "expected WAIT_OBJECT_0, got %u\n", dwret
);
3614 RegDeleteKeyA(key
, "SubKey");
3615 RegDeleteKeyA(key
, "");
3616 RegCloseKey(subkey
);
3621 #define cmp_li(a, b, c) cmp_li_real(a, b, c, __LINE__)
3622 static void cmp_li_real(LARGE_INTEGER
*l1
, LARGE_INTEGER
*l2
, LONGLONG slack
, int line
)
3624 LONGLONG diff
= l2
->QuadPart
- l1
->QuadPart
;
3625 if (diff
< 0) diff
= -diff
;
3626 ok_(__FILE__
, line
)(diff
<= slack
, "values don't match: %s/%s\n",
3627 wine_dbgstr_longlong(l1
->QuadPart
), wine_dbgstr_longlong(l2
->QuadPart
));
3630 static void test_RegQueryValueExPerformanceData(void)
3632 static const WCHAR globalW
[] = { 'G','l','o','b','a','l',0 };
3633 static const WCHAR dummyW
[5] = { 'd','u','m','m','y' };
3634 static const char * const names
[] = { NULL
, "", "Global", "2", "invalid counter name" };
3635 DWORD cbData
, len
, i
, type
;
3639 PERF_DATA_BLOCK
*pdb
;
3641 BYTE buf
[256 + sizeof(PERF_DATA_BLOCK
)];
3643 /* Test with data == NULL */
3644 dwret
= RegQueryValueExA( HKEY_PERFORMANCE_DATA
, "Global", NULL
, NULL
, NULL
, &cbData
);
3645 ok( dwret
== ERROR_MORE_DATA
, "expected ERROR_MORE_DATA, got %d\n", dwret
);
3647 dwret
= RegQueryValueExW( HKEY_PERFORMANCE_DATA
, globalW
, NULL
, NULL
, NULL
, &cbData
);
3648 ok( dwret
== ERROR_MORE_DATA
, "expected ERROR_MORE_DATA, got %d\n", dwret
);
3650 /* Test ERROR_MORE_DATA, start with small buffer */
3652 value
= HeapAlloc(GetProcessHeap(), 0, len
);
3655 dwret
= RegQueryValueExA( HKEY_PERFORMANCE_DATA
, "Global", NULL
, &type
, value
, &cbData
);
3656 ok( dwret
== ERROR_MORE_DATA
, "expected ERROR_MORE_DATA, got %d\n", dwret
);
3657 ok(type
== REG_BINARY
, "got %u\n", type
);
3658 while( dwret
== ERROR_MORE_DATA
&& limit
)
3661 value
= HeapReAlloc( GetProcessHeap(), 0, value
, len
);
3664 dwret
= RegQueryValueExA( HKEY_PERFORMANCE_DATA
, "Global", NULL
, &type
, value
, &cbData
);
3667 ok(limit
> 0, "too many times ERROR_MORE_DATA returned\n");
3669 ok(dwret
== ERROR_SUCCESS
, "expected ERROR_SUCCESS, got %d\n", dwret
);
3670 ok(type
== REG_BINARY
, "got %u\n", type
);
3672 /* Check returned data */
3673 if (dwret
== ERROR_SUCCESS
)
3675 ok(len
>= sizeof(PERF_DATA_BLOCK
), "got size %d\n", len
);
3676 if (len
>= sizeof(PERF_DATA_BLOCK
)) {
3677 pdb
= (PERF_DATA_BLOCK
*) value
;
3678 ok(pdb
->Signature
[0] == 'P', "expected Signature[0] = 'P', got 0x%x\n", pdb
->Signature
[0]);
3679 ok(pdb
->Signature
[1] == 'E', "expected Signature[1] = 'E', got 0x%x\n", pdb
->Signature
[1]);
3680 ok(pdb
->Signature
[2] == 'R', "expected Signature[2] = 'R', got 0x%x\n", pdb
->Signature
[2]);
3681 ok(pdb
->Signature
[3] == 'F', "expected Signature[3] = 'F', got 0x%x\n", pdb
->Signature
[3]);
3682 /* TODO: check other field */
3686 HeapFree(GetProcessHeap(), 0, value
);
3688 for (i
= 0; i
< ARRAY_SIZE(names
); i
++)
3690 cbData
= 0xdeadbeef;
3691 dwret
= RegQueryValueExA(HKEY_PERFORMANCE_DATA
, names
[i
], NULL
, NULL
, NULL
, &cbData
);
3692 ok(dwret
== ERROR_MORE_DATA
, "%u/%s: got %u\n", i
, names
[i
], dwret
);
3693 ok(cbData
== 0, "got %u\n", cbData
);
3696 dwret
= RegQueryValueExA(HKEY_PERFORMANCE_DATA
, names
[i
], NULL
, NULL
, NULL
, &cbData
);
3697 ok(dwret
== ERROR_MORE_DATA
, "%u/%s: got %u\n", i
, names
[i
], dwret
);
3698 ok(cbData
== 0, "got %u\n", cbData
);
3700 cbData
= 0xdeadbeef;
3701 dwret
= RegQueryValueExA(HKEY_PERFORMANCE_TEXT
, names
[i
], NULL
, NULL
, NULL
, &cbData
);
3703 ok(dwret
== ERROR_MORE_DATA
, "%u/%s: got %u\n", i
, names
[i
], dwret
);
3704 ok(cbData
== 0, "got %u\n", cbData
);
3707 dwret
= RegQueryValueExA(HKEY_PERFORMANCE_TEXT
, names
[i
], NULL
, NULL
, NULL
, &cbData
);
3709 ok(dwret
== ERROR_MORE_DATA
, "%u/%s: got %u\n", i
, names
[i
], dwret
);
3710 ok(cbData
== 0, "got %u\n", cbData
);
3712 cbData
= 0xdeadbeef;
3713 dwret
= RegQueryValueExA(HKEY_PERFORMANCE_NLSTEXT
, names
[i
], NULL
, NULL
, NULL
, &cbData
);
3715 ok(dwret
== ERROR_MORE_DATA
, "%u/%s: got %u\n", i
, names
[i
], dwret
);
3716 ok(cbData
== 0, "got %u\n", cbData
);
3719 dwret
= RegQueryValueExA(HKEY_PERFORMANCE_NLSTEXT
, names
[i
], NULL
, NULL
, NULL
, &cbData
);
3721 ok(dwret
== ERROR_MORE_DATA
, "%u/%s: got %u\n", i
, names
[i
], dwret
);
3722 ok(cbData
== 0, "got %u\n", cbData
);
3725 memset(buf
, 0x77, sizeof(buf
));
3727 cbData
= sizeof(buf
);
3728 dwret
= RegQueryValueExA(HKEY_PERFORMANCE_DATA
, "invalid counter name", NULL
, &type
, buf
, &cbData
);
3729 ok(dwret
== ERROR_SUCCESS
, "got %u\n", dwret
);
3730 ok(type
== REG_BINARY
, "got %u\n", type
);
3731 if (dwret
== ERROR_SUCCESS
)
3734 WCHAR sysname
[MAX_COMPUTERNAME_LENGTH
+ 1];
3736 LARGE_INTEGER counter
, freq
, ftime
;
3739 GetSystemTimeAsFileTime((FILETIME
*)&ftime
);
3740 QueryPerformanceCounter(&counter
);
3741 QueryPerformanceFrequency(&freq
);
3743 sysname_len
= MAX_COMPUTERNAME_LENGTH
+ 1;
3744 GetComputerNameW(sysname
, &sysname_len
);
3746 pdb
= (PERF_DATA_BLOCK
*)buf
;
3747 ok(pdb
->Signature
[0] == 'P', "got '%c'\n", pdb
->Signature
[0]);
3748 ok(pdb
->Signature
[1] == 'E', "got '%c'\n", pdb
->Signature
[1]);
3749 ok(pdb
->Signature
[2] == 'R', "got '%c'\n", pdb
->Signature
[2]);
3750 ok(pdb
->Signature
[3] == 'F', "got '%c'\n", pdb
->Signature
[3]);
3752 ok(pdb
->LittleEndian
== 1, "got %u\n", pdb
->LittleEndian
);
3753 ok(pdb
->Version
== 1, "got %u\n", pdb
->Version
);
3754 ok(pdb
->Revision
== 1, "got %u\n", pdb
->Revision
);
3755 len
= (sizeof(*pdb
) + pdb
->SystemNameLength
+ 7) & ~7;
3756 ok(pdb
->TotalByteLength
== len
, "got %u vs %u\n", pdb
->TotalByteLength
, len
);
3757 ok(pdb
->HeaderLength
== pdb
->TotalByteLength
, "got %u\n", pdb
->HeaderLength
);
3758 ok(pdb
->NumObjectTypes
== 0, "got %u\n", pdb
->NumObjectTypes
);
3760 ok(pdb
->DefaultObject
!= 0, "got %u\n", pdb
->DefaultObject
);
3761 ok(pdb
->SystemTime
.wYear
== st
.wYear
, "got %u\n", pdb
->SystemTime
.wYear
);
3762 ok(pdb
->SystemTime
.wMonth
== st
.wMonth
, "got %u\n", pdb
->SystemTime
.wMonth
);
3763 ok(pdb
->SystemTime
.wDayOfWeek
== st
.wDayOfWeek
, "got %u\n", pdb
->SystemTime
.wDayOfWeek
);
3764 ok(pdb
->SystemTime
.wDay
== st
.wDay
, "got %u\n", pdb
->SystemTime
.wDay
);
3765 if (U(pdb
->PerfTime
).LowPart
!= 0x77777777) /* TestBot is broken */
3766 cmp_li(&pdb
->PerfTime
, &counter
, freq
.QuadPart
);
3767 if (U(pdb
->PerfFreq
).LowPart
!= 0x77777777) /* TestBot is broken */
3768 cmp_li(&pdb
->PerfFreq
, &freq
, 0);
3769 cmp_li(&pdb
->PerfTime100nSec
, &ftime
, 200000); /* TestBot needs huge slack value */
3770 ok(pdb
->SystemNameLength
== (sysname_len
+ 1) * sizeof(WCHAR
), "expected %u, got %u\n",
3771 (sysname_len
+ 1) * 2 /*sizeof(WCHAR)*/, pdb
->SystemNameLength
);
3772 ok(pdb
->SystemNameOffset
== sizeof(*pdb
), "got %u\n", pdb
->SystemNameOffset
);
3773 ok(!lstrcmpW(sysname
, (LPCWSTR
)(pdb
+ 1)), "%s != %s\n",
3774 wine_dbgstr_w(sysname
), wine_dbgstr_w((LPCWSTR
)(pdb
+ 1)));
3776 len
= pdb
->TotalByteLength
- (sizeof(*pdb
) + pdb
->SystemNameLength
);
3779 BYTE remainder
[8], *p
;
3781 memset(remainder
, 0x77, sizeof(remainder
));
3782 p
= buf
+ sizeof(*pdb
) + pdb
->SystemNameLength
;
3783 ok(!memcmp(p
, remainder
, len
), "remainder: %02x,%02x...\n", p
[0], p
[1]);
3787 dwret
= RegOpenKeyA(HKEY_PERFORMANCE_DATA
, NULL
, &hkey
);
3789 ok(dwret
== ERROR_INVALID_HANDLE
, "got %u\n", dwret
);
3791 dwret
= RegOpenKeyA(HKEY_PERFORMANCE_DATA
, "Global", &hkey
);
3793 ok(dwret
== ERROR_INVALID_HANDLE
, "got %u\n", dwret
);
3795 dwret
= RegOpenKeyExA(HKEY_PERFORMANCE_DATA
, "Global", 0, KEY_READ
, &hkey
);
3797 ok(dwret
== ERROR_INVALID_HANDLE
, "got %u\n", dwret
);
3799 dwret
= RegQueryValueA(HKEY_PERFORMANCE_DATA
, "Global", NULL
, (LONG
*)&cbData
);
3801 ok(dwret
== ERROR_INVALID_HANDLE
, "got %u\n", dwret
);
3803 dwret
= RegSetValueA(HKEY_PERFORMANCE_DATA
, "Global", REG_SZ
, "dummy", 4);
3805 ok(dwret
== ERROR_INVALID_HANDLE
, "got %u\n", dwret
);
3807 dwret
= RegSetValueExA(HKEY_PERFORMANCE_DATA
, "Global", 0, REG_SZ
, (const BYTE
*)"dummy", 40);
3809 ok(dwret
== ERROR_INVALID_HANDLE
, "got %u\n", dwret
);
3811 cbData
= sizeof(buf
);
3812 dwret
= RegEnumKeyA(HKEY_PERFORMANCE_DATA
, 0, (LPSTR
)buf
, cbData
);
3814 ok(dwret
== ERROR_INVALID_HANDLE
, "got %u\n", dwret
);
3816 cbData
= sizeof(buf
);
3817 dwret
= RegEnumValueA(HKEY_PERFORMANCE_DATA
, 0, (LPSTR
)buf
, &cbData
, NULL
, NULL
, NULL
, NULL
);
3819 ok(dwret
== ERROR_MORE_DATA
, "got %u\n", dwret
);
3821 ok(cbData
== sizeof(buf
), "got %u\n", cbData
);
3823 dwret
= RegEnumValueA(HKEY_PERFORMANCE_DATA
, 0, NULL
, &cbData
, NULL
, NULL
, NULL
, NULL
);
3824 ok(dwret
== ERROR_INVALID_PARAMETER
, "got %u\n", dwret
);
3826 if (pRegSetKeyValueW
)
3828 dwret
= pRegSetKeyValueW(HKEY_PERFORMANCE_DATA
, NULL
, globalW
, REG_SZ
, dummyW
, sizeof(dummyW
));
3830 ok(dwret
== ERROR_INVALID_HANDLE
, "got %u\n", dwret
);
3833 dwret
= RegCloseKey(HKEY_PERFORMANCE_DATA
);
3834 ok(dwret
== ERROR_SUCCESS
, "got %u\n", dwret
);
3837 static void test_RegLoadMUIString(void)
3839 HMODULE hUser32
, hResDll
;
3840 int (WINAPI
*pLoadStringW
)(HMODULE
, UINT
, WCHAR
*, int);
3843 DWORD type
, size
, text_size
;
3845 char buf
[64], *p
, sysdir
[MAX_PATH
];
3846 WCHAR textW
[64], bufW
[64];
3847 WCHAR curdirW
[MAX_PATH
], sysdirW
[MAX_PATH
];
3848 const static char tz_value
[] = "MUI_Std";
3849 const static WCHAR tz_valueW
[] = {'M','U','I','_','S','t','d', 0};
3851 if (!pRegLoadMUIStringA
|| !pRegLoadMUIStringW
)
3853 win_skip("RegLoadMUIString is not available\n");
3857 hUser32
= LoadLibraryA("user32.dll");
3858 ok(hUser32
!= NULL
, "cannot load user32.dll\n");
3859 pLoadStringW
= (void *)GetProcAddress(hUser32
, "LoadStringW");
3860 ok(pLoadStringW
!= NULL
, "failed to get LoadStringW address\n");
3862 ret
= RegOpenKeyExA(HKEY_LOCAL_MACHINE
,
3863 "Software\\Microsoft\\Windows NT\\CurrentVersion\\Time Zones\\UTC", 0,
3865 ok(ret
== ERROR_SUCCESS
, "got %d\n", ret
);
3867 size
= ARRAY_SIZE(buf
);
3868 ret
= RegQueryValueExA(hkey
, tz_value
, NULL
, &type
, (BYTE
*)buf
, &size
);
3869 ok(ret
== ERROR_SUCCESS
, "got %d\n", ret
);
3870 ok(buf
[0] == '@', "got %s\n", buf
);
3872 p
= strrchr(buf
, ',');
3874 i
= atoi(p
+ 2); /* skip ',-' */
3875 hResDll
= LoadLibraryExA(&buf
[1], NULL
, LOAD_LIBRARY_AS_DATAFILE
| LOAD_LIBRARY_AS_IMAGE_RESOURCE
);
3876 memset(textW
, 0xaa, sizeof(textW
));
3877 ret
= pLoadStringW(hResDll
, i
, textW
, ARRAY_SIZE(textW
));
3878 ok(ret
> 0, "failed to load string resource\n");
3879 text_size
= (ret
+ 1) * sizeof(WCHAR
);
3880 FreeLibrary(hResDll
);
3881 FreeLibrary(hUser32
);
3883 ret
= GetSystemDirectoryW(sysdirW
, ARRAY_SIZE(sysdirW
));
3884 ok(ret
> 0, "GetSystemDirectoryW failed\n");
3885 ret
= GetSystemDirectoryA(sysdir
, ARRAY_SIZE(sysdir
));
3886 ok(ret
> 0, "GetSystemDirectoryA failed\n");
3888 /* change the current direcoty to system32 */
3889 GetCurrentDirectoryW(ARRAY_SIZE(curdirW
), curdirW
);
3890 SetCurrentDirectoryW(sysdirW
);
3893 ret
= pRegLoadMUIStringW(hkey
, tz_valueW
, NULL
, 0, &size
, 0, NULL
);
3894 ok(ret
== ERROR_MORE_DATA
, "got %d, expected ERROR_MORE_DATA\n", ret
);
3895 todo_wine
ok(size
== text_size
, "got %u, expected %u\n", size
, text_size
);
3897 memset(bufW
, 0xff, sizeof(bufW
));
3898 ret
= pRegLoadMUIStringW(hkey
, tz_valueW
, bufW
, sizeof(WCHAR
)+1, &size
, 0, NULL
);
3899 ok(ret
== ERROR_INVALID_PARAMETER
, "got %d, expected ERROR_INVALID_PARAMETER\n", ret
);
3900 ok(bufW
[0] == 0xffff, "got 0x%04x, expected 0xffff\n", bufW
[0]);
3903 memset(bufW
, 0xff, sizeof(bufW
));
3904 ret
= pRegLoadMUIStringW(hkey
, tz_valueW
, bufW
, sizeof(WCHAR
)*2, &size
, 0, NULL
);
3905 todo_wine
ok(ret
== ERROR_MORE_DATA
, "got %d, expected ERROR_MORE_DATA\n", ret
);
3906 todo_wine
ok(size
== text_size
|| broken(size
== text_size
+ sizeof(WCHAR
) /* vista */),
3907 "got %u, expected %u\n", size
, text_size
);
3908 todo_wine
ok(bufW
[0] == 0xffff, "got 0x%04x, expected 0xffff\n", bufW
[0]);
3911 memset(bufW
, 0xff, sizeof(bufW
));
3912 ret
= pRegLoadMUIStringW(hkey
, tz_valueW
, bufW
, ARRAY_SIZE(bufW
), &size
, 0, NULL
);
3913 ok(ret
== ERROR_SUCCESS
, "got %d, expected ERROR_SUCCESS\n", ret
);
3914 todo_wine
ok(size
== text_size
, "got %u, expected %u\n", size
, text_size
);
3915 size
= min(size
, sizeof(bufW
));
3916 todo_wine
ok(!memcmp(textW
, bufW
, size
), "got %s, expected %s\n",
3917 wine_dbgstr_wn(bufW
, size
/ sizeof(WCHAR
)), wine_dbgstr_wn(textW
, text_size
/ sizeof(WCHAR
)));
3919 ret
= pRegLoadMUIStringA(hkey
, tz_value
, buf
, ARRAY_SIZE(buf
), &size
, 0, NULL
);
3920 ok(ret
== ERROR_CALL_NOT_IMPLEMENTED
, "got %d, expected ERROR_CALL_NOT_IMPLEMENTED\n", ret
);
3922 /* change the current direcoty to other than system32 directory */
3923 SetCurrentDirectoryA("\\");
3926 memset(bufW
, 0xff, sizeof(bufW
));
3927 ret
= pRegLoadMUIStringW(hkey
, tz_valueW
, bufW
, ARRAY_SIZE(bufW
), &size
, 0, sysdirW
);
3928 ok(ret
== ERROR_SUCCESS
, "got %d, expected ERROR_SUCCESS\n", ret
);
3929 todo_wine
ok(size
== text_size
, "got %u, expected %u\n", size
, text_size
);
3930 size
= min(size
, sizeof(bufW
));
3931 todo_wine
ok(!memcmp(textW
, bufW
, size
), "got %s, expected %s\n",
3932 wine_dbgstr_wn(bufW
, size
/ sizeof(WCHAR
)), wine_dbgstr_wn(textW
, text_size
/ sizeof(WCHAR
)));
3934 ret
= pRegLoadMUIStringA(hkey
, tz_value
, buf
, ARRAY_SIZE(buf
), &size
, 0, sysdir
);
3935 ok(ret
== ERROR_CALL_NOT_IMPLEMENTED
, "got %d, expected ERROR_CALL_NOT_IMPLEMENTED\n", ret
);
3937 ret
= pRegLoadMUIStringW(hkey
, tz_valueW
, bufW
, ARRAY_SIZE(bufW
), &size
, 0, NULL
);
3938 ok(ret
== ERROR_FILE_NOT_FOUND
, "got %d, expected ERROR_FILE_NOT_FOUND\n", ret
);
3940 ret
= pRegLoadMUIStringA(hkey
, tz_value
, buf
, ARRAY_SIZE(buf
), &size
, 0, NULL
);
3941 ok(ret
== ERROR_CALL_NOT_IMPLEMENTED
, "got %d, expected ERROR_CALL_NOT_IMPLEMENTED\n", ret
);
3944 SetCurrentDirectoryW(curdirW
);
3947 START_TEST(registry
)
3949 /* Load pointers for functions that are not available in all Windows versions */
3955 create_test_entries();
3957 test_query_value_ex();
3959 test_reg_open_key();
3960 test_reg_create_key();
3961 test_reg_close_key();
3962 test_reg_delete_key();
3963 test_reg_query_value();
3964 test_reg_query_info();
3965 test_string_termination();
3969 test_classesroot_enum();
3970 test_classesroot_mask();
3971 test_reg_save_key();
3972 test_reg_load_key();
3973 test_reg_unload_key();
3974 test_reg_copy_tree();
3975 test_reg_delete_tree();
3978 test_delete_value();
3979 test_delete_key_value();
3980 test_RegOpenCurrentUser();
3981 test_RegNotifyChangeKeyValue();
3982 test_RegQueryValueExPerformanceData();
3983 test_RegLoadMUIString();
3986 delete_key( hkey_main
);
3988 test_regconnectregistry();