2 * Copyright 2010 Andrew Eikum for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #include "wine/test.h"
23 static BOOL supports_wchar
;
25 #define lok ok_(__FILE__,line)
27 #define exec_import_str(c) r_exec_import_str(__LINE__, c)
28 static BOOL
r_exec_import_str(unsigned line
, const char *file_contents
)
30 STARTUPINFOA si
= {sizeof(STARTUPINFOA
)};
31 PROCESS_INFORMATION pi
;
35 char cmd
[] = "regedit /s test.reg";
37 regfile
= CreateFileA("test.reg", GENERIC_WRITE
, 0, NULL
, CREATE_ALWAYS
,
38 FILE_ATTRIBUTE_NORMAL
, NULL
);
39 lok(regfile
!= INVALID_HANDLE_VALUE
, "Failed to create test.reg file\n");
40 if(regfile
== INVALID_HANDLE_VALUE
)
43 br
= WriteFile(regfile
, file_contents
, strlen(file_contents
), &written
,
45 lok(br
== TRUE
, "WriteFile failed: %d\n", GetLastError());
49 if(!CreateProcessA(NULL
, cmd
, NULL
, NULL
, FALSE
, 0, NULL
, NULL
, &si
, &pi
))
52 dr
= WaitForSingleObject(pi
.hProcess
, 10000);
53 if(dr
== WAIT_TIMEOUT
)
54 TerminateProcess(pi
.hProcess
, 1);
55 CloseHandle(pi
.hThread
);
56 CloseHandle(pi
.hProcess
);
58 br
= DeleteFileA("test.reg");
59 lok(br
== TRUE
, "DeleteFileA failed: %d\n", GetLastError());
61 return (dr
!= WAIT_TIMEOUT
);
64 #define exec_import_wstr(c) r_exec_import_wstr(__LINE__, c)
65 static BOOL
r_exec_import_wstr(unsigned line
, const WCHAR
*file_contents
)
67 STARTUPINFOA si
= {sizeof(STARTUPINFOA
)};
68 PROCESS_INFORMATION pi
;
72 char cmd
[] = "regedit /s test.reg";
74 regfile
= CreateFileA("test.reg", GENERIC_WRITE
, 0, NULL
, CREATE_ALWAYS
,
75 FILE_ATTRIBUTE_NORMAL
, NULL
);
76 lok(regfile
!= INVALID_HANDLE_VALUE
, "Failed to create test.reg file\n");
77 if(regfile
== INVALID_HANDLE_VALUE
)
80 br
= WriteFile(regfile
, file_contents
,
81 lstrlenW(file_contents
) * sizeof(WCHAR
), &written
, NULL
);
82 lok(br
== TRUE
, "WriteFile failed: %d\n", GetLastError());
86 if(!CreateProcessA(NULL
, cmd
, NULL
, NULL
, FALSE
, 0, NULL
, NULL
, &si
, &pi
))
89 dr
= WaitForSingleObject(pi
.hProcess
, 10000);
90 if(dr
== WAIT_TIMEOUT
)
91 TerminateProcess(pi
.hProcess
, 1);
92 CloseHandle(pi
.hThread
);
93 CloseHandle(pi
.hProcess
);
95 br
= DeleteFileA("test.reg");
96 lok(br
== TRUE
, "DeleteFileA failed: %d\n", GetLastError());
98 return (dr
!= WAIT_TIMEOUT
);
101 #define TODO_REG_TYPE (0x0001u)
102 #define TODO_REG_SIZE (0x0002u)
103 #define TODO_REG_DATA (0x0004u)
105 /* verify_reg() adapted from programs/reg/tests/reg.c */
106 #define verify_reg(k,v,t,d,s,todo) verify_reg_(__LINE__,k,v,t,d,s,todo)
107 static void verify_reg_(unsigned line
, HKEY hkey
, const char *value
,
108 DWORD exp_type
, const void *exp_data
, DWORD exp_size
, DWORD todo
)
115 memset(data
, 0xdd, size
);
116 err
= RegQueryValueExA(hkey
, value
, NULL
, &type
, data
, &size
);
117 lok(err
== ERROR_SUCCESS
, "RegQueryValueEx failed: got %d\n", err
);
118 if (err
!= ERROR_SUCCESS
)
121 todo_wine_if (todo
& TODO_REG_TYPE
)
122 lok(type
== exp_type
, "got wrong type %d, expected %d\n", type
, exp_type
);
123 todo_wine_if (todo
& TODO_REG_SIZE
)
124 lok(size
== exp_size
, "got wrong size %d, expected %d\n", size
, exp_size
);
125 todo_wine_if (todo
& TODO_REG_DATA
)
126 lok(memcmp(data
, exp_data
, size
) == 0, "got wrong data\n");
129 #define verify_reg_wsz(k,n,e) r_verify_reg_wsz(__LINE__,k,n,e)
130 static void r_verify_reg_wsz(unsigned line
, HKEY key
, const char *value_name
, const WCHAR
*exp_value
)
133 DWORD fnd_type
, fnd_len
;
134 WCHAR fnd_value
[1024], value_nameW
[1024];
136 MultiByteToWideChar(CP_ACP
, 0, value_name
, -1, value_nameW
,
137 sizeof(value_nameW
)/sizeof(value_nameW
[0]));
139 fnd_len
= sizeof(fnd_value
);
140 lr
= RegQueryValueExW(key
, value_nameW
, NULL
, &fnd_type
, (BYTE
*)fnd_value
, &fnd_len
);
141 lok(lr
== ERROR_SUCCESS
, "RegQueryValueExW failed: %d\n", lr
);
142 if(lr
!= ERROR_SUCCESS
)
145 lok(fnd_type
== REG_SZ
, "Got wrong type: %d\n", fnd_type
);
146 if(fnd_type
!= REG_SZ
)
148 lok(!lstrcmpW(exp_value
, fnd_value
),
149 "Strings differ: expected %s, got %s\n",
150 wine_dbgstr_w(exp_value
), wine_dbgstr_w(fnd_value
));
153 #define verify_reg_nonexist(k,n) r_verify_reg_nonexist(__LINE__,k,n)
154 static void r_verify_reg_nonexist(unsigned line
, HKEY key
, const char *value_name
)
158 lr
= RegQueryValueExA(key
, value_name
, NULL
, NULL
, NULL
, NULL
);
159 lok(lr
== ERROR_FILE_NOT_FOUND
, "registry value '%s' shouldn't exist; got %d, expected 2\n",
160 (value_name
&& *value_name
) ? value_name
: "(Default)", lr
);
163 #define verify_key(k,s) verify_key_(__LINE__,k,s)
164 static void verify_key_(unsigned line
, HKEY key_base
, const char *subkey
)
169 lr
= RegOpenKeyExA(key_base
, subkey
, 0, KEY_READ
, &hkey
);
170 lok(lr
== ERROR_SUCCESS
, "RegOpenKeyExA failed: got %d\n", lr
);
176 #define verify_key_nonexist(k,s) verify_key_nonexist_(__LINE__,k,s)
177 static void verify_key_nonexist_(unsigned line
, HKEY key_base
, const char *subkey
)
182 lr
= RegOpenKeyExA(key_base
, subkey
, 0, KEY_READ
, &hkey
);
183 lok(lr
== ERROR_FILE_NOT_FOUND
, "registry key '%s' shouldn't exist; got %d, expected 2\n",
190 #define KEY_BASE "Software\\Wine\\regedit_test"
192 static void test_basic_import(void)
195 DWORD dword
= 0x17, type
, size
;
196 char exp_binary
[] = {0xAA,0xBB,0xCC,0x11};
197 WCHAR wide_test
[] = {0xFEFF,'W','i','n','d','o','w','s',' ','R','e','g',
198 'i','s','t','r','y',' ','E','d','i','t','o','r',' ','V','e','r','s',
199 'i','o','n',' ','5','.','0','0','\n','\n',
200 '[','H','K','E','Y','_','C','U','R','R','E','N','T','_','U','S','E',
201 'R','\\','S','o','f','t','w','a','r','e','\\','W','i','n','e','\\',
202 'r','e','g','e','d','i','t','_','t','e','s','t',']','\n',
203 '"','T','e','s','t','V','a','l','u','e','3','"','=','"',0x3041,'V','a',
204 'l','u','e','"','\n',0};
205 WCHAR wide_test_r
[] = {0xFEFF,'W','i','n','d','o','w','s',' ','R','e','g',
206 'i','s','t','r','y',' ','E','d','i','t','o','r',' ','V','e','r','s',
207 'i','o','n',' ','5','.','0','0','\r','\r',
208 '[','H','K','E','Y','_','C','U','R','R','E','N','T','_','U','S','E',
209 'R','\\','S','o','f','t','w','a','r','e','\\','W','i','n','e','\\',
210 'r','e','g','e','d','i','t','_','t','e','s','t',']','\r',
211 '"','T','e','s','t','V','a','l','u','e','5','"','=','"',0x3041,'V','a',
212 'l','u','e','"','\r',0};
213 WCHAR wide_exp
[] = {0x3041,'V','a','l','u','e',0};
218 lr
= RegDeleteKeyA(HKEY_CURRENT_USER
, KEY_BASE
);
219 ok(lr
== ERROR_SUCCESS
|| lr
== ERROR_FILE_NOT_FOUND
,
220 "RegDeleteKeyA failed: %d\n", lr
);
222 exec_import_str("REGEDIT4\n\n"
223 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
224 "\"TestValue\"=\"AValue\"\n");
225 lr
= RegOpenKeyExA(HKEY_CURRENT_USER
, KEY_BASE
, 0, KEY_READ
, &hkey
);
226 ok(lr
== ERROR_SUCCESS
, "RegOpenKeyExA failed: %d\n", lr
);
227 verify_reg(hkey
, "TestValue", REG_SZ
, "AValue", 7, 0);
229 exec_import_str("REGEDIT4\r\n\r\n"
230 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\r\n"
231 "\"TestValue2\"=\"BValue\"\r\n");
232 verify_reg(hkey
, "TestValue2", REG_SZ
, "BValue", 7, 0);
236 exec_import_wstr(wide_test
);
237 verify_reg_wsz(hkey
, "TestValue3", wide_exp
);
239 exec_import_wstr(wide_test_r
);
240 verify_reg_wsz(hkey
, "TestValue5", wide_exp
);
243 win_skip("Some WCHAR tests skipped\n");
245 exec_import_str("REGEDIT4\r\r"
246 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\r"
247 "\"TestValue4\"=\"DValue\"\r");
248 verify_reg(hkey
, "TestValue4", REG_SZ
, "DValue", 7, 0);
250 exec_import_str("REGEDIT4\n\n"
251 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
252 "\"TestDword\"=dword:00000017\n");
253 verify_reg(hkey
, "TestDword", REG_DWORD
, &dword
, sizeof(dword
), 0);
255 exec_import_str("REGEDIT4\n\n"
256 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
257 "\"TestBinary\"=hex:aa,bb,cc,11\n");
258 verify_reg(hkey
, "TestBinary", REG_BINARY
, exp_binary
, sizeof(exp_binary
), 0);
260 exec_import_str("REGEDIT4\n\n"
261 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
262 "\"With=Equals\"=\"asdf\"\n");
263 verify_reg(hkey
, "With=Equals", REG_SZ
, "asdf", 5, 0);
265 exec_import_str("REGEDIT4\n\n"
266 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
267 "\"Empty string\"=\"\"\n"
268 "\"\"=\"Default registry value\"\n\n");
269 verify_reg(hkey
, "Empty string", REG_SZ
, "", 1, 0);
270 verify_reg(hkey
, NULL
, REG_SZ
, "Default registry value", 23, 0);
272 exec_import_str("REGEDIT4\n\n"
273 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
274 "\"Line1\"=\"Value1\"\n\n"
275 "\"Line2\"=\"Value2\"\n\n\n"
276 "\"Line3\"=\"Value3\"\n\n\n\n"
277 "\"Line4\"=\"Value4\"\n\n");
278 verify_reg(hkey
, "Line1", REG_SZ
, "Value1", 7, 0);
279 verify_reg(hkey
, "Line2", REG_SZ
, "Value2", 7, 0);
280 verify_reg(hkey
, "Line3", REG_SZ
, "Value3", 7, 0);
281 verify_reg(hkey
, "Line4", REG_SZ
, "Value4", 7, 0);
283 exec_import_str("REGEDIT4\n\n"
284 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
285 "\"Wine1\"=dword:00000782\n\n"
286 "\"Wine2\"=\"Test Value\"\n"
287 "\"Wine3\"=hex(7):4c,69,6e,65,20,\\\n"
288 " 63,6f,6e,63,61,74,65,6e,61,74,69,6f,6e,00,00\n"
292 "\"Wine4\"=dword:12345678\n\n");
294 verify_reg(hkey
, "Wine1", REG_DWORD
, &dword
, sizeof(dword
), 0);
295 verify_reg(hkey
, "Wine2", REG_SZ
, "Test Value", 11, 0);
296 verify_reg(hkey
, "Wine3", REG_MULTI_SZ
, "Line concatenation\0", 20, 0);
297 verify_reg(hkey
, "", REG_SZ
, "Test", 5, 0);
299 verify_reg(hkey
, "Wine4", REG_DWORD
, &dword
, sizeof(dword
), 0);
301 exec_import_str("REGEDIT4\n\n"
302 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
303 "\"Wine5\"=\"No newline\"");
304 verify_reg(hkey
, "Wine5", REG_SZ
, "No newline", 11, 0);
306 exec_import_str("REGEDIT4\n\n"
307 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
308 "\"Wine6\"=dword:00000050\n\n"
309 "\"Wine7\"=\"No newline\"");
311 verify_reg(hkey
, "Wine6", REG_DWORD
, &dword
, sizeof(dword
), 0);
312 verify_reg(hkey
, "Wine7", REG_SZ
, "No newline", 11, 0);
314 exec_import_str("REGEDIT4\n\n"
315 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
316 "\"Wine8a\"=dword:1\n"
317 "\"Wine8b\"=dword:4444\n\n");
319 verify_reg(hkey
, "Wine8a", REG_DWORD
, &dword
, sizeof(dword
), 0);
321 verify_reg(hkey
, "Wine8b", REG_DWORD
, &dword
, sizeof(dword
), 0);
323 exec_import_str("REGEDIT4\n\n"
324 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
325 "\"Wine9a\"=hex(2):4c,69,6e,65,00\n"
326 "\"Wine9b\"=\"Value 1\"\n"
327 "\"Wine9c\"=hex(2):4c,69,6e,65\\\n"
328 "\"Wine9d\"=\"Value 2\"\n"
329 "\"Wine9e\"=hex(2):4c,69,6e,65,\\\n"
330 "\"Wine9f\"=\"Value 3\"\n"
331 "\"Wine9g\"=\"Value 4\"\n\n");
332 verify_reg(hkey
, "Wine9a", REG_EXPAND_SZ
, "Line", 5, 0);
333 verify_reg(hkey
, "Wine9b", REG_SZ
, "Value 1", 8, 0);
334 verify_reg_nonexist(hkey
, "Wine9c");
335 verify_reg(hkey
, "Wine9d", REG_SZ
, "Value 2", 8, 0);
336 verify_reg_nonexist(hkey
, "Wine9e");
337 verify_reg_nonexist(hkey
, "Wine9f");
338 verify_reg(hkey
, "Wine9g", REG_SZ
, "Value 4", 8, 0);
340 exec_import_str("REGEDIT4\n\n"
341 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
342 "\"double\\\"quote\"=\"valid \\\"or\\\" not\"\n"
343 "\"single'quote\"=dword:00000008\n\n");
344 verify_reg(hkey
, "double\"quote", REG_SZ
, "valid \"or\" not", 15, 0);
346 verify_reg(hkey
, "single'quote", REG_DWORD
, &dword
, sizeof(dword
), 0);
348 /* Test hex data concatenation for REG_NONE, REG_EXPAND_SZ and REG_BINARY */
349 exec_import_str("REGEDIT4\n\n"
350 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
351 "\"Wine10a\"=hex(0):56,00,61,00,6c,00,75,00,65,00,00,00\n"
352 "\"Wine10b\"=hex(0):56,00,61,00,6c,00,\\\n"
353 " 75,00,65,00,00,00\n"
354 "\"Wine10c\"=hex(0):56,00,61,00,\\;comment\n"
357 "\"Wine10d\"=hex(0):56,00,61,00,\\;comment\n"
360 "\"Wine10e\"=hex(0):56,00,61,00,\\;comment\n"
361 " 6c,00,75,00,;comment\n"
363 verify_reg(hkey
, "Wine10a", REG_NONE
, "V\0a\0l\0u\0e\0\0", 12, 0);
364 verify_reg(hkey
, "Wine10b", REG_NONE
, "V\0a\0l\0u\0e\0\0", 12, 0);
365 verify_reg(hkey
, "Wine10c", REG_NONE
, "V\0a\0l\0u\0e\0\0", 12, 0);
366 verify_reg(hkey
, "Wine10d", REG_NONE
, "V\0a\0l\0u", 8, 0);
367 todo_wine
verify_reg(hkey
, "Wine10e", REG_NONE
, "V\0a\0l\0u", 8, 0);
369 exec_import_str("REGEDIT4\n\n"
370 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
371 "\"Wine11a\"=hex(2):25,50,41,54,48,25,00\n"
372 "\"Wine11b\"=hex(2):25,50,41,\\\n"
374 "\"Wine11c\"=hex(2):25,50,41,\\;comment\n"
377 "\"Wine11d\"=hex(2):25,50,41,\\;comment\n"
380 "\"Wine11e\"=hex(2):25,50,41,\\;comment\n"
383 verify_reg(hkey
, "Wine11a", REG_EXPAND_SZ
, "%PATH%", 7, 0);
384 verify_reg(hkey
, "Wine11b", REG_EXPAND_SZ
, "%PATH%", 7, 0);
385 verify_reg(hkey
, "Wine11c", REG_EXPAND_SZ
, "%PATH%", 7, 0);
387 size
= sizeof(buffer
);
388 lr
= RegQueryValueExA(hkey
, "Wine11d", NULL
, &type
, (BYTE
*)&buffer
, &size
);
389 ok(lr
== ERROR_SUCCESS
, "RegQueryValueExA failed: %d\n", lr
);
390 ok(type
== REG_EXPAND_SZ
, "got wrong type %u, expected %u\n", type
, REG_EXPAND_SZ
);
391 todo_wine
ok(size
== 6 || broken(size
== 5) /* WinXP */, "got wrong size %u, expected 6\n", size
);
392 ok(memcmp(buffer
, "%PATH", size
) == 0, "got wrong data\n");
394 size
= sizeof(buffer
);
395 memset(buffer
, '-', size
);
396 lr
= RegQueryValueExA(hkey
, "Wine11e", NULL
, &type
, (BYTE
*)&buffer
, &size
);
397 todo_wine
ok(lr
== ERROR_SUCCESS
, "RegQueryValueExA failed: %d\n", lr
);
398 todo_wine
ok(type
== REG_EXPAND_SZ
, "got wrong type %u, expected %u\n", type
, REG_EXPAND_SZ
);
399 todo_wine
ok(size
== 6 || broken(size
== 5) /* WinXP */, "got wrong size %u, expected 6\n", size
);
400 todo_wine
ok(memcmp(buffer
, "%PATH", size
) == 0, "got wrong data\n");
402 exec_import_str("REGEDIT4\n\n"
403 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
404 "\"Wine12a\"=hex:11,22,33,44,55,66,77,88\n"
405 "\"Wine12b\"=hex:11,22,33,44,\\\n"
407 "\"Wine12c\"=hex:11,22,33,44,\\;comment\n"
410 "\"Wine12d\"=hex:11,22,33,44,\\;comment\n"
413 "\"Wine12e\"=hex:11,22,33,44,\\;comment\n"
416 hex
[0] = 0x11; hex
[1] = 0x22; hex
[2] = 0x33; hex
[3] = 0x44;
417 hex
[4] = 0x55; hex
[5] = 0x66; hex
[6] = 0x77; hex
[7] = 0x88;
418 verify_reg(hkey
, "Wine12a", REG_BINARY
, hex
, sizeof(hex
), 0);
419 verify_reg(hkey
, "Wine12b", REG_BINARY
, hex
, sizeof(hex
), 0);
420 verify_reg(hkey
, "Wine12c", REG_BINARY
, hex
, sizeof(hex
), 0);
421 verify_reg(hkey
, "Wine12d", REG_BINARY
, hex
, 6, 0);
422 todo_wine
verify_reg(hkey
, "Wine12e", REG_BINARY
, hex
, 6, 0);
424 /* Test import with subkeys */
425 exec_import_str("REGEDIT4\n\n"
426 "[HKEY_CURRENT_USER\\" KEY_BASE
"\\Subkey\"1]\n"
427 "\"Wine\\\\31\"=\"Test value\"\n\n");
428 lr
= RegOpenKeyExA(hkey
, "Subkey\"1", 0, KEY_READ
, &subkey
);
429 ok(lr
== ERROR_SUCCESS
, "got %d, expected 0\n", lr
);
430 verify_reg(subkey
, "Wine\\31", REG_SZ
, "Test value", 11, 0);
431 lr
= RegCloseKey(subkey
);
432 ok(lr
== ERROR_SUCCESS
, "got %d, expected 0\n", lr
);
433 lr
= RegDeleteKeyA(HKEY_CURRENT_USER
, KEY_BASE
"\\Subkey\"1");
434 ok(lr
== ERROR_SUCCESS
, "got %d, expected 0\n", lr
);
436 exec_import_str("REGEDIT4\n\n"
437 "[HKEY_CURRENT_USER\\" KEY_BASE
"\\Subkey/2]\n"
438 "\"123/\\\"4;'5\"=\"Random value name\"\n\n");
439 lr
= RegOpenKeyExA(hkey
, "Subkey/2", 0, KEY_READ
, &subkey
);
440 ok(lr
== ERROR_SUCCESS
, "got %d, expected 0\n", lr
);
441 verify_reg(subkey
, "123/\"4;'5", REG_SZ
, "Random value name", 18, 0);
442 lr
= RegCloseKey(subkey
);
443 ok(lr
== ERROR_SUCCESS
, "got %d, expected 0\n", lr
);
444 lr
= RegDeleteKeyA(HKEY_CURRENT_USER
, KEY_BASE
"\\Subkey/2");
445 ok(lr
== ERROR_SUCCESS
, "got %d, expected 0\n", lr
);
447 /* Test the accepted range of the hex-based data types */
448 exec_import_str("REGEDIT4\n\n"
449 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
450 "\"Wine13a\"=hex(0):56,61,6c,75,65,00\n"
451 "\"Wine13b\"=hex(10):56,61,6c,75,65,00\n"
452 "\"Wine13c\"=hex(100):56,61,6c,75,65,00\n"
453 "\"Wine13d\"=hex(1000):56,61,6c,75,65,00\n"
454 "\"Wine13e\"=hex(7fff):56,61,6c,75,65,00\n"
455 "\"Wine13f\"=hex(ffff):56,61,6c,75,65,00\n"
456 "\"Wine13g\"=hex(7fffffff):56,61,6c,75,65,00\n"
457 "\"Wine13h\"=hex(ffffffff):56,61,6c,75,65,00\n"
458 "\"Wine13i\"=hex(100000000):56,61,6c,75,65,00\n"
459 "\"Wine13j\"=hex(0x2):56,61,6c,75,65,00\n"
460 "\"Wine13k\"=hex(x2):56,61,6c,75,65,00\n\n");
461 verify_reg(hkey
, "Wine13a", REG_NONE
, "Value", 6, 0);
462 verify_reg(hkey
, "Wine13b", 0x10, "Value", 6, 0);
463 verify_reg(hkey
, "Wine13c", 0x100, "Value", 6, 0);
464 verify_reg(hkey
, "Wine13d", 0x1000, "Value", 6, 0);
465 verify_reg(hkey
, "Wine13e", 0x7fff, "Value", 6, 0);
466 verify_reg(hkey
, "Wine13f", 0xffff, "Value", 6, 0);
467 verify_reg(hkey
, "Wine13g", 0x7fffffff, "Value", 6, 0);
468 verify_reg(hkey
, "Wine13h", 0xffffffff, "Value", 6, 0);
469 verify_reg_nonexist(hkey
, "Wine13i");
470 todo_wine
verify_reg_nonexist(hkey
, "Wine13j");
471 verify_reg_nonexist(hkey
, "Wine13k");
473 exec_import_str("REGEDIT4\n\n"
474 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
475 "\"Wine14a\"=hex(7):4c,69,6e,65,20, \\\n"
476 " 63,6f,6e,63,61,74,65,6e,61,74,69,6f,6e,00,00\n"
477 "\"Wine14b\"=hex(7):4c,69,6e,65,20,\t\\\n"
478 " 63,6f,6e,63,61,74,65,6e,61,74,69,6f,6e,00,00\n\n");
479 verify_reg(hkey
, "Wine14a", REG_MULTI_SZ
, "Line concatenation\0", 20, 0);
480 verify_reg(hkey
, "Wine14b", REG_MULTI_SZ
, "Line concatenation\0", 20, 0);
482 exec_import_str("REGEDIT4\n\n"
483 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
484 "\"Wine15\"=hex(2):25,50,41,54,48,25,00,\n\n");
485 verify_reg(hkey
, "Wine15", REG_EXPAND_SZ
, "%PATH%", 7, 0);
487 exec_import_str("REGEDIT4\n\n"
488 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
489 "\"Wine16\"=hex(2):\\\n"
490 " 25,48,4f,4d,45,25,00\n\n");
491 verify_reg(hkey
, "Wine16", REG_EXPAND_SZ
, "%HOME%", 7, 0);
493 exec_import_str("REGEDIT4\n\n"
494 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
495 "\"Wine17\"=hex(7):4c,69,6e,65,20,\\");
496 lr
= RegQueryValueExA(hkey
, "Wine17", NULL
, NULL
, NULL
, NULL
);
497 ok(lr
== ERROR_SUCCESS
|| broken(lr
== ERROR_FILE_NOT_FOUND
) /* WinXP */, "got %u, expected 0\n", lr
);
498 if (lr
== ERROR_SUCCESS
)
499 verify_reg(hkey
, "Wine17", REG_MULTI_SZ
, "Line ", 6, TODO_REG_SIZE
| TODO_REG_DATA
);
503 lr
= RegDeleteKeyA(HKEY_CURRENT_USER
, KEY_BASE
);
504 ok(lr
== ERROR_SUCCESS
, "RegDeleteKeyA failed: %d\n", lr
);
507 static void test_basic_import_31(void)
512 lr
= RegDeleteKeyA(HKEY_CLASSES_ROOT
, KEY_BASE
);
513 ok(lr
== ERROR_SUCCESS
|| lr
== ERROR_FILE_NOT_FOUND
,
514 "RegDeleteKeyA failed: %d\n", lr
);
516 /* Test simple value */
517 exec_import_str("REGEDIT\r\n"
518 "HKEY_CLASSES_ROOT\\" KEY_BASE
" = Value0\r\n");
519 lr
= RegOpenKeyExA(HKEY_CLASSES_ROOT
, KEY_BASE
, 0, KEY_READ
, &hkey
);
520 ok(lr
== ERROR_SUCCESS
, "RegOpenKeyExA failed: %d\n", lr
);
521 verify_reg(hkey
, "", REG_SZ
, "Value0", 7, 0);
523 /* Test proper handling of spaces and equals signs */
524 exec_import_str("REGEDIT\r\n"
525 "HKEY_CLASSES_ROOT\\" KEY_BASE
" =Value1\r\n");
526 verify_reg(hkey
, "", REG_SZ
, "Value1", 7, 0);
528 exec_import_str("REGEDIT\r\n"
529 "HKEY_CLASSES_ROOT\\" KEY_BASE
" = Value2\r\n");
530 verify_reg(hkey
, "", REG_SZ
, " Value2", 8, 0);
532 exec_import_str("REGEDIT\r\n"
533 "HKEY_CLASSES_ROOT\\" KEY_BASE
" = Value3 \r\n");
534 verify_reg(hkey
, "", REG_SZ
, "Value3 ", 8, 0);
536 exec_import_str("REGEDIT\r\n"
537 "HKEY_CLASSES_ROOT\\" KEY_BASE
" Value4\r\n");
538 verify_reg(hkey
, "", REG_SZ
, "Value4", 7, 0);
540 exec_import_str("REGEDIT\r\n"
541 "HKEY_CLASSES_ROOT\\" KEY_BASE
" Value5\r\n");
542 verify_reg(hkey
, "", REG_SZ
, "Value5", 7, 0);
544 exec_import_str("REGEDIT\r\n"
545 "HKEY_CLASSES_ROOT\\" KEY_BASE
"\r\n");
546 verify_reg(hkey
, "", REG_SZ
, "", 1, 0);
548 exec_import_str("REGEDIT\r\n"
549 "HKEY_CLASSES_ROOT\\" KEY_BASE
" \r\n");
550 verify_reg(hkey
, "", REG_SZ
, "", 1, 0);
552 exec_import_str("REGEDIT\r\n"
553 "HKEY_CLASSES_ROOT\\" KEY_BASE
" = No newline");
554 verify_reg(hkey
, "", REG_SZ
, "No newline", 11, 0);
558 lr
= RegDeleteKeyA(HKEY_CLASSES_ROOT
, KEY_BASE
);
559 ok(lr
== ERROR_SUCCESS
, "RegDeleteKeyA failed: %d\n", lr
);
562 static void test_invalid_import(void)
568 lr
= RegDeleteKeyA(HKEY_CURRENT_USER
, KEY_BASE
);
569 ok(lr
== ERROR_SUCCESS
|| lr
== ERROR_FILE_NOT_FOUND
, "RegDeleteKeyA failed: %d\n", lr
);
571 exec_import_str("REGEDIT4\n\n"
572 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
573 "\"TestNoEndQuote\"=\"Asdffdsa\n");
574 lr
= RegOpenKeyExA(HKEY_CURRENT_USER
, KEY_BASE
, 0, KEY_READ
|KEY_SET_VALUE
, &hkey
);
575 ok(lr
== ERROR_SUCCESS
, "RegOpenKeyExA failed: %d\n", lr
);
576 verify_reg_nonexist(hkey
, "TestNoEndQuote");
578 exec_import_str("REGEDIT4\n\n"
579 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
580 "\"TestNoBeginQuote\"=Asdffdsa\"\n");
581 verify_reg_nonexist(hkey
, "TestNoBeginQuote");
583 exec_import_str("REGEDIT4\n\n"
584 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
585 "\"TestNoQuotes\"=Asdffdsa\n");
586 verify_reg_nonexist(hkey
, "TestNoQuotes");
588 exec_import_str("REGEDIT4\n\n"
589 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
590 "\"NameNoEndQuote=\"Asdffdsa\"\n");
591 verify_reg_nonexist(hkey
, "NameNoEndQuote");
593 exec_import_str("REGEDIT4\n\n"
594 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
595 "NameNoBeginQuote\"=\"Asdffdsa\"\n");
596 verify_reg_nonexist(hkey
, "NameNoBeginQuote");
598 exec_import_str("REGEDIT4\n\n"
599 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
600 "NameNoQuotes=\"Asdffdsa\"\n");
601 verify_reg_nonexist(hkey
, "NameNoQuotes");
603 exec_import_str("REGEDIT4\n\n"
604 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
605 "\"MixedQuotes=Asdffdsa\"\n");
606 verify_reg_nonexist(hkey
, "MixedQuotes");
607 verify_reg_nonexist(hkey
, "MixedQuotes=Asdffdsa");
609 /* Test import with non-standard registry file headers */
610 exec_import_str("REGEDIT3\n\n"
611 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
612 "\"Test1\"=\"Value\"\n");
613 verify_reg_nonexist(hkey
, "Test1");
615 exec_import_str("regedit4\n\n"
616 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
617 "\"Test2\"=\"Value\"\n");
618 verify_reg_nonexist(hkey
, "Test2");
620 exec_import_str("Regedit4\n\n"
621 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
622 "\"Test3\"=\"Value\"\n");
623 verify_reg_nonexist(hkey
, "Test3");
625 exec_import_str("REGEDIT 4\n\n"
626 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
627 "\"Test4\"=\"Value\"\n");
628 verify_reg_nonexist(hkey
, "Test4");
630 exec_import_str("REGEDIT4FOO\n\n"
631 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
632 "\"Test5\"=\"Value\"\n");
633 verify_reg_nonexist(hkey
, "Test5");
635 exec_import_str("REGEDIT4 FOO\n\n"
636 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
637 "\"Test6\"=\"Value\"\n");
638 verify_reg_nonexist(hkey
, "Test6");
640 exec_import_str("REGEDIT5\n\n"
641 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
642 "\"Test7\"=\"Value\"\n");
643 verify_reg_nonexist(hkey
, "Test7");
645 exec_import_str("Windows Registry Editor Version 4.00\n\n"
646 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
647 "\"Test8\"=\"Value\"\n");
648 verify_reg_nonexist(hkey
, "Test8");
650 exec_import_str("Windows Registry Editor Version 5\n\n"
651 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
652 "\"Test9\"=\"Value\"\n");
653 verify_reg_nonexist(hkey
, "Test9");
655 exec_import_str("WINDOWS REGISTRY EDITOR VERSION 5.00\n\n"
656 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
657 "\"Test10\"=\"Value\"\n");
658 verify_reg_nonexist(hkey
, "Test10");
660 exec_import_str("Windows Registry Editor version 5.00\n\n"
661 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
662 "\"Test11\"=\"Value\"\n");
663 verify_reg_nonexist(hkey
, "Test11");
665 /* Test multi-line import with incorrect comma placement */
666 exec_import_str("REGEDIT4\n\n"
667 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
668 "\"Multi-Line1\"=hex(7):4c,69,6e,65,20\\\n"
669 ",63,6f,6e,63,61,74,65,6e,61,74,69,6f,6e,00,00\n\n");
670 verify_reg_nonexist(hkey
, "Multi-Line1");
672 exec_import_str("REGEDIT4\n\n"
673 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
674 "\"Multi-Line2\"=hex(7):4c,69,6e,65,20\\\n"
675 " ,63,6f,6e,63,61,74,65,6e,61,74,69,6f,6e,00,00\n\n");
676 verify_reg_nonexist(hkey
, "Multi-Line2");
678 exec_import_str("Windows Registry Editor Version 5.00\n\n"
679 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
680 "\"Multi-Line3\"=hex(7):4c,69,6e,65,20\\\n"
681 ",63,6f,6e,63,61,74,65,6e,61,74,69,6f,6e,00,00\n\n");
682 verify_reg_nonexist(hkey
, "Multi-Line3");
684 exec_import_str("Windows Registry Editor Version 5.00\n\n"
685 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
686 "\"Multi-Line4\"=hex(7):4c,69,6e,65,20\\\n"
687 " ,63,6f,6e,63,61,74,65,6e,61,74,69,6f,6e,00,00\n\n");
688 verify_reg_nonexist(hkey
, "Multi-Line4");
690 exec_import_str("REGEDIT4\n\n"
691 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
692 "\"Test12a\"=dword:\n"
693 "\"Test12b\"=dword:hello\n"
694 "\"Test12c\"=dword:123456789\n"
695 "\"Test12d\"=dword:012345678\n"
696 "\"Test12e\"=dword:000000001\n\n");
697 verify_reg_nonexist(hkey
, "Test12a");
698 verify_reg_nonexist(hkey
, "Test12b");
699 verify_reg_nonexist(hkey
, "Test12c");
700 verify_reg_nonexist(hkey
, "Test12d");
701 verify_reg_nonexist(hkey
, "Test12e");
703 exec_import_str("REGEDIT4\n\n"
704 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
705 "\"Test13a\"=dword:12345678abc\n"
706 "\"Test13b\"=dword:12345678 abc\n\n");
707 verify_reg_nonexist(hkey
, "Test13a");
708 verify_reg_nonexist(hkey
, "Test13b");
710 exec_import_str("REGEDIT4\n\n"
711 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
712 "\"Test14a\"=dword:0x123\n"
713 "\"Test14b\"=dword:123 456\n"
714 "\"Test14c\"=dword:1234 5678\n\n");
715 verify_reg_nonexist(hkey
, "Test14a");
716 verify_reg_nonexist(hkey
, "Test14b");
717 verify_reg_nonexist(hkey
, "Test14c");
719 exec_import_str("REGEDIT4\n\n"
720 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
721 "\"Test15a\"=\"foo\"bar\"\n"
722 "\"Test15b\"=\"foo\"\"bar\"\n\n");
723 verify_reg_nonexist(hkey
, "Test15a");
724 verify_reg_nonexist(hkey
, "Test15b");
726 exec_import_str("REGEDIT4\n\n"
727 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
730 "\"Test16c\"=\\\"Value\\\"\n"
731 "\"Test16d\"=\\\"Value\"\n\n");
732 verify_reg_nonexist(hkey
, "Test16a");
733 verify_reg_nonexist(hkey
, "Test16b");
734 verify_reg_nonexist(hkey
, "Test16c");
735 verify_reg_nonexist(hkey
, "Test16d");
737 /* Test key name and value name concatenation */
738 exec_import_str("REGEDIT4\n\n"
739 "[HKEY_CURRENT_USER\\" KEY_BASE
"\\\n"
741 verify_key_nonexist(hkey
, "Subkey1");
743 exec_import_str("REGEDIT4\n\n"
744 "[HKEY_CURRENT_USER\\" KEY_BASE
"\n"
746 verify_key_nonexist(hkey
, "Subkey2");
748 exec_import_str("REGEDIT4\n\n"
749 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
751 "17a\"=\"Value 1\"\n"
752 "\"Test17b\"=\"Value 2\"\n"
754 "\\17c\"=\"Value 3\"\n\n");
755 verify_reg_nonexist(hkey
, "Test17a");
756 verify_reg(hkey
, "Test17b", REG_SZ
, "Value 2", 8, 0);
757 verify_reg_nonexist(hkey
, "Test17c");
759 exec_import_str("REGEDIT4\n\n"
760 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
761 "\"Test18a\"=dword:1234\\\n"
763 "\"Test18b\"=\"Test \\\n"
765 verify_reg_nonexist(hkey
, "Test18a");
766 verify_reg_nonexist(hkey
, "Test18b");
768 /* Test hex data concatenation for REG_NONE, REG_EXPAND_SZ and REG_BINARY */
769 exec_import_str("REGEDIT4\n\n"
770 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
771 "\"Test19a\"=hex(0):56,00,61,00,6c,00\\\n"
772 ",75,00,65,00,00,00\n"
773 "\"Test19b\"=hex(0):56,00,61,00,6c,00\\\n"
774 " ,75,00,65,00,00,00\n"
775 "\"Test19c\"=hex(0):56,00,61,00,6c,00\\\n"
776 " 75,00,65,00,00,00\n"
777 "\"Test19d\"=hex(0):56,00,61,00,6c,00,7\\\n"
779 "\"Test19e\"=hex(0):56,00,61,00,6c,00,7\\\n"
780 " 5,00,65,00,00,00\n"
781 "\"Test19f\"=hex(0):56,00,61,00,\\;comment\n"
782 " 6c,00,75,00,\\#comment\n"
784 verify_reg_nonexist(hkey
, "Test19a");
785 verify_reg_nonexist(hkey
, "Test19b");
786 verify_reg_nonexist(hkey
, "Test19c");
787 verify_reg_nonexist(hkey
, "Test19d");
788 verify_reg_nonexist(hkey
, "Test19e");
789 verify_reg_nonexist(hkey
, "Test19f");
791 exec_import_str("REGEDIT4\n\n"
792 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
793 "\"Test20a\"=hex(2):25,50,41\\\n"
795 "\"Test20b\"=hex(2):25,50,41\\\n"
797 "\"Test20c\"=hex(2):25,50,41\\\n"
799 "\"Test20d\"=hex(2):25,50,4\\\n"
801 "\"Test20e\"=hex(2):25,50,4\\\n"
803 "\"Test20f\"=hex(2):25,50,41,\\;comment\n"
804 " 54,48,\\#comment\n"
806 verify_reg_nonexist(hkey
, "Test20a");
807 verify_reg_nonexist(hkey
, "Test20b");
808 verify_reg_nonexist(hkey
, "Test20c");
809 verify_reg_nonexist(hkey
, "Test20d");
810 verify_reg_nonexist(hkey
, "Test20e");
811 verify_reg_nonexist(hkey
, "Test20f");
813 exec_import_str("REGEDIT4\n\n"
814 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
815 "\"Test21a\"=hex:11,22,33,44\\\n"
817 "\"Test21b\"=hex:11,22,33,44\\\n"
819 "\"Test21c\"=hex:11,22,33,44\\\n"
821 "\"Test21d\"=hex:11,22,33,4\\\n"
823 "\"Test21e\"=hex:11,22,33,4\\\n"
825 "\"Test21f\"=hex:11,22,33,\\;comment\n"
826 " 44,55,66,\\#comment\n"
828 verify_reg_nonexist(hkey
, "Test21a");
829 verify_reg_nonexist(hkey
, "Test21b");
830 verify_reg_nonexist(hkey
, "Test21c");
831 verify_reg_nonexist(hkey
, "Test21d");
832 verify_reg_nonexist(hkey
, "Test21e");
833 verify_reg_nonexist(hkey
, "Test21f");
835 /* Test support for characters greater than 0xff */
836 exec_import_str("REGEDIT4\n\n"
837 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
838 "\"Wine22a\"=hex(0):25,50,100,54,48,25,00\n"
839 "\"Wine22b\"=hex(0):25,1a4,100,164,124,25,00\n\n");
840 verify_reg_nonexist(hkey
, "Wine22a");
841 verify_reg_nonexist(hkey
, "Wine22b");
843 /* Test the effect of backslashes in hex data */
844 exec_import_str("REGEDIT4\n\n"
845 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
846 "\"Wine23a\"=hex(2):25,48\\,4f,4d,45,25,00\n"
847 "\"Wine23b\"=hex(2):25,48,\\4f,4d,45,25,00\n"
848 "\"Wine23c\"=hex(2):25,48\\ ,4f,4d,45,25,00\n"
849 "\"Wine23d\"=hex(2):25,48,\\ 4f,4d,45,25,00\n"
850 "\"Wine23e\"=hex(2):\\25,48,4f,4d,45,25,00\n"
851 "\"Wine23f\"=hex(2):\\ 25,48,4f,4d,45,25,00\n"
852 "\"Wine23g\"=hex(2):25,48,4\\f,4d,45,25,00\n"
853 "\"Wine23h\"=hex(2):25,48,4\\\n"
855 "\"Wine23i\"=hex(2):25,50,\\,41,54,48,25,00\n"
856 "\"Wine23j\"=hex(2):25,48,4f,4d,45,25,5c,\\\\\n"
857 " 25,50,41,54,48,25,00\n"
858 "\"Wine23k\"=hex(2):,\\\n"
859 " 25,48,4f,4d,45,25,00\n\n");
860 verify_reg_nonexist(hkey
, "Wine23a");
861 verify_reg_nonexist(hkey
, "Wine23b");
862 verify_reg_nonexist(hkey
, "Wine23c");
863 verify_reg_nonexist(hkey
, "Wine23d");
864 verify_reg_nonexist(hkey
, "Wine23e");
865 verify_reg_nonexist(hkey
, "Wine23f");
866 verify_reg_nonexist(hkey
, "Wine23g");
867 verify_reg_nonexist(hkey
, "Wine23h");
868 verify_reg_nonexist(hkey
, "Wine23i");
869 verify_reg_nonexist(hkey
, "Wine23j");
870 verify_reg_nonexist(hkey
, "Wine23k");
872 exec_import_str("REGEDIT4\n\n"
873 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
874 "\"Wine24a\"=hex(2):4c,69,6e,65,20,\\\n"
875 "[HKEY_CURRENT_USER\\" KEY_BASE
"\\Subkey1]\n");
876 verify_reg_nonexist(hkey
, "Wine24a");
877 verify_key_nonexist(hkey
, "Subkey1");
879 exec_import_str("REGEDIT4\n\n"
880 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
881 "\"Wine24b\"=hex(2):4c,69,6e,65,20\\\n"
882 "[HKEY_CURRENT_USER\\" KEY_BASE
"\\Subkey2]\n");
883 verify_reg_nonexist(hkey
, "Wine24b");
884 verify_key(hkey
, "Subkey2");
886 lr
= RegDeleteKeyA(hkey
, "Subkey2");
887 ok(lr
== ERROR_SUCCESS
, "RegDeleteKey failed: %u\n", lr
);
889 exec_import_str("REGEDIT4\n\n"
890 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
891 "\"Wine25a\"=hex(2):4c,69,6e,65,20,\\\n"
892 "\"Wine25b\"=\"Test value\"\n"
894 "\"Wine25c\"=hex(2):4c,69,6e,65,20,\\\n"
896 "\"Wine25d\"=\"Test value\"\n"
898 "\"Wine25e\"=hex(2):4c,69,6e,65,20,\\\n"
900 "\"Wine25f\"=\"Test value\"\n"
902 "\"Wine25g\"=hex(2):4c,69,6e,65,20,\\\n\n"
903 "\"Wine25h\"=\"Test value\"\n"
905 "\"Wine25i\"=hex(2):4c,69,6e,65,20\\\n"
906 "\"Wine25j\"=\"Test value\"\n\n");
907 verify_reg_nonexist(hkey
, "Wine25a");
908 verify_reg_nonexist(hkey
, "Wine25b");
909 verify_reg_nonexist(hkey
, "Wine25c");
910 verify_reg_nonexist(hkey
, "Wine25d");
911 verify_reg_nonexist(hkey
, "Wine25e");
912 verify_reg(hkey
, "Wine25f", REG_SZ
, "Test value", 11, 0);
913 verify_reg_nonexist(hkey
, "Wine25g");
914 verify_reg_nonexist(hkey
, "Wine25h");
915 verify_reg_nonexist(hkey
, "Wine25i");
916 verify_reg(hkey
, "Wine25j", REG_SZ
, "Test value", 11, 0);
918 exec_import_str("REGEDIT4\n\n"
919 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
920 "\"Wine26a\"=hex(2):4c,69,6e,65,20,\\\n"
921 "\"Wine26b\"=dword:00000008\n"
923 "\"Wine26c\"=hex(2):4c,69,6e,65,20,\\\n"
925 "\"Wine26d\"=dword:00000008\n"
927 "\"Wine26e\"=hex(2):4c,69,6e,65,20,\\\n"
929 "\"Wine26f\"=dword:00000008\n"
931 "\"Wine26g\"=hex(2):4c,69,6e,65,20,\\\n\n"
932 "\"Wine26h\"=dword:00000008\n"
934 "\"Wine26i\"=hex(2):4c,69,6e,65,20\\\n"
935 "\"Wine26j\"=dword:00000008\n\n");
936 verify_reg_nonexist(hkey
, "Wine26a");
937 verify_reg_nonexist(hkey
, "Wine26b");
938 verify_reg_nonexist(hkey
, "Wine26c");
939 verify_reg_nonexist(hkey
, "Wine26d");
940 verify_reg_nonexist(hkey
, "Wine26e");
941 verify_reg(hkey
, "Wine26f", REG_DWORD
, &dword
, sizeof(dword
), 0);
942 verify_reg_nonexist(hkey
, "Wine26g");
943 verify_reg_nonexist(hkey
, "Wine26h");
944 verify_reg_nonexist(hkey
, "Wine26i");
945 verify_reg(hkey
, "Wine26j", REG_DWORD
, &dword
, sizeof(dword
), 0);
947 exec_import_str("REGEDIT4\n\n"
948 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
949 "\"Wine27a\"=hex(2):25,48,4f,4d,45,25,5c,\\\n"
950 "\"Wine27b\"=hex(2):25,50,41,54,48,25,00\n"
952 "\"Wine27c\"=hex(2):25,48,4f,4d,45,25,5c,\\\n"
954 "\"Wine27d\"=hex(2):25,50,41,54,48,25,00\n"
956 "\"Wine27e\"=hex(2):25,48,4f,4d,45,25,5c,\\\n"
958 "\"Wine27f\"=hex(2):25,50,41,54,48,25,00\n"
960 "\"Wine27g\"=hex(2):25,48,4f,4d,45,25,5c,\\\n\n"
961 "\"Wine27h\"=hex(2):25,50,41,54,48,25,00\n"
963 "\"Wine27i\"=hex(2):25,48,4f,4d,45,25,5c\\\n"
964 "\"Wine27j\"=hex(2):25,50,41,54,48,25,00\n\n");
965 verify_reg_nonexist(hkey
, "Wine27a");
966 verify_reg_nonexist(hkey
, "Wine27b");
967 verify_reg_nonexist(hkey
, "Wine27c");
968 verify_reg_nonexist(hkey
, "Wine27d");
969 verify_reg_nonexist(hkey
, "Wine27e");
970 verify_reg(hkey
, "Wine27f", REG_EXPAND_SZ
, "%PATH%", 7, 0);
971 verify_reg_nonexist(hkey
, "Wine27g");
972 verify_reg_nonexist(hkey
, "Wine27h");
973 verify_reg_nonexist(hkey
, "Wine27i");
974 verify_reg(hkey
, "Wine27j", REG_EXPAND_SZ
, "%PATH%", 7, 0);
976 exec_import_str("REGEDIT4\n\n"
977 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
978 "\"Wine28a\"=hex(2):4c,69,6e,65,20,\\\n"
979 "@=\"Default value 1\"\n\n");
980 verify_reg_nonexist(hkey
, "Wine28a");
981 verify_reg_nonexist(hkey
, NULL
);
983 exec_import_str("REGEDIT4\n\n"
984 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
985 "\"Wine28b\"=hex(2):4c,69,6e,65,20,\\\n"
987 "@=\"Default value 2\"\n\n");
988 verify_reg_nonexist(hkey
, "Wine28b");
989 verify_reg_nonexist(hkey
, NULL
);
991 exec_import_str("REGEDIT4\n\n"
992 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
993 "\"Wine28c\"=hex(2):4c,69,6e,65,20,\\\n"
995 "@=\"Default value 3\"\n\n");
996 verify_reg_nonexist(hkey
, "Wine28c");
997 verify_reg(hkey
, NULL
, REG_SZ
, "Default value 3", 16, 0);
999 lr
= RegDeleteValueW(hkey
, NULL
);
1000 ok(lr
== ERROR_SUCCESS
, "RegDeleteValue failed: %u\n", lr
);
1002 exec_import_str("REGEDIT4\n\n"
1003 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
1004 "\"Wine28d\"=hex(2):4c,69,6e,65,20,\\\n\n"
1005 "@=\"Default value 4\"\n\n");
1006 verify_reg_nonexist(hkey
, "Wine28d");
1007 verify_reg_nonexist(hkey
, NULL
);
1009 exec_import_str("REGEDIT4\n\n"
1010 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
1011 "\"Wine28e\"=hex(2):4c,69,6e,65,20\\\n"
1012 "@=\"Default value 5\"\n\n");
1013 verify_reg_nonexist(hkey
, "Wine28e");
1014 verify_reg(hkey
, NULL
, REG_SZ
, "Default value 5", 16, 0);
1016 exec_import_str("REGEDIT4\n\n"
1017 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
1018 "\"Wine29a\"=hex:11,22,33,\\\n"
1021 "\"Wine29b\"=hex:11,22,33,\\\n"
1024 verify_reg_nonexist(hkey
, "Wine29a");
1025 verify_reg_nonexist(hkey
, "Wine29b");
1027 exec_import_str("REGEDIT4\n\n"
1028 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
1029 "\"Wine30a\"=hex(0):25,48,4f,4d,45,25,5c,/\n"
1030 " 25,50,41,54,48,25,00\n"
1031 "\"Wine30b\"=hex(0):25,48,4f,4d,45,25,5c/\n"
1032 " 25,50,41,54,48,25,00\n\n");
1033 verify_reg_nonexist(hkey
, "Wine30a");
1034 verify_reg_nonexist(hkey
, "Wine30b");
1036 exec_import_str("REGEDIT4\n\n"
1037 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
1038 "\"Wine31\"=hex(7):4c,69,6e,65,20\\");
1039 verify_reg_nonexist(hkey
, "Wine31");
1041 exec_import_str("REGEDIT4\n\n"
1042 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
1043 "\"Wine32a\"=hex(7):4c,69,6e,65,20,\\\n"
1044 " ,63,6f,6e,63,61,74,65,6e,61,74,69,6f,6e,00,00\n"
1045 "\"Wine32b\"=hex(7):4c,69,6e,65,20,\\\n"
1046 " 63,,6f,6e,63,61,74,65,6e,61,74,69,6f,6e,00,00\n\n");
1047 verify_reg_nonexist(hkey
, "Wine32a");
1048 verify_reg_nonexist(hkey
, "Wine32b");
1052 lr
= RegDeleteKeyA(HKEY_CURRENT_USER
, KEY_BASE
);
1053 ok(lr
== ERROR_SUCCESS
, "RegDeleteKeyA failed: %d\n", lr
);
1056 static void test_invalid_import_31(void)
1061 lr
= RegCreateKeyExA(HKEY_CLASSES_ROOT
, KEY_BASE
, 0, NULL
, REG_OPTION_NON_VOLATILE
,
1062 KEY_READ
, NULL
, &hkey
, NULL
);
1063 ok(lr
== ERROR_SUCCESS
, "RegCreateKeyExA failed: %d\n", lr
);
1065 /* Test character validity at the start of the line */
1066 exec_import_str("REGEDIT\r\n"
1067 " HKEY_CLASSES_ROOT\\" KEY_BASE
" = Value1a\r\n");
1068 verify_reg_nonexist(hkey
, "");
1070 exec_import_str("REGEDIT\r\n"
1071 " HKEY_CLASSES_ROOT\\" KEY_BASE
" = Value1b\r\n");
1072 verify_reg_nonexist(hkey
, "");
1074 exec_import_str("REGEDIT\r\n"
1075 "\tHKEY_CLASSES_ROOT\\" KEY_BASE
" = Value1c\r\n");
1076 verify_reg_nonexist(hkey
, "");
1078 exec_import_str("REGEDIT\r\n"
1079 ";HKEY_CLASSES_ROOT\\" KEY_BASE
" = Value2a\r\n");
1080 verify_reg_nonexist(hkey
, "");
1082 exec_import_str("REGEDIT\r\n"
1083 "#HKEY_CLASSES_ROOT\\" KEY_BASE
" = Value2b\r\n");
1084 verify_reg_nonexist(hkey
, "");
1086 /* Test case sensitivity */
1087 exec_import_str("REGEDIT\r\n"
1088 "hkey_classes_root\\" KEY_BASE
" = Value3a\r\n");
1089 verify_reg_nonexist(hkey
, "");
1091 exec_import_str("REGEDIT\r\n"
1092 "hKEY_CLASSES_ROOT\\" KEY_BASE
" = Value3b\r\n");
1093 verify_reg_nonexist(hkey
, "");
1095 exec_import_str("REGEDIT\r\n"
1096 "Hkey_Classes_Root\\" KEY_BASE
" = Value3c\r\n");
1097 verify_reg_nonexist(hkey
, "");
1101 lr
= RegDeleteKeyA(HKEY_CLASSES_ROOT
, KEY_BASE
);
1102 ok(lr
== ERROR_SUCCESS
, "RegDeleteKeyA failed: %d\n", lr
);
1105 static void test_comments(void)
1111 lr
= RegDeleteKeyA(HKEY_CURRENT_USER
, KEY_BASE
);
1112 ok(lr
== ERROR_SUCCESS
|| lr
== ERROR_FILE_NOT_FOUND
, "RegDeleteKeyA failed: %d\n", lr
);
1114 exec_import_str("REGEDIT4\n\n"
1115 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
1117 "\"Wine1\"=\"Line 1\"\n"
1119 "\"Wine2\"=\"Line 2\"\n\n");
1120 lr
= RegOpenKeyExA(HKEY_CURRENT_USER
, KEY_BASE
, 0, KEY_READ
, &hkey
);
1121 ok(lr
== ERROR_SUCCESS
, "RegOpenKeyExA failed: %d\n", lr
);
1122 verify_reg(hkey
, "Wine1", REG_SZ
, "Line 1", 7, 0);
1123 verify_reg(hkey
, "Wine2", REG_SZ
, "Line 2", 7, 0);
1125 exec_import_str("REGEDIT4\n\n"
1126 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
1127 "\"Wine3\"=\"Value 1\"#comment\n"
1128 "\"Wine4\"=\"Value 2\";comment\n"
1129 "\"Wine5\"=dword:01020304 #comment\n"
1130 "\"Wine6\"=dword:02040608 ;comment\n\n");
1131 verify_reg_nonexist(hkey
, "Wine3");
1132 verify_reg(hkey
, "Wine4", REG_SZ
, "Value 2", 8, 0);
1133 verify_reg_nonexist(hkey
, "Wine5");
1135 verify_reg(hkey
, "Wine6", REG_DWORD
, &dword
, sizeof(dword
), 0);
1137 exec_import_str("REGEDIT4\n\n"
1138 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
1139 "\"Wine7\"=hex(7):4c,69,6e,65,20,\\\n"
1141 " 63,6f,6e,63,61,74,65,6e,61,74,69,6f,6e,00,00\n"
1142 "\"Wine8\"=\"A valid line\"\n"
1143 "\"Wine9\"=hex(7):4c,69,6e,65,20,\\\n"
1145 " 63,6f,6e,63,61,74,65,6e,61,74,69,6f,6e,00,00\n"
1146 "\"Wine10\"=\"Another valid line\"\n\n");
1147 verify_reg_nonexist(hkey
, "Wine7");
1148 verify_reg(hkey
, "Wine8", REG_SZ
, "A valid line", 13, 0);
1149 verify_reg(hkey
, "Wine9", REG_MULTI_SZ
, "Line concatenation\0", 20, 0);
1150 verify_reg(hkey
, "Wine10", REG_SZ
, "Another valid line", 19, 0);
1152 exec_import_str("REGEDIT4\n\n"
1153 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
1154 "#\"Comment1\"=\"Value 1\"\n"
1155 ";\"Comment2\"=\"Value 2\"\n"
1156 " #\"Comment3\"=\"Value 3\"\n"
1157 " ;\"Comment4\"=\"Value 4\"\n"
1158 "\"Wine11\"=\"Value 6\"#\"Comment5\"=\"Value 5\"\n"
1159 "\"Wine12\"=\"Value 7\";\"Comment6\"=\"Value 6\"\n\n");
1160 verify_reg_nonexist(hkey
, "Comment1");
1161 verify_reg_nonexist(hkey
, "Comment2");
1162 verify_reg_nonexist(hkey
, "Comment3");
1163 verify_reg_nonexist(hkey
, "Comment4");
1164 verify_reg_nonexist(hkey
, "Wine11");
1165 verify_reg_nonexist(hkey
, "Comment5");
1166 verify_reg(hkey
, "Wine12", REG_SZ
, "Value 7", 8, 0);
1167 verify_reg_nonexist(hkey
, "Comment6");
1169 exec_import_str("REGEDIT4\n\n"
1170 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
1171 "\"Wine13\"=#\"Value 8\"\n"
1172 "\"Wine14\"=;\"Value 9\"\n"
1173 "\"Wine15\"=\"#comment1\"\n"
1174 "\"Wine16\"=\";comment2\"\n"
1175 "\"Wine17\"=\"Value#comment3\"\n"
1176 "\"Wine18\"=\"Value;comment4\"\n"
1177 "\"Wine19\"=\"Value #comment5\"\n"
1178 "\"Wine20\"=\"Value ;comment6\"\n"
1179 "\"Wine21\"=#dword:00000001\n"
1180 "\"Wine22\"=;dword:00000002\n"
1181 "\"Wine23\"=dword:00000003#comment\n"
1182 "\"Wine24\"=dword:00000004;comment\n\n");
1183 verify_reg_nonexist(hkey
, "Wine13");
1184 verify_reg_nonexist(hkey
, "Wine14");
1185 verify_reg(hkey
, "Wine15", REG_SZ
, "#comment1", 10, 0);
1186 verify_reg(hkey
, "Wine16", REG_SZ
, ";comment2", 10, 0);
1187 verify_reg(hkey
, "Wine17", REG_SZ
, "Value#comment3", 15, 0);
1188 verify_reg(hkey
, "Wine18", REG_SZ
, "Value;comment4", 15, 0);
1189 verify_reg(hkey
, "Wine19", REG_SZ
, "Value #comment5", 16, 0);
1190 verify_reg(hkey
, "Wine20", REG_SZ
, "Value ;comment6", 16, 0);
1191 verify_reg_nonexist(hkey
, "Wine21");
1192 verify_reg_nonexist(hkey
, "Wine22");
1193 verify_reg_nonexist(hkey
, "Wine23");
1195 verify_reg(hkey
, "Wine24", REG_DWORD
, &dword
, sizeof(dword
), 0);
1197 exec_import_str("REGEDIT4\n\n"
1198 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
1199 "\"Wine25a\"=dword:1234;5678\n"
1200 "\"Wine25b\"=dword:1234 ;5678\n"
1201 "\"Wine25c\"=dword:1234#5678\n"
1202 "\"Wine25d\"=dword:1234 #5678\n\n");
1204 verify_reg(hkey
, "Wine25a", REG_DWORD
, &dword
, sizeof(dword
), 0);
1205 verify_reg(hkey
, "Wine25b", REG_DWORD
, &dword
, sizeof(dword
), 0);
1206 verify_reg_nonexist(hkey
, "Wine25c");
1207 verify_reg_nonexist(hkey
, "Wine25d");
1209 exec_import_str("REGEDIT4\n\n"
1210 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
1211 "\"Wine26a\"=\"Value1\" ;comment\n"
1212 "\"Wine26b\"=\"Value2\"\t\t;comment\n"
1213 "\"Wine26c\"=\"Value3\" #comment\n"
1214 "\"Wine26d\"=\"Value4\"\t\t#comment\n\n");
1215 verify_reg(hkey
, "Wine26a", REG_SZ
, "Value1", 7, 0);
1216 verify_reg(hkey
, "Wine26b", REG_SZ
, "Value2", 7, 0);
1217 verify_reg_nonexist(hkey
, "Wine26c");
1218 verify_reg_nonexist(hkey
, "Wine26d");
1220 exec_import_str("REGEDIT4\n\n"
1221 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
1222 "\"Multi-Line1\"=hex(7):4c,69,6e,65,20,\\\n"
1223 " 63,6f,6e,\\;comment\n"
1224 " 63,61,74,\\;comment\n"
1225 " 65,6e,61,74,69,6f,6e,00,00\n\n");
1226 verify_reg(hkey
, "Multi-Line1", REG_MULTI_SZ
, "Line concatenation\0", 20, 0);
1228 exec_import_str("REGEDIT4\n\n"
1229 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
1230 "\"Multi-Line2\"=hex(7):4c,69,6e,65,20,\\\n"
1231 " 63,6f,6e,\\;comment\n"
1232 " 63,61,74,;comment\n"
1233 " 65,6e,61,74,69,6f,6e,00,00\n\n");
1234 todo_wine
verify_reg(hkey
, "Multi-Line2", REG_MULTI_SZ
, "Line concat", 12, 0);
1236 exec_import_str("REGEDIT4\n\n"
1237 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
1238 "\"Multi-Line3\"=hex(7):4c,69,6e,\\;comment\n"
1239 " 65,20,\\;comment\n"
1240 " 63,6f,6e,\\;comment\n"
1241 " 63,61,74,\\;comment\n"
1242 " 65,6e,61,74,69,6f,6e,00,00\n\n");
1243 verify_reg(hkey
, "Multi-Line3", REG_MULTI_SZ
, "Line concatenation\0", 20, 0);
1245 exec_import_str("REGEDIT4\n\n"
1246 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
1247 "\"Multi-Line4\"=hex(7):4c,69,6e,\\;#comment\n"
1248 " 65,20,\\;#comment\n"
1249 " 63,6f,6e,\\;#comment\n"
1250 " 63,61,74,\\;#comment\n"
1251 " 65,6e,61,74,69,6f,6e,00,00\n\n");
1252 verify_reg(hkey
, "Multi-Line4", REG_MULTI_SZ
, "Line concatenation\0", 20, 0);
1254 exec_import_str("REGEDIT4\n\n"
1255 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
1256 "\"Multi-Line5\"=hex(7):4c,69,6e,\\;comment\n"
1257 " 65,20,\\;comment\n"
1258 " 63,6f,6e,\\;comment\n"
1259 " 63,61,74,\\#comment\n"
1260 " 65,6e,61,74,69,6f,6e,00,00\n\n");
1261 verify_reg_nonexist(hkey
, "Multi-Line5");
1263 exec_import_str("REGEDIT4\n\n"
1264 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
1265 "\"Multi-Line6\"=hex(7):4c,69,6e,65,20,\\\n"
1266 " 63,6f,6e,\\;comment\n"
1268 " 65,6e,\\;comment\n\n"
1269 " 61,74,69,6f,6e,00,00\n\n");
1270 verify_reg(hkey
, "Multi-Line6", REG_MULTI_SZ
, "Line concatenation\0", 20, 0);
1272 exec_import_str("REGEDIT4\n\n"
1273 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
1274 "\"Wine27a\"=hex(2):25,50,41,54,48,25,00 ;comment\n"
1275 "\"Wine27b\"=hex(2):25,50,41,54,48,25,00\t;comment\n"
1276 "\"Wine27c\"=hex(2):25,50,41,54,48,25,00 #comment\n"
1277 "\"Wine27d\"=hex(2):25,50,41,54,48,25,00\t#comment\n\n");
1278 verify_reg(hkey
, "Wine27a", REG_EXPAND_SZ
, "%PATH%", 7, 0);
1279 verify_reg(hkey
, "Wine27b", REG_EXPAND_SZ
, "%PATH%", 7, 0);
1280 verify_reg_nonexist(hkey
, "Wine27c");
1281 verify_reg_nonexist(hkey
, "Wine27d");
1283 exec_import_str("REGEDIT4\n\n"
1284 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
1285 "\"Wine28a\"=hex(2):25,48,4f,4d,45,25,5c,\\\n"
1286 " 25,50,41,54,48,25,00\n"
1287 "\"Wine28b\"=hex(2):25,48,4f,4d,45,25,5c\\\n"
1288 " 25,50,41,54,48,25,00\n"
1289 "\"Wine28c\"=hex(2):25,48,4f,4d,45,25,5c, \\ ;comment\n"
1290 " 25,50,41,54,48,25,00\n"
1291 "\"Wine28d\"=hex(2):25,48,4f,4d,45,25,5c \\ ;comment\n"
1292 " 25,50,41,54,48,25,00\n"
1293 "\"Wine28e\"=hex(2):25,48,4f,4d,45,25,5c,\\\t ;comment\n"
1294 " 25,50,41,54,48,25,00\n"
1295 "\"Wine28f\"=hex(2):25,48,4f,4d,45,25,5c\\\t ;comment\n"
1296 " 25,50,41,54,48,25,00\n\n");
1297 verify_reg(hkey
, "Wine28a", REG_EXPAND_SZ
, "%HOME%\\%PATH%", 14, 0);
1298 verify_reg_nonexist(hkey
, "Wine28b");
1299 verify_reg(hkey
, "Wine28c", REG_EXPAND_SZ
, "%HOME%\\%PATH%", 14, 0);
1300 verify_reg_nonexist(hkey
, "Wine28d");
1301 verify_reg(hkey
, "Wine28e", REG_EXPAND_SZ
, "%HOME%\\%PATH%", 14, 0);
1302 verify_reg_nonexist(hkey
, "Wine28f");
1304 exec_import_str("REGEDIT4\n\n"
1305 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
1306 "\"Wine29a\"=hex(7):4c,69,6e,65,20,\\\n"
1307 " 63,6f,6e,63,61,74,\\\n"
1309 " 65,6e,\\;comment\n"
1310 " 61,74,69,6f,6e,00,00\n\n");
1311 verify_reg(hkey
, "Wine29a", REG_MULTI_SZ
, "Line concatenation\0", 20, 0);
1313 exec_import_str("REGEDIT4\n\n"
1314 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
1315 "\"Wine29b\"=hex(7):4c,69,6e,65,20,\\\n"
1316 " 63,6f,6e,63,61,74,\\\n"
1318 " 65,6e,\\;comment\n"
1319 " 61,74,69,6f,6e,00,00\n\n");
1320 verify_reg(hkey
, "Wine29b", REG_MULTI_SZ
, "Line concatenation\0", 20, 0);
1322 exec_import_str("REGEDIT4\n\n"
1323 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
1324 "\"Wine29c\"=hex(7):4c,69,6e,65,20,\\\n"
1325 " 63,6f,6e,63,61,74,\\\n"
1327 " 65,6e,\\;comment\n"
1328 " 61,74,69,6f,6e,00,00\n\n");
1329 verify_reg_nonexist(hkey
, "Wine29c");
1331 exec_import_str("REGEDIT4\n\n"
1332 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
1333 "\"Wine29d\"=hex(7):4c,69,6e,65,20,\\\n"
1334 " 63,6f,6e,63,61,74,\\\n"
1336 " 65,6e,\\;comment\n"
1337 " 61,74,69,6f,6e,00,00\n\n");
1338 verify_reg_nonexist(hkey
, "Wine29d");
1342 lr
= RegDeleteKeyA(HKEY_CURRENT_USER
, KEY_BASE
);
1343 ok(lr
== ERROR_SUCCESS
, "RegDeleteKeyA failed: %d\n", lr
);
1346 static void test_import_with_whitespace(void)
1352 exec_import_str(" REGEDIT4\n\n"
1353 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n\n");
1355 lr
= RegOpenKeyExA(HKEY_CURRENT_USER
, KEY_BASE
, 0, KEY_READ
, &hkey
);
1356 ok(lr
== ERROR_SUCCESS
, "RegOpenKeyExA failed: got %d, expected 0\n", lr
);
1358 exec_import_str(" REGEDIT4\n\n"
1359 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
1360 "\"Wine1a\"=\"Value\"\n\n");
1361 verify_reg(hkey
, "Wine1a", REG_SZ
, "Value", 6, 0);
1363 exec_import_str("\tREGEDIT4\n\n"
1364 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
1365 "\"Wine1b\"=\"Value\"\n\n");
1366 verify_reg(hkey
, "Wine1b", REG_SZ
, "Value", 6, 0);
1368 exec_import_str(" \t REGEDIT4\n\n"
1369 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
1370 "\"Wine1c\"=\"Value\"\n\n");
1371 verify_reg(hkey
, "Wine1c", REG_SZ
, "Value", 6, 0);
1373 exec_import_str("REGEDIT4\n\n"
1374 " [HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
1375 "\"Wine2a\"=\"Value\"\n\n");
1376 verify_reg(hkey
, "Wine2a", REG_SZ
, "Value", 6, 0);
1378 exec_import_str("REGEDIT4\n\n"
1379 "\t[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
1380 "\"Wine2b\"=\"Value\"\n\n");
1381 verify_reg(hkey
, "Wine2b", REG_SZ
, "Value", 6, 0);
1383 exec_import_str("REGEDIT4\n\n"
1384 " \t [HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
1385 "\"Wine2c\"=\"Value\"\n\n");
1386 verify_reg(hkey
, "Wine2c", REG_SZ
, "Value", 6, 0);
1388 exec_import_str("REGEDIT4\n\n"
1389 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
1390 " \"Wine3a\"=\"Two leading spaces\"\n\n");
1391 verify_reg(hkey
, "Wine3a", REG_SZ
, "Two leading spaces", 19, 0);
1393 exec_import_str("REGEDIT4\n\n"
1394 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
1395 "\t\"Wine3b\"=\"One leading tab\"\n\n");
1396 verify_reg(hkey
, "Wine3b", REG_SZ
, "One leading tab", 16, 0);
1398 exec_import_str("REGEDIT4\n\n"
1399 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
1400 " \t \"Wine3c\"=\"Space, tab, space\"\n\n");
1401 verify_reg(hkey
, "Wine3c", REG_SZ
, "Space, tab, space", 18, 0);
1403 exec_import_str(" REGEDIT4\n\n"
1404 "\t\t\t[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
1405 "\t \"Wine4a\"=\"Tab and four spaces\"\n"
1406 " \"Wine4b\"=dword:00112233\n"
1407 "\t \t \t \t \t \t \"Wine4c\"=hex(7):4c,69,6e,65,20,\\\n"
1408 " 63,6f,6e,\\;comment\n"
1409 "\t\t\t\t63,61,74,\\;comment\n"
1410 " \t65,6e,61,74,69,6f,6e,00,00\n\n");
1411 verify_reg(hkey
, "Wine4a", REG_SZ
, "Tab and four spaces", 20, 0);
1413 verify_reg(hkey
, "Wine4b", REG_DWORD
, &dword
, sizeof(dword
), 0);
1414 verify_reg(hkey
, "Wine4c", REG_MULTI_SZ
, "Line concatenation\0", 20, 0);
1416 exec_import_str(" REGEDIT4\n\n"
1417 "\t[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
1418 " \"Wine5a\"=\"Leading spaces\"\n"
1419 "\t\t\"Wine5b\"\t\t=\"Leading tabs\"\n"
1420 "\t \"Wine5c\"=\t \"Tabs and spaces\"\n"
1421 " \"Wine5d\" \t = \t \"More whitespace\"\n\n");
1422 verify_reg(hkey
, "Wine5a", REG_SZ
, "Leading spaces", 15, 0);
1423 verify_reg(hkey
, "Wine5b", REG_SZ
, "Leading tabs", 13, 0);
1424 verify_reg(hkey
, "Wine5c", REG_SZ
, "Tabs and spaces", 16, 0);
1425 verify_reg(hkey
, "Wine5d", REG_SZ
, "More whitespace", 16, 0);
1427 exec_import_str("REGEDIT4\n\n"
1428 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
1429 "\" Wine6a\"=\"Leading spaces\"\n"
1430 "\"\t\tWine6b\"=\"Leading tabs\"\n"
1431 " \" Wine6c \" = \" Spaces everywhere \" \n\n");
1432 verify_reg(hkey
, " Wine6a", REG_SZ
, "Leading spaces", 15, 0);
1433 verify_reg(hkey
, "\t\tWine6b", REG_SZ
, "Leading tabs", 13, 0);
1434 verify_reg(hkey
, " Wine6c ", REG_SZ
, " Spaces everywhere ", 22, 0);
1436 exec_import_str("REGEDIT4\n\n"
1437 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
1438 "\"Wine7a\"=\" Four spaces in the data\"\n"
1439 "\"Wine7b\"=\"\t\tTwo tabs in the data\"\n\n");
1440 verify_reg(hkey
, "Wine7a", REG_SZ
, " Four spaces in the data", 28, 0);
1441 verify_reg(hkey
, "Wine7b", REG_SZ
, "\t\tTwo tabs in the data", 23, 0);
1443 exec_import_str("REGEDIT4\n\n"
1444 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
1445 "\"Wine8a\"=\"Trailing spaces\" \n"
1446 "\"Wine8b\"=\"Trailing tabs and spaces\"\t \t\n\n");
1447 verify_reg(hkey
, "Wine8a", REG_SZ
, "Trailing spaces", 16, 0);
1448 verify_reg(hkey
, "Wine8b", REG_SZ
, "Trailing tabs and spaces", 25, 0);
1450 exec_import_str("REGEDIT4\n\n"
1451 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
1452 "\"Wine9a\"=dword: 00000008\n"
1453 "\"Wine9b\"=dword:\t\t00000008\n\n");
1455 verify_reg(hkey
, "Wine9a", REG_DWORD
, &dword
, sizeof(dword
), 0);
1456 verify_reg(hkey
, "Wine9b", REG_DWORD
, &dword
, sizeof(dword
), 0);
1458 exec_import_str("REGEDIT4\n\n"
1459 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
1460 "@ = \"Test Value\"\n\n");
1461 verify_reg(hkey
, "", REG_SZ
, "Test Value", 11, 0);
1463 exec_import_str("REGEDIT4\n\n"
1464 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
1465 "\t@\t=\tdword:\t00000008\t\n\n");
1466 verify_reg(hkey
, "", REG_DWORD
, &dword
, sizeof(DWORD
), 0);
1468 exec_import_str("REGEDIT4\n\n"
1469 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
1470 "\"Wine10a\"=hex(7):4c,69,6e,65,20,\\\n"
1472 " 63,61,74,\\\n\n\n"
1474 " 61,74,69,6f,6e,00,00\n\n");
1475 verify_reg(hkey
, "Wine10a", REG_MULTI_SZ
, "Line concatenation\0", 20, 0);
1477 exec_import_str("REGEDIT4\n\n"
1478 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
1479 "\"Wine10b\"=hex(7):4c,69,6e,65,20,\\\n"
1481 " 63,61,74,\\\n\t\n\t\n"
1482 " 65,6e,\\\n\t \t\n\t \t\n\t \t\n"
1483 " 61,74,69,6f,6e,00,00\n\n");
1484 verify_reg(hkey
, "Wine10b", REG_MULTI_SZ
, "Line concatenation\0", 20, 0);
1486 lr
= RegCloseKey(hkey
);
1487 ok(lr
== ERROR_SUCCESS
, "RegCloseKey failed: got %d, expected 0\n", lr
);
1489 lr
= RegDeleteKeyA(HKEY_CURRENT_USER
, KEY_BASE
);
1490 ok(lr
== ERROR_SUCCESS
, "RegDeleteKeyA failed: got %d, expected 0\n", lr
);
1493 static void test_key_creation_and_deletion(void)
1498 exec_import_str("REGEDIT4\n\n"
1499 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n\n");
1501 lr
= RegOpenKeyExA(HKEY_CURRENT_USER
, KEY_BASE
, 0, KEY_READ
, &hkey
);
1502 ok(lr
== ERROR_SUCCESS
, "RegOpenKeyExA failed: got %d, expected 0\n", lr
);
1504 /* Test key creation */
1505 exec_import_str("REGEDIT4\n\n"
1506 "HKEY_CURRENT_USER\\" KEY_BASE
"\\No_Opening_Bracket]\n");
1507 verify_key_nonexist(hkey
, "No_Opening_Bracket");
1509 exec_import_str("REGEDIT4\n\n"
1510 "[HKEY_CURRENT_USER\\" KEY_BASE
"\\No_Closing_Bracket\n");
1511 verify_key_nonexist(hkey
, "No_Closing_Bracket");
1513 exec_import_str("REGEDIT4\n\n"
1514 "[ HKEY_CURRENT_USER\\" KEY_BASE
"\\Subkey1a]\n");
1515 verify_key_nonexist(hkey
, "Subkey1a");
1517 exec_import_str("REGEDIT4\n\n"
1518 "[\tHKEY_CURRENT_USER\\" KEY_BASE
"\\Subkey1b]\n");
1519 verify_key_nonexist(hkey
, "Subkey1b");
1521 exec_import_str("REGEDIT4\n\n"
1522 "[HKEY_CURRENT_USER\\" KEY_BASE
"\\Subkey1c ]\n");
1523 verify_key(hkey
, "Subkey1c ");
1524 lr
= RegDeleteKeyA(hkey
, "Subkey1c ");
1525 ok(lr
== ERROR_SUCCESS
, "got %d, expected 0\n", lr
);
1527 exec_import_str("REGEDIT4\n\n"
1528 "[HKEY_CURRENT_USER\\" KEY_BASE
"\\Subkey1d\t]\n");
1529 verify_key(hkey
, "Subkey1d\t");
1530 lr
= RegDeleteKeyA(hkey
, "Subkey1d\t");
1531 ok(lr
== ERROR_SUCCESS
, "got %d, expected 0\n", lr
);
1533 exec_import_str("REGEDIT4\n\n"
1534 "[HKEY_CURRENT_USER\\" KEY_BASE
"\\Subkey1e\\]\n"
1535 "\"Wine\"=\"Test value\"\n\n");
1536 verify_key(hkey
, "Subkey1e\\");
1537 verify_key(hkey
, "Subkey1e");
1538 lr
= RegOpenKeyExA(hkey
, "Subkey1e", 0, KEY_READ
, &subkey
);
1539 ok(lr
== ERROR_SUCCESS
, "RegOpenKeyExA failed: got %u, expected 0\n", lr
);
1540 verify_reg(subkey
, "Wine", REG_SZ
, "Test value", 11, 0);
1541 RegCloseKey(subkey
);
1542 lr
= RegDeleteKeyA(hkey
, "Subkey1e");
1543 ok(lr
== ERROR_SUCCESS
, "RegDeleteKeyA failed: got %u, expected 0\n", lr
);
1545 exec_import_str("REGEDIT4\n\n"
1546 "[HKEY_CURRENT_USER\\" KEY_BASE
"\\Subkey1f\\\\]\n"
1547 "\"Wine\"=\"Test value\"\n\n");
1548 verify_key(hkey
, "Subkey1f\\\\");
1549 verify_key(hkey
, "Subkey1f\\");
1550 verify_key(hkey
, "Subkey1f");
1551 lr
= RegOpenKeyExA(hkey
, "Subkey1f\\\\", 0, KEY_READ
, &subkey
);
1552 ok(lr
== ERROR_SUCCESS
, "RegOpenKeyExA failed: got %u, expected 0\n", lr
);
1553 verify_reg(subkey
, "Wine", REG_SZ
, "Test value", 11, 0);
1554 RegCloseKey(subkey
);
1555 lr
= RegDeleteKeyA(hkey
, "Subkey1f\\\\");
1556 ok(lr
== ERROR_SUCCESS
, "RegDeleteKeyA failed: got %u, expected 0\n", lr
);
1558 exec_import_str("REGEDIT4\n\n"
1559 "[HKEY_CURRENT_USER\\" KEY_BASE
"\\Subkey1g\\\\\\\\]\n"
1560 "\"Wine\"=\"Test value\"\n\n");
1561 verify_key(hkey
, "Subkey1g\\\\\\\\");
1562 verify_key(hkey
, "Subkey1g\\\\");
1563 verify_key(hkey
, "Subkey1g\\");
1564 verify_key(hkey
, "Subkey1g");
1565 lr
= RegOpenKeyExA(hkey
, "Subkey1g\\\\", 0, KEY_READ
, &subkey
);
1566 ok(lr
== ERROR_SUCCESS
, "RegOpenKeyExA failed: got %u, expected 0\n", lr
);
1567 verify_reg(subkey
, "Wine", REG_SZ
, "Test value", 11, 0);
1568 RegCloseKey(subkey
);
1569 lr
= RegDeleteKeyA(hkey
, "Subkey1g\\\\");
1570 ok(lr
== ERROR_SUCCESS
, "RegDeleteKeyA failed: got %u, expected 0\n", lr
);
1572 /* Test key deletion. We start by creating some registry keys. */
1573 exec_import_str("REGEDIT4\n\n"
1574 "[HKEY_CURRENT_USER\\" KEY_BASE
"\\Subkey2a]\n\n"
1575 "[HKEY_CURRENT_USER\\" KEY_BASE
"\\Subkey2b]\n\n");
1576 verify_key(hkey
, "Subkey2a");
1577 verify_key(hkey
, "Subkey2b");
1579 exec_import_str("REGEDIT4\n\n"
1580 "[ -HKEY_CURRENT_USER\\" KEY_BASE
"\\Subkey2a]\n");
1581 verify_key(hkey
, "Subkey2a");
1583 exec_import_str("REGEDIT4\n\n"
1584 "[\t-HKEY_CURRENT_USER\\" KEY_BASE
"\\Subkey2b]\n");
1585 verify_key(hkey
, "Subkey2b");
1587 exec_import_str("REGEDIT4\n\n"
1588 "[- HKEY_CURRENT_USER\\" KEY_BASE
"\\Subkey2a]\n");
1589 verify_key(hkey
, "Subkey2a");
1591 exec_import_str("REGEDIT4\n\n"
1592 "[-\tHKEY_CURRENT_USER\\" KEY_BASE
"\\Subkey2b]\n");
1593 verify_key(hkey
, "Subkey2b");
1595 exec_import_str("REGEDIT4\n\n"
1596 "[-HKEY_CURRENT_USER\\" KEY_BASE
"\\Subkey2a]\n\n"
1597 "[-HKEY_CURRENT_USER\\" KEY_BASE
"\\Subkey2b]\n\n");
1598 verify_key_nonexist(hkey
, "Subkey2a");
1599 verify_key_nonexist(hkey
, "Subkey2b");
1601 /* Test case sensitivity when creating and deleting registry keys. */
1602 exec_import_str("REGEDIT4\n\n"
1603 "[hkey_CURRENT_user\\" KEY_BASE
"\\Subkey3a]\n\n"
1604 "[HkEy_CuRrEnT_uSeR\\" KEY_BASE
"\\SuBkEy3b]\n\n");
1605 verify_key(hkey
, "Subkey3a");
1606 verify_key(hkey
, "Subkey3b");
1608 exec_import_str("REGEDIT4\n\n"
1609 "[-HKEY_current_USER\\" KEY_BASE
"\\sUBKEY3A]\n\n"
1610 "[-hKeY_cUrReNt_UsEr\\" KEY_BASE
"\\sUbKeY3B]\n\n");
1611 verify_key_nonexist(hkey
, "Subkey3a");
1612 verify_key_nonexist(hkey
, "Subkey3b");
1614 lr
= RegCloseKey(hkey
);
1615 ok(lr
== ERROR_SUCCESS
, "RegCloseKey failed: got %d, expected 0\n", lr
);
1617 lr
= RegDeleteKeyA(HKEY_CURRENT_USER
, KEY_BASE
);
1618 ok(lr
== ERROR_SUCCESS
, "RegDeleteKeyA failed: got %d, expected 0\n", lr
);
1621 static void test_value_deletion(void)
1626 BYTE hex
[4] = {0x11, 0x22, 0x33, 0x44};
1628 exec_import_str("REGEDIT4\n\n"
1629 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n\n");
1631 lr
= RegOpenKeyExA(HKEY_CURRENT_USER
, KEY_BASE
, 0, KEY_READ
, &hkey
);
1632 ok(lr
== ERROR_SUCCESS
, "RegOpenKeyExA failed: got %d, expected 0\n", lr
);
1634 /* Test value deletion. We start by creating some registry values. */
1635 exec_import_str("REGEDIT4\n\n"
1636 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
1637 "\"Wine46a\"=\"Test Value\"\n"
1638 "\"Wine46b\"=dword:00000008\n"
1639 "\"Wine46c\"=hex:11,22,33,44\n"
1640 "\"Wine46d\"=hex(7):4c,69,6e,65,20,\\\n"
1641 " 63,6f,6e,63,61,74,65,6e,61,74,69,6f,6e,00,00\n"
1642 "\"Wine46e\"=hex(2):25,50,41,54,48,25,00\n"
1643 "\"Wine46f\"=hex(0):56,00,61,00,6c,00,75,00,65,00,00,00\n\n");
1644 verify_reg(hkey
, "Wine46a", REG_SZ
, "Test Value", 11, 0);
1645 verify_reg(hkey
, "Wine46b", REG_DWORD
, &dword
, sizeof(dword
), 0);
1646 verify_reg(hkey
, "Wine46c", REG_BINARY
, hex
, 4, 0);
1647 verify_reg(hkey
, "Wine46d", REG_MULTI_SZ
, "Line concatenation\0", 20, 0);
1648 verify_reg(hkey
, "Wine46e", REG_EXPAND_SZ
, "%PATH%", 7, 0);
1649 verify_reg(hkey
, "Wine46f", REG_NONE
, "V\0a\0l\0u\0e\0\0", 12, 0);
1651 exec_import_str("REGEDIT4\n\n"
1652 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
1655 "\"Wine46c\"= \t-\t \n"
1656 "\"Wine46d\"=-\"Test\"\n"
1657 "\"Wine46e\"=- ;comment\n"
1658 "\"Wine46f\"=- #comment\n\n");
1659 verify_reg_nonexist(hkey
, "Wine46a");
1660 verify_reg_nonexist(hkey
, "Wine46b");
1661 verify_reg_nonexist(hkey
, "Wine46c");
1662 verify_reg(hkey
, "Wine46d", REG_MULTI_SZ
, "Line concatenation\0", 20, 0);
1663 verify_reg_nonexist(hkey
, "Wine46e");
1664 verify_reg(hkey
, "Wine46f", REG_NONE
, "V\0a\0l\0u\0e\0\0", 12, 0);
1666 lr
= RegCloseKey(hkey
);
1667 ok(lr
== ERROR_SUCCESS
, "RegCloseKey failed: got %d, expected 0\n", lr
);
1669 lr
= RegDeleteKeyA(HKEY_CURRENT_USER
, KEY_BASE
);
1670 ok(lr
== ERROR_SUCCESS
, "RegDeleteKeyA failed: got %d, expected 0\n", lr
);
1675 WCHAR wchar_test
[] = {0xFEFF,'W','i','n','d','o','w','s',' ','R','e','g',
1676 'i','s','t','r','y',' ','E','d','i','t','o','r',' ','V','e','r','s',
1677 'i','o','n',' ','5','.','0','0','\n','\n',0};
1679 if(!exec_import_str("REGEDIT4\r\n\r\n")){
1680 win_skip("regedit not available, skipping regedit tests\n");
1684 supports_wchar
= exec_import_wstr(wchar_test
);
1686 test_basic_import();
1687 test_basic_import_31();
1688 test_invalid_import();
1689 test_invalid_import_31();
1691 test_import_with_whitespace();
1692 test_key_creation_and_deletion();
1693 test_value_deletion();