656762a4b030ca3487f3b0ededf6ebea639b8ae2
[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 <winreg.h>
23
24 #define lok ok_(__FILE__,line)
25 #define KEY_BASE "Software\\Wine\\reg_test"
26 #define REG_EXIT_SUCCESS 0
27 #define REG_EXIT_FAILURE 1
28 #define TODO_REG_TYPE (0x0001u)
29 #define TODO_REG_SIZE (0x0002u)
30 #define TODO_REG_DATA (0x0004u)
31
32 #define run_reg_exe(c,r) run_reg_exe_(__LINE__,c,r)
33 static BOOL run_reg_exe_(unsigned line, const char *cmd, DWORD *rc)
34 {
35 STARTUPINFOA si = {sizeof(STARTUPINFOA)};
36 PROCESS_INFORMATION pi;
37 BOOL bret;
38 DWORD ret;
39 char cmdline[256];
40
41 si.dwFlags = STARTF_USESTDHANDLES;
42 si.hStdInput = INVALID_HANDLE_VALUE;
43 si.hStdOutput = INVALID_HANDLE_VALUE;
44 si.hStdError = INVALID_HANDLE_VALUE;
45
46 strcpy(cmdline, cmd);
47 if (!CreateProcessA(NULL, cmdline, NULL, NULL, TRUE, 0, NULL, NULL, &si, &pi))
48 return FALSE;
49
50 ret = WaitForSingleObject(pi.hProcess, 10000);
51 if (ret == WAIT_TIMEOUT)
52 TerminateProcess(pi.hProcess, 1);
53
54 bret = GetExitCodeProcess(pi.hProcess, rc);
55 lok(bret, "GetExitCodeProcess failed: %d\n", GetLastError());
56
57 CloseHandle(pi.hThread);
58 CloseHandle(pi.hProcess);
59 return bret;
60 }
61
62 #define verify_reg(k,v,t,d,s,todo) verify_reg_(__LINE__,k,v,t,d,s,todo)
63 static void verify_reg_(unsigned line, HKEY hkey, const char* value,
64 DWORD exp_type, const void *exp_data, DWORD exp_size, DWORD todo)
65 {
66 DWORD type, size;
67 BYTE data[256];
68 LONG err;
69
70 size = sizeof(data);
71 memset(data, 0xdd, size);
72 err = RegQueryValueExA(hkey, value, NULL, &type, data, &size);
73 lok(err == ERROR_SUCCESS, "RegQueryValueEx failed: got %d\n", err);
74 if (err != ERROR_SUCCESS)
75 return;
76
77 todo_wine_if (todo & TODO_REG_TYPE)
78 lok(type == exp_type, "got wrong type %d, expected %d\n", type, exp_type);
79 todo_wine_if (todo & TODO_REG_SIZE)
80 lok(size == exp_size, "got wrong size %d, expected %d\n", size, exp_size);
81 todo_wine_if (todo & TODO_REG_DATA)
82 lok(memcmp(data, exp_data, size) == 0, "got wrong data\n");
83 }
84
85 static void test_add(void)
86 {
87 HKEY hkey, subkey;
88 LONG err;
89 DWORD r, dword, type, size;
90 char buffer[22];
91
92 run_reg_exe("reg add", &r);
93 ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
94
95 run_reg_exe("reg add /?", &r);
96 ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
97
98 err = RegDeleteKeyA(HKEY_CURRENT_USER, KEY_BASE);
99 ok(err == ERROR_SUCCESS || err == ERROR_FILE_NOT_FOUND, "got %d\n", err);
100
101 err = RegOpenKeyExA(HKEY_CURRENT_USER, KEY_BASE, 0, KEY_READ, &hkey);
102 ok(err == ERROR_FILE_NOT_FOUND, "got %d\n", err);
103
104 run_reg_exe("reg add HKCU\\" KEY_BASE " /f", &r);
105 ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
106
107 err = RegOpenKeyExA(HKEY_CURRENT_USER, KEY_BASE, 0, KEY_READ, &hkey);
108 ok(err == ERROR_SUCCESS, "key creation failed, got %d\n", err);
109
110 /* Test empty type */
111 run_reg_exe("reg add HKCU\\" KEY_BASE " /v emptyType /t \"\" /d WineTest /f", &r);
112 ok(r == REG_EXIT_FAILURE, "got exit code %u\n", r);
113
114 /* Test input key formats */
115 run_reg_exe("reg add \\HKCU\\" KEY_BASE "\\keytest0 /f", &r);
116 ok(r == REG_EXIT_FAILURE, "got exit code %u\n", r);
117 err = RegDeleteKeyA(HKEY_CURRENT_USER, KEY_BASE "\\keytest0");
118 ok(err == ERROR_FILE_NOT_FOUND, "got exit code %d\n", r);
119
120 run_reg_exe("reg add \\\\HKCU\\" KEY_BASE "\\keytest1 /f", &r);
121 ok(r == REG_EXIT_FAILURE, "got exit code %u\n", r);
122 err = RegDeleteKeyA(HKEY_CURRENT_USER, KEY_BASE "\\keytest1");
123 ok(err == ERROR_FILE_NOT_FOUND, "got exit code %d\n", r);
124
125 run_reg_exe("reg add HKCU\\" KEY_BASE "\\keytest2\\\\ /f", &r);
126 ok(r == REG_EXIT_FAILURE || broken(r == REG_EXIT_SUCCESS /* WinXP */),
127 "got exit code %u\n", r);
128 err = RegDeleteKeyA(HKEY_CURRENT_USER, KEY_BASE "\\keytest2");
129 ok(err == ERROR_FILE_NOT_FOUND || broken(err == ERROR_SUCCESS /* WinXP */),
130 "got exit code %d\n", r);
131
132 run_reg_exe("reg add HKCU\\" KEY_BASE "\\keytest3\\ /f", &r);
133 ok(r == REG_EXIT_SUCCESS, "got exit code %u\n", r);
134 err = RegOpenKeyExA(HKEY_CURRENT_USER, KEY_BASE "\\keytest3", 0, KEY_READ, &subkey);
135 ok(err == ERROR_SUCCESS, "key creation failed, got %d\n", err);
136 RegCloseKey(subkey);
137 err = RegDeleteKeyA(HKEY_CURRENT_USER, KEY_BASE "\\keytest3");
138 ok(err == ERROR_SUCCESS, "got exit code %d\n", r);
139
140 run_reg_exe("reg add HKCU\\" KEY_BASE "\\keytest4 /f", &r);
141 ok(r == REG_EXIT_SUCCESS, "got exit code %u\n", r);
142 err = RegOpenKeyExA(HKEY_CURRENT_USER, KEY_BASE "\\keytest4", 0, KEY_READ, &subkey);
143 ok(err == ERROR_SUCCESS, "key creation failed, got %d\n", err);
144 RegCloseKey(subkey);
145 err = RegDeleteKeyA(HKEY_CURRENT_USER, KEY_BASE "\\keytest4");
146 ok(err == ERROR_SUCCESS, "got exit code %d\n", r);
147
148 /* REG_NONE */
149 run_reg_exe("reg add HKCU\\" KEY_BASE " /v none0 /d deadbeef /t REG_NONE /f", &r);
150 ok(r == REG_EXIT_SUCCESS, "got exit code %d\n", r);
151 verify_reg(hkey, "none0", REG_NONE, "d\0e\0a\0d\0b\0e\0e\0f\0\0", 18, 0);
152
153 run_reg_exe("reg add HKCU\\" KEY_BASE " /v none1 /t REG_NONE /f", &r);
154 ok(r == REG_EXIT_SUCCESS, "got exit code %u, expected 0\n", r);
155 verify_reg(hkey, "none1", REG_NONE, "\0", 2, 0);
156
157 run_reg_exe("reg add HKCU\\" KEY_BASE " /ve /t REG_NONE /f", &r);
158 ok(r == REG_EXIT_SUCCESS, "got exit code %u, expected 0\n", r);
159 verify_reg(hkey, NULL, REG_NONE, "\0", 2, 0);
160
161 /* REG_SZ */
162 run_reg_exe("reg add HKCU\\" KEY_BASE " /d WineTest /f", &r);
163 ok(r == REG_EXIT_SUCCESS || broken(r == REG_EXIT_FAILURE /* WinXP */),
164 "got exit code %d, expected 0\n", r);
165 if (r == REG_EXIT_SUCCESS)
166 verify_reg(hkey, "", REG_SZ, "WineTest", 9, 0);
167 else
168 win_skip("broken reg.exe detected\n");
169
170 run_reg_exe("reg add HKCU\\" KEY_BASE " /v test /d deadbeef /f", &r);
171 ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
172 verify_reg(hkey, "test", REG_SZ, "deadbeef", 9, 0);
173
174 run_reg_exe("reg add HKCU\\" KEY_BASE " /v test /f", &r);
175 ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
176 verify_reg(hkey, "test", REG_SZ, "", 1, 0);
177
178 run_reg_exe("reg add HKCU\\" KEY_BASE " /v test1 /t REG_SZ /f /d", &r);
179 ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
180
181 run_reg_exe("reg add HKEY_CURRENT_USER\\" KEY_BASE " /ve /d WineTEST /f", &r);
182 ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
183 verify_reg(hkey, "", REG_SZ, "WineTEST", 9, 0);
184
185 run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_SZ /v test2 /f", &r);
186 ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
187 verify_reg(hkey, "test2", REG_SZ, "", 1, 0);
188
189 run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_SZ /v test3 /f /d \"\"", &r);
190 ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
191 verify_reg(hkey, "test3", REG_SZ, "", 1, 0);
192
193 run_reg_exe("reg add HKCU\\" KEY_BASE " /ve /f", &r);
194 ok(r == REG_EXIT_SUCCESS, "got exit code %u, expected 0\n", r);
195 verify_reg(hkey, NULL, REG_SZ, "", 1, 0);
196
197 run_reg_exe("reg add HKCU\\" KEY_BASE " /ve /t REG_SZ /f", &r);
198 ok(r == REG_EXIT_SUCCESS, "got exit code %u, expected 0\n", r);
199 verify_reg(hkey, NULL, REG_SZ, "", 1, 0);
200
201 /* REG_EXPAND_SZ */
202 run_reg_exe("reg add HKCU\\" KEY_BASE " /v expand0 /t REG_EXpand_sz /d \"dead%PATH%beef\" /f", &r);
203 ok(r == REG_EXIT_SUCCESS, "got exit code %u\n", r);
204 verify_reg(hkey, "expand0", REG_EXPAND_SZ, "dead%PATH%beef", 15, 0);
205
206 run_reg_exe("reg add HKCU\\" KEY_BASE " /v expand1 /t REG_EXpand_sz /d \"dead^%PATH^%beef\" /f", &r);
207 ok(r == REG_EXIT_SUCCESS, "got exit code %u\n", r);
208 verify_reg(hkey, "expand1", REG_EXPAND_SZ, "dead^%PATH^%beef", 17, 0);
209
210 run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_EXPAND_SZ /v expand2 /f", &r);
211 ok(r == REG_EXIT_SUCCESS, "got exit code %u\n", r);
212 verify_reg(hkey, "expand2", REG_EXPAND_SZ, "", 1, 0);
213
214 run_reg_exe("reg add HKEY_CURRENT_USER\\" KEY_BASE " /ve /t REG_EXPAND_SZ /d WineTEST /f", &r);
215 ok(r == REG_EXIT_SUCCESS, "got exit code %u\n", r);
216 verify_reg(hkey, "", REG_EXPAND_SZ, "WineTEST", 9, 0);
217
218 run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_EXPAND_SZ /v expand3 /f /d \"\"", &r);
219 ok(r == REG_EXIT_SUCCESS, "got exit code %u\n", r);
220 verify_reg(hkey, "expand3", REG_EXPAND_SZ, "", 1, 0);
221
222 run_reg_exe("reg add HKCU\\" KEY_BASE " /ve /t REG_EXPAND_SZ /f", &r);
223 ok(r == REG_EXIT_SUCCESS, "got exit code %u, expected 0\n", r);
224 verify_reg(hkey, NULL, REG_EXPAND_SZ, "", 1, 0);
225
226 /* REG_BINARY */
227 run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_BINARY /v bin0 /f", &r);
228 ok(r == REG_EXIT_SUCCESS, "got exit code %u\n", r);
229 verify_reg(hkey, "bin0", REG_BINARY, buffer, 0, 0);
230
231 run_reg_exe("reg add HKEY_CURRENT_USER\\" KEY_BASE " /ve /t REG_BINARY /d deadbeef /f", &r);
232 ok(r == REG_EXIT_SUCCESS, "got exit code %u\n", r);
233 dword = 0xefbeadde;
234 verify_reg(hkey, "", REG_BINARY, &dword, sizeof(DWORD), 0);
235
236 run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_BINARY /v bin1 /f /d 0xDeAdBeEf", &r);
237 ok(r == REG_EXIT_FAILURE, "got exit code %u\n", r);
238 run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_BINARY /v bin2 /f /d x01", &r);
239 ok(r == REG_EXIT_FAILURE, "got exit code %u\n", r);
240 run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_BINARY /v bin3 /f /d 01x", &r);
241 ok(r == REG_EXIT_FAILURE, "got exit code %u\n", r);
242
243 run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_BINARY /v bin4 /f /d DeAdBeEf0DD", &r);
244 ok(r == REG_EXIT_SUCCESS, "got exit code %u\n", r);
245 /* Remaining nibble prefixed */
246 buffer[0] = 0x0d; buffer[1] = 0xea; buffer[2] = 0xdb;
247 buffer[3] = 0xee; buffer[4] = 0xf0; buffer[5] = 0xdd;
248 /* Remaining nibble suffixed on winXP */
249 buffer[6] = 0xde; buffer[7] = 0xad; buffer[8] = 0xbe;
250 buffer[9] = 0xef; buffer[10] = 0x0d; buffer[11] = 0xd0;
251 size = 6;
252 err = RegQueryValueExA(hkey, "bin4", NULL, &type, (void *) (buffer+12), &size);
253 ok(err == ERROR_SUCCESS, "RegQueryValueEx failed: got %d\n", err);
254 ok(type == REG_BINARY, "got wrong type %u\n", type);
255 ok(size == 6, "got wrong size %u\n", size);
256 ok(memcmp(buffer, buffer+12, 6) == 0 ||
257 broken(memcmp(buffer+6, buffer+12, 6) == 0 /* WinXP */), "got wrong data\n");
258
259 run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_BINARY /v bin5 /d \"\" /f", &r);
260 ok(r == REG_EXIT_SUCCESS, "got exit code %u\n", r);
261 verify_reg(hkey, "bin5", REG_BINARY, buffer, 0, 0);
262
263 run_reg_exe("reg add HKCU\\" KEY_BASE " /v bin6 /t REG_BINARY /f /d", &r);
264 ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
265
266 run_reg_exe("reg add HKCU\\" KEY_BASE " /ve /t REG_BINARY /f", &r);
267 ok(r == REG_EXIT_SUCCESS, "got exit code %u, expected 0\n", r);
268 verify_reg(hkey, NULL, REG_BINARY, buffer, 0, 0);
269
270 /* REG_DWORD */
271 run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_DWORD /f /d 12345678", &r);
272 ok(r == REG_EXIT_SUCCESS || broken(r == REG_EXIT_FAILURE /* WinXP */),
273 "got exit code %d, expected 0\n", r);
274 dword = 12345678;
275 if (r == REG_EXIT_SUCCESS)
276 verify_reg(hkey, "", REG_DWORD, &dword, sizeof(dword), 0);
277 else
278 win_skip("broken reg.exe detected\n");
279
280 run_reg_exe("reg add HKCU\\" KEY_BASE " /v dword0 /t REG_DWORD /f /d", &r);
281 ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
282 run_reg_exe("reg add HKCU\\" KEY_BASE " /v dword1 /t REG_DWORD /f", &r);
283 ok(r == REG_EXIT_FAILURE || broken(r == REG_EXIT_SUCCESS /* WinXP */),
284 "got exit code %d, expected 1\n", r);
285 run_reg_exe("reg add HKCU\\" KEY_BASE " /v dword2 /t REG_DWORD /d zzz /f", &r);
286 ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
287 run_reg_exe("reg add HKCU\\" KEY_BASE " /v dword3 /t REG_DWORD /d deadbeef /f", &r);
288 ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
289 run_reg_exe("reg add HKCU\\" KEY_BASE " /v dword4 /t REG_DWORD /d 123xyz /f", &r);
290 ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
291
292 run_reg_exe("reg add HKCU\\" KEY_BASE " /v dword5 /t reg_dword /d 12345678 /f", &r);
293 ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
294 dword = 12345678;
295 verify_reg(hkey, "dword5", REG_DWORD, &dword, sizeof(dword), 0);
296
297 run_reg_exe("reg add HKCU\\" KEY_BASE " /v dword6 /t REG_DWORD /D 0123 /f", &r);
298 ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
299 size = sizeof(dword);
300 err = RegQueryValueExA(hkey, "dword6", NULL, &type, (LPBYTE)&dword, &size);
301 ok(err == ERROR_SUCCESS, "RegQueryValueEx failed: got %d\n", err);
302 ok(type == REG_DWORD, "got wrong type %d, expected %d\n", type, REG_DWORD);
303 ok(size == sizeof(DWORD), "got wrong size %d, expected %d\n", size, (int)sizeof(DWORD));
304 ok(dword == 123 || broken(dword == 0123 /* WinXP */), "got wrong data %d, expected 123\n", dword);
305
306 run_reg_exe("reg add HKCU\\" KEY_BASE " /v dword7 /t reg_dword /d 0xabcdefg /f", &r);
307 ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
308
309 run_reg_exe("reg add HKCU\\" KEY_BASE " /v dword8 /t REG_dword /d 0xdeadbeef /f", &r);
310 ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
311 dword = 0xdeadbeef;
312 verify_reg(hkey, "dword8", REG_DWORD, &dword, sizeof(dword), 0);
313
314 run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_DWORD /v dword9 /f /d -1", &r);
315 ok(r == REG_EXIT_FAILURE || broken(r == REG_EXIT_SUCCESS /* WinXP */), "got exit code %u\n", r);
316 run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_DWORD /v dword10 /f /d -0x1", &r);
317 ok(r == REG_EXIT_FAILURE || broken(r == REG_EXIT_SUCCESS /* WinXP */), "got exit code %u\n", r);
318
319 run_reg_exe("reg add HKCU\\" KEY_BASE " /v dword8 /t REG_dword /d 0x01ffffffff /f", &r);
320 ok(r == REG_EXIT_FAILURE || broken(r == REG_EXIT_SUCCESS /* WinXP */), "got exit code %d\n", r);
321
322 run_reg_exe("reg add HKCU\\" KEY_BASE " /v dword12 /t REG_DWORD /d 0xffffffff /f", &r);
323 ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
324 dword = ~0u;
325 verify_reg(hkey, "dword12", REG_DWORD, &dword, sizeof(dword), 0);
326
327 run_reg_exe("reg add HKCU\\" KEY_BASE " /v dword13 /t REG_DWORD /d 00x123 /f", &r);
328 ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
329
330 run_reg_exe("reg add HKCU\\" KEY_BASE " /v dword14 /t REG_DWORD /d 0X123 /f", &r);
331 ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
332 dword = 0x123;
333 verify_reg(hkey, "dword14", REG_DWORD, &dword, sizeof(dword), 0);
334
335 run_reg_exe("reg add HKCU\\" KEY_BASE " /v dword15 /t REG_DWORD /d 4294967296 /f", &r);
336 ok(r == REG_EXIT_FAILURE || broken(r == REG_EXIT_SUCCESS /* WinXP */), "got exit code %u\n", r);
337
338 run_reg_exe("reg add HKCU\\" KEY_BASE " /ve /t REG_DWORD /f", &r);
339 ok(r == REG_EXIT_FAILURE || broken(r == REG_EXIT_SUCCESS /* WinXP */), "got exit code %u\n", r);
340
341 /* REG_DWORD_LITTLE_ENDIAN */
342 run_reg_exe("reg add HKCU\\" KEY_BASE " /v DWORD_LE /t REG_DWORD_LITTLE_ENDIAN /d 456 /f", &r);
343 ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
344 dword = 456;
345 verify_reg(hkey, "DWORD_LE", REG_DWORD_LITTLE_ENDIAN, &dword, sizeof(dword), 0);
346
347 /* REG_DWORD_BIG_ENDIAN */
348 run_reg_exe("reg add HKCU\\" KEY_BASE " /v DWORD_BE /t REG_DWORD_BIG_ENDIAN /d 456 /f", &r);
349 ok(r == REG_EXIT_SUCCESS, "got exit code %u\n", r);
350 dword = 456;
351 verify_reg(hkey, "DWORD_BE", REG_DWORD_BIG_ENDIAN, &dword, sizeof(dword), 0);
352 /* REG_DWORD_BIG_ENDIAN is broken in every version of windows. It behaves like
353 * an ordinary REG_DWORD - that is little endian. GG */
354
355 run_reg_exe("reg add HKCU\\" KEY_BASE " /v DWORD_BE2 /t REG_DWORD_BIG_ENDIAN /f /d", &r);
356 ok(r == REG_EXIT_FAILURE, "got exit code %u, expected 1\n", r);
357
358 run_reg_exe("reg add HKCU\\" KEY_BASE " /v DWORD_BE3 /t REG_DWORD_BIG_ENDIAN /f", &r);
359 ok(r == REG_EXIT_FAILURE || broken(r == REG_EXIT_SUCCESS /* WinXP */), "got exit code %u\n", r);
360
361 run_reg_exe("reg add HKCU\\" KEY_BASE " /ve /t REG_DWORD_BIG_ENDIAN /f", &r);
362 ok(r == REG_EXIT_FAILURE || broken(r == REG_EXIT_SUCCESS /* WinXP */), "got exit code %u\n", r);
363
364 /* REG_MULTI_SZ */
365 run_reg_exe("reg add HKCU\\" KEY_BASE " /v multi0 /t REG_MULTI_SZ /d \"three\\0little\\0strings\" /f", &r);
366 ok(r == REG_EXIT_SUCCESS, "got exit code %u, expected 0\n", r);
367 memcpy(buffer, "three\0little\0strings\0", 22);
368 verify_reg(hkey, "multi0", REG_MULTI_SZ, buffer, 22, 0);
369
370 run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_MULTI_SZ /v multi1 /s \"#\" /d \"three#little#strings\" /f", &r);
371 ok(r == REG_EXIT_SUCCESS, "got exit code %u, expected 0\n", r);
372 verify_reg(hkey, "multi1", REG_MULTI_SZ, buffer, 22, 0);
373
374 run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_MULTI_SZ /v multi2 /d \"\" /f", &r);
375 ok(r == REG_EXIT_SUCCESS, "got exit code %u, expected 0\n", r);
376 verify_reg(hkey, "multi2", REG_MULTI_SZ, &buffer[21], 1, 0);
377
378 run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_MULTI_SZ /v multi3 /f", &r);
379 ok(r == REG_EXIT_SUCCESS, "got exit code %u\n", r);
380 verify_reg(hkey, "multi3", REG_MULTI_SZ, &buffer[21], 1, 0);
381
382 run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_MULTI_SZ /v multi4 /s \"#\" /d \"threelittlestrings\" /f", &r);
383 ok(r == REG_EXIT_SUCCESS, "got exit code %u, expected 0\n", r);
384 verify_reg(hkey, "multi4", REG_MULTI_SZ, "threelittlestrings\0", 20, 0);
385
386 run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_MULTI_SZ /v multi5 /s \"#randomgibberish\" /d \"three#little#strings\" /f", &r);
387 ok(r == REG_EXIT_FAILURE, "got exit code %u\n", r);
388 run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_MULTI_SZ /v multi6 /s \"\\0\" /d \"three\\0little\\0strings\" /f", &r);
389 ok(r == REG_EXIT_FAILURE, "got exit code %u\n", r);
390 run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_MULTI_SZ /v multi7 /s \"\" /d \"three#little#strings\" /f", &r);
391 ok(r == REG_EXIT_FAILURE, "got exit code %u\n", r);
392 run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_MULTI_SZ /v multi8 /s \"#\" /d \"##\" /f", &r);
393 ok(r == REG_EXIT_FAILURE, "got exit code %u\n", r);
394 run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_MULTI_SZ /v multi9 /s \"#\" /d \"two##strings\" /f", &r);
395 ok(r == REG_EXIT_FAILURE, "got exit code %u\n", r);
396 run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_MULTI_SZ /v multi10 /s \"#\" /d \"#a\" /f", &r);
397 ok(r == REG_EXIT_FAILURE, "got exit code %u\n", r);
398
399 run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_MULTI_SZ /v multi11 /s \"#\" /d \"a#\" /f", &r);
400 ok(r == REG_EXIT_SUCCESS, "got exit code %u, expected 0\n", r);
401 buffer[0]='a'; buffer[1]=0; buffer[2]=0;
402 verify_reg(hkey, "multi11", REG_MULTI_SZ, buffer, 3, 0);
403
404 run_reg_exe("reg add HKCU\\" KEY_BASE " /v multi12 /t REG_MULTI_SZ /f /d", &r);
405 ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
406
407 run_reg_exe("reg add HKCU\\" KEY_BASE " /v multi13 /t REG_MULTI_SZ /f /s", &r);
408 ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
409
410 run_reg_exe("reg add HKCU\\" KEY_BASE " /v multi14 /t REG_MULTI_SZ /d \"\\0a\" /f", &r);
411 ok(r == REG_EXIT_FAILURE, "got exit code %u, expected 1\n", r);
412
413 run_reg_exe("reg add HKCU\\" KEY_BASE " /v multi15 /t REG_MULTI_SZ /d \"a\\0\" /f", &r);
414 ok(r == REG_EXIT_SUCCESS, "got exit code %u, expected 0\n", r);
415 verify_reg(hkey, "multi15", REG_MULTI_SZ, buffer, 3, 0);
416
417 run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_MULTI_SZ /v multi16 /d \"two\\0\\0strings\" /f", &r);
418 ok(r == REG_EXIT_FAILURE, "got exit code %u, expected 1\n", r);
419
420 run_reg_exe("reg add HKCU\\" KEY_BASE " /v multi17 /t REG_MULTI_SZ /s \"#\" /d \"#\" /f", &r);
421 ok(r == REG_EXIT_SUCCESS, "got exit code %u, expected 0\n", r);
422 buffer[0] = 0; buffer[1] = 0;
423 verify_reg(hkey, "multi17", REG_MULTI_SZ, buffer, 2, 0);
424
425 run_reg_exe("reg add HKCU\\" KEY_BASE " /v multi18 /t REG_MULTI_SZ /d \"\\0\" /f", &r);
426 ok(r == REG_EXIT_SUCCESS, "got exit code %u, expected 0\n", r);
427 verify_reg(hkey, "multi18", REG_MULTI_SZ, buffer, 2, 0);
428
429 run_reg_exe("reg add HKCU\\" KEY_BASE " /v multi19 /t REG_MULTI_SZ /s \"#\" /d \"two\\0#strings\" /f", &r);
430 ok(r == REG_EXIT_SUCCESS, "got exit code %u, expected 0\n", r);
431 verify_reg(hkey, "multi19", REG_MULTI_SZ, "two\\0\0strings\0", 15, 0);
432
433 run_reg_exe("reg add HKCU\\" KEY_BASE " /v multi20 /t REG_MULTI_SZ /s \"#\" /d \"two#\\0strings\" /f", &r);
434 ok(r == REG_EXIT_SUCCESS, "got exit code %u, expected 0\n", r);
435 verify_reg(hkey, "multi20", REG_MULTI_SZ, "two\0\\0strings\0", 15, 0);
436
437 run_reg_exe("reg add HKCU\\" KEY_BASE " /v multi21 /t REG_MULTI_SZ /s \"#\" /d \"two\\0\\0strings\" /f", &r);
438 ok(r == REG_EXIT_SUCCESS, "got exit code %u, expected 0\n", r);
439 verify_reg(hkey, "multi21", REG_MULTI_SZ, "two\\0\\0strings\0", 16, 0);
440
441 run_reg_exe("reg add HKCU\\" KEY_BASE " /ve /t REG_MULTI_SZ /f", &r);
442 ok(r == REG_EXIT_SUCCESS, "got exit code %u, expected 0\n", r);
443 verify_reg(hkey, NULL, REG_MULTI_SZ, buffer, 1, 0);
444
445 RegCloseKey(hkey);
446
447 /* Test duplicate switches */
448 run_reg_exe("reg add HKCU\\" KEY_BASE " /v dup1 /t REG_DWORD /d 123 /f /t REG_SZ", &r);
449 ok(r == REG_EXIT_FAILURE || broken(r == REG_EXIT_SUCCESS /* WinXP */),
450 "got exit code %u, expected 1\n", r);
451
452 run_reg_exe("reg add HKCU\\" KEY_BASE " /v dup2 /t REG_DWORD /d 123 /f /d 456", &r);
453 ok(r == REG_EXIT_FAILURE, "got exit code %u, expected 1\n", r);
454
455 /* Test invalid switches */
456 run_reg_exe("reg add HKCU\\" KEY_BASE " /v invalid1 /a", &r);
457 ok(r == REG_EXIT_FAILURE, "got exit code %u, expected 1\n", r);
458
459 run_reg_exe("reg add HKCU\\" KEY_BASE " /v invalid2 /ae", &r);
460 ok(r == REG_EXIT_FAILURE, "got exit code %u, expected 1\n", r);
461
462 run_reg_exe("reg add HKCU\\" KEY_BASE " /v invalid3 /", &r);
463 ok(r == REG_EXIT_FAILURE, "got exit code %u, expected 1\n", r);
464
465 run_reg_exe("reg add HKCU\\" KEY_BASE " /v invalid4 -", &r);
466 ok(r == REG_EXIT_FAILURE, "got exit code %u, expected 1\n", r);
467
468 err = RegDeleteKeyA(HKEY_CURRENT_USER, KEY_BASE);
469 ok(err == ERROR_SUCCESS, "got %d\n", err);
470 }
471
472 static void test_delete(void)
473 {
474 HKEY hkey, hsubkey;
475 LONG err;
476 DWORD r;
477 const DWORD deadbeef = 0xdeadbeef;
478
479 run_reg_exe("reg delete", &r);
480 ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
481
482 run_reg_exe("reg delete /?", &r);
483 ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
484
485 err = RegCreateKeyExA(HKEY_CURRENT_USER, KEY_BASE, 0, NULL, 0, KEY_ALL_ACCESS, NULL, &hkey, NULL);
486 ok(err == ERROR_SUCCESS, "got %d\n", err);
487
488 err = RegSetValueExA(hkey, "foo", 0, REG_DWORD, (LPBYTE)&deadbeef, sizeof(deadbeef));
489 ok(err == ERROR_SUCCESS, "got %d\n" ,err);
490
491 err = RegSetValueExA(hkey, "bar", 0, REG_DWORD, (LPBYTE)&deadbeef, sizeof(deadbeef));
492 ok(err == ERROR_SUCCESS, "got %d\n" ,err);
493
494 err = RegSetValueExA(hkey, "", 0, REG_DWORD, (LPBYTE)&deadbeef, sizeof(deadbeef));
495 ok(err == ERROR_SUCCESS, "got %d\n" ,err);
496
497 err = RegCreateKeyExA(hkey, "subkey", 0, NULL, 0, KEY_ALL_ACCESS, NULL, &hsubkey, NULL);
498 ok(err == ERROR_SUCCESS, "got %d\n" ,err);
499 RegCloseKey(hsubkey);
500
501 run_reg_exe("reg delete HKCU\\" KEY_BASE " /v bar /f", &r);
502 ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
503 err = RegQueryValueExA(hkey, "bar", NULL, NULL, NULL, NULL);
504 ok(err == ERROR_FILE_NOT_FOUND, "got %d\n", err);
505
506 run_reg_exe("reg delete HKCU\\" KEY_BASE " /ve /f", &r);
507 ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
508 err = RegQueryValueExA(hkey, "", NULL, NULL, NULL, NULL);
509 ok(err == ERROR_FILE_NOT_FOUND, "got %d, expected 2\n", err);
510
511 run_reg_exe("reg delete HKCU\\" KEY_BASE " /va /f", &r);
512 ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
513 err = RegQueryValueExA(hkey, "foo", NULL, NULL, NULL, NULL);
514 ok(err == ERROR_FILE_NOT_FOUND, "got %d\n", err);
515 err = RegOpenKeyExA(hkey, "subkey", 0, KEY_READ, &hsubkey);
516 ok(err == ERROR_SUCCESS, "got %d\n", err);
517 RegCloseKey(hsubkey);
518 RegCloseKey(hkey);
519
520 run_reg_exe("reg delete HKCU\\" KEY_BASE " /f", &r);
521 ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
522 err = RegOpenKeyExA(HKEY_CURRENT_USER, KEY_BASE, 0, KEY_READ, &hkey);
523 ok(err == ERROR_FILE_NOT_FOUND, "got %d\n", err);
524
525 run_reg_exe("reg delete HKCU\\" KEY_BASE " /f", &r);
526 ok(r == REG_EXIT_FAILURE, "got exit code %u\n", r);
527 }
528
529 static void test_query(void)
530 {
531 DWORD r;
532 HKEY key, subkey;
533 LONG err;
534 const char hello[] = "Hello";
535 const char world[] = "World";
536 const char empty1[] = "Empty1";
537 const char empty2[] = "Empty2";
538 const DWORD dword1 = 0x123;
539 const DWORD dword2 = 0xabc;
540
541 run_reg_exe("reg query", &r);
542 ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
543
544 run_reg_exe("reg query /?", &r);
545 ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
546
547 /* Create a test key */
548 err = RegCreateKeyExA(HKEY_CURRENT_USER, KEY_BASE, 0, NULL, 0, KEY_ALL_ACCESS, NULL, &key, NULL);
549 ok(err == ERROR_SUCCESS, "got %d, expected 0\n", err);
550
551 run_reg_exe("reg query HKCU\\" KEY_BASE " /ve", &r);
552 ok(r == REG_EXIT_SUCCESS || broken(r == REG_EXIT_FAILURE /* WinXP */),
553 "got exit code %d, expected 0\n", r);
554
555 err = RegSetValueExA(key, "Test", 0, REG_SZ, (BYTE *)hello, sizeof(hello));
556 ok(err == ERROR_SUCCESS, "got %d, expected 0\n", err);
557
558 err = RegSetValueExA(key, "Wine", 0, REG_DWORD, (BYTE *)&dword1, sizeof(dword1));
559 ok(err == ERROR_SUCCESS, "got %d, expected 0\n", err);
560
561 err = RegSetValueExA(key, NULL, 0, REG_SZ, (BYTE *)empty1, sizeof(empty1));
562 ok(err == ERROR_SUCCESS, "got %d, expected 0\n", err);
563
564 run_reg_exe("reg query HKCU\\" KEY_BASE, &r);
565 ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
566
567 run_reg_exe("reg query HKCU\\" KEY_BASE " /v", &r);
568 ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
569
570 run_reg_exe("reg query HKCU\\" KEY_BASE " /v Missing", &r);
571 ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
572
573 run_reg_exe("reg query HKCU\\" KEY_BASE " /v Test", &r);
574 ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
575
576 run_reg_exe("reg query HKCU\\" KEY_BASE " /v Wine", &r);
577 ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
578
579 run_reg_exe("reg query HKCU\\" KEY_BASE " /ve", &r);
580 ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
581
582 /* Create a test subkey */
583 err = RegCreateKeyExA(key, "Subkey", 0, NULL, 0, KEY_ALL_ACCESS, NULL, &subkey, NULL);
584 ok(err == ERROR_SUCCESS, "got %d\n", err);
585
586 err = RegSetValueExA(subkey, "Test", 0, REG_SZ, (BYTE *)world, sizeof(world));
587 ok(err == ERROR_SUCCESS, "got %d, expected 0\n", err);
588
589 err = RegSetValueExA(subkey, "Wine", 0, REG_DWORD, (BYTE *)&dword2, sizeof(dword2));
590 ok(err == ERROR_SUCCESS, "got %d, expected 0\n", err);
591
592 err = RegSetValueExA(subkey, NULL, 0, REG_SZ, (BYTE *)empty2, sizeof(empty2));
593 ok(err == ERROR_SUCCESS, "got %d, expected 0\n", err);
594
595 err = RegCloseKey(subkey);
596 ok(err == ERROR_SUCCESS, "got %d, expected 0\n", err);
597
598 run_reg_exe("reg query HKCU\\" KEY_BASE "\\subkey", &r);
599 ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
600
601 run_reg_exe("reg query HKCU\\" KEY_BASE "\\subkey /v Test", &r);
602 ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
603
604 run_reg_exe("reg query HKCU\\" KEY_BASE "\\subkey /v Wine", &r);
605 ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
606
607 run_reg_exe("reg query HKCU\\" KEY_BASE "\\subkey /ve", &r);
608 ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
609
610 /* Test recursion */
611 run_reg_exe("reg query HKCU\\" KEY_BASE " /s", &r);
612 ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
613
614 run_reg_exe("reg query HKCU\\" KEY_BASE " /v Test /s", &r);
615 ok(r == REG_EXIT_SUCCESS || r == REG_EXIT_FAILURE /* WinXP */,
616 "got exit code %d, expected 0\n", r);
617
618 run_reg_exe("reg query HKCU\\" KEY_BASE " /v Wine /s", &r);
619 ok(r == REG_EXIT_SUCCESS || r == REG_EXIT_FAILURE /* WinXP */,
620 "got exit code %d, expected 0\n", r);
621
622 run_reg_exe("reg query HKCU\\" KEY_BASE " /ve /s", &r);
623 ok(r == REG_EXIT_SUCCESS || r == REG_EXIT_FAILURE /* WinXP */,
624 "got exit code %d, expected 0\n", r);
625
626 /* Clean-up, then query */
627 err = RegDeleteKeyA(key, "subkey");
628 ok(err == ERROR_SUCCESS, "got %d, expected 0\n", err);
629
630 err = RegCloseKey(key);
631 ok(err == ERROR_SUCCESS, "got %d, expected 0\n", err);
632
633 run_reg_exe("reg query HKCU\\" KEY_BASE "\\subkey", &r);
634 ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
635
636 err = RegDeleteKeyA(HKEY_CURRENT_USER, KEY_BASE);
637 ok(err == ERROR_SUCCESS, "got %d, expected 0\n", err);
638
639 run_reg_exe("reg query HKCU\\" KEY_BASE, &r);
640 ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
641 }
642
643 static void test_v_flags(void)
644 {
645 DWORD r;
646
647 run_reg_exe("reg add HKCU\\" KEY_BASE " /v Wine /ve", &r);
648 ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
649
650 run_reg_exe("reg delete HKCU\\" KEY_BASE " /v Wine /ve", &r);
651 ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
652
653 run_reg_exe("reg delete HKCU\\" KEY_BASE " /v Wine /va", &r);
654 ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
655
656 run_reg_exe("reg delete HKCU\\" KEY_BASE " /ve /va", &r);
657 ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
658
659 /* No /v argument */
660 run_reg_exe("reg add HKCU\\" KEY_BASE " /v", &r);
661 ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
662
663 run_reg_exe("reg add HKCU\\" KEY_BASE " /d Test /f /v", &r);
664 ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
665
666 run_reg_exe("reg delete HKCU\\" KEY_BASE " /v", &r);
667 ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
668
669 run_reg_exe("reg delete HKCU\\" KEY_BASE " /f /v", &r);
670 ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
671
672 /* Multiple /v switches */
673 run_reg_exe("reg add HKCU\\" KEY_BASE " /v Wine /t REG_DWORD /d 0x1 /v Test /f", &r);
674 ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
675
676 run_reg_exe("reg delete HKCU\\" KEY_BASE " /v Wine /v Test /f", &r);
677 ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
678 }
679
680 static BOOL write_reg_file(const char *value, char *tmp_name)
681 {
682 static const char regedit4[] = "REGEDIT4";
683 static const char key[] = "[HKEY_CURRENT_USER\\" KEY_BASE "]";
684 char file_data[MAX_PATH], tmp_path[MAX_PATH];
685 HANDLE hfile;
686 DWORD written;
687 BOOL ret;
688
689 sprintf(file_data, "%s\n\n%s\n%s\n", regedit4, key, value);
690
691 GetTempPathA(MAX_PATH, tmp_path);
692 GetTempFileNameA(tmp_path, "reg", 0, tmp_name);
693
694 hfile = CreateFileA(tmp_name, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0);
695 if (hfile == INVALID_HANDLE_VALUE)
696 return FALSE;
697
698 ret = WriteFile(hfile, file_data, strlen(file_data), &written, NULL);
699 CloseHandle(hfile);
700 return ret;
701 }
702
703 static void test_import(void)
704 {
705 DWORD r, dword = 0x123;
706 char test1_reg[MAX_PATH], test2_reg[MAX_PATH];
707 char cmdline[MAX_PATH];
708 char test_string[] = "Test string";
709 HKEY hkey;
710 LONG err;
711
712 run_reg_exe("reg import", &r);
713 ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
714
715 run_reg_exe("reg import /?", &r);
716 todo_wine ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
717
718 run_reg_exe("reg import missing.reg", &r);
719 ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
720
721 /* Create test files */
722 ok(write_reg_file("\"Wine\"=dword:00000123", test1_reg), "Failed to write registry file\n");
723 ok(write_reg_file("@=\"Test string\"", test2_reg), "Failed to write registry file\n");
724
725 sprintf(cmdline, "reg import %s", test1_reg);
726 run_reg_exe(cmdline, &r);
727 todo_wine ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
728
729 sprintf(cmdline, "reg import %s", test2_reg);
730 run_reg_exe(cmdline, &r);
731 todo_wine ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
732
733 err = RegOpenKeyExA(HKEY_CURRENT_USER, KEY_BASE, 0, KEY_READ, &hkey);
734 todo_wine ok(err == ERROR_SUCCESS, "got %d, expected 0\n", err);
735
736 todo_wine verify_reg(hkey, "Wine", REG_DWORD, &dword, sizeof(dword), 0);
737 todo_wine verify_reg(hkey, "", REG_SZ, test_string, sizeof(test_string), 0);
738
739 err = RegCloseKey(hkey);
740 todo_wine ok(err == ERROR_SUCCESS, "got %d, expected 0\n", err);
741
742 err = RegDeleteKeyA(HKEY_CURRENT_USER, KEY_BASE);
743 todo_wine ok(err == ERROR_SUCCESS, "got %d, expected 0\n", err);
744
745 sprintf(cmdline, "reg import %s %s", test1_reg, test2_reg);
746 run_reg_exe(cmdline, &r);
747 ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
748
749 DeleteFileA(test1_reg);
750 DeleteFileA(test2_reg);
751 }
752
753 START_TEST(reg)
754 {
755 DWORD r;
756 if (!run_reg_exe("reg.exe /?", &r)) {
757 win_skip("reg.exe not available, skipping reg.exe tests\n");
758 return;
759 }
760
761 test_add();
762 test_delete();
763 test_query();
764 test_v_flags();
765 test_import();
766 }