[REG_WINETEST] Sync with Wine Staging 2.2. CORE-12823
[reactos.git] / rostests / winetests / reg / reg.c
1 /*
2 * Copyright 2014 Akihiro Sagawa
3 *
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.
8 *
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.
13 *
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
17 */
18
19 #include <stdio.h>
20
21 #include <wine/test.h>
22 #include <winnls.h>
23 #include <winreg.h>
24
25 #define lok ok_(__FILE__,line)
26 #define KEY_BASE "Software\\Wine\\reg_test"
27 #define REG_EXIT_SUCCESS 0
28 #define REG_EXIT_FAILURE 1
29 #define TODO_REG_TYPE (0x0001u)
30 #define TODO_REG_SIZE (0x0002u)
31 #define TODO_REG_DATA (0x0004u)
32
33 #define run_reg_exe(c,r) run_reg_exe_(__LINE__,c,r)
34 static BOOL run_reg_exe_(unsigned line, const char *cmd, DWORD *rc)
35 {
36 STARTUPINFOA si = {sizeof(STARTUPINFOA)};
37 PROCESS_INFORMATION pi;
38 BOOL bret;
39 DWORD ret;
40 char cmdline[256];
41
42 si.dwFlags = STARTF_USESTDHANDLES;
43 si.hStdInput = INVALID_HANDLE_VALUE;
44 si.hStdOutput = INVALID_HANDLE_VALUE;
45 si.hStdError = INVALID_HANDLE_VALUE;
46
47 strcpy(cmdline, cmd);
48 if (!CreateProcessA(NULL, cmdline, NULL, NULL, TRUE, 0, NULL, NULL, &si, &pi))
49 return FALSE;
50
51 ret = WaitForSingleObject(pi.hProcess, 10000);
52 if (ret == WAIT_TIMEOUT)
53 TerminateProcess(pi.hProcess, 1);
54
55 bret = GetExitCodeProcess(pi.hProcess, rc);
56 lok(bret, "GetExitCodeProcess failed: %d\n", GetLastError());
57
58 CloseHandle(pi.hThread);
59 CloseHandle(pi.hProcess);
60 return bret;
61 }
62
63 #define verify_reg(k,v,t,d,s,todo) verify_reg_(__LINE__,k,v,t,d,s,todo)
64 static void verify_reg_(unsigned line, HKEY hkey, const char* value,
65 DWORD exp_type, const void *exp_data, DWORD exp_size, DWORD todo)
66 {
67 DWORD type, size;
68 BYTE data[256];
69 LONG err;
70
71 size = sizeof(data);
72 memset(data, 0xdd, size);
73 err = RegQueryValueExA(hkey, value, NULL, &type, data, &size);
74 lok(err == ERROR_SUCCESS, "RegQueryValueEx failed: got %d\n", err);
75 if (err != ERROR_SUCCESS)
76 return;
77
78 todo_wine_if (todo & TODO_REG_TYPE)
79 lok(type == exp_type, "got wrong type %d, expected %d\n", type, exp_type);
80 todo_wine_if (todo & TODO_REG_SIZE)
81 lok(size == exp_size, "got wrong size %d, expected %d\n", size, exp_size);
82 todo_wine_if (todo & TODO_REG_DATA)
83 lok(memcmp(data, exp_data, size) == 0, "got wrong data\n");
84 }
85
86 #define verify_reg_nonexist(k,v) verify_reg_nonexist_(__LINE__,k,v)
87 static void verify_reg_nonexist_(unsigned line, HKEY hkey, const char *value)
88 {
89 LONG err;
90
91 err = RegQueryValueExA(hkey, value, NULL, NULL, NULL, NULL);
92 lok(err == ERROR_FILE_NOT_FOUND, "registry value '%s' shouldn't exist; got %d, expected 2\n",
93 value, err);
94 }
95
96 static void test_add(void)
97 {
98 HKEY hkey, subkey;
99 LONG err;
100 DWORD r, dword, type, size;
101 char buffer[22];
102
103 run_reg_exe("reg add", &r);
104 ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
105
106 run_reg_exe("reg add /?", &r);
107 ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
108
109 err = RegDeleteKeyA(HKEY_CURRENT_USER, KEY_BASE);
110 ok(err == ERROR_SUCCESS || err == ERROR_FILE_NOT_FOUND, "got %d\n", err);
111
112 err = RegOpenKeyExA(HKEY_CURRENT_USER, KEY_BASE, 0, KEY_READ, &hkey);
113 ok(err == ERROR_FILE_NOT_FOUND, "got %d\n", err);
114
115 run_reg_exe("reg add HKCU\\" KEY_BASE " /f", &r);
116 ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
117
118 err = RegOpenKeyExA(HKEY_CURRENT_USER, KEY_BASE, 0, KEY_READ, &hkey);
119 ok(err == ERROR_SUCCESS, "key creation failed, got %d\n", err);
120
121 /* Test empty type */
122 run_reg_exe("reg add HKCU\\" KEY_BASE " /v emptyType /t \"\" /d WineTest /f", &r);
123 ok(r == REG_EXIT_FAILURE, "got exit code %u\n", r);
124
125 /* Test input key formats */
126 run_reg_exe("reg add \\HKCU\\" KEY_BASE "\\keytest0 /f", &r);
127 ok(r == REG_EXIT_FAILURE, "got exit code %u\n", r);
128 err = RegDeleteKeyA(HKEY_CURRENT_USER, KEY_BASE "\\keytest0");
129 ok(err == ERROR_FILE_NOT_FOUND, "got exit code %d\n", err);
130
131 run_reg_exe("reg add \\\\HKCU\\" KEY_BASE "\\keytest1 /f", &r);
132 ok(r == REG_EXIT_FAILURE, "got exit code %u\n", r);
133 err = RegDeleteKeyA(HKEY_CURRENT_USER, KEY_BASE "\\keytest1");
134 ok(err == ERROR_FILE_NOT_FOUND, "got exit code %d\n", err);
135
136 run_reg_exe("reg add HKCU\\" KEY_BASE "\\keytest2\\\\ /f", &r);
137 ok(r == REG_EXIT_FAILURE || broken(r == REG_EXIT_SUCCESS /* WinXP */),
138 "got exit code %u\n", r);
139 err = RegDeleteKeyA(HKEY_CURRENT_USER, KEY_BASE "\\keytest2");
140 ok(err == ERROR_FILE_NOT_FOUND || broken(err == ERROR_SUCCESS /* WinXP */),
141 "got exit code %d\n", err);
142
143 run_reg_exe("reg add HKCU\\" KEY_BASE "\\keytest3\\ /f", &r);
144 ok(r == REG_EXIT_SUCCESS, "got exit code %u\n", r);
145 err = RegOpenKeyExA(HKEY_CURRENT_USER, KEY_BASE "\\keytest3", 0, KEY_READ, &subkey);
146 ok(err == ERROR_SUCCESS, "key creation failed, got %d\n", err);
147 RegCloseKey(subkey);
148 err = RegDeleteKeyA(HKEY_CURRENT_USER, KEY_BASE "\\keytest3");
149 ok(err == ERROR_SUCCESS, "got exit code %d\n", err);
150
151 run_reg_exe("reg add HKCU\\" KEY_BASE "\\keytest4 /f", &r);
152 ok(r == REG_EXIT_SUCCESS, "got exit code %u\n", r);
153 err = RegOpenKeyExA(HKEY_CURRENT_USER, KEY_BASE "\\keytest4", 0, KEY_READ, &subkey);
154 ok(err == ERROR_SUCCESS, "key creation failed, got %d\n", err);
155 RegCloseKey(subkey);
156 err = RegDeleteKeyA(HKEY_CURRENT_USER, KEY_BASE "\\keytest4");
157 ok(err == ERROR_SUCCESS, "got exit code %d\n", err);
158
159 /* REG_NONE */
160 run_reg_exe("reg add HKCU\\" KEY_BASE " /v none0 /d deadbeef /t REG_NONE /f", &r);
161 ok(r == REG_EXIT_SUCCESS, "got exit code %d\n", r);
162 verify_reg(hkey, "none0", REG_NONE, "d\0e\0a\0d\0b\0e\0e\0f\0\0", 18, 0);
163
164 run_reg_exe("reg add HKCU\\" KEY_BASE " /v none1 /t REG_NONE /f", &r);
165 ok(r == REG_EXIT_SUCCESS, "got exit code %u, expected 0\n", r);
166 verify_reg(hkey, "none1", REG_NONE, "\0", 2, 0);
167
168 run_reg_exe("reg add HKCU\\" KEY_BASE " /ve /t REG_NONE /f", &r);
169 ok(r == REG_EXIT_SUCCESS, "got exit code %u, expected 0\n", r);
170 verify_reg(hkey, NULL, REG_NONE, "\0", 2, 0);
171
172 /* REG_SZ */
173 run_reg_exe("reg add HKCU\\" KEY_BASE " /d WineTest /f", &r);
174 ok(r == REG_EXIT_SUCCESS || broken(r == REG_EXIT_FAILURE /* WinXP */),
175 "got exit code %d, expected 0\n", r);
176 if (r == REG_EXIT_SUCCESS)
177 verify_reg(hkey, "", REG_SZ, "WineTest", 9, 0);
178 else
179 win_skip("broken reg.exe detected\n");
180
181 run_reg_exe("reg add HKCU\\" KEY_BASE " /v test /d deadbeef /f", &r);
182 ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
183 verify_reg(hkey, "test", REG_SZ, "deadbeef", 9, 0);
184
185 run_reg_exe("reg add HKCU\\" KEY_BASE " /v test /f", &r);
186 ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
187 verify_reg(hkey, "test", REG_SZ, "", 1, 0);
188
189 run_reg_exe("reg add HKCU\\" KEY_BASE " /v test1 /t REG_SZ /f /d", &r);
190 ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
191
192 run_reg_exe("reg add HKEY_CURRENT_USER\\" KEY_BASE " /ve /d WineTEST /f", &r);
193 ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
194 verify_reg(hkey, "", REG_SZ, "WineTEST", 9, 0);
195
196 run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_SZ /v test2 /f", &r);
197 ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
198 verify_reg(hkey, "test2", REG_SZ, "", 1, 0);
199
200 run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_SZ /v test3 /f /d \"\"", &r);
201 ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
202 verify_reg(hkey, "test3", REG_SZ, "", 1, 0);
203
204 run_reg_exe("reg add HKCU\\" KEY_BASE " /ve /f", &r);
205 ok(r == REG_EXIT_SUCCESS, "got exit code %u, expected 0\n", r);
206 verify_reg(hkey, NULL, REG_SZ, "", 1, 0);
207
208 run_reg_exe("reg add HKCU\\" KEY_BASE " /ve /t REG_SZ /f", &r);
209 ok(r == REG_EXIT_SUCCESS, "got exit code %u, expected 0\n", r);
210 verify_reg(hkey, NULL, REG_SZ, "", 1, 0);
211
212 /* REG_EXPAND_SZ */
213 run_reg_exe("reg add HKCU\\" KEY_BASE " /v expand0 /t REG_EXpand_sz /d \"dead%PATH%beef\" /f", &r);
214 ok(r == REG_EXIT_SUCCESS, "got exit code %u\n", r);
215 verify_reg(hkey, "expand0", REG_EXPAND_SZ, "dead%PATH%beef", 15, 0);
216
217 run_reg_exe("reg add HKCU\\" KEY_BASE " /v expand1 /t REG_EXpand_sz /d \"dead^%PATH^%beef\" /f", &r);
218 ok(r == REG_EXIT_SUCCESS, "got exit code %u\n", r);
219 verify_reg(hkey, "expand1", REG_EXPAND_SZ, "dead^%PATH^%beef", 17, 0);
220
221 run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_EXPAND_SZ /v expand2 /f", &r);
222 ok(r == REG_EXIT_SUCCESS, "got exit code %u\n", r);
223 verify_reg(hkey, "expand2", REG_EXPAND_SZ, "", 1, 0);
224
225 run_reg_exe("reg add HKEY_CURRENT_USER\\" KEY_BASE " /ve /t REG_EXPAND_SZ /d WineTEST /f", &r);
226 ok(r == REG_EXIT_SUCCESS, "got exit code %u\n", r);
227 verify_reg(hkey, "", REG_EXPAND_SZ, "WineTEST", 9, 0);
228
229 run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_EXPAND_SZ /v expand3 /f /d \"\"", &r);
230 ok(r == REG_EXIT_SUCCESS, "got exit code %u\n", r);
231 verify_reg(hkey, "expand3", REG_EXPAND_SZ, "", 1, 0);
232
233 run_reg_exe("reg add HKCU\\" KEY_BASE " /ve /t REG_EXPAND_SZ /f", &r);
234 ok(r == REG_EXIT_SUCCESS, "got exit code %u, expected 0\n", r);
235 verify_reg(hkey, NULL, REG_EXPAND_SZ, "", 1, 0);
236
237 /* REG_BINARY */
238 run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_BINARY /v bin0 /f", &r);
239 ok(r == REG_EXIT_SUCCESS, "got exit code %u\n", r);
240 verify_reg(hkey, "bin0", REG_BINARY, buffer, 0, 0);
241
242 run_reg_exe("reg add HKEY_CURRENT_USER\\" KEY_BASE " /ve /t REG_BINARY /d deadbeef /f", &r);
243 ok(r == REG_EXIT_SUCCESS, "got exit code %u\n", r);
244 dword = 0xefbeadde;
245 verify_reg(hkey, "", REG_BINARY, &dword, sizeof(DWORD), 0);
246
247 run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_BINARY /v bin1 /f /d 0xDeAdBeEf", &r);
248 ok(r == REG_EXIT_FAILURE, "got exit code %u\n", r);
249 run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_BINARY /v bin2 /f /d x01", &r);
250 ok(r == REG_EXIT_FAILURE, "got exit code %u\n", r);
251 run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_BINARY /v bin3 /f /d 01x", &r);
252 ok(r == REG_EXIT_FAILURE, "got exit code %u\n", r);
253
254 run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_BINARY /v bin4 /f /d DeAdBeEf0DD", &r);
255 ok(r == REG_EXIT_SUCCESS, "got exit code %u\n", r);
256 /* Remaining nibble prefixed */
257 buffer[0] = 0x0d; buffer[1] = 0xea; buffer[2] = 0xdb;
258 buffer[3] = 0xee; buffer[4] = 0xf0; buffer[5] = 0xdd;
259 /* Remaining nibble suffixed on winXP */
260 buffer[6] = 0xde; buffer[7] = 0xad; buffer[8] = 0xbe;
261 buffer[9] = 0xef; buffer[10] = 0x0d; buffer[11] = 0xd0;
262 size = 6;
263 err = RegQueryValueExA(hkey, "bin4", NULL, &type, (void *) (buffer+12), &size);
264 ok(err == ERROR_SUCCESS, "RegQueryValueEx failed: got %d\n", err);
265 ok(type == REG_BINARY, "got wrong type %u\n", type);
266 ok(size == 6, "got wrong size %u\n", size);
267 ok(memcmp(buffer, buffer+12, 6) == 0 ||
268 broken(memcmp(buffer+6, buffer+12, 6) == 0 /* WinXP */), "got wrong data\n");
269
270 run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_BINARY /v bin5 /d \"\" /f", &r);
271 ok(r == REG_EXIT_SUCCESS, "got exit code %u\n", r);
272 verify_reg(hkey, "bin5", REG_BINARY, buffer, 0, 0);
273
274 run_reg_exe("reg add HKCU\\" KEY_BASE " /v bin6 /t REG_BINARY /f /d", &r);
275 ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
276
277 run_reg_exe("reg add HKCU\\" KEY_BASE " /ve /t REG_BINARY /f", &r);
278 ok(r == REG_EXIT_SUCCESS, "got exit code %u, expected 0\n", r);
279 verify_reg(hkey, NULL, REG_BINARY, buffer, 0, 0);
280
281 /* REG_DWORD */
282 run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_DWORD /f /d 12345678", &r);
283 ok(r == REG_EXIT_SUCCESS || broken(r == REG_EXIT_FAILURE /* WinXP */),
284 "got exit code %d, expected 0\n", r);
285 dword = 12345678;
286 if (r == REG_EXIT_SUCCESS)
287 verify_reg(hkey, "", REG_DWORD, &dword, sizeof(dword), 0);
288 else
289 win_skip("broken reg.exe detected\n");
290
291 run_reg_exe("reg add HKCU\\" KEY_BASE " /v dword0 /t REG_DWORD /f /d", &r);
292 ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
293 run_reg_exe("reg add HKCU\\" KEY_BASE " /v dword1 /t REG_DWORD /f", &r);
294 ok(r == REG_EXIT_FAILURE || broken(r == REG_EXIT_SUCCESS /* WinXP */),
295 "got exit code %d, expected 1\n", r);
296 run_reg_exe("reg add HKCU\\" KEY_BASE " /v dword2 /t REG_DWORD /d zzz /f", &r);
297 ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
298 run_reg_exe("reg add HKCU\\" KEY_BASE " /v dword3 /t REG_DWORD /d deadbeef /f", &r);
299 ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
300 run_reg_exe("reg add HKCU\\" KEY_BASE " /v dword4 /t REG_DWORD /d 123xyz /f", &r);
301 ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
302
303 run_reg_exe("reg add HKCU\\" KEY_BASE " /v dword5 /t reg_dword /d 12345678 /f", &r);
304 ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
305 dword = 12345678;
306 verify_reg(hkey, "dword5", REG_DWORD, &dword, sizeof(dword), 0);
307
308 run_reg_exe("reg add HKCU\\" KEY_BASE " /v dword6 /t REG_DWORD /D 0123 /f", &r);
309 ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
310 size = sizeof(dword);
311 err = RegQueryValueExA(hkey, "dword6", NULL, &type, (LPBYTE)&dword, &size);
312 ok(err == ERROR_SUCCESS, "RegQueryValueEx failed: got %d\n", err);
313 ok(type == REG_DWORD, "got wrong type %d, expected %d\n", type, REG_DWORD);
314 ok(size == sizeof(DWORD), "got wrong size %d, expected %d\n", size, (int)sizeof(DWORD));
315 ok(dword == 123 || broken(dword == 0123 /* WinXP */), "got wrong data %d, expected 123\n", dword);
316
317 run_reg_exe("reg add HKCU\\" KEY_BASE " /v dword7 /t reg_dword /d 0xabcdefg /f", &r);
318 ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
319
320 run_reg_exe("reg add HKCU\\" KEY_BASE " /v dword8 /t REG_dword /d 0xdeadbeef /f", &r);
321 ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
322 dword = 0xdeadbeef;
323 verify_reg(hkey, "dword8", REG_DWORD, &dword, sizeof(dword), 0);
324
325 run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_DWORD /v dword9 /f /d -1", &r);
326 ok(r == REG_EXIT_FAILURE || broken(r == REG_EXIT_SUCCESS /* WinXP */), "got exit code %u\n", r);
327 run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_DWORD /v dword10 /f /d -0x1", &r);
328 ok(r == REG_EXIT_FAILURE || broken(r == REG_EXIT_SUCCESS /* WinXP */), "got exit code %u\n", r);
329
330 run_reg_exe("reg add HKCU\\" KEY_BASE " /v dword8 /t REG_dword /d 0x01ffffffff /f", &r);
331 ok(r == REG_EXIT_FAILURE || broken(r == REG_EXIT_SUCCESS /* WinXP */), "got exit code %d\n", r);
332
333 run_reg_exe("reg add HKCU\\" KEY_BASE " /v dword12 /t REG_DWORD /d 0xffffffff /f", &r);
334 ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
335 dword = ~0u;
336 verify_reg(hkey, "dword12", REG_DWORD, &dword, sizeof(dword), 0);
337
338 run_reg_exe("reg add HKCU\\" KEY_BASE " /v dword13 /t REG_DWORD /d 00x123 /f", &r);
339 ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
340
341 run_reg_exe("reg add HKCU\\" KEY_BASE " /v dword14 /t REG_DWORD /d 0X123 /f", &r);
342 ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
343 dword = 0x123;
344 verify_reg(hkey, "dword14", REG_DWORD, &dword, sizeof(dword), 0);
345
346 run_reg_exe("reg add HKCU\\" KEY_BASE " /v dword15 /t REG_DWORD /d 4294967296 /f", &r);
347 ok(r == REG_EXIT_FAILURE || broken(r == REG_EXIT_SUCCESS /* WinXP */), "got exit code %u\n", r);
348
349 run_reg_exe("reg add HKCU\\" KEY_BASE " /ve /t REG_DWORD /f", &r);
350 ok(r == REG_EXIT_FAILURE || broken(r == REG_EXIT_SUCCESS /* WinXP */), "got exit code %u\n", r);
351
352 /* REG_DWORD_LITTLE_ENDIAN */
353 run_reg_exe("reg add HKCU\\" KEY_BASE " /v DWORD_LE /t REG_DWORD_LITTLE_ENDIAN /d 456 /f", &r);
354 ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
355 dword = 456;
356 verify_reg(hkey, "DWORD_LE", REG_DWORD_LITTLE_ENDIAN, &dword, sizeof(dword), 0);
357
358 /* REG_DWORD_BIG_ENDIAN */
359 run_reg_exe("reg add HKCU\\" KEY_BASE " /v DWORD_BE /t REG_DWORD_BIG_ENDIAN /d 456 /f", &r);
360 ok(r == REG_EXIT_SUCCESS, "got exit code %u\n", r);
361 dword = 456;
362 verify_reg(hkey, "DWORD_BE", REG_DWORD_BIG_ENDIAN, &dword, sizeof(dword), 0);
363 /* REG_DWORD_BIG_ENDIAN is broken in every version of windows. It behaves like
364 * an ordinary REG_DWORD - that is little endian. GG */
365
366 run_reg_exe("reg add HKCU\\" KEY_BASE " /v DWORD_BE2 /t REG_DWORD_BIG_ENDIAN /f /d", &r);
367 ok(r == REG_EXIT_FAILURE, "got exit code %u, expected 1\n", r);
368
369 run_reg_exe("reg add HKCU\\" KEY_BASE " /v DWORD_BE3 /t REG_DWORD_BIG_ENDIAN /f", &r);
370 ok(r == REG_EXIT_FAILURE || broken(r == REG_EXIT_SUCCESS /* WinXP */), "got exit code %u\n", r);
371
372 run_reg_exe("reg add HKCU\\" KEY_BASE " /ve /t REG_DWORD_BIG_ENDIAN /f", &r);
373 ok(r == REG_EXIT_FAILURE || broken(r == REG_EXIT_SUCCESS /* WinXP */), "got exit code %u\n", r);
374
375 /* REG_MULTI_SZ */
376 run_reg_exe("reg add HKCU\\" KEY_BASE " /v multi0 /t REG_MULTI_SZ /d \"three\\0little\\0strings\" /f", &r);
377 ok(r == REG_EXIT_SUCCESS, "got exit code %u, expected 0\n", r);
378 memcpy(buffer, "three\0little\0strings\0", 22);
379 verify_reg(hkey, "multi0", REG_MULTI_SZ, buffer, 22, 0);
380
381 run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_MULTI_SZ /v multi1 /s \"#\" /d \"three#little#strings\" /f", &r);
382 ok(r == REG_EXIT_SUCCESS, "got exit code %u, expected 0\n", r);
383 verify_reg(hkey, "multi1", REG_MULTI_SZ, buffer, 22, 0);
384
385 run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_MULTI_SZ /v multi2 /d \"\" /f", &r);
386 ok(r == REG_EXIT_SUCCESS, "got exit code %u, expected 0\n", r);
387 verify_reg(hkey, "multi2", REG_MULTI_SZ, &buffer[21], 1, 0);
388
389 run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_MULTI_SZ /v multi3 /f", &r);
390 ok(r == REG_EXIT_SUCCESS, "got exit code %u\n", r);
391 verify_reg(hkey, "multi3", REG_MULTI_SZ, &buffer[21], 1, 0);
392
393 run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_MULTI_SZ /v multi4 /s \"#\" /d \"threelittlestrings\" /f", &r);
394 ok(r == REG_EXIT_SUCCESS, "got exit code %u, expected 0\n", r);
395 verify_reg(hkey, "multi4", REG_MULTI_SZ, "threelittlestrings\0", 20, 0);
396
397 run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_MULTI_SZ /v multi5 /s \"#randomgibberish\" /d \"three#little#strings\" /f", &r);
398 ok(r == REG_EXIT_FAILURE, "got exit code %u\n", r);
399 run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_MULTI_SZ /v multi6 /s \"\\0\" /d \"three\\0little\\0strings\" /f", &r);
400 ok(r == REG_EXIT_FAILURE, "got exit code %u\n", r);
401 run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_MULTI_SZ /v multi7 /s \"\" /d \"three#little#strings\" /f", &r);
402 ok(r == REG_EXIT_FAILURE, "got exit code %u\n", r);
403 run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_MULTI_SZ /v multi8 /s \"#\" /d \"##\" /f", &r);
404 ok(r == REG_EXIT_FAILURE, "got exit code %u\n", r);
405 run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_MULTI_SZ /v multi9 /s \"#\" /d \"two##strings\" /f", &r);
406 ok(r == REG_EXIT_FAILURE, "got exit code %u\n", r);
407 run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_MULTI_SZ /v multi10 /s \"#\" /d \"#a\" /f", &r);
408 ok(r == REG_EXIT_FAILURE, "got exit code %u\n", r);
409
410 run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_MULTI_SZ /v multi11 /s \"#\" /d \"a#\" /f", &r);
411 ok(r == REG_EXIT_SUCCESS, "got exit code %u, expected 0\n", r);
412 buffer[0]='a'; buffer[1]=0; buffer[2]=0;
413 verify_reg(hkey, "multi11", REG_MULTI_SZ, buffer, 3, 0);
414
415 run_reg_exe("reg add HKCU\\" KEY_BASE " /v multi12 /t REG_MULTI_SZ /f /d", &r);
416 ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
417
418 run_reg_exe("reg add HKCU\\" KEY_BASE " /v multi13 /t REG_MULTI_SZ /f /s", &r);
419 ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
420
421 run_reg_exe("reg add HKCU\\" KEY_BASE " /v multi14 /t REG_MULTI_SZ /d \"\\0a\" /f", &r);
422 ok(r == REG_EXIT_FAILURE, "got exit code %u, expected 1\n", r);
423
424 run_reg_exe("reg add HKCU\\" KEY_BASE " /v multi15 /t REG_MULTI_SZ /d \"a\\0\" /f", &r);
425 ok(r == REG_EXIT_SUCCESS, "got exit code %u, expected 0\n", r);
426 verify_reg(hkey, "multi15", REG_MULTI_SZ, buffer, 3, 0);
427
428 run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_MULTI_SZ /v multi16 /d \"two\\0\\0strings\" /f", &r);
429 ok(r == REG_EXIT_FAILURE, "got exit code %u, expected 1\n", r);
430
431 run_reg_exe("reg add HKCU\\" KEY_BASE " /v multi17 /t REG_MULTI_SZ /s \"#\" /d \"#\" /f", &r);
432 ok(r == REG_EXIT_SUCCESS, "got exit code %u, expected 0\n", r);
433 buffer[0] = 0; buffer[1] = 0;
434 verify_reg(hkey, "multi17", REG_MULTI_SZ, buffer, 2, 0);
435
436 run_reg_exe("reg add HKCU\\" KEY_BASE " /v multi18 /t REG_MULTI_SZ /d \"\\0\" /f", &r);
437 ok(r == REG_EXIT_SUCCESS, "got exit code %u, expected 0\n", r);
438 verify_reg(hkey, "multi18", REG_MULTI_SZ, buffer, 2, 0);
439
440 run_reg_exe("reg add HKCU\\" KEY_BASE " /v multi19 /t REG_MULTI_SZ /s \"#\" /d \"two\\0#strings\" /f", &r);
441 ok(r == REG_EXIT_SUCCESS, "got exit code %u, expected 0\n", r);
442 verify_reg(hkey, "multi19", REG_MULTI_SZ, "two\\0\0strings\0", 15, 0);
443
444 run_reg_exe("reg add HKCU\\" KEY_BASE " /v multi20 /t REG_MULTI_SZ /s \"#\" /d \"two#\\0strings\" /f", &r);
445 ok(r == REG_EXIT_SUCCESS, "got exit code %u, expected 0\n", r);
446 verify_reg(hkey, "multi20", REG_MULTI_SZ, "two\0\\0strings\0", 15, 0);
447
448 run_reg_exe("reg add HKCU\\" KEY_BASE " /v multi21 /t REG_MULTI_SZ /s \"#\" /d \"two\\0\\0strings\" /f", &r);
449 ok(r == REG_EXIT_SUCCESS, "got exit code %u, expected 0\n", r);
450 verify_reg(hkey, "multi21", REG_MULTI_SZ, "two\\0\\0strings\0", 16, 0);
451
452 run_reg_exe("reg add HKCU\\" KEY_BASE " /ve /t REG_MULTI_SZ /f", &r);
453 ok(r == REG_EXIT_SUCCESS, "got exit code %u, expected 0\n", r);
454 verify_reg(hkey, NULL, REG_MULTI_SZ, buffer, 1, 0);
455
456 RegCloseKey(hkey);
457
458 /* Test duplicate switches */
459 run_reg_exe("reg add HKCU\\" KEY_BASE " /v dup1 /t REG_DWORD /d 123 /f /t REG_SZ", &r);
460 ok(r == REG_EXIT_FAILURE || broken(r == REG_EXIT_SUCCESS /* WinXP */),
461 "got exit code %u, expected 1\n", r);
462
463 run_reg_exe("reg add HKCU\\" KEY_BASE " /v dup2 /t REG_DWORD /d 123 /f /d 456", &r);
464 ok(r == REG_EXIT_FAILURE, "got exit code %u, expected 1\n", r);
465
466 /* Test invalid switches */
467 run_reg_exe("reg add HKCU\\" KEY_BASE " /v invalid1 /a", &r);
468 ok(r == REG_EXIT_FAILURE, "got exit code %u, expected 1\n", r);
469
470 run_reg_exe("reg add HKCU\\" KEY_BASE " /v invalid2 /ae", &r);
471 ok(r == REG_EXIT_FAILURE, "got exit code %u, expected 1\n", r);
472
473 run_reg_exe("reg add HKCU\\" KEY_BASE " /v invalid3 /", &r);
474 ok(r == REG_EXIT_FAILURE, "got exit code %u, expected 1\n", r);
475
476 run_reg_exe("reg add HKCU\\" KEY_BASE " /v invalid4 -", &r);
477 ok(r == REG_EXIT_FAILURE, "got exit code %u, expected 1\n", r);
478
479 err = RegDeleteKeyA(HKEY_CURRENT_USER, KEY_BASE);
480 ok(err == ERROR_SUCCESS, "got %d\n", err);
481 }
482
483 static void test_delete(void)
484 {
485 HKEY hkey, hsubkey;
486 LONG err;
487 DWORD r;
488 const DWORD deadbeef = 0xdeadbeef;
489
490 run_reg_exe("reg delete", &r);
491 ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
492
493 run_reg_exe("reg delete /?", &r);
494 ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
495
496 err = RegCreateKeyExA(HKEY_CURRENT_USER, KEY_BASE, 0, NULL, 0, KEY_ALL_ACCESS, NULL, &hkey, NULL);
497 ok(err == ERROR_SUCCESS, "got %d\n", err);
498
499 err = RegSetValueExA(hkey, "foo", 0, REG_DWORD, (LPBYTE)&deadbeef, sizeof(deadbeef));
500 ok(err == ERROR_SUCCESS, "got %d\n" ,err);
501
502 err = RegSetValueExA(hkey, "bar", 0, REG_DWORD, (LPBYTE)&deadbeef, sizeof(deadbeef));
503 ok(err == ERROR_SUCCESS, "got %d\n" ,err);
504
505 err = RegSetValueExA(hkey, "", 0, REG_DWORD, (LPBYTE)&deadbeef, sizeof(deadbeef));
506 ok(err == ERROR_SUCCESS, "got %d\n" ,err);
507
508 err = RegCreateKeyExA(hkey, "subkey", 0, NULL, 0, KEY_ALL_ACCESS, NULL, &hsubkey, NULL);
509 ok(err == ERROR_SUCCESS, "got %d\n" ,err);
510 RegCloseKey(hsubkey);
511
512 run_reg_exe("reg delete HKCU\\" KEY_BASE " /v bar /f", &r);
513 ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
514 verify_reg_nonexist(hkey, "bar");
515
516 run_reg_exe("reg delete HKCU\\" KEY_BASE " /ve /f", &r);
517 ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
518 verify_reg_nonexist(hkey, "");
519
520 run_reg_exe("reg delete HKCU\\" KEY_BASE " /va /f", &r);
521 ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
522 verify_reg_nonexist(hkey, "foo");
523 err = RegOpenKeyExA(hkey, "subkey", 0, KEY_READ, &hsubkey);
524 ok(err == ERROR_SUCCESS, "got %d\n", err);
525 RegCloseKey(hsubkey);
526 RegCloseKey(hkey);
527
528 run_reg_exe("reg delete HKCU\\" KEY_BASE " /f", &r);
529 ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
530 err = RegOpenKeyExA(HKEY_CURRENT_USER, KEY_BASE, 0, KEY_READ, &hkey);
531 ok(err == ERROR_FILE_NOT_FOUND, "got %d\n", err);
532
533 run_reg_exe("reg delete HKCU\\" KEY_BASE " /f", &r);
534 ok(r == REG_EXIT_FAILURE, "got exit code %u\n", r);
535 }
536
537 static void test_query(void)
538 {
539 DWORD r;
540 HKEY key, subkey;
541 LONG err;
542 const char hello[] = "Hello";
543 const char world[] = "World";
544 const char empty1[] = "Empty1";
545 const char empty2[] = "Empty2";
546 const DWORD dword1 = 0x123;
547 const DWORD dword2 = 0xabc;
548
549 run_reg_exe("reg query", &r);
550 ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
551
552 run_reg_exe("reg query /?", &r);
553 ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
554
555 /* Create a test key */
556 err = RegCreateKeyExA(HKEY_CURRENT_USER, KEY_BASE, 0, NULL, 0, KEY_ALL_ACCESS, NULL, &key, NULL);
557 ok(err == ERROR_SUCCESS, "got %d, expected 0\n", err);
558
559 run_reg_exe("reg query HKCU\\" KEY_BASE " /ve", &r);
560 ok(r == REG_EXIT_SUCCESS || broken(r == REG_EXIT_FAILURE /* WinXP */),
561 "got exit code %d, expected 0\n", r);
562
563 err = RegSetValueExA(key, "Test", 0, REG_SZ, (BYTE *)hello, sizeof(hello));
564 ok(err == ERROR_SUCCESS, "got %d, expected 0\n", err);
565
566 err = RegSetValueExA(key, "Wine", 0, REG_DWORD, (BYTE *)&dword1, sizeof(dword1));
567 ok(err == ERROR_SUCCESS, "got %d, expected 0\n", err);
568
569 err = RegSetValueExA(key, NULL, 0, REG_SZ, (BYTE *)empty1, sizeof(empty1));
570 ok(err == ERROR_SUCCESS, "got %d, expected 0\n", err);
571
572 run_reg_exe("reg query HKCU\\" KEY_BASE, &r);
573 ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
574
575 run_reg_exe("reg query HKCU\\" KEY_BASE " /v", &r);
576 ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
577
578 run_reg_exe("reg query HKCU\\" KEY_BASE " /v Missing", &r);
579 ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
580
581 run_reg_exe("reg query HKCU\\" KEY_BASE " /v Test", &r);
582 ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
583
584 run_reg_exe("reg query HKCU\\" KEY_BASE " /v Wine", &r);
585 ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
586
587 run_reg_exe("reg query HKCU\\" KEY_BASE " /ve", &r);
588 ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
589
590 /* Create a test subkey */
591 err = RegCreateKeyExA(key, "Subkey", 0, NULL, 0, KEY_ALL_ACCESS, NULL, &subkey, NULL);
592 ok(err == ERROR_SUCCESS, "got %d\n", err);
593
594 err = RegSetValueExA(subkey, "Test", 0, REG_SZ, (BYTE *)world, sizeof(world));
595 ok(err == ERROR_SUCCESS, "got %d, expected 0\n", err);
596
597 err = RegSetValueExA(subkey, "Wine", 0, REG_DWORD, (BYTE *)&dword2, sizeof(dword2));
598 ok(err == ERROR_SUCCESS, "got %d, expected 0\n", err);
599
600 err = RegSetValueExA(subkey, NULL, 0, REG_SZ, (BYTE *)empty2, sizeof(empty2));
601 ok(err == ERROR_SUCCESS, "got %d, expected 0\n", err);
602
603 err = RegCloseKey(subkey);
604 ok(err == ERROR_SUCCESS, "got %d, expected 0\n", err);
605
606 run_reg_exe("reg query HKCU\\" KEY_BASE "\\subkey", &r);
607 ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
608
609 run_reg_exe("reg query HKCU\\" KEY_BASE "\\subkey /v Test", &r);
610 ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
611
612 run_reg_exe("reg query HKCU\\" KEY_BASE "\\subkey /v Wine", &r);
613 ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
614
615 run_reg_exe("reg query HKCU\\" KEY_BASE "\\subkey /ve", &r);
616 ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
617
618 /* Test recursion */
619 run_reg_exe("reg query HKCU\\" KEY_BASE " /s", &r);
620 ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
621
622 run_reg_exe("reg query HKCU\\" KEY_BASE " /v Test /s", &r);
623 ok(r == REG_EXIT_SUCCESS || r == REG_EXIT_FAILURE /* WinXP */,
624 "got exit code %d, expected 0\n", r);
625
626 run_reg_exe("reg query HKCU\\" KEY_BASE " /v Wine /s", &r);
627 ok(r == REG_EXIT_SUCCESS || r == REG_EXIT_FAILURE /* WinXP */,
628 "got exit code %d, expected 0\n", r);
629
630 run_reg_exe("reg query HKCU\\" KEY_BASE " /ve /s", &r);
631 ok(r == REG_EXIT_SUCCESS || r == REG_EXIT_FAILURE /* WinXP */,
632 "got exit code %d, expected 0\n", r);
633
634 /* Clean-up, then query */
635 err = RegDeleteKeyA(key, "subkey");
636 ok(err == ERROR_SUCCESS, "got %d, expected 0\n", err);
637
638 err = RegCloseKey(key);
639 ok(err == ERROR_SUCCESS, "got %d, expected 0\n", err);
640
641 run_reg_exe("reg query HKCU\\" KEY_BASE "\\subkey", &r);
642 ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
643
644 err = RegDeleteKeyA(HKEY_CURRENT_USER, KEY_BASE);
645 ok(err == ERROR_SUCCESS, "got %d, expected 0\n", err);
646
647 run_reg_exe("reg query HKCU\\" KEY_BASE, &r);
648 ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
649 }
650
651 static void test_v_flags(void)
652 {
653 DWORD r;
654
655 run_reg_exe("reg add HKCU\\" KEY_BASE " /v Wine /ve", &r);
656 ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
657
658 run_reg_exe("reg delete HKCU\\" KEY_BASE " /v Wine /ve", &r);
659 ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
660
661 run_reg_exe("reg delete HKCU\\" KEY_BASE " /v Wine /va", &r);
662 ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
663
664 run_reg_exe("reg delete HKCU\\" KEY_BASE " /ve /va", &r);
665 ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
666
667 /* No /v argument */
668 run_reg_exe("reg add HKCU\\" KEY_BASE " /v", &r);
669 ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
670
671 run_reg_exe("reg add HKCU\\" KEY_BASE " /d Test /f /v", &r);
672 ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
673
674 run_reg_exe("reg delete HKCU\\" KEY_BASE " /v", &r);
675 ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
676
677 run_reg_exe("reg delete HKCU\\" KEY_BASE " /f /v", &r);
678 ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
679
680 /* Multiple /v switches */
681 run_reg_exe("reg add HKCU\\" KEY_BASE " /v Wine /t REG_DWORD /d 0x1 /v Test /f", &r);
682 ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
683
684 run_reg_exe("reg delete HKCU\\" KEY_BASE " /v Wine /v Test /f", &r);
685 ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
686 }
687
688 static BOOL write_reg_file(const char *value, char *tmp_name)
689 {
690 static const char regedit4[] = "REGEDIT4";
691 static const char key[] = "[HKEY_CURRENT_USER\\" KEY_BASE "]";
692 char file_data[MAX_PATH], tmp_path[MAX_PATH];
693 HANDLE hfile;
694 DWORD written;
695 BOOL ret;
696
697 sprintf(file_data, "%s\n\n%s\n%s\n", regedit4, key, value);
698
699 GetTempPathA(MAX_PATH, tmp_path);
700 GetTempFileNameA(tmp_path, "reg", 0, tmp_name);
701
702 hfile = CreateFileA(tmp_name, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0);
703 if (hfile == INVALID_HANDLE_VALUE)
704 return FALSE;
705
706 ret = WriteFile(hfile, file_data, strlen(file_data), &written, NULL);
707 CloseHandle(hfile);
708 return ret;
709 }
710
711 #define test_import_str(c,r) test_import_str_(__LINE__,c,r)
712 static BOOL test_import_str_(unsigned line, const char *file_contents, DWORD *rc)
713 {
714 HANDLE regfile;
715 DWORD written;
716 BOOL ret;
717
718 regfile = CreateFileA("test.reg", GENERIC_WRITE, 0, NULL, CREATE_ALWAYS,
719 FILE_ATTRIBUTE_NORMAL, NULL);
720 lok(regfile != INVALID_HANDLE_VALUE, "Failed to create test.reg file\n");
721 if(regfile == INVALID_HANDLE_VALUE)
722 return FALSE;
723
724 ret = WriteFile(regfile, file_contents, strlen(file_contents), &written, NULL);
725 lok(ret, "WriteFile failed: %u\n", GetLastError());
726 CloseHandle(regfile);
727
728 run_reg_exe("reg import test.reg", rc);
729
730 ret = DeleteFileA("test.reg");
731 lok(ret, "DeleteFile failed: %u\n", GetLastError());
732
733 return ret;
734 }
735
736 #define test_import_wstr(c,r) test_import_wstr_(__LINE__,c,r)
737 static BOOL test_import_wstr_(unsigned line, const char *file_contents, DWORD *rc)
738 {
739 int lenA, len, memsize;
740 WCHAR *wstr;
741 HANDLE regfile;
742 DWORD written;
743 BOOL ret;
744
745 lenA = strlen(file_contents);
746
747 len = MultiByteToWideChar(CP_UTF8, 0, file_contents, lenA, NULL, 0);
748 memsize = len * sizeof(WCHAR);
749 wstr = HeapAlloc(GetProcessHeap(), 0, memsize);
750 if (!wstr) return FALSE;
751 MultiByteToWideChar(CP_UTF8, 0, file_contents, lenA, wstr, memsize);
752
753 regfile = CreateFileA("test.reg", GENERIC_WRITE, 0, NULL, CREATE_ALWAYS,
754 FILE_ATTRIBUTE_NORMAL, NULL);
755 lok(regfile != INVALID_HANDLE_VALUE, "Failed to create test.reg file\n");
756 if(regfile == INVALID_HANDLE_VALUE)
757 return FALSE;
758
759 ret = WriteFile(regfile, wstr, memsize, &written, NULL);
760 lok(ret, "WriteFile failed: %u\n", GetLastError());
761 CloseHandle(regfile);
762
763 HeapFree(GetProcessHeap(), 0, wstr);
764
765 run_reg_exe("reg import test.reg", rc);
766
767 ret = DeleteFileA("test.reg");
768 lok(ret, "DeleteFile failed: %u\n", GetLastError());
769
770 return ret;
771 }
772
773 static void test_import(void)
774 {
775 DWORD r, dword = 0x123;
776 char test1_reg[MAX_PATH], test2_reg[MAX_PATH];
777 char cmdline[MAX_PATH];
778 char test_string[] = "Test string";
779 HKEY hkey, subkey;
780 LONG err;
781
782 run_reg_exe("reg import", &r);
783 ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
784
785 run_reg_exe("reg import /?", &r);
786 todo_wine ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
787
788 run_reg_exe("reg import missing.reg", &r);
789 ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
790
791 /* Create test files */
792 ok(write_reg_file("\"Wine\"=dword:00000123", test1_reg), "Failed to write registry file\n");
793 ok(write_reg_file("@=\"Test string\"", test2_reg), "Failed to write registry file\n");
794
795 sprintf(cmdline, "reg import %s", test1_reg);
796 run_reg_exe(cmdline, &r);
797 todo_wine ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
798
799 sprintf(cmdline, "reg import %s", test2_reg);
800 run_reg_exe(cmdline, &r);
801 todo_wine ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
802
803 err = RegOpenKeyExA(HKEY_CURRENT_USER, KEY_BASE, 0, KEY_READ, &hkey);
804 todo_wine ok(err == ERROR_SUCCESS, "got %d, expected 0\n", err);
805
806 todo_wine verify_reg(hkey, "Wine", REG_DWORD, &dword, sizeof(dword), 0);
807 todo_wine verify_reg(hkey, "", REG_SZ, test_string, sizeof(test_string), 0);
808
809 err = RegCloseKey(hkey);
810 todo_wine ok(err == ERROR_SUCCESS, "got %d, expected 0\n", err);
811
812 err = RegDeleteKeyA(HKEY_CURRENT_USER, KEY_BASE);
813 todo_wine ok(err == ERROR_SUCCESS, "got %d, expected 0\n", err);
814
815 sprintf(cmdline, "reg import %s %s", test1_reg, test2_reg);
816 run_reg_exe(cmdline, &r);
817 ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
818
819 DeleteFileA(test1_reg);
820 DeleteFileA(test2_reg);
821
822 /* Test file contents */
823 test_import_str("regedit\n", &r);
824 ok(r == REG_EXIT_FAILURE || broken(r == REG_EXIT_SUCCESS) /* WinXP */,
825 "got exit code %d, expected 1\n", r);
826
827 test_import_str("regedit4\n", &r);
828 ok(r == REG_EXIT_FAILURE || broken(r == REG_EXIT_SUCCESS) /* WinXP */,
829 "got exit code %d, expected 1\n", r);
830
831 test_import_str("REGEDIT", &r);
832 todo_wine ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
833
834 test_import_str("REGEDIT\n", &r);
835 todo_wine ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
836
837 test_import_str("REGEDIT4\n", &r);
838 todo_wine ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
839
840 test_import_str(" REGEDIT4\n", &r);
841 todo_wine ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
842
843 test_import_str("\tREGEDIT4\n", &r);
844 todo_wine ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
845
846 test_import_str("\nREGEDIT4\n", &r);
847 ok(r == REG_EXIT_FAILURE || broken(r == REG_EXIT_SUCCESS) /* WinXP */,
848 "got exit code %d, expected 1\n", r);
849
850 test_import_str("AREGEDIT4\n", &r);
851 ok(r == REG_EXIT_FAILURE || broken(r == REG_EXIT_SUCCESS) /* WinXP */,
852 "got exit code %d, expected 1\n", r);
853
854 test_import_str("1REGEDIT4\n", &r);
855 ok(r == REG_EXIT_FAILURE || broken(r == REG_EXIT_SUCCESS) /* WinXP */,
856 "got exit code %d, expected 1\n", r);
857
858 test_import_str("REGEDIT3\n", &r);
859 todo_wine ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
860
861 test_import_str("REGEDIT5\n", &r);
862 todo_wine ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
863
864 test_import_str("REGEDIT9\n", &r);
865 todo_wine ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
866
867 test_import_str("REGEDIT 4\n", &r);
868 todo_wine ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
869
870 test_import_str("REGEDIT4 FOO\n", &r);
871 todo_wine ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
872
873 test_import_str("REGEDIT4\n"
874 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n", &r);
875 todo_wine ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
876
877 err = RegOpenKeyExA(HKEY_CURRENT_USER, KEY_BASE, 0, KEY_READ, &hkey);
878 todo_wine ok(err == ERROR_SUCCESS, "got %d, expected 0\n", err);
879
880 test_import_str("REGEDIT4\n"
881 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
882 "\"Test1\"=\"Value1\"\n", &r);
883 todo_wine ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
884 todo_wine verify_reg(hkey, "Test1", REG_SZ, "Value1", 7, 0);
885
886 test_import_str("REGEDIT4\n"
887 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
888 "\"Test2\"=\"Value2\"\n\n", &r);
889 todo_wine ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
890 todo_wine verify_reg(hkey, "Test2", REG_SZ, "Value2", 7, 0);
891
892 test_import_str("REGEDIT4\n\n"
893 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
894 "\"Test3\"=\"Value3\"\n\n", &r);
895 todo_wine ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
896 todo_wine verify_reg(hkey, "Test3", REG_SZ, "Value3", 7, 0);
897
898 test_import_str("Windows Registry Editor Version 4.00\n", &r);
899 ok(r == REG_EXIT_FAILURE || broken(r == REG_EXIT_SUCCESS) /* WinXP */,
900 "got exit code %d, expected 1\n", r);
901
902 test_import_str("Windows Registry Editor Version 5.00\n", &r);
903 todo_wine ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
904
905 test_import_str("Windows Registry Editor Version 5.00\n"
906 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
907 "\"Test4\"=\"Value4\"\n", &r);
908 todo_wine ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
909 todo_wine verify_reg(hkey, "Test4", REG_SZ, "Value4", 7, 0);
910
911 test_import_str("Windows Registry Editor Version 5.00\n"
912 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
913 "\"Test5\"=\"Value5\"\n\n", &r);
914 todo_wine ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
915 todo_wine verify_reg(hkey, "Test5", REG_SZ, "Value5", 7, 0);
916
917 test_import_str("Windows Registry Editor Version 5.00\n\n"
918 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
919 "\"Test6\"=\"Value6\"\n\n", &r);
920 todo_wine ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
921 todo_wine verify_reg(hkey, "Test6", REG_SZ, "Value6", 7, 0);
922
923 test_import_str("REGEDIT4\n\n"
924 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
925 "\"Line1\"=\"Value1\"\n\n"
926 "\"Line2\"=\"Value2\"\n\n\n"
927 "\"Line3\"=\"Value3\"\n\n\n\n"
928 "\"Line4\"=\"Value4\"\n\n", &r);
929 todo_wine ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
930 todo_wine verify_reg(hkey, "Line1", REG_SZ, "Value1", 7, TODO_REG_TYPE|TODO_REG_SIZE|TODO_REG_DATA);
931 todo_wine verify_reg(hkey, "Line2", REG_SZ, "Value2", 7, TODO_REG_TYPE|TODO_REG_SIZE|TODO_REG_DATA);
932 todo_wine verify_reg(hkey, "Line3", REG_SZ, "Value3", 7, TODO_REG_TYPE|TODO_REG_SIZE|TODO_REG_DATA);
933 todo_wine verify_reg(hkey, "Line4", REG_SZ, "Value4", 7, TODO_REG_TYPE|TODO_REG_SIZE|TODO_REG_DATA);
934
935 test_import_str("REGEDIT4\n\n"
936 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
937 "\"Wine1\"=dword:00000782\n\n"
938 "\"Wine2\"=\"Test Value\"\n"
939 "\"Wine3\"=hex(7):4c,69,6e,65,20,\\\n"
940 " 63,6f,6e,63,61,74,65,6e,61,74,69,6f,6e,00,00\n"
941 "#comment\n"
942 "@=\"Test\"\n"
943 ";comment\n\n"
944 "\"Wine4\"=dword:12345678\n\n", &r);
945 todo_wine ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
946 dword = 0x782;
947 todo_wine verify_reg(hkey, "Wine1", REG_DWORD, &dword, sizeof(dword),
948 TODO_REG_TYPE|TODO_REG_SIZE|TODO_REG_DATA);
949 todo_wine verify_reg(hkey, "Wine2", REG_SZ, "Test Value", 11,
950 TODO_REG_TYPE|TODO_REG_SIZE|TODO_REG_DATA);
951 todo_wine verify_reg(hkey, "Wine3", REG_MULTI_SZ, "Line concatenation\0", 20,
952 TODO_REG_TYPE|TODO_REG_SIZE|TODO_REG_DATA);
953 todo_wine verify_reg(hkey, "", REG_SZ, "Test", 5,
954 TODO_REG_TYPE|TODO_REG_SIZE|TODO_REG_DATA);
955 dword = 0x12345678;
956 todo_wine verify_reg(hkey, "Wine4", REG_DWORD, &dword, sizeof(dword),
957 TODO_REG_TYPE|TODO_REG_SIZE|TODO_REG_DATA);
958
959 test_import_str("REGEDIT4\n\n"
960 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
961 "\"Wine5\"=\"No newline\"", &r);
962 todo_wine ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
963 err = RegQueryValueExA(hkey, "Wine5", NULL, NULL, NULL, NULL);
964 todo_wine ok(err == ERROR_SUCCESS || broken(err == ERROR_FILE_NOT_FOUND /* WinXP */),
965 "got %d, expected 0\n", err);
966 if (err == ERROR_SUCCESS)
967 verify_reg(hkey, "Wine5", REG_SZ, "No newline", 11, 0);
968
969 test_import_str("REGEDIT4\n\n"
970 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
971 "\"Wine6\"=dword:00000050\n\n"
972 "\"Wine7\"=\"No newline\"", &r);
973 todo_wine ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
974 dword = 0x50;
975 todo_wine verify_reg(hkey, "Wine6", REG_DWORD, &dword, sizeof(dword),
976 TODO_REG_TYPE|TODO_REG_SIZE|TODO_REG_DATA);
977 err = RegQueryValueExA(hkey, "Wine7", NULL, NULL, NULL, NULL);
978 todo_wine ok(err == ERROR_SUCCESS || broken(err == ERROR_FILE_NOT_FOUND /* WinXP */),
979 "got %d, expected 0\n", err);
980 if (err == ERROR_SUCCESS)
981 verify_reg(hkey, "Wine7", REG_SZ, "No newline", 11, 0);
982
983 test_import_str("REGEDIT4\n\n"
984 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
985 "#comment\\\n"
986 "\"Wine8\"=\"Line 1\"\n"
987 ";comment\\\n"
988 "\"Wine9\"=\"Line 2\"\n\n", &r);
989 todo_wine ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
990 todo_wine verify_reg(hkey, "Wine8", REG_SZ, "Line 1", 7, 0);
991 todo_wine verify_reg(hkey, "Wine9", REG_SZ, "Line 2", 7, 0);
992
993 test_import_str("REGEDIT4\n\n"
994 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
995 "\"Wine10\"=\"Value 1\"#comment\n"
996 "\"Wine11\"=\"Value 2\";comment\n"
997 "\"Wine12\"=dword:01020304 #comment\n"
998 "\"Wine13\"=dword:02040608 ;comment\n\n", &r);
999 todo_wine ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
1000 todo_wine verify_reg_nonexist(hkey, "Wine10");
1001 todo_wine verify_reg(hkey, "Wine11", REG_SZ, "Value 2", 8, 0);
1002 todo_wine verify_reg_nonexist(hkey, "Wine12");
1003 dword = 0x2040608;
1004 todo_wine verify_reg(hkey, "Wine13", REG_DWORD, &dword, sizeof(dword), 0);
1005
1006 test_import_str("REGEDIT4\n\n"
1007 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1008 "\"Wine14\"=hex(7):4c,69,6e,65,20,\\\n"
1009 " #comment\n"
1010 " 63,6f,6e,63,61,74,65,6e,61,74,69,6f,6e,00,00\n"
1011 "\"Wine15\"=\"A valid line\"\n"
1012 "\"Wine16\"=hex(7):4c,69,6e,65,20,\\\n"
1013 " ;comment\n"
1014 " 63,6f,6e,63,61,74,65,6e,61,74,69,6f,6e,00,00\n"
1015 "\"Wine17\"=\"Another valid line\"\n\n", &r);
1016 todo_wine ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
1017 todo_wine verify_reg_nonexist(hkey, "Wine14");
1018 todo_wine verify_reg(hkey, "Wine15", REG_SZ, "A valid line", 13, 0);
1019 todo_wine verify_reg(hkey, "Wine16", REG_MULTI_SZ, "Line concatenation\0", 20, 0);
1020 todo_wine verify_reg(hkey, "Wine17", REG_SZ, "Another valid line", 19, 0);
1021
1022 test_import_str("REGEDIT4\n\n"
1023 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1024 "#\"Comment1\"=\"Value 1\"\n"
1025 ";\"Comment2\"=\"Value 2\"\n"
1026 " #\"Comment3\"=\"Value 3\"\n"
1027 " ;\"Comment4\"=\"Value 4\"\n"
1028 "\"Wine18\"=\"Value 6\"#\"Comment5\"=\"Value 5\"\n"
1029 "\"Wine19\"=\"Value 7\";\"Comment6\"=\"Value 6\"\n\n", &r);
1030 todo_wine ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
1031 todo_wine verify_reg_nonexist(hkey, "Comment1");
1032 todo_wine verify_reg_nonexist(hkey, "Comment2");
1033 todo_wine verify_reg_nonexist(hkey, "Comment3");
1034 todo_wine verify_reg_nonexist(hkey, "Comment4");
1035 todo_wine verify_reg_nonexist(hkey, "Wine18");
1036 todo_wine verify_reg_nonexist(hkey, "Comment5");
1037 todo_wine verify_reg(hkey, "Wine19", REG_SZ, "Value 7", 8, TODO_REG_SIZE|TODO_REG_DATA);
1038 todo_wine verify_reg_nonexist(hkey, "Comment6");
1039
1040 test_import_str("REGEDIT4\n\n"
1041 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1042 "\"Wine20\"=#\"Value 8\"\n"
1043 "\"Wine21\"=;\"Value 9\"\n"
1044 "\"Wine22\"=\"#comment1\"\n"
1045 "\"Wine23\"=\";comment2\"\n"
1046 "\"Wine24\"=\"Value#comment3\"\n"
1047 "\"Wine25\"=\"Value;comment4\"\n"
1048 "\"Wine26\"=\"Value #comment5\"\n"
1049 "\"Wine27\"=\"Value ;comment6\"\n"
1050 "\"Wine28\"=#dword:00000001\n"
1051 "\"Wine29\"=;dword:00000002\n"
1052 "\"Wine30\"=dword:00000003#comment\n"
1053 "\"Wine31\"=dword:00000004;comment\n\n", &r);
1054 todo_wine ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
1055 todo_wine verify_reg_nonexist(hkey, "Wine20");
1056 todo_wine verify_reg_nonexist(hkey, "Wine21");
1057 todo_wine verify_reg(hkey, "Wine22", REG_SZ, "#comment1", 10, 0);
1058 todo_wine verify_reg(hkey, "Wine23", REG_SZ, ";comment2", 10, 0);
1059 todo_wine verify_reg(hkey, "Wine24", REG_SZ, "Value#comment3", 15, 0);
1060 todo_wine verify_reg(hkey, "Wine25", REG_SZ, "Value;comment4", 15, 0);
1061 todo_wine verify_reg(hkey, "Wine26", REG_SZ, "Value #comment5", 16, 0);
1062 todo_wine verify_reg(hkey, "Wine27", REG_SZ, "Value ;comment6", 16, 0);
1063 todo_wine verify_reg_nonexist(hkey, "Wine28");
1064 todo_wine verify_reg_nonexist(hkey, "Wine29");
1065 todo_wine verify_reg_nonexist(hkey, "Wine30");
1066 dword = 0x00000004;
1067 todo_wine verify_reg(hkey, "Wine31", REG_DWORD, &dword, sizeof(dword), 0);
1068
1069 test_import_str("REGEDIT4\n\n"
1070 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1071 "\"Multi-Line1\"=hex(7):4c,69,6e,65,20,\\\n"
1072 " 63,6f,6e,\\;comment\n"
1073 " 63,61,74,\\;comment\n"
1074 " 65,6e,61,74,69,6f,6e,00,00\n\n", &r);
1075 todo_wine ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
1076 todo_wine verify_reg(hkey, "Multi-Line1", REG_MULTI_SZ, "Line concatenation\0", 20, 0);
1077
1078 test_import_str("REGEDIT4\n\n"
1079 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1080 "\"Multi-Line2\"=hex(7):4c,69,6e,65,20,\\\n"
1081 " 63,6f,6e,\\;comment\n"
1082 " 63,61,74,;comment\n"
1083 " 65,6e,61,74,69,6f,6e,00,00\n\n", &r);
1084 todo_wine ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
1085 todo_wine verify_reg(hkey, "Multi-Line2", REG_MULTI_SZ, "Line concat", 12, 0);
1086
1087 test_import_str("REGEDIT4\n\n"
1088 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1089 "\"double\\\"quote\"=\"valid \\\"or\\\" not\"\n"
1090 "\"single'quote\"=dword:00000008\n\n", &r);
1091 todo_wine ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
1092 todo_wine verify_reg(hkey, "double\"quote", REG_SZ, "valid \"or\" not", 15, 0);
1093 dword = 0x00000008;
1094 todo_wine verify_reg(hkey, "single'quote", REG_DWORD, &dword, sizeof(dword), 0);
1095
1096 test_import_str("REGEDIT4\n\n"
1097 "[HKEY_CURRENT_USER\\" KEY_BASE "\\Subkey\"1]\n"
1098 "\"Wine\\\\31\"=\"Test value\"\n\n", &r);
1099 todo_wine ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
1100 err = RegOpenKeyExA(hkey, "Subkey\"1", 0, KEY_READ, &subkey);
1101 todo_wine ok(err == ERROR_SUCCESS, "got %d, expected 0\n", err);
1102 todo_wine verify_reg(subkey, "Wine\\31", REG_SZ, "Test value", 11, 0);
1103 err = RegCloseKey(subkey);
1104 todo_wine ok(err == ERROR_SUCCESS, "got %d, expected 0\n", err);
1105 err = RegDeleteKeyA(HKEY_CURRENT_USER, KEY_BASE "\\Subkey\"1");
1106 todo_wine ok(err == ERROR_SUCCESS, "got %d, expected 0\n", err);
1107
1108 test_import_str("REGEDIT4\n\n"
1109 "[HKEY_CURRENT_USER\\" KEY_BASE "\\Subkey/2]\n"
1110 "\"123/\\\"4;'5\"=\"Random value name\"\n\n", &r);
1111 todo_wine ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
1112 err = RegOpenKeyExA(hkey, "Subkey/2", 0, KEY_READ, &subkey);
1113 todo_wine ok(err == ERROR_SUCCESS, "got %d, expected 0\n", err);
1114 todo_wine verify_reg(subkey, "123/\"4;'5", REG_SZ, "Random value name", 18, 0);
1115 err = RegCloseKey(subkey);
1116 todo_wine ok(err == ERROR_SUCCESS, "got %d, expected 0\n", err);
1117 err = RegDeleteKeyA(HKEY_CURRENT_USER, KEY_BASE "\\Subkey/2");
1118 todo_wine ok(err == ERROR_SUCCESS, "got %d, expected 0\n", err);
1119
1120 err = RegCloseKey(hkey);
1121 todo_wine ok(err == ERROR_SUCCESS, "got %d, expected 0\n", err);
1122
1123 err = RegDeleteKeyA(HKEY_CURRENT_USER, KEY_BASE);
1124 todo_wine ok(err == ERROR_SUCCESS, "got %d, expected 0\n", err);
1125
1126 /* Test file contents - Unicode */
1127 test_import_wstr("REGEDIT\n", &r);
1128 ok(r == REG_EXIT_FAILURE || broken(r == REG_EXIT_SUCCESS) /* WinXP */,
1129 "got exit code %d, expected 1\n", r);
1130
1131 test_import_wstr("REGEDIT4\n", &r);
1132 ok(r == REG_EXIT_FAILURE || broken(r == REG_EXIT_SUCCESS) /* WinXP */,
1133 "got exit code %d, expected 1\n", r);
1134
1135 test_import_wstr("\xef\xbb\xbfREGEDIT", &r);
1136 todo_wine ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
1137
1138 test_import_wstr("\xef\xbb\xbfREGEDIT\n", &r);
1139 todo_wine ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
1140
1141 test_import_wstr("\xef\xbb\xbfREGEDIT4", &r);
1142 todo_wine ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
1143
1144 test_import_wstr("\xef\xbb\xbfREGEDIT4\n", &r);
1145 todo_wine ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
1146
1147 test_import_wstr("\xef\xbb\xbf REGEDIT4\n", &r);
1148 todo_wine ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
1149
1150 test_import_wstr("\xef\xbb\xbf\tREGEDIT4\n", &r);
1151 todo_wine ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
1152
1153 test_import_wstr("\xef\xbb\xbf\nREGEDIT4\n", &r);
1154 ok(r == REG_EXIT_FAILURE || broken(r == REG_EXIT_SUCCESS) /* WinXP */,
1155 "got exit code %d, expected 1\n", r);
1156
1157 test_import_wstr("\xef\xbb\xbfREGEDIT4\n"
1158 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n", &r);
1159 todo_wine ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
1160
1161 err = RegOpenKeyExA(HKEY_CURRENT_USER, KEY_BASE, 0, KEY_READ, &hkey);
1162 todo_wine ok(err == ERROR_SUCCESS, "got %d, expected 0\n", err);
1163
1164 test_import_wstr("\xef\xbb\xbfREGEDIT4\n"
1165 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1166 "\"Unicode1\"=\"Value1\"\n", &r);
1167 todo_wine ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
1168 todo_wine verify_reg(hkey, "Unicode1", REG_SZ, "Value1", 7, 0);
1169
1170 test_import_wstr("\xef\xbb\xbfREGEDIT4\n"
1171 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1172 "\"Unicode2\"=\"Value2\"\n\n", &r);
1173 todo_wine ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
1174 todo_wine verify_reg(hkey, "Unicode2", REG_SZ, "Value2", 7, 0);
1175
1176 test_import_wstr("\xef\xbb\xbfREGEDIT4\n\n"
1177 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1178 "\"Unicode3\"=\"Value3\"\n\n", &r);
1179 todo_wine ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
1180 todo_wine verify_reg(hkey, "Unicode3", REG_SZ, "Value3", 7, 0);
1181
1182 test_import_wstr("Windows Registry Editor Version 4.00\n", &r);
1183 ok(r == REG_EXIT_FAILURE || broken(r == REG_EXIT_SUCCESS) /* WinXP */,
1184 "got exit code %d, expected 1\n", r);
1185
1186 test_import_wstr("Windows Registry Editor Version 5.00\n", &r);
1187 ok(r == REG_EXIT_FAILURE || broken(r == REG_EXIT_SUCCESS) /* WinXP */,
1188 "got exit code %d, expected 1\n", r);
1189
1190 test_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5\n", &r);
1191 ok(r == REG_EXIT_FAILURE || broken(r == REG_EXIT_SUCCESS) /* WinXP */,
1192 "got exit code %d, expected 1\n", r);
1193
1194 test_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00", &r);
1195 todo_wine ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
1196
1197 test_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n", &r);
1198 todo_wine ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
1199
1200 test_import_wstr("\xef\xbb\xbfWINDOWS Registry Editor Version 5.00\n", &r);
1201 ok(r == REG_EXIT_FAILURE || broken(r == REG_EXIT_SUCCESS) /* WinXP */,
1202 "got exit code %d, expected 1\n", r);
1203
1204 test_import_wstr("\xef\xbb\xbf Windows Registry Editor Version 5.00\n", &r);
1205 todo_wine ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
1206
1207 test_import_wstr("\xef\xbb\xbf\tWindows Registry Editor Version 5.00\n", &r);
1208 todo_wine ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
1209
1210 test_import_wstr("\xef\xbb\xbf\nWindows Registry Editor Version 5.00\n", &r);
1211 ok(r == REG_EXIT_FAILURE || broken(r == REG_EXIT_SUCCESS) /* WinXP */,
1212 "got exit code %d, expected 1\n", r);
1213
1214 test_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n"
1215 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1216 "\"Unicode4\"=\"Value4\"\n", &r);
1217 todo_wine ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
1218 todo_wine verify_reg(hkey, "Unicode4", REG_SZ, "Value4", 7, 0);
1219
1220 test_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n"
1221 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1222 "\"Unicode5\"=\"Value5\"\n\n", &r);
1223 todo_wine ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
1224 todo_wine verify_reg(hkey, "Unicode5", REG_SZ, "Value5", 7, 0);
1225
1226 test_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
1227 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1228 "\"Unicode6\"=\"Value6\"\n\n", &r);
1229 todo_wine ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
1230 todo_wine verify_reg(hkey, "Unicode6", REG_SZ, "Value6", 7, 0);
1231
1232 test_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
1233 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1234 "\"Line1\"=\"Value1\"\n\n"
1235 "\"Line2\"=\"Value2\"\n\n\n"
1236 "\"Line3\"=\"Value3\"\n\n\n\n"
1237 "\"Line4\"=\"Value4\"\n\n", &r);
1238 todo_wine ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
1239 todo_wine verify_reg(hkey, "Line1", REG_SZ, "Value1", 7, TODO_REG_TYPE|TODO_REG_SIZE|TODO_REG_DATA);
1240 todo_wine verify_reg(hkey, "Line2", REG_SZ, "Value2", 7, TODO_REG_TYPE|TODO_REG_SIZE|TODO_REG_DATA);
1241 todo_wine verify_reg(hkey, "Line3", REG_SZ, "Value3", 7, TODO_REG_TYPE|TODO_REG_SIZE|TODO_REG_DATA);
1242 todo_wine verify_reg(hkey, "Line4", REG_SZ, "Value4", 7, TODO_REG_TYPE|TODO_REG_SIZE|TODO_REG_DATA);
1243
1244 test_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
1245 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1246 "\"Wine1\"=dword:00000782\n\n"
1247 "\"Wine2\"=\"Test Value\"\n"
1248 "\"Wine3\"=hex(7):4c,00,69,00,6e,00,65,00,20,00,63,00,6f,00,6e,00,63,00,\\\n"
1249 " 61,00,74,00,65,00,6e,00,61,00,74,00,69,00,6f,00,6e,00,00,00,00,00\n"
1250 "#comment\n"
1251 "@=\"Test\"\n"
1252 ";comment\n\n"
1253 "\"Wine4\"=dword:12345678\n\n", &r);
1254 todo_wine ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
1255 dword = 0x782;
1256 todo_wine verify_reg(hkey, "Wine1", REG_DWORD, &dword, sizeof(dword),
1257 TODO_REG_TYPE|TODO_REG_SIZE|TODO_REG_DATA);
1258 todo_wine verify_reg(hkey, "Wine2", REG_SZ, "Test Value", 11,
1259 TODO_REG_TYPE|TODO_REG_SIZE|TODO_REG_DATA);
1260 todo_wine verify_reg(hkey, "Wine3", REG_MULTI_SZ, "Line concatenation\0", 20,
1261 TODO_REG_TYPE|TODO_REG_SIZE|TODO_REG_DATA);
1262 todo_wine verify_reg(hkey, "", REG_SZ, "Test", 5,
1263 TODO_REG_TYPE|TODO_REG_SIZE|TODO_REG_DATA);
1264 dword = 0x12345678;
1265 todo_wine verify_reg(hkey, "Wine4", REG_DWORD, &dword, sizeof(dword),
1266 TODO_REG_TYPE|TODO_REG_SIZE|TODO_REG_DATA);
1267
1268 test_import_wstr("\xef\xbb\xbfREGEDIT4\n\n"
1269 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1270 "\"Wine5\"=\"No newline\"", &r);
1271 todo_wine ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
1272 err = RegQueryValueExA(hkey, "Wine5", NULL, NULL, NULL, NULL);
1273 todo_wine ok(err == ERROR_SUCCESS || broken(err == ERROR_FILE_NOT_FOUND /* WinXP */),
1274 "got %d, expected 0\n", err);
1275 if (err == ERROR_SUCCESS)
1276 verify_reg(hkey, "Wine5", REG_SZ, "No newline", 11, 0);
1277
1278 test_import_wstr("\xef\xbb\xbfREGEDIT4\n\n"
1279 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1280 "\"Wine6\"=dword:00000050\n\n"
1281 "\"Wine7\"=\"No newline\"", &r);
1282 todo_wine ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
1283 dword = 0x50;
1284 todo_wine verify_reg(hkey, "Wine6", REG_DWORD, &dword, sizeof(dword),
1285 TODO_REG_TYPE|TODO_REG_SIZE|TODO_REG_DATA);
1286 err = RegQueryValueExA(hkey, "Wine7", NULL, NULL, NULL, NULL);
1287 todo_wine ok(err == ERROR_SUCCESS || broken(err == ERROR_FILE_NOT_FOUND /* WinXP */),
1288 "got %d, expected 0\n", err);
1289 if (err == ERROR_SUCCESS)
1290 verify_reg(hkey, "Wine7", REG_SZ, "No newline", 11, 0);
1291
1292 test_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
1293 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1294 "#comment\\\n"
1295 "\"Wine8\"=\"Line 1\"\n"
1296 ";comment\\\n"
1297 "\"Wine9\"=\"Line 2\"\n\n", &r);
1298 todo_wine ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
1299 todo_wine verify_reg(hkey, "Wine8", REG_SZ, "Line 1", 7, 0);
1300 todo_wine verify_reg(hkey, "Wine9", REG_SZ, "Line 2", 7, 0);
1301
1302 test_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
1303 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1304 "\"Wine10\"=\"Value 1\"#comment\n"
1305 "\"Wine11\"=\"Value 2\";comment\n"
1306 "\"Wine12\"=dword:01020304 #comment\n"
1307 "\"Wine13\"=dword:02040608 ;comment\n\n", &r);
1308 todo_wine ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
1309 todo_wine verify_reg_nonexist(hkey, "Wine10");
1310 todo_wine verify_reg(hkey, "Wine11", REG_SZ, "Value 2", 8, 0);
1311 todo_wine verify_reg_nonexist(hkey, "Wine12");
1312 dword = 0x2040608;
1313 todo_wine verify_reg(hkey, "Wine13", REG_DWORD, &dword, sizeof(dword), 0);
1314
1315 test_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
1316 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1317 "\"Wine14\"=hex(7):4c,00,69,00,6e,00,65,00,20,00,63,00,6f,00,6e,00,63,00,\\\n"
1318 " #comment\n"
1319 " 61,00,74,00,65,00,6e,00,61,00,74,00,69,00,6f,00,6e,00,00,00,00,00\n"
1320 "\"Wine15\"=\"A valid line\"\n"
1321 "\"Wine16\"=hex(7):4c,00,69,00,6e,00,65,00,20,00,63,00,6f,00,6e,00,63,00,\\\n"
1322 " ;comment\n"
1323 " 61,00,74,00,65,00,6e,00,61,00,74,00,69,00,6f,00,6e,00,00,00,00,00\n"
1324 "\"Wine17\"=\"Another valid line\"\n\n", &r);
1325 todo_wine ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
1326 todo_wine verify_reg_nonexist(hkey, "Wine14");
1327 todo_wine verify_reg(hkey, "Wine15", REG_SZ, "A valid line", 13, 0);
1328 todo_wine verify_reg(hkey, "Wine16", REG_MULTI_SZ, "Line concatenation\0", 20, 0);
1329 todo_wine verify_reg(hkey, "Wine17", REG_SZ, "Another valid line", 19, 0);
1330
1331 test_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
1332 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1333 "#\"Comment1\"=\"Value 1\"\n"
1334 ";\"Comment2\"=\"Value 2\"\n"
1335 " #\"Comment3\"=\"Value 3\"\n"
1336 " ;\"Comment4\"=\"Value 4\"\n"
1337 "\"Wine18\"=\"Value 6\"#\"Comment5\"=\"Value 5\"\n"
1338 "\"Wine19\"=\"Value 7\";\"Comment6\"=\"Value 6\"\n\n", &r);
1339 todo_wine ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
1340 todo_wine verify_reg_nonexist(hkey, "Comment1");
1341 todo_wine verify_reg_nonexist(hkey, "Comment2");
1342 todo_wine verify_reg_nonexist(hkey, "Comment3");
1343 todo_wine verify_reg_nonexist(hkey, "Comment4");
1344 todo_wine verify_reg_nonexist(hkey, "Wine18");
1345 todo_wine verify_reg_nonexist(hkey, "Comment5");
1346 todo_wine verify_reg(hkey, "Wine19", REG_SZ, "Value 7", 8, TODO_REG_SIZE|TODO_REG_DATA);
1347 todo_wine verify_reg_nonexist(hkey, "Comment6");
1348
1349 test_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
1350 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1351 "\"Wine20\"=#\"Value 8\"\n"
1352 "\"Wine21\"=;\"Value 9\"\n"
1353 "\"Wine22\"=\"#comment1\"\n"
1354 "\"Wine23\"=\";comment2\"\n"
1355 "\"Wine24\"=\"Value#comment3\"\n"
1356 "\"Wine25\"=\"Value;comment4\"\n"
1357 "\"Wine26\"=\"Value #comment5\"\n"
1358 "\"Wine27\"=\"Value ;comment6\"\n"
1359 "\"Wine28\"=#dword:00000001\n"
1360 "\"Wine29\"=;dword:00000002\n"
1361 "\"Wine30\"=dword:00000003#comment\n"
1362 "\"Wine31\"=dword:00000004;comment\n\n", &r);
1363 todo_wine ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
1364 todo_wine verify_reg_nonexist(hkey, "Wine20");
1365 todo_wine verify_reg_nonexist(hkey, "Wine21");
1366 todo_wine verify_reg(hkey, "Wine22", REG_SZ, "#comment1", 10, 0);
1367 todo_wine verify_reg(hkey, "Wine23", REG_SZ, ";comment2", 10, 0);
1368 todo_wine verify_reg(hkey, "Wine24", REG_SZ, "Value#comment3", 15, 0);
1369 todo_wine verify_reg(hkey, "Wine25", REG_SZ, "Value;comment4", 15, 0);
1370 todo_wine verify_reg(hkey, "Wine26", REG_SZ, "Value #comment5", 16, 0);
1371 todo_wine verify_reg(hkey, "Wine27", REG_SZ, "Value ;comment6", 16, 0);
1372 todo_wine verify_reg_nonexist(hkey, "Wine28");
1373 todo_wine verify_reg_nonexist(hkey, "Wine29");
1374 todo_wine verify_reg_nonexist(hkey, "Wine30");
1375 dword = 0x00000004;
1376 todo_wine verify_reg(hkey, "Wine31", REG_DWORD, &dword, sizeof(dword), 0);
1377
1378 test_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
1379 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1380 "\"Multi-Line1\"=hex(7):4c,00,69,00,6e,00,65,00,20,00,\\\n"
1381 " 63,00,6f,00,6e,00,\\;comment\n"
1382 " 63,00,61,00,74,00,\\;comment\n"
1383 " 65,00,6e,00,61,00,74,00,69,00,6f,00,6e,00,00,00,00,00\n\n", &r);
1384 todo_wine ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
1385 todo_wine verify_reg(hkey, "Multi-Line1", REG_MULTI_SZ, "Line concatenation\0", 20, 0);
1386
1387 test_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
1388 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1389 "\"Multi-Line2\"=hex(7):4c,00,69,00,6e,00,65,00,20,00,\\\n"
1390 " 63,00,6f,00,6e,00,\\;comment\n"
1391 " 63,00,61,00,74,00,;comment\n"
1392 " 65,00,6e,00,61,00,74,00,69,00,6f,00,6e,00,00,00,00,00\n\n", &r);
1393 todo_wine ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
1394 todo_wine verify_reg(hkey, "Multi-Line2", REG_MULTI_SZ, "Line concat", 12, 0);
1395
1396 test_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
1397 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1398 "\"double\\\"quote\"=\"valid \\\"or\\\" not\"\n"
1399 "\"single'quote\"=dword:00000008\n\n", &r);
1400 todo_wine ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
1401 todo_wine verify_reg(hkey, "double\"quote", REG_SZ, "valid \"or\" not", 15, 0);
1402 dword = 0x00000008;
1403 todo_wine verify_reg(hkey, "single'quote", REG_DWORD, &dword, sizeof(dword), 0);
1404
1405 test_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
1406 "[HKEY_CURRENT_USER\\" KEY_BASE "\\Subkey\"1]\n"
1407 "\"Wine\\\\31\"=\"Test value\"\n\n", &r);
1408 todo_wine ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
1409 err = RegOpenKeyExA(hkey, "Subkey\"1", 0, KEY_READ, &subkey);
1410 todo_wine ok(err == ERROR_SUCCESS, "got %d, expected 0\n", err);
1411 todo_wine verify_reg(subkey, "Wine\\31", REG_SZ, "Test value", 11, 0);
1412 err = RegCloseKey(subkey);
1413 todo_wine ok(err == ERROR_SUCCESS, "got %d, expected 0\n", err);
1414 err = RegDeleteKeyA(HKEY_CURRENT_USER, KEY_BASE "\\Subkey\"1");
1415 todo_wine ok(err == ERROR_SUCCESS, "got %d, expected 0\n", err);
1416
1417 test_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
1418 "[HKEY_CURRENT_USER\\" KEY_BASE "\\Subkey/2]\n"
1419 "\"123/\\\"4;'5\"=\"Random value name\"\n\n", &r);
1420 todo_wine ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
1421 err = RegOpenKeyExA(hkey, "Subkey/2", 0, KEY_READ, &subkey);
1422 todo_wine ok(err == ERROR_SUCCESS, "got %d, expected 0\n", err);
1423 todo_wine verify_reg(subkey, "123/\"4;'5", REG_SZ, "Random value name", 18, 0);
1424 err = RegCloseKey(subkey);
1425 todo_wine ok(err == ERROR_SUCCESS, "got %d, expected 0\n", err);
1426 err = RegDeleteKeyA(HKEY_CURRENT_USER, KEY_BASE "\\Subkey/2");
1427 todo_wine ok(err == ERROR_SUCCESS, "got %d, expected 0\n", err);
1428
1429 err = RegCloseKey(hkey);
1430 todo_wine ok(err == ERROR_SUCCESS, "got %d, expected 0\n", err);
1431
1432 err = RegDeleteKeyA(HKEY_CURRENT_USER, KEY_BASE);
1433 todo_wine ok(err == ERROR_SUCCESS, "got %d, expected 0\n", err);
1434 }
1435
1436 START_TEST(reg)
1437 {
1438 DWORD r;
1439 if (!run_reg_exe("reg.exe /?", &r)) {
1440 win_skip("reg.exe not available, skipping reg.exe tests\n");
1441 return;
1442 }
1443
1444 test_add();
1445 test_delete();
1446 test_query();
1447 test_v_flags();
1448 test_import();
1449 }