add some tests
[reactos.git] / reactos / apps / tests / regtest / regtest.c
1 #include <stdarg.h>
2 #include <string.h>
3 #include <stdio.h>
4 #include <windows.h>
5 #include <ddk/ntddk.h>
6
7 HANDLE OutputHandle;
8 HANDLE InputHandle;
9
10 void dprintf(char* fmt, ...)
11 {
12 va_list args;
13 char buffer[255];
14
15 va_start(args,fmt);
16 vsprintf(buffer,fmt,args);
17 WriteConsoleA(OutputHandle, buffer, strlen(buffer), NULL, NULL);
18 va_end(args);
19 }
20
21 void test1(void)
22 {
23 HKEY hKey = NULL,hKey1;
24 OBJECT_ATTRIBUTES ObjectAttributes;
25 NTSTATUS Status;
26 UNICODE_STRING KeyName;
27 ULONG Index,Length,i;
28 KEY_BASIC_INFORMATION KeyInformation[5];
29 KEY_VALUE_FULL_INFORMATION KeyValueInformation[5];
30
31 AllocConsole();
32 InputHandle = GetStdHandle(STD_INPUT_HANDLE);
33 OutputHandle = GetStdHandle(STD_OUTPUT_HANDLE);
34
35 dprintf("NtOpenKey \\Registry : ");
36 RtlInitUnicodeString(&KeyName, L"\\Registry");
37 InitializeObjectAttributes(&ObjectAttributes,
38 &KeyName,
39 OBJ_CASE_INSENSITIVE,
40 NULL,
41 NULL);
42 Status=NtOpenKey( &hKey1, MAXIMUM_ALLOWED, &ObjectAttributes);
43 dprintf("\t\t\t\tStatus =%x\n",Status);
44 if(Status==0)
45 {
46 dprintf("NtQueryKey : ");
47 Status=NtQueryKey(hKey1,KeyBasicInformation
48 ,&KeyInformation[0], sizeof(KeyInformation)
49 ,&Length);
50 dprintf("\t\t\t\t\tStatus =%x\n",Status);
51 if (Status == STATUS_SUCCESS)
52 {
53 dprintf("\tKey Name = ");
54 for (i=0;i<KeyInformation[0].NameLength/2;i++)
55 dprintf("%C",KeyInformation[0].Name[i]);
56 dprintf("\n");
57 }
58 dprintf("NtEnumerateKey : \n");
59 Index=0;
60 while(Status == STATUS_SUCCESS)
61 {
62 Status=NtEnumerateKey(hKey1,Index++,KeyBasicInformation
63 ,&KeyInformation[0], sizeof(KeyInformation)
64 ,&Length);
65 if(Status== STATUS_SUCCESS)
66 {
67 dprintf("\tSubKey Name = ");
68 for (i=0;i<KeyInformation[0].NameLength/2;i++)
69 dprintf("%C",KeyInformation[0].Name[i]);
70 dprintf("\n");
71 }
72 }
73 dprintf("NtClose : ");
74 Status = NtClose( hKey1 );
75 dprintf("\t\t\t\t\tStatus =%x\n",Status);
76 }
77 NtClose(hKey);
78
79 dprintf("NtOpenKey \\Registry\\Machine : ");
80 RtlInitUnicodeString(&KeyName, L"\\Registry\\Machine");
81 InitializeObjectAttributes(&ObjectAttributes,
82 &KeyName,
83 OBJ_CASE_INSENSITIVE,
84 NULL,
85 NULL);
86 Status=NtOpenKey( &hKey1, MAXIMUM_ALLOWED, &ObjectAttributes);
87 dprintf("\t\t\tStatus =%x\n",Status);
88
89 dprintf("NtOpenKey System\\Setup : ");
90 RtlInitUnicodeString(&KeyName, L"System\\Setup");
91 InitializeObjectAttributes(&ObjectAttributes, &KeyName, OBJ_CASE_INSENSITIVE
92 , hKey1 , NULL);
93 Status = NtOpenKey ( &hKey, KEY_READ , &ObjectAttributes);
94 dprintf("\t\t\tStatus =%x\n",Status);
95 if(Status==0)
96 {
97 dprintf("NtQueryValueKey : ");
98 RtlInitUnicodeString(&KeyName, L"CmdLine");
99 Status=NtQueryValueKey(hKey,&KeyName,KeyValueFullInformation
100 ,&KeyValueInformation[0], sizeof(KeyValueInformation)
101 ,&Length);
102 dprintf("\t\t\t\tStatus =%x\n",Status);
103 if (Status == STATUS_SUCCESS)
104 {
105 dprintf("\tValue:DO=%d, DL=%d, NL=%d, Name = "
106 ,KeyValueInformation[0].DataOffset
107 ,KeyValueInformation[0].DataLength
108 ,KeyValueInformation[0].NameLength);
109 for (i=0;i<10 && i<KeyValueInformation[0].NameLength/2;i++)
110 dprintf("%C",KeyValueInformation[0].Name[i]);
111 dprintf("\n");
112 dprintf("\t\tType = %d\n",KeyValueInformation[0].Type);
113 if (KeyValueInformation[0].Type == REG_SZ)
114 dprintf("\t\tValue = %S\n",KeyValueInformation[0].Name+1
115 +KeyValueInformation[0].NameLength/2);
116 }
117 dprintf("NtEnumerateValueKey : \n");
118 Index=0;
119 while(Status == STATUS_SUCCESS)
120 {
121 Status=NtEnumerateValueKey(hKey,Index++,KeyValueFullInformation
122 ,&KeyValueInformation[0], sizeof(KeyValueInformation)
123 ,&Length);
124 if(Status== STATUS_SUCCESS)
125 {
126 dprintf("\tValue:DO=%d, DL=%d, NL=%d, Name = "
127 ,KeyValueInformation[0].DataOffset
128 ,KeyValueInformation[0].DataLength
129 ,KeyValueInformation[0].NameLength);
130 for (i=0;i<KeyValueInformation[0].NameLength/2;i++)
131 dprintf("%C",KeyValueInformation[0].Name[i]);
132 dprintf(", Type = %d\n",KeyValueInformation[0].Type);
133 if (KeyValueInformation[0].Type == REG_SZ)
134 dprintf("\t\tValue = %S\n",((char*)&KeyValueInformation[0]
135 +KeyValueInformation[0].DataOffset));
136 }
137 }
138 dprintf("NtClose : ");
139 Status = NtClose( hKey );
140 dprintf("\t\t\t\t\tStatus =%x\n",Status);
141 }
142 NtClose( hKey1 );
143 }
144
145 void test2(void)
146 {
147 HKEY hKey,hKey1;
148 OBJECT_ATTRIBUTES ObjectAttributes;
149 UNICODE_STRING KeyName,ValueName;
150 NTSTATUS Status;
151 KEY_VALUE_FULL_INFORMATION KeyValueInformation[5];
152 ULONG Index,Length,i;
153 char Buffer[10];
154 DWORD Result;
155 dprintf("NtCreateKey volatile: \n");
156 dprintf(" \\Registry\\Machine\\Software\\test2reactos: ");
157 RtlInitUnicodeString(&KeyName, L"\\Registry\\Machine\\Software\\test2reactos");
158 InitializeObjectAttributes(&ObjectAttributes, &KeyName, OBJ_CASE_INSENSITIVE
159 , NULL, NULL);
160 Status = NtCreateKey ( &hKey, KEY_ALL_ACCESS , &ObjectAttributes
161 ,0,NULL,REG_OPTION_VOLATILE,NULL);
162 dprintf("\t\tStatus=%x\n",Status);
163 NtClose(hKey);
164 dprintf(" ...\\test2 :");
165 RtlInitUnicodeString(&KeyName, L"\\Registry\\Machine\\Software\\test2reactos\\test2");
166 InitializeObjectAttributes(&ObjectAttributes, &KeyName, OBJ_CASE_INSENSITIVE
167 , NULL, NULL);
168 Status = NtCreateKey ( &hKey1, KEY_ALL_ACCESS , &ObjectAttributes
169 ,0,NULL,REG_OPTION_VOLATILE,NULL);
170 dprintf("\t\t\t\t\tStatus=%x\n",Status);
171 dprintf(" ...\\TestVolatile :");
172 RtlInitUnicodeString(&KeyName, L"TestVolatile");
173 InitializeObjectAttributes(&ObjectAttributes, &KeyName, OBJ_CASE_INSENSITIVE
174 , hKey1, NULL);
175 Status = NtCreateKey ( &hKey, KEY_ALL_ACCESS , &ObjectAttributes
176 ,0,NULL,REG_OPTION_VOLATILE,NULL);
177 dprintf("\t\t\t\tStatus=%x\n",Status);
178 NtClose(hKey1);
179 RtlInitUnicodeString(&ValueName, L"TestREG_SZ");
180 dprintf("NtSetValueKey reg_sz: ");
181 Status=NtSetValueKey(hKey,&ValueName,0,REG_SZ,(PVOID)L"Test Reg_sz",24);
182 dprintf("\t\t\t\tStatus=%x\n",Status);
183 RtlInitUnicodeString(&ValueName, L"TestDWORD");
184 dprintf("NtSetValueKey reg_dword: ");
185 Status=NtSetValueKey(hKey,&ValueName,0,REG_DWORD,(PVOID)"reac",4);
186 dprintf("\t\t\tStatus=%x\n",Status);
187 NtClose(hKey);
188 dprintf("NtOpenKey \\Registry\\Machine\\Software\\test2reactos\\test2\\TestVolatile : ");
189 RtlInitUnicodeString(&KeyName, L"\\Registry\\Machine\\Software\\test2reactos\\test2\\TestVolatile");
190 InitializeObjectAttributes(&ObjectAttributes,
191 &KeyName,
192 OBJ_CASE_INSENSITIVE,
193 NULL,
194 NULL);
195 Status=NtOpenKey( &hKey, MAXIMUM_ALLOWED, &ObjectAttributes);
196 dprintf("\t\t\t\tStatus =%x\n",Status);
197 if(Status==0)
198 {
199 dprintf("NtEnumerateValueKey : \n");
200 Index=0;
201 while(Status == STATUS_SUCCESS)
202 {
203 Status=NtEnumerateValueKey(hKey,Index++,KeyValueFullInformation
204 ,&KeyValueInformation[0], sizeof(KeyValueInformation)
205 ,&Length);
206 if(Status== STATUS_SUCCESS)
207 {
208 dprintf("\tValue:DO=%d, DL=%d, NL=%d, Name = "
209 ,KeyValueInformation[0].DataOffset
210 ,KeyValueInformation[0].DataLength
211 ,KeyValueInformation[0].NameLength);
212 for (i=0;i<KeyValueInformation[0].NameLength/2;i++)
213 dprintf("%C",KeyValueInformation[0].Name[i]);
214 dprintf(", Type = %d\n",KeyValueInformation[0].Type);
215 if (KeyValueInformation[0].Type == REG_SZ)
216 dprintf("\t\tValue = %S\n",((char*)&KeyValueInformation[0]
217 +KeyValueInformation[0].DataOffset));
218 }
219 }
220 }
221 NtClose(hKey);
222 dprintf("delete \\Registry\\Machine\\software\\test3reactos ?");
223 ReadConsoleA(InputHandle, Buffer, 3, &Result, NULL) ;
224 if (Buffer[0] != 'y' && Buffer[0] != 'Y') return;
225 RtlInitUnicodeString(&KeyName, L"\\Registry\\Machine\\Software\\test2reactos\\test2\\TestVolatile");
226 InitializeObjectAttributes(&ObjectAttributes,
227 &KeyName,
228 OBJ_CASE_INSENSITIVE,
229 NULL,
230 NULL);
231 dprintf("NtOpenKey : ");
232 Status=NtOpenKey( &hKey, KEY_ALL_ACCESS, &ObjectAttributes);
233 dprintf("\t\t\t\tStatus =%x\n",Status);
234 dprintf("NtDeleteKey : ");
235 Status=NtDeleteKey(hKey);
236 dprintf("\t\t\t\tStatus =%x\n",Status);
237 NtClose(hKey);
238 RtlInitUnicodeString(&KeyName, L"\\Registry\\Machine\\Software\\test2reactos\\test2");
239 InitializeObjectAttributes(&ObjectAttributes,
240 &KeyName,
241 OBJ_CASE_INSENSITIVE,
242 NULL,
243 NULL);
244 dprintf("NtOpenKey : ");
245 Status=NtOpenKey( &hKey, KEY_ALL_ACCESS, &ObjectAttributes);
246 dprintf("\t\t\t\tStatus =%x\n",Status);
247 dprintf("NtDeleteKey : ");
248 Status=NtDeleteKey(hKey);
249 dprintf("\t\t\t\tStatus =%x\n",Status);
250 NtClose(hKey);
251 RtlInitUnicodeString(&KeyName, L"\\Registry\\Machine\\Software\\test2reactos");
252 InitializeObjectAttributes(&ObjectAttributes,
253 &KeyName,
254 OBJ_CASE_INSENSITIVE,
255 NULL,
256 NULL);
257 dprintf("NtOpenKey : ");
258 Status=NtOpenKey( &hKey, KEY_ALL_ACCESS, &ObjectAttributes);
259 dprintf("\t\t\t\tStatus =%x\n",Status);
260 dprintf("NtDeleteKey : ");
261 Status=NtDeleteKey(hKey);
262 dprintf("\t\t\t\tStatus =%x\n",Status);
263 NtClose(hKey);
264 }
265
266 void test3(void)
267 {
268 HKEY hKey,hKey1;
269 OBJECT_ATTRIBUTES ObjectAttributes;
270 UNICODE_STRING KeyName,ValueName;
271 NTSTATUS Status;
272 KEY_VALUE_FULL_INFORMATION KeyValueInformation[5];
273 ULONG Index,Length,i;
274 char Buffer[10];
275 DWORD Result;
276 dprintf("NtCreateKey non volatile: \n");
277 dprintf(" \\Registry\\Machine\\Software\\test3reactos: ");
278 RtlInitUnicodeString(&KeyName, L"\\Registry\\Machine\\Software\\test3reactos");
279 InitializeObjectAttributes(&ObjectAttributes, &KeyName, OBJ_CASE_INSENSITIVE
280 , NULL, NULL);
281 Status = NtCreateKey ( &hKey, KEY_ALL_ACCESS , &ObjectAttributes
282 ,0,NULL,REG_OPTION_NON_VOLATILE,NULL);
283 dprintf("\t\tStatus=%x\n",Status);
284 NtClose(hKey);
285 dprintf(" ...\\test3 :");
286 RtlInitUnicodeString(&KeyName, L"\\Registry\\Machine\\Software\\test3reactos\\test3");
287 InitializeObjectAttributes(&ObjectAttributes, &KeyName, OBJ_CASE_INSENSITIVE
288 , NULL, NULL);
289 Status = NtCreateKey ( &hKey1, KEY_ALL_ACCESS , &ObjectAttributes
290 ,0,NULL,REG_OPTION_NON_VOLATILE,NULL);
291 dprintf("\t\t\t\t\tStatus=%x\n",Status);
292 dprintf(" ...\\testNonVolatile :");
293 RtlInitUnicodeString(&KeyName, L"TestNonVolatile");
294 InitializeObjectAttributes(&ObjectAttributes, &KeyName, OBJ_CASE_INSENSITIVE
295 , hKey1, NULL);
296 Status = NtCreateKey ( &hKey, KEY_ALL_ACCESS , &ObjectAttributes
297 ,0,NULL,REG_OPTION_NON_VOLATILE,NULL);
298 dprintf("\t\t\t\tStatus=%x\n",Status);
299 NtClose(hKey1);
300 RtlInitUnicodeString(&ValueName, L"TestREG_SZ");
301 dprintf("NtSetValueKey reg_sz: ");
302 Status=NtSetValueKey(hKey,&ValueName,0,REG_SZ,(PVOID)L"Test Reg_sz",24);
303 dprintf("\t\t\t\tStatus=%x\n",Status);
304 RtlInitUnicodeString(&ValueName, L"TestDWORD");
305 dprintf("NtSetValueKey reg_dword: ");
306 Status=NtSetValueKey(hKey,&ValueName,0,REG_DWORD,(PVOID)"reac",4);
307 dprintf("\t\t\tStatus=%x\n",Status);
308 NtClose(hKey);
309 dprintf("NtOpenKey \\Registry\\Machine\\Software\\test3reactos\\test3\\testNonVolatile : ");
310 RtlInitUnicodeString(&KeyName, L"\\Registry\\Machine\\Software\\test3reactos\\test3\\testNonVolatile");
311 InitializeObjectAttributes(&ObjectAttributes,
312 &KeyName,
313 OBJ_CASE_INSENSITIVE,
314 NULL,
315 NULL);
316 Status=NtOpenKey( &hKey, MAXIMUM_ALLOWED, &ObjectAttributes);
317 dprintf("\t\t\t\tStatus =%x\n",Status);
318 if(Status==0)
319 {
320 dprintf("NtEnumerateValueKey : \n");
321 Index=0;
322 while(Status == STATUS_SUCCESS)
323 {
324 Status=NtEnumerateValueKey(hKey,Index++,KeyValueFullInformation
325 ,&KeyValueInformation[0], sizeof(KeyValueInformation)
326 ,&Length);
327 if(Status== STATUS_SUCCESS)
328 {
329 dprintf("\tValue:DO=%d, DL=%d, NL=%d, Name = "
330 ,KeyValueInformation[0].DataOffset
331 ,KeyValueInformation[0].DataLength
332 ,KeyValueInformation[0].NameLength);
333 for (i=0;i<KeyValueInformation[0].NameLength/2;i++)
334 dprintf("%C",KeyValueInformation[0].Name[i]);
335 dprintf(", Type = %d\n",KeyValueInformation[0].Type);
336 if (KeyValueInformation[0].Type == REG_SZ)
337 dprintf("\t\tValue = %S\n",((char*)&KeyValueInformation[0]
338 +KeyValueInformation[0].DataOffset));
339 }
340 }
341 }
342 NtClose(hKey);
343 dprintf("delete \\Registry\\Machine\\software\\test3reactos ?");
344 ReadConsoleA(InputHandle, Buffer, 3, &Result, NULL) ;
345 if (Buffer[0] != 'y' && Buffer[0] != 'Y') return;
346 RtlInitUnicodeString(&KeyName, L"\\Registry\\Machine\\Software\\test3reactos\\test3\\testNonvolatile");
347 InitializeObjectAttributes(&ObjectAttributes,
348 &KeyName,
349 OBJ_CASE_INSENSITIVE,
350 NULL,
351 NULL);
352 dprintf("NtOpenKey : ");
353 Status=NtOpenKey( &hKey, KEY_ALL_ACCESS, &ObjectAttributes);
354 dprintf("\t\t\t\tStatus =%x\n",Status);
355 dprintf("NtDeleteKey : ");
356 Status=NtDeleteKey(hKey);
357 dprintf("\t\t\t\tStatus =%x\n",Status);
358 RtlInitUnicodeString(&KeyName, L"\\Registry\\Machine\\Software\\test3reactos\\test3");
359 InitializeObjectAttributes(&ObjectAttributes,
360 &KeyName,
361 OBJ_CASE_INSENSITIVE,
362 NULL,
363 NULL);
364 dprintf("NtOpenKey : ");
365 Status=NtOpenKey( &hKey, KEY_ALL_ACCESS, &ObjectAttributes);
366 dprintf("\t\t\t\tStatus =%x\n",Status);
367 dprintf("NtDeleteKey : ");
368 Status=NtDeleteKey(hKey);
369 dprintf("\t\t\t\tStatus =%x\n",Status);
370 NtClose(hKey);
371 RtlInitUnicodeString(&KeyName, L"\\Registry\\Machine\\Software\\test3reactos");
372 InitializeObjectAttributes(&ObjectAttributes,
373 &KeyName,
374 OBJ_CASE_INSENSITIVE,
375 NULL,
376 NULL);
377 dprintf("NtOpenKey : ");
378 Status=NtOpenKey( &hKey, KEY_ALL_ACCESS, &ObjectAttributes);
379 dprintf("\t\t\t\tStatus =%x\n",Status);
380 dprintf("NtDeleteKey : ");
381 Status=NtDeleteKey(hKey);
382 dprintf("\t\t\t\tStatus =%x\n",Status);
383 NtClose(hKey);
384 }
385
386 void test4(void)
387 {
388 HKEY hKey = NULL,hKey1;
389 DWORD dwDisposition;
390 DWORD dwError;
391 DWORD RegDataType, RegDataSize;
392 BOOL GlobalFifoEnable;
393 HKEY hPortKey;
394 DWORD RegDisposition;
395 WCHAR szClass[260];
396 DWORD cchClass;
397 DWORD cSubKeys;
398 DWORD cchMaxSubkey;
399 DWORD cchMaxClass;
400 DWORD cValues;
401 DWORD cchMaxValueName;
402 DWORD cbMaxValueData;
403 DWORD cbSecurityDescriptor;
404 FILETIME ftLastWriteTime;
405 SYSTEMTIME LastWriteTime;
406
407 dprintf ("RegOpenKeyExW HKLM\\System\\Setup: ");
408 dwError = RegOpenKeyExW(HKEY_LOCAL_MACHINE,
409 L"System\\Setup",
410 0,
411 KEY_ALL_ACCESS,
412 &hKey1);
413 dprintf("\t\tdwError =%x\n",dwError);
414 if (dwError == ERROR_SUCCESS)
415 {
416 dprintf("RegQueryInfoKeyW: ");
417 cchClass=260;
418 dwError = RegQueryInfoKeyW(hKey1
419 , szClass, &cchClass, NULL, &cSubKeys
420 , &cchMaxSubkey, &cchMaxClass, &cValues, &cchMaxValueName
421 , &cbMaxValueData, &cbSecurityDescriptor, &ftLastWriteTime);
422 dprintf ("\t\t\t\tdwError %x\n", dwError);
423 FileTimeToSystemTime(&ftLastWriteTime,&LastWriteTime);
424 dprintf ("\tnb of subkeys=%d,last write : %d/%d/%d %d:%02.2d'%02.2d''%03.3d\n",cSubKeys
425 ,LastWriteTime.wMonth
426 ,LastWriteTime.wDay
427 ,LastWriteTime.wYear
428 ,LastWriteTime.wHour
429 ,LastWriteTime.wMinute
430 ,LastWriteTime.wSecond
431 ,LastWriteTime.wMilliseconds
432 );
433 }
434
435
436 dprintf ("RegOpenKeyExW: ");
437 dwError = RegOpenKeyExW(HKEY_LOCAL_MACHINE,
438 L"System\\ControlSet001\\Services\\Serial",
439 0,
440 KEY_ALL_ACCESS,
441 &hKey);
442 dprintf ("\t\t\t\t\tdwError %x\n", dwError);
443 RegDataSize = sizeof(GlobalFifoEnable);
444 if (dwError == ERROR_SUCCESS)
445 {
446 dprintf ("RegQueryValueExW: ");
447 dwError = RegQueryValueExW(hKey,
448 L"ForceFifoEnable",
449 NULL,
450 &RegDataType,
451 (PBYTE)&GlobalFifoEnable,
452 &RegDataSize);
453 dprintf("\t\t\t\tdwError =%x\n",dwError);
454 if (dwError == 0)
455 {
456 dprintf("\tValue:DT=%d, DS=%d, Value=%d\n"
457 ,RegDataType
458 ,RegDataSize
459 ,GlobalFifoEnable);
460 }
461 }
462 dprintf ("RegCreateKeyExW: ");
463 dwError = RegCreateKeyExW(hKey,
464 L"Parameters\\Serial001",
465 0,
466 NULL,
467 0,
468 KEY_ALL_ACCESS,
469 NULL,
470 &hPortKey,
471 &RegDisposition
472 );
473 dprintf ("\t\t\t\tdwError %x\n", dwError);
474
475 dprintf ("RegCreateKeyExW: ");
476 dwError = RegCreateKeyExW (HKEY_LOCAL_MACHINE,
477 L"Software\\test4reactos\\test",
478 0,
479 NULL,
480 REG_OPTION_NON_VOLATILE,
481 KEY_ALL_ACCESS,
482 NULL,
483 &hKey,
484 &dwDisposition);
485
486 dprintf ("\t\t\t\tdwError %x ", dwError);
487 dprintf ("dwDisposition %x\n", dwDisposition);
488 if (dwError == ERROR_SUCCESS)
489 {
490 dprintf ("RegSetValueExW: ");
491 dwError = RegSetValueExW (hKey,
492 L"TestValue",
493 0,
494 REG_SZ,
495 (BYTE*)L"TestString",
496 20);
497
498 dprintf ("\t\t\t\tdwError %x\n", dwError);
499 dprintf ("RegCloseKey: ");
500 dwError = RegCloseKey (hKey);
501 dprintf ("\t\t\t\t\tdwError %x\n", dwError);
502 }
503 dprintf ("\n\n");
504
505 hKey = NULL;
506
507 dprintf ("RegCreateKeyExW: ");
508 dwError = RegCreateKeyExW (HKEY_LOCAL_MACHINE,
509 L"software\\Test",
510 0,
511 NULL,
512 REG_OPTION_VOLATILE,
513 KEY_ALL_ACCESS,
514 NULL,
515 &hKey,
516 &dwDisposition);
517
518 dprintf ("\t\t\t\tdwError %x ", dwError);
519 dprintf ("dwDisposition %x\n", dwDisposition);
520
521
522 if (dwError == ERROR_SUCCESS)
523 {
524 dprintf("RegQueryInfoKeyW: ");
525 cchClass=260;
526 dwError = RegQueryInfoKeyW(hKey
527 , szClass, &cchClass, NULL, &cSubKeys
528 , &cchMaxSubkey, &cchMaxClass, &cValues, &cchMaxValueName
529 , &cbMaxValueData, &cbSecurityDescriptor, &ftLastWriteTime);
530 dprintf ("\t\t\t\tdwError %x\n", dwError);
531 FileTimeToSystemTime(&ftLastWriteTime,&LastWriteTime);
532 dprintf ("\tnb of subkeys=%d,last write : %d/%d/%d %d:%02.2d'%02.2d''%03.3d\n",cSubKeys
533 ,LastWriteTime.wMonth
534 ,LastWriteTime.wDay
535 ,LastWriteTime.wYear
536 ,LastWriteTime.wHour
537 ,LastWriteTime.wMinute
538 ,LastWriteTime.wSecond
539 ,LastWriteTime.wMilliseconds
540 );
541 dprintf ("RegCloseKey: ");
542 dwError = RegCloseKey (hKey);
543 dprintf ("\t\t\t\t\tdwError %x\n", dwError);
544 }
545 dprintf ("\nTests done...\n");
546 }
547
548 int main(int argc, char* argv[])
549 {
550 char Buffer[10];
551 DWORD Result;
552
553 AllocConsole();
554 InputHandle = GetStdHandle(STD_INPUT_HANDLE);
555 OutputHandle = GetStdHandle(STD_OUTPUT_HANDLE);
556
557 dprintf("choose test :\n");
558 dprintf(" 1=Ntxxx read functions\n");
559 dprintf(" 2=Ntxxx write functions : volatile keys\n");
560 dprintf(" 3=Ntxxx write functions : non volatile keys\n");
561 dprintf(" 4=Regxxx functions\n");
562 ReadConsoleA(InputHandle, Buffer, 3, &Result, NULL) ;
563 switch (Buffer[0])
564 {
565 case '1':
566 test1();
567 break;
568 case '2':
569 test2();
570 break;
571 case '3':
572 test3();
573 break;
574 case '4':
575 test4();
576 break;
577 }
578 return 0;
579 }