No longer directly accessing debuggee memory.
[wine] / programs / regtest / regtest.c
1 /*
2  * Registry testing program
3  *
4  * Copyright 1998 Matthew Becker
5  *
6  * The return codes were generated in an NT40 environment, using lcc-win32
7  *
8  * NOTES
9  *    When compiling under lcc-win32, I get three (3) warning, but they all
10  *    seem to be issues with lcc.
11  *
12  *    If creating a new testing sequence, please try to clean up any
13  *    registry changes that are made.
14  */
15
16 #include <stdio.h>
17 #include <malloc.h>
18 #include <windows.h>
19 #include <winreg.h>
20 #include <winerror.h>
21 #include <winnt.h>
22
23 /* True this when security is implemented */
24 #define CHECK_SAM FALSE
25
26 #define xERROR(s,d) fprintf(stderr, "%s:#%d(Status=%ld)\n", __FUNCTION__,s,d)
27
28 /*
29  * NOTES: These individual routines are listed in alphabetical order.
30  *
31  * They are meant to test error conditions.  Success conditions are
32  * tested in the sequences found at the end.
33  */
34
35 /******************************************************************************
36  * TestCloseKey
37  */
38 void TestCloseKey()
39 {
40     long lSts;
41
42     lSts = RegCloseKey((HKEY)2);
43     if (lSts != ERROR_INVALID_HANDLE) xERROR(1,lSts);
44
45     lSts = RegCloseKey(HKEY_LOCAL_MACHINE);
46     if (lSts != ERROR_SUCCESS) xERROR(2,lSts);
47
48     /* Check twice just for kicks */
49     lSts = RegCloseKey(HKEY_LOCAL_MACHINE);
50     if (lSts != ERROR_SUCCESS) xERROR(3,lSts);
51 }
52
53 /******************************************************************************
54  * TestConnectRegistry
55  */
56 void TestConnectRegistry()
57 {
58     long lSts;
59     HKEY hkey;
60
61     lSts = RegConnectRegistry("",(HKEY)2,&hkey);
62     if (lSts != ERROR_SUCCESS) xERROR(1,lSts);
63
64     lSts = RegConnectRegistry("",HKEY_LOCAL_MACHINE,&hkey);
65     if (lSts != ERROR_SUCCESS) xERROR(2,lSts);
66
67 #if TOO_SLOW
68     lSts = RegConnectRegistry("\\\\regtest",HKEY_LOCAL_MACHINE,&hkey);
69     if (lSts != ERROR_BAD_NETPATH) xERROR(3,lSts);
70 #endif
71 }
72
73 /******************************************************************************
74  * TestCreateKey
75  */
76 void TestCreateKey()
77 {
78     long lSts;
79     HKEY hkey;
80
81     lSts = RegCreateKey((HKEY)2,"",&hkey);
82     if (lSts != ERROR_BADKEY) xERROR(1,lSts);
83
84     lSts = RegCreateKey(HKEY_LOCAL_MACHINE,"",&hkey);
85     if (lSts != ERROR_SUCCESS) xERROR(2,lSts);
86     RegCloseKey(hkey);
87
88     lSts = RegCreateKey(HKEY_LOCAL_MACHINE,"\\asdf",&hkey);
89     if (lSts != ERROR_BAD_PATHNAME) xERROR(3,lSts);
90
91 #if 0
92     lSts = RegCreateKey(HKEY_LOCAL_MACHINE,"asdf\\",&hkey);
93     if (lSts != ERROR_INVALID_PARAMETER) xERROR(4,lSts);
94 #endif
95
96     lSts = RegCreateKey(HKEY_LOCAL_MACHINE,"\\asdf\\",&hkey);
97     if (lSts != ERROR_BAD_PATHNAME) xERROR(5,lSts);
98 }
99
100 /******************************************************************************
101  * TestCreateKeyEx
102  */
103 void TestCreateKeyEx()
104 {
105     long lSts;
106     HKEY hkey;
107     DWORD dwDisp;
108
109     lSts = RegCreateKeyEx((HKEY)2,"",0,"",0,0,NULL,&hkey,&dwDisp);
110     if (lSts != ERROR_INVALID_HANDLE) xERROR(1,lSts);
111
112     lSts = RegCreateKeyEx(HKEY_LOCAL_MACHINE,"regtest",0,"",0,0,NULL,&hkey,
113                           &dwDisp);
114     if (lSts != ERROR_INVALID_PARAMETER) xERROR(2,lSts);
115
116     lSts = RegCreateKeyEx(HKEY_LOCAL_MACHINE,"regtest",0,"asdf",0,
117                           KEY_ALL_ACCESS,NULL,&hkey,&dwDisp);
118     if (lSts != ERROR_INVALID_PARAMETER) xERROR(3,lSts);
119
120     lSts = RegCreateKeyEx(HKEY_LOCAL_MACHINE,"regtest",0,"",0,
121                           KEY_ALL_ACCESS,NULL,&hkey,&dwDisp);
122     if (lSts != ERROR_INVALID_PARAMETER) xERROR(4,lSts);
123
124 }
125
126 /******************************************************************************
127  * TestDeleteKey
128  */
129 void TestDeleteKey()
130 {
131     long lSts;
132
133     lSts = RegDeleteKey((HKEY)2, "asdf");
134     if (lSts != ERROR_INVALID_HANDLE) xERROR(1,lSts);
135
136     lSts = RegDeleteKey(HKEY_CURRENT_USER, "asdf");
137     if (lSts != ERROR_FILE_NOT_FOUND) xERROR(2,lSts);
138
139 #if CHECK_SAM
140     lSts = RegDeleteKey(HKEY_CURRENT_USER, "");
141     if (lSts != ERROR_ACCESS_DENIED) xERROR(3,lSts);
142 #endif
143 }
144
145 /******************************************************************************
146  * TestDeleteValue
147  */
148 void TestDeleteValue()
149 {
150     long lSts;
151
152     lSts = RegDeleteValue((HKEY)2, "asdf");
153     if (lSts != ERROR_INVALID_HANDLE) xERROR(1,lSts);
154
155     lSts = RegDeleteValue(HKEY_CURRENT_USER, "");
156     if (lSts != ERROR_FILE_NOT_FOUND) xERROR(2,lSts);
157
158     lSts = RegDeleteValue(HKEY_CURRENT_USER, "asdf");
159     if (lSts != ERROR_FILE_NOT_FOUND) xERROR(3,lSts);
160
161     lSts = RegDeleteValue(HKEY_CURRENT_USER, "\\asdf");
162     if (lSts != ERROR_FILE_NOT_FOUND) xERROR(4,lSts);
163 }
164
165 /******************************************************************************
166  * TestEnumKey
167  */
168 void TestEnumKey()
169 {
170     long lSts;
171     char *sVal;
172     long lVal;
173
174     lVal = 1;
175     sVal = (char *)malloc(lVal * sizeof(char));
176
177     lSts = RegEnumKey((HKEY)2,3,sVal,lVal);
178     if (lSts != ERROR_INVALID_HANDLE) xERROR(1,lSts);
179
180     lSts = RegEnumKey(HKEY_CURRENT_USER,-1,sVal,lVal);
181     if (lSts != ERROR_NO_MORE_ITEMS) xERROR(2,lSts);
182
183     lSts = RegEnumKey(HKEY_CURRENT_USER,0,sVal,lVal);
184     if (lSts != ERROR_MORE_DATA) xERROR(3,lSts);
185 }
186
187 /******************************************************************************
188  * TestEnumKeyEx
189  */
190 void TestEnumKeyEx()
191 {
192     long lSts;
193     char *sVal;
194     char *sClass;
195     unsigned long lLen1;
196     unsigned long lLen2;
197     FILETIME ft;
198
199     lLen1 = 1;
200     sVal = (char *)malloc(lLen1 * sizeof(char));
201     lLen2 = 1;
202     sClass = (char *)malloc(lLen2 * sizeof(char));
203
204     lSts = RegEnumKeyEx((HKEY)2,0,sVal,&lLen1,0,sClass,&lLen2,&ft);
205     if (lSts != ERROR_INVALID_HANDLE) xERROR(1,lSts);
206
207     lSts = RegEnumKeyEx(HKEY_LOCAL_MACHINE,0,sVal,&lLen1,0,sClass,&lLen2,&ft);
208     if (lSts != ERROR_MORE_DATA) xERROR(2,lSts);
209
210     lSts = RegEnumKeyEx(HKEY_LOCAL_MACHINE,0,sVal,&lLen1,0,sClass,&lLen2,&ft);
211     if (lSts != ERROR_MORE_DATA) xERROR(3,lSts);
212 }
213
214 /******************************************************************************
215  * TestEnumValue
216  */
217 void TestEnumValue()
218 {
219     long lSts;
220     char *sVal;
221     unsigned long lVal;
222     unsigned long lType;
223     unsigned long lLen1;
224     char *bVal;
225
226     lVal = 1;
227     sVal = (char *)malloc(lVal * sizeof(char));
228     lLen1 = 1;
229     bVal = (char *)malloc(lLen1 * sizeof(char));
230
231     lSts = RegEnumValue((HKEY)2,-1,sVal,&lVal,0,&lType,NULL,&lLen1);
232     if (lSts != ERROR_INVALID_HANDLE) xERROR(1,lSts);
233
234     lSts = RegEnumValue(HKEY_LOCAL_MACHINE,-1,sVal,&lVal,0,&lType,NULL,&lLen1);
235     if (lSts != ERROR_NO_MORE_ITEMS) xERROR(2,lSts);
236
237     lSts = RegEnumValue(HKEY_LOCAL_MACHINE,0,sVal,&lVal,0,&lType,NULL,&lLen1);
238     if (lSts != ERROR_SUCCESS) xERROR(3,lSts);
239
240     lSts = RegEnumValue(HKEY_LOCAL_MACHINE,0,sVal,&lVal,0,NULL,NULL,&lLen1);
241     if (lSts != ERROR_SUCCESS) xERROR(4,lSts);
242
243     lSts = RegEnumValue(HKEY_LOCAL_MACHINE,1,sVal,&lVal,0,&lType,bVal,&lLen1);
244     if (lSts != ERROR_NO_MORE_ITEMS) xERROR(5,lSts);
245 }
246
247 /******************************************************************************
248  * TestFlushKey
249  */
250 void TestFlushKey()
251 {
252     long lSts;
253
254     lSts = RegFlushKey((HKEY)2);
255     if (lSts != ERROR_INVALID_HANDLE) xERROR(1,lSts);
256
257     lSts = RegFlushKey(HKEY_LOCAL_MACHINE);
258     if (lSts != ERROR_SUCCESS) xERROR(2,lSts);
259 }
260
261 /******************************************************************************
262  * TestGetKeySecurity
263  */
264 void TestGetKeySecurity()
265 {
266     long lSts;
267     SECURITY_INFORMATION si;
268     SECURITY_DESCRIPTOR sd;
269     unsigned long lLen;
270
271     lLen = sizeof(sd);
272     si = 0;
273     lSts = RegGetKeySecurity((HKEY)2,si,&sd,&lLen);
274     if (lSts != ERROR_INVALID_HANDLE) xERROR(1,lSts);
275
276     lSts = RegGetKeySecurity(HKEY_LOCAL_MACHINE,si,&sd,&lLen);
277     if (lSts != ERROR_INSUFFICIENT_BUFFER) xERROR(2,lSts);
278
279     si = GROUP_SECURITY_INFORMATION;
280     lSts = RegGetKeySecurity(HKEY_LOCAL_MACHINE,si,&sd,&lLen);
281     if (lSts != ERROR_SUCCESS) xERROR(3,lSts);
282 }
283
284 /******************************************************************************
285  * TestLoadKey
286  */
287 void TestLoadKey()
288 {
289     long lSts;
290
291     lSts = RegLoadKey((HKEY)2,"","");
292     if (lSts != ERROR_INVALID_PARAMETER) xERROR(1,lSts);
293
294     lSts = RegLoadKey(HKEY_CURRENT_USER,"","");
295     if (lSts != ERROR_INVALID_PARAMETER) xERROR(2,lSts);
296
297     lSts = RegLoadKey(HKEY_CURRENT_USER,"regtest","");
298     if (lSts != ERROR_INVALID_PARAMETER) xERROR(3,lSts);
299
300     lSts = RegLoadKey(HKEY_CURRENT_USER,"\\regtest","");
301     if (lSts != ERROR_INVALID_PARAMETER) xERROR(4,lSts);
302
303 #if CHECK_SAM
304     lSts = RegLoadKey(HKEY_CURRENT_USER,"regtest","regtest.dat");
305     if (lSts != ERROR_PRIVILEGE_NOT_HELD) xERROR(5,lSts);
306
307     lSts = RegLoadKey(HKEY_CURRENT_USER,"\\regtest","regtest.dat");
308     if (lSts != ERROR_PRIVILEGE_NOT_HELD) xERROR(6,lSts);
309 #endif
310 }
311
312 /******************************************************************************
313  * TestNotifyChangeKeyValue
314  */
315 void TestNotifyChangeKeyValue()
316 {
317     long lSts;
318     HANDLE hEvent;
319
320     hEvent = (HANDLE)0;
321
322     lSts = RegNotifyChangeKeyValue((HKEY)2, TRUE, REG_NOTIFY_CHANGE_NAME, 0, 0);
323     if (lSts != ERROR_INVALID_HANDLE) xERROR(1,lSts);
324
325     lSts = RegNotifyChangeKeyValue(HKEY_CURRENT_USER, TRUE, REG_NOTIFY_CHANGE_NAME, 0, 1);
326     if (lSts != ERROR_INVALID_PARAMETER) xERROR(2,lSts);
327
328     hEvent = (HANDLE)HKEY_CURRENT_USER;
329     lSts = RegNotifyChangeKeyValue(HKEY_CURRENT_USER, TRUE, REG_NOTIFY_CHANGE_NAME, hEvent, 1);
330     if (lSts != ERROR_INVALID_HANDLE) xERROR(3,lSts);
331 }
332
333 /******************************************************************************
334  * TestOpenKey
335  */
336 void TestOpenKey()
337 {
338     long lSts;
339     HKEY hkey;
340
341     lSts = RegOpenKey((HKEY)72, "",&hkey);
342     if (lSts != ERROR_SUCCESS) xERROR(1,lSts);
343     RegCloseKey(hkey);
344
345     lSts = RegOpenKey((HKEY)2, "regtest",&hkey);
346     if (lSts != ERROR_INVALID_HANDLE) xERROR(2,lSts);
347
348     lSts = RegOpenKey(HKEY_CURRENT_USER, "regtest",&hkey);
349     if (lSts != ERROR_FILE_NOT_FOUND) xERROR(3,lSts);
350
351     lSts = RegOpenKey(HKEY_CURRENT_USER, "\\regtest",&hkey);
352     if (lSts != ERROR_BAD_PATHNAME) xERROR(4,lSts);
353 }
354
355 /******************************************************************************
356  * TestOpenKeyEx
357  */
358 void TestOpenKeyEx()
359 {
360     long lSts;
361     HKEY hkey;
362
363     lSts = RegOpenKeyEx((HKEY)2,"",0,KEY_ALL_ACCESS,&hkey);
364     if (lSts != ERROR_INVALID_HANDLE) xERROR(1,lSts);
365
366     lSts = RegOpenKeyEx(HKEY_CURRENT_USER,"\\regtest",0,KEY_ALL_ACCESS,&hkey);
367     if (lSts != ERROR_BAD_PATHNAME) xERROR(2,lSts);
368
369     lSts = RegOpenKeyEx(HKEY_CURRENT_USER,"regtest",0,0,&hkey);
370     if (lSts != ERROR_FILE_NOT_FOUND) xERROR(3,lSts);
371
372     lSts = RegOpenKeyEx(HKEY_CURRENT_USER,"regtest\\",0,0,&hkey);
373     if (lSts != ERROR_FILE_NOT_FOUND) xERROR(4,lSts);
374 }
375
376 /******************************************************************************
377  * TestQueryInfoKey
378  */
379 void TestQueryInfoKey()
380 {
381     long lSts;
382     char *sClass;
383     unsigned long lClass;
384     unsigned long lSubKeys;
385     unsigned long lMaxSubLen;
386     unsigned long lMaxClassLen;
387     unsigned long lValues;
388     unsigned long lMaxValNameLen;
389     unsigned long lMaxValLen;
390     unsigned long lSecDescLen;
391     FILETIME ft;
392
393     lClass = 1;
394     sClass = (char *)malloc(lClass * sizeof(char));
395
396     lSts = RegQueryInfoKey((HKEY)2,sClass,&lClass,0,&lSubKeys,&lMaxSubLen,
397                            &lMaxClassLen,&lValues,&lMaxValNameLen,&lMaxValLen,
398                            &lSecDescLen, &ft);
399     if (lSts != ERROR_INVALID_HANDLE) xERROR(1,lSts);
400
401     lSts = RegQueryInfoKey(HKEY_CURRENT_USER,sClass,&lClass,0,&lSubKeys,
402                            &lMaxSubLen,&lMaxClassLen,&lValues,&lMaxValNameLen,
403                            &lMaxValLen,&lSecDescLen, &ft);
404     if (lSts != ERROR_SUCCESS) xERROR(2,lSts);
405 }
406
407 /******************************************************************************
408  * TestQueryValue
409  */
410 void TestQueryValue()
411 {
412     long lSts;
413     long lLen;
414     char *sVal;
415
416     sVal = (char *)malloc(80 * sizeof(char));
417     lLen = strlen(sVal);
418
419     lSts = RegQueryValue((HKEY)2,"",NULL,&lLen);
420     if (lSts != ERROR_INVALID_HANDLE) xERROR(1,lSts);
421
422     lSts = RegQueryValue(HKEY_CURRENT_USER,"",NULL,&lLen);
423     if (lSts != ERROR_SUCCESS) xERROR(2,lSts);
424
425     lSts = RegQueryValue(HKEY_CURRENT_USER,"\\regtest",NULL,&lLen);
426     if (lSts != ERROR_BAD_PATHNAME) xERROR(3,lSts);
427
428     lSts = RegQueryValue(HKEY_CURRENT_USER,"",sVal,&lLen);
429     if (lSts != ERROR_SUCCESS) xERROR(4,lSts);
430 }
431
432 /******************************************************************************
433  * TestQueryValueEx
434  */
435 void TestQueryValueEx()
436 {
437     char *sVal;
438     long lSts;
439     unsigned long lType;
440     unsigned long lLen;
441
442     lLen = 80;
443     sVal = (char *)malloc(lLen * sizeof(char));
444
445     lSts = RegQueryValueEx((HKEY)2,"",0,&lType,sVal,&lLen);
446     if (lSts != ERROR_INVALID_HANDLE) xERROR(1,lSts);
447
448     lSts = RegQueryValueEx(HKEY_CURRENT_USER,"",(LPDWORD)1,&lType,sVal,&lLen);
449     if (lSts != ERROR_INVALID_PARAMETER) xERROR(2,lSts);
450
451     lSts = RegQueryValueEx(HKEY_LOCAL_MACHINE,"",0,&lType,sVal,&lLen);
452     if (lSts != ERROR_SUCCESS) xERROR(3,lSts);
453 }
454
455 /******************************************************************************
456  * TestReplaceKey
457  */
458 void TestReplaceKey()
459 {
460     long lSts;
461
462     lSts = RegReplaceKey((HKEY)2,"","","");
463     if (lSts != ERROR_INVALID_HANDLE) xERROR(1,lSts);
464
465 #if CHECK_SAM
466     lSts = RegReplaceKey(HKEY_LOCAL_MACHINE,"","","");
467     if (lSts != ERROR_ACCESS_DENIED) xERROR(2,lSts);
468
469     lSts = RegReplaceKey(HKEY_LOCAL_MACHINE,"Software","","");
470     if (lSts != ERROR_ACCESS_DENIED) xERROR(3,lSts);
471 #endif
472 }
473
474 /******************************************************************************
475  * TestRestoreKey
476  */
477 void TestRestoreKey()
478 {
479     long lSts;
480
481     lSts = RegRestoreKey((HKEY)2,"",0);
482     if (lSts != ERROR_INVALID_PARAMETER) xERROR(1,lSts);
483
484     lSts = RegRestoreKey(HKEY_LOCAL_MACHINE,"",0);
485     if (lSts != ERROR_INVALID_PARAMETER) xERROR(2,lSts);
486
487     lSts = RegRestoreKey(HKEY_LOCAL_MACHINE,"a.a",0);
488     if (lSts != ERROR_FILE_NOT_FOUND) xERROR(3,lSts);
489 }
490
491 /******************************************************************************
492  * TestSaveKey
493  */
494 void TestSaveKey()
495 {
496     long lSts;
497
498     lSts = RegSaveKey((HKEY)2,"",NULL);
499     if (lSts != ERROR_INVALID_PARAMETER) xERROR(1,lSts);
500
501     lSts = RegSaveKey(HKEY_LOCAL_MACHINE,"",NULL);
502     if (lSts != ERROR_INVALID_PARAMETER) xERROR(2,lSts);
503
504 #if CHECK_SAM
505     lSts = RegSaveKey(HKEY_LOCAL_MACHINE,"a.a",NULL);
506     if (lSts != ERROR_PRIVILEGE_NOT_HELD) xERROR(3,lSts);
507 #endif
508 }
509
510 /******************************************************************************
511  * TestSetKeySecurity
512  */
513 void TestSetKeySecurity()
514 {
515     long lSts;
516     SECURITY_DESCRIPTOR sd;
517
518     lSts = RegSetKeySecurity((HKEY)2,0,NULL);
519     if (lSts != ERROR_INVALID_PARAMETER) xERROR(1,lSts);
520
521     lSts = RegSetKeySecurity(HKEY_LOCAL_MACHINE,0,NULL);
522     if (lSts != ERROR_INVALID_PARAMETER) xERROR(2,lSts);
523
524     lSts = RegSetKeySecurity(HKEY_LOCAL_MACHINE,OWNER_SECURITY_INFORMATION,NULL);
525     if (lSts != ERROR_INVALID_PARAMETER) xERROR(3,lSts);
526
527     lSts = RegSetKeySecurity(HKEY_LOCAL_MACHINE,OWNER_SECURITY_INFORMATION,&sd);
528     if (lSts != ERROR_INVALID_PARAMETER) xERROR(4,lSts);
529 }
530
531 /******************************************************************************
532  * TestSetValue
533  */
534 void TestSetValue()
535 {
536 #if MAKE_NT_CRASH
537     long lSts;
538 #endif
539
540 #if MAKE_NT_CRASH
541     lSts = RegSetValue((HKEY)2,"",0,NULL,0);
542     if (lSts != ERROR_INVALID_PARAMETER) xERROR(1,lSts);
543 #endif
544
545 #if MAKE_NT_CRASH
546     lSts = RegSetValue((HKEY)2,"regtest",0,NULL,0);
547     if (lSts != ERROR_INVALID_PARAMETER) xERROR(2,lSts);
548 #endif
549
550 #if MAKE_NT_CRASH
551     lSts = RegSetValue((HKEY)2,"regtest",REG_SZ,NULL,0);
552     if (lSts != ERROR_INVALID_HANDLE) xERROR(3,lSts);
553 #endif
554
555 #if MAKE_NT_CRASH
556     lSts = RegSetValue(HKEY_LOCAL_MACHINE,"regtest",REG_SZ,NULL,0);
557     if (lSts != ERROR_INVALID_HANDLE) xERROR(4,lSts);
558 #endif
559 }
560
561 /******************************************************************************
562  * TestSetValueEx
563  */
564 void TestSetValueEx()
565 {
566     long lSts;
567
568     lSts = RegSetValueEx((HKEY)2,"",0,0,NULL,0);
569     if (lSts != ERROR_INVALID_HANDLE) xERROR(1,lSts);
570
571     lSts = RegSetValueEx(HKEY_LOCAL_MACHINE,"",0,0,NULL,0);
572     if (lSts != ERROR_SUCCESS) xERROR(2,lSts);
573 }
574
575 /******************************************************************************
576  * TestUnLoadKey
577  */
578 void TestUnLoadKey()
579 {
580 #if CHECK_SAM
581     long lSts;
582 #endif
583
584 #if CHECK_SAM
585     lSts = RegUnLoadKey((HKEY)2,"");
586     if (lSts != ERROR_PRIVILEGE_NOT_HELD) xERROR(1,lSts);
587
588     lSts = RegUnLoadKey(HKEY_LOCAL_MACHINE,"");
589     if (lSts != ERROR_PRIVILEGE_NOT_HELD) xERROR(2,lSts);
590
591     lSts = RegUnLoadKey(HKEY_LOCAL_MACHINE,"\\regtest");
592     if (lSts != ERROR_PRIVILEGE_NOT_HELD) xERROR(3,lSts);
593 #endif
594 }
595
596 /******************************************************************************
597  * TestSequence1
598  */
599 void TestSequence1()
600 {
601     HKEY hkey;
602     long lSts;
603
604     lSts = RegCreateKey(HKEY_CURRENT_USER,"regtest",&hkey);
605     if (lSts != ERROR_SUCCESS) xERROR(1,lSts);
606
607 /*    fprintf(stderr, " hkey=0x%x\n", hkey); */
608
609     lSts = RegDeleteKey(HKEY_CURRENT_USER, "regtest");
610     if (lSts != ERROR_SUCCESS) xERROR(2,lSts);
611     lSts = RegCloseKey(hkey);
612     if (lSts != ERROR_SUCCESS) xERROR(3,lSts);
613 }
614
615
616 int PASCAL WinMain (HANDLE inst, HANDLE prev, LPSTR cmdline, int show)
617 {
618
619     /* These can be in any order */
620     TestCloseKey();
621     TestConnectRegistry();
622     TestCreateKey();
623     TestCreateKeyEx();
624     TestDeleteKey();
625     TestDeleteValue();
626     TestEnumKey();
627     TestEnumKeyEx();
628     TestEnumValue();
629     TestFlushKey();
630     TestGetKeySecurity();
631     TestLoadKey();
632     TestNotifyChangeKeyValue();
633     TestOpenKey();
634     TestOpenKeyEx();
635     TestQueryInfoKey();
636     TestQueryValue();
637     TestQueryValueEx();
638     TestReplaceKey();
639     TestRestoreKey();
640     TestSaveKey();
641     TestSetKeySecurity();
642     TestSetValue();
643     TestSetValueEx();
644     TestUnLoadKey();
645
646     /* Now we have some sequence testing */
647     TestSequence1();
648
649     return 0;
650 }
651