add some tests
authorjean <jean@svn.reactos.org>
Thu, 5 Oct 2000 14:55:55 +0000 (14:55 +0000)
committerjean <jean@svn.reactos.org>
Thu, 5 Oct 2000 14:55:55 +0000 (14:55 +0000)
svn path=/trunk/; revision=1377

reactos/apps/tests/regtest/regtest.c

index 2e135af..ea50cf6 100644 (file)
@@ -18,21 +18,12 @@ void dprintf(char* fmt, ...)
    va_end(args);
 }
 
-
-int main(int argc, char* argv[])
+void test1(void)
 {
-   HKEY hKey = NULL,hKey1;
-   DWORD dwDisposition;
-   DWORD dwError;
-    DWORD Err, RegDataType, RegDataSize, OldComPortNumber;
-    OBJECT_ATTRIBUTES ObjectAttributes; 
-    HANDLE StConfigHandle; 
-    ULONG Disposition; 
-    NTSTATUS Status; 
-  UNICODE_STRING KeyName;
-    BOOL GlobalFifoEnable;
-    HKEY hPortKey;
-    DWORD RegDisposition;
+ HKEY hKey = NULL,hKey1;
+ OBJECT_ATTRIBUTES ObjectAttributes; 
+ NTSTATUS Status; 
+ UNICODE_STRING KeyName;
  ULONG Index,Length,i;
  KEY_BASIC_INFORMATION KeyInformation[5];
  KEY_VALUE_FULL_INFORMATION KeyValueInformation[5];
@@ -79,10 +70,11 @@ int main(int argc, char* argv[])
         dprintf("\n");
        }
     }
-    dprintf("NtCloseKey : ");
+    dprintf("NtClose : ");
     Status = NtClose( hKey1 );
     dprintf("\t\t\t\t\tStatus =%x\n",Status);
   }
+  NtClose(hKey);
 
   dprintf("NtOpenKey \\Registry\\Machine : ");
   RtlInitUnicodeString(&KeyName, L"\\Registry\\Machine");
@@ -110,9 +102,9 @@ int main(int argc, char* argv[])
     dprintf("\t\t\t\tStatus =%x\n",Status);
     if (Status == STATUS_SUCCESS)
     {
-        dprintf("\tValue:DO=%d, DL=%d, NL=%d, Name = "\r
-               ,KeyValueInformation[0].DataOffset\r
-               ,KeyValueInformation[0].DataLength\r
+        dprintf("\tValue:DO=%d, DL=%d, NL=%d, Name = "
+               ,KeyValueInformation[0].DataOffset
+               ,KeyValueInformation[0].DataLength
                ,KeyValueInformation[0].NameLength);
          for (i=0;i<10 && i<KeyValueInformation[0].NameLength/2;i++)
                dprintf("%C",KeyValueInformation[0].Name[i]);
@@ -131,10 +123,10 @@ int main(int argc, char* argv[])
                ,&Length);
       if(Status== STATUS_SUCCESS)
        {
-        dprintf("\tValue:DO=%d, DL=%d, NL=%d, Name = "\r
-               ,KeyValueInformation[0].DataOffset\r
-               ,KeyValueInformation[0].DataLength\r
-               ,KeyValueInformation[0].NameLength);\r
+        dprintf("\tValue:DO=%d, DL=%d, NL=%d, Name = "
+               ,KeyValueInformation[0].DataOffset
+               ,KeyValueInformation[0].DataLength
+               ,KeyValueInformation[0].NameLength);
          for (i=0;i<KeyValueInformation[0].NameLength/2;i++)
                dprintf("%C",KeyValueInformation[0].Name[i]);
         dprintf(", Type = %d\n",KeyValueInformation[0].Type);
@@ -143,27 +135,302 @@ int main(int argc, char* argv[])
                                        +KeyValueInformation[0].DataOffset));
        }
     }
-    dprintf("NtCloseKey : ");
-    Status = NtClose( hKey1 );
+    dprintf("NtClose : ");
+    Status = NtClose( hKey );
     dprintf("\t\t\t\t\tStatus =%x\n",Status);
   }
+  NtClose( hKey1 );
+}
 
+void test2(void)
+{
+ HKEY hKey,hKey1;
+ OBJECT_ATTRIBUTES ObjectAttributes; 
+ UNICODE_STRING KeyName,ValueName;
+ NTSTATUS Status; 
+ KEY_VALUE_FULL_INFORMATION KeyValueInformation[5];
+ ULONG Index,Length,i;
+ char Buffer[10];
+ DWORD Result;
+  dprintf("NtCreateKey volatile: \n");
+  dprintf("  \\Registry\\Machine\\Software\\test2reactos: ");
+  RtlInitUnicodeString(&KeyName, L"\\Registry\\Machine\\Software\\test2reactos");
+  InitializeObjectAttributes(&ObjectAttributes, &KeyName, OBJ_CASE_INSENSITIVE
+                               , NULL, NULL);
+  Status = NtCreateKey ( &hKey, KEY_ALL_ACCESS , &ObjectAttributes
+               ,0,NULL,REG_OPTION_VOLATILE,NULL);
+  dprintf("\t\tStatus=%x\n",Status);
+  NtClose(hKey);
+  dprintf("  ...\\test2 :");
+  RtlInitUnicodeString(&KeyName, L"\\Registry\\Machine\\Software\\test2reactos\\test2");
+  InitializeObjectAttributes(&ObjectAttributes, &KeyName, OBJ_CASE_INSENSITIVE
+                               , NULL, NULL);
+  Status = NtCreateKey ( &hKey1, KEY_ALL_ACCESS , &ObjectAttributes
+               ,0,NULL,REG_OPTION_VOLATILE,NULL);
+  dprintf("\t\t\t\t\tStatus=%x\n",Status);
+  dprintf("  ...\\TestVolatile :");
+  RtlInitUnicodeString(&KeyName, L"TestVolatile");
+  InitializeObjectAttributes(&ObjectAttributes, &KeyName, OBJ_CASE_INSENSITIVE
+                               , hKey1, NULL);
+  Status = NtCreateKey ( &hKey, KEY_ALL_ACCESS , &ObjectAttributes
+               ,0,NULL,REG_OPTION_VOLATILE,NULL);
+  dprintf("\t\t\t\tStatus=%x\n",Status);
+  NtClose(hKey1);
+  RtlInitUnicodeString(&ValueName, L"TestREG_SZ");
+  dprintf("NtSetValueKey reg_sz: ");
+  Status=NtSetValueKey(hKey,&ValueName,0,REG_SZ,(PVOID)L"Test Reg_sz",24);
+  dprintf("\t\t\t\tStatus=%x\n",Status);
+  RtlInitUnicodeString(&ValueName, L"TestDWORD");
+  dprintf("NtSetValueKey reg_dword: ");
+  Status=NtSetValueKey(hKey,&ValueName,0,REG_DWORD,(PVOID)"reac",4);
+  dprintf("\t\t\tStatus=%x\n",Status);
+  NtClose(hKey);
+  dprintf("NtOpenKey \\Registry\\Machine\\Software\\test2reactos\\test2\\TestVolatile : ");
+  RtlInitUnicodeString(&KeyName, L"\\Registry\\Machine\\Software\\test2reactos\\test2\\TestVolatile");
+  InitializeObjectAttributes(&ObjectAttributes,
+                               &KeyName,
+                               OBJ_CASE_INSENSITIVE,
+                               NULL,
+                               NULL);
+  Status=NtOpenKey( &hKey, MAXIMUM_ALLOWED, &ObjectAttributes);
+  dprintf("\t\t\t\tStatus =%x\n",Status);
+  if(Status==0)
+  {
+    dprintf("NtEnumerateValueKey : \n");
+    Index=0;
+    while(Status == STATUS_SUCCESS)
+    {
+      Status=NtEnumerateValueKey(hKey,Index++,KeyValueFullInformation
+               ,&KeyValueInformation[0], sizeof(KeyValueInformation)
+               ,&Length);
+      if(Status== STATUS_SUCCESS)
+       {
+        dprintf("\tValue:DO=%d, DL=%d, NL=%d, Name = "
+               ,KeyValueInformation[0].DataOffset
+               ,KeyValueInformation[0].DataLength
+               ,KeyValueInformation[0].NameLength);
+         for (i=0;i<KeyValueInformation[0].NameLength/2;i++)
+               dprintf("%C",KeyValueInformation[0].Name[i]);
+        dprintf(", Type = %d\n",KeyValueInformation[0].Type);
+         if (KeyValueInformation[0].Type == REG_SZ)
+          dprintf("\t\tValue = %S\n",((char*)&KeyValueInformation[0]
+                                       +KeyValueInformation[0].DataOffset));
+       }
+    }
+  }
+  NtClose(hKey);
+  dprintf("delete \\Registry\\Machine\\software\\test3reactos ?");
+  ReadConsoleA(InputHandle, Buffer, 3, &Result, NULL) ;
+  if (Buffer[0] != 'y' && Buffer[0] != 'Y') return;
+  RtlInitUnicodeString(&KeyName, L"\\Registry\\Machine\\Software\\test2reactos\\test2\\TestVolatile");
+  InitializeObjectAttributes(&ObjectAttributes,
+                               &KeyName,
+                               OBJ_CASE_INSENSITIVE,
+                               NULL,
+                               NULL);
+  dprintf("NtOpenKey : ");
+  Status=NtOpenKey( &hKey, KEY_ALL_ACCESS, &ObjectAttributes);
+  dprintf("\t\t\t\tStatus =%x\n",Status);
+  dprintf("NtDeleteKey : ");
+  Status=NtDeleteKey(hKey);
+  dprintf("\t\t\t\tStatus =%x\n",Status);
+  NtClose(hKey);
+  RtlInitUnicodeString(&KeyName, L"\\Registry\\Machine\\Software\\test2reactos\\test2");
+  InitializeObjectAttributes(&ObjectAttributes,
+                               &KeyName,
+                               OBJ_CASE_INSENSITIVE,
+                               NULL,
+                               NULL);
+  dprintf("NtOpenKey : ");
+  Status=NtOpenKey( &hKey, KEY_ALL_ACCESS, &ObjectAttributes);
+  dprintf("\t\t\t\tStatus =%x\n",Status);
+  dprintf("NtDeleteKey : ");
+  Status=NtDeleteKey(hKey);
+  dprintf("\t\t\t\tStatus =%x\n",Status);
+  NtClose(hKey);
+  RtlInitUnicodeString(&KeyName, L"\\Registry\\Machine\\Software\\test2reactos");
+  InitializeObjectAttributes(&ObjectAttributes,
+                               &KeyName,
+                               OBJ_CASE_INSENSITIVE,
+                               NULL,
+                               NULL);
+  dprintf("NtOpenKey : ");
+  Status=NtOpenKey( &hKey, KEY_ALL_ACCESS, &ObjectAttributes);
+  dprintf("\t\t\t\tStatus =%x\n",Status);
+  dprintf("NtDeleteKey : ");
+  Status=NtDeleteKey(hKey);
+  dprintf("\t\t\t\tStatus =%x\n",Status);
+  NtClose(hKey);
+}
 
-return 0;\r
+void test3(void)
+{
+ HKEY hKey,hKey1;
+ OBJECT_ATTRIBUTES ObjectAttributes; 
+ UNICODE_STRING KeyName,ValueName;
+ NTSTATUS Status; 
+ KEY_VALUE_FULL_INFORMATION KeyValueInformation[5];
+ ULONG Index,Length,i;
+ char Buffer[10];
+ DWORD Result;
+  dprintf("NtCreateKey non volatile: \n");
+  dprintf("  \\Registry\\Machine\\Software\\test3reactos: ");
+  RtlInitUnicodeString(&KeyName, L"\\Registry\\Machine\\Software\\test3reactos");
+  InitializeObjectAttributes(&ObjectAttributes, &KeyName, OBJ_CASE_INSENSITIVE
+                               , NULL, NULL);
+  Status = NtCreateKey ( &hKey, KEY_ALL_ACCESS , &ObjectAttributes
+               ,0,NULL,REG_OPTION_NON_VOLATILE,NULL);
+  dprintf("\t\tStatus=%x\n",Status);
+  NtClose(hKey);
+  dprintf("  ...\\test3 :");
+  RtlInitUnicodeString(&KeyName, L"\\Registry\\Machine\\Software\\test3reactos\\test3");
+  InitializeObjectAttributes(&ObjectAttributes, &KeyName, OBJ_CASE_INSENSITIVE
+                               , NULL, NULL);
+  Status = NtCreateKey ( &hKey1, KEY_ALL_ACCESS , &ObjectAttributes
+               ,0,NULL,REG_OPTION_NON_VOLATILE,NULL);
+  dprintf("\t\t\t\t\tStatus=%x\n",Status);
+  dprintf("  ...\\testNonVolatile :");
+  RtlInitUnicodeString(&KeyName, L"TestNonVolatile");
+  InitializeObjectAttributes(&ObjectAttributes, &KeyName, OBJ_CASE_INSENSITIVE
+                               , hKey1, NULL);
+  Status = NtCreateKey ( &hKey, KEY_ALL_ACCESS , &ObjectAttributes
+               ,0,NULL,REG_OPTION_NON_VOLATILE,NULL);
+  dprintf("\t\t\t\tStatus=%x\n",Status);
+  NtClose(hKey1);
+  RtlInitUnicodeString(&ValueName, L"TestREG_SZ");
+  dprintf("NtSetValueKey reg_sz: ");
+  Status=NtSetValueKey(hKey,&ValueName,0,REG_SZ,(PVOID)L"Test Reg_sz",24);
+  dprintf("\t\t\t\tStatus=%x\n",Status);
+  RtlInitUnicodeString(&ValueName, L"TestDWORD");
+  dprintf("NtSetValueKey reg_dword: ");
+  Status=NtSetValueKey(hKey,&ValueName,0,REG_DWORD,(PVOID)"reac",4);
+  dprintf("\t\t\tStatus=%x\n",Status);
+  NtClose(hKey);
+  dprintf("NtOpenKey \\Registry\\Machine\\Software\\test3reactos\\test3\\testNonVolatile : ");
+  RtlInitUnicodeString(&KeyName, L"\\Registry\\Machine\\Software\\test3reactos\\test3\\testNonVolatile");
+  InitializeObjectAttributes(&ObjectAttributes,
+                               &KeyName,
+                               OBJ_CASE_INSENSITIVE,
+                               NULL,
+                               NULL);
+  Status=NtOpenKey( &hKey, MAXIMUM_ALLOWED, &ObjectAttributes);
+  dprintf("\t\t\t\tStatus =%x\n",Status);
+  if(Status==0)
+  {
+    dprintf("NtEnumerateValueKey : \n");
+    Index=0;
+    while(Status == STATUS_SUCCESS)
+    {
+      Status=NtEnumerateValueKey(hKey,Index++,KeyValueFullInformation
+               ,&KeyValueInformation[0], sizeof(KeyValueInformation)
+               ,&Length);
+      if(Status== STATUS_SUCCESS)
+       {
+        dprintf("\tValue:DO=%d, DL=%d, NL=%d, Name = "
+               ,KeyValueInformation[0].DataOffset
+               ,KeyValueInformation[0].DataLength
+               ,KeyValueInformation[0].NameLength);
+         for (i=0;i<KeyValueInformation[0].NameLength/2;i++)
+               dprintf("%C",KeyValueInformation[0].Name[i]);
+        dprintf(", Type = %d\n",KeyValueInformation[0].Type);
+         if (KeyValueInformation[0].Type == REG_SZ)
+          dprintf("\t\tValue = %S\n",((char*)&KeyValueInformation[0]
+                                       +KeyValueInformation[0].DataOffset));
+       }
+    }
+  }
+  NtClose(hKey);
+  dprintf("delete \\Registry\\Machine\\software\\test3reactos ?");
+  ReadConsoleA(InputHandle, Buffer, 3, &Result, NULL) ;
+  if (Buffer[0] != 'y' && Buffer[0] != 'Y') return;
+  RtlInitUnicodeString(&KeyName, L"\\Registry\\Machine\\Software\\test3reactos\\test3\\testNonvolatile");
+  InitializeObjectAttributes(&ObjectAttributes,
+                               &KeyName,
+                               OBJ_CASE_INSENSITIVE,
+                               NULL,
+                               NULL);
+  dprintf("NtOpenKey : ");
+  Status=NtOpenKey( &hKey, KEY_ALL_ACCESS, &ObjectAttributes);
+  dprintf("\t\t\t\tStatus =%x\n",Status);
+  dprintf("NtDeleteKey : ");
+  Status=NtDeleteKey(hKey);
+  dprintf("\t\t\t\tStatus =%x\n",Status);
+  RtlInitUnicodeString(&KeyName, L"\\Registry\\Machine\\Software\\test3reactos\\test3");
+  InitializeObjectAttributes(&ObjectAttributes,
+                               &KeyName,
+                               OBJ_CASE_INSENSITIVE,
+                               NULL,
+                               NULL);
+  dprintf("NtOpenKey : ");
+  Status=NtOpenKey( &hKey, KEY_ALL_ACCESS, &ObjectAttributes);
+  dprintf("\t\t\t\tStatus =%x\n",Status);
+  dprintf("NtDeleteKey : ");
+  Status=NtDeleteKey(hKey);
+  dprintf("\t\t\t\tStatus =%x\n",Status);
+  NtClose(hKey);
+  RtlInitUnicodeString(&KeyName, L"\\Registry\\Machine\\Software\\test3reactos");
+  InitializeObjectAttributes(&ObjectAttributes,
+                               &KeyName,
+                               OBJ_CASE_INSENSITIVE,
+                               NULL,
+                               NULL);
+  dprintf("NtOpenKey : ");
+  Status=NtOpenKey( &hKey, KEY_ALL_ACCESS, &ObjectAttributes);
+  dprintf("\t\t\t\tStatus =%x\n",Status);
+  dprintf("NtDeleteKey : ");
+  Status=NtDeleteKey(hKey);
+  dprintf("\t\t\t\tStatus =%x\n",Status);
+  NtClose(hKey);
+}
 
+void test4(void)
+{
+ HKEY hKey = NULL,hKey1;
+ DWORD dwDisposition;
+ DWORD dwError;
+ DWORD  RegDataType, RegDataSize;
+ BOOL GlobalFifoEnable;
+ HKEY hPortKey;
+ DWORD RegDisposition;
+ WCHAR szClass[260];
+ DWORD cchClass;       
+ DWORD cSubKeys;       
+ DWORD cchMaxSubkey;   
+ DWORD cchMaxClass;    
+ DWORD cValues;        
+ DWORD cchMaxValueName;        
+ DWORD cbMaxValueData; 
+ DWORD cbSecurityDescriptor;   
+ FILETIME ftLastWriteTime;     
+ SYSTEMTIME LastWriteTime;
 
-   dprintf ("RegOpenKeyExW HKLM\\System\\ControlSet001: ");
+   dprintf ("RegOpenKeyExW HKLM\\System\\Setup: ");
    dwError = RegOpenKeyExW(HKEY_LOCAL_MACHINE,
-                           L"System\\ControlSet001",
+                           L"System\\Setup",
                            0,
                            KEY_ALL_ACCESS,
-                           &hKey); 
-   dprintf ("dwError %x\n", dwError);
-/*
-  Status = NtCreateKey ( &hKey, KEY_ALL_ACCESS , &ObjectAttributes
-               ,0,NULL,REG_OPTION_VOLATILE,NULL);
-  dprintf("Status=%x\n",Status);
-*/
+                           &hKey1); 
+    dprintf("\t\tdwError =%x\n",dwError);
+   if (dwError == ERROR_SUCCESS)
+   {
+     dprintf("RegQueryInfoKeyW: ");
+     cchClass=260;
+     dwError = RegQueryInfoKeyW(hKey1
+       , szClass, &cchClass, NULL, &cSubKeys
+       , &cchMaxSubkey, &cchMaxClass, &cValues, &cchMaxValueName
+       , &cbMaxValueData, &cbSecurityDescriptor, &ftLastWriteTime);
+     dprintf ("\t\t\t\tdwError %x\n", dwError);
+     FileTimeToSystemTime(&ftLastWriteTime,&LastWriteTime);
+     dprintf ("\tnb of subkeys=%d,last write : %d/%d/%d %d:%02.2d'%02.2d''%03.3d\n",cSubKeys
+               ,LastWriteTime.wMonth
+               ,LastWriteTime.wDay
+               ,LastWriteTime.wYear
+               ,LastWriteTime.wHour
+               ,LastWriteTime.wMinute
+               ,LastWriteTime.wSecond
+               ,LastWriteTime.wMilliseconds
+               );
+   }
 
 
    dprintf ("RegOpenKeyExW: ");
@@ -172,7 +439,7 @@ return 0;
                            0,
                            KEY_ALL_ACCESS,
                            &hKey); 
-   dprintf ("dwError %x\n", dwError);
+   dprintf ("\t\t\t\t\tdwError %x\n", dwError);
    RegDataSize = sizeof(GlobalFifoEnable);
    if (dwError == ERROR_SUCCESS)
    {
@@ -183,7 +450,14 @@ return 0;
                         &RegDataType,
                         (PBYTE)&GlobalFifoEnable,
                         &RegDataSize);
-     dprintf ("dwError %x\n", dwError);
+    dprintf("\t\t\t\tdwError =%x\n",dwError);
+    if (dwError == 0)
+    {
+        dprintf("\tValue:DT=%d, DS=%d, Value=%d\n"
+               ,RegDataType
+               ,RegDataSize
+               ,GlobalFifoEnable);
+    }
    }
    dprintf ("RegCreateKeyExW: ");
    dwError = RegCreateKeyExW(hKey,
@@ -196,12 +470,11 @@ return 0;
                          &hPortKey,
                          &RegDisposition
                         );
-   dprintf ("dwError %x\n", dwError);
+   dprintf ("\t\t\t\tdwError %x\n", dwError);
 
    dprintf ("RegCreateKeyExW: ");
    dwError = RegCreateKeyExW (HKEY_LOCAL_MACHINE,
-//                           L"System\\ControlSet001\\Services\\Serial\\Test",
-                           L"Software\\reactos\\test",
+                              L"Software\\test4reactos\\test",
                               0,
                               NULL,
                               REG_OPTION_NON_VOLATILE,
@@ -210,7 +483,7 @@ return 0;
                               &hKey,
                               &dwDisposition);
 
-   dprintf ("dwError %x ", dwError);
+   dprintf ("\t\t\t\tdwError %x ", dwError);
    dprintf ("dwDisposition %x\n", dwDisposition);
    if (dwError == ERROR_SUCCESS)
    {
@@ -219,19 +492,19 @@ return 0;
                              L"TestValue",
                              0,
                              REG_SZ,
-                             L"TestString",
+                             (BYTE*)L"TestString",
                              20);
 
-     dprintf ("dwError %x\n", dwError);
+     dprintf ("\t\t\t\tdwError %x\n", dwError);
      dprintf ("RegCloseKey: ");
      dwError = RegCloseKey (hKey);
-     dprintf ("dwError %x\n", dwError);
+     dprintf ("\t\t\t\t\tdwError %x\n", dwError);
    }
    dprintf ("\n\n");
 
    hKey = NULL;
 
-   dprintf ("RegCreateKeyExW:\n");
+   dprintf ("RegCreateKeyExW: ");
    dwError = RegCreateKeyExW (HKEY_LOCAL_MACHINE,
                               L"software\\Test",
                               0,
@@ -242,22 +515,65 @@ return 0;
                               &hKey,
                               &dwDisposition);
 
-   dprintf ("dwError %x ", dwError);
+   dprintf ("\t\t\t\tdwError %x ", dwError);
    dprintf ("dwDisposition %x\n", dwDisposition);
 
-#if 0
-   dprintf ("RegQueryKeyExW:\n");
 
-#endif
    if (dwError == ERROR_SUCCESS)
    {
-     dprintf ("RegCloseKey:\n");
+     dprintf("RegQueryInfoKeyW: ");
+     cchClass=260;
+     dwError = RegQueryInfoKeyW(hKey
+       , szClass, &cchClass, NULL, &cSubKeys
+       , &cchMaxSubkey, &cchMaxClass, &cValues, &cchMaxValueName
+       , &cbMaxValueData, &cbSecurityDescriptor, &ftLastWriteTime);
+     dprintf ("\t\t\t\tdwError %x\n", dwError);
+     FileTimeToSystemTime(&ftLastWriteTime,&LastWriteTime);
+     dprintf ("\tnb of subkeys=%d,last write : %d/%d/%d %d:%02.2d'%02.2d''%03.3d\n",cSubKeys
+               ,LastWriteTime.wMonth
+               ,LastWriteTime.wDay
+               ,LastWriteTime.wYear
+               ,LastWriteTime.wHour
+               ,LastWriteTime.wMinute
+               ,LastWriteTime.wSecond
+               ,LastWriteTime.wMilliseconds
+               );
+     dprintf ("RegCloseKey: ");
      dwError = RegCloseKey (hKey);
-     dprintf ("dwError %x\n", dwError);
+     dprintf ("\t\t\t\t\tdwError %x\n", dwError);
    }
-
    dprintf ("\nTests done...\n");
-
-   return 0;
 }
 
+int main(int argc, char* argv[])
+{
+ char Buffer[10];
+ DWORD Result;
+
+  AllocConsole();
+  InputHandle = GetStdHandle(STD_INPUT_HANDLE);
+  OutputHandle =  GetStdHandle(STD_OUTPUT_HANDLE);
+
+  dprintf("choose test :\n");
+  dprintf("  1=Ntxxx read functions\n");
+  dprintf("  2=Ntxxx write functions : volatile keys\n");
+  dprintf("  3=Ntxxx write functions : non volatile keys\n");
+  dprintf("  4=Regxxx functions\n");
+  ReadConsoleA(InputHandle, Buffer, 3, &Result, NULL) ;
+  switch (Buffer[0])
+  {
+   case '1':
+    test1();
+    break;
+   case '2':
+    test2();
+    break;
+   case '3':
+    test3();
+    break;
+   case '4':
+    test4();
+    break;
+  }
+  return 0;
+}