#define WIN32_LAN_AND_MEAN
#include <windows.h>
#include <stdio.h>

void main(void)
{
  char tmp[256],tmp1[256];
  LoadString(0,1001,tmp,sizeof tmp);
  printf("Installing %s driver... ",tmp);
  LoadString(0,1002,tmp,sizeof tmp);
  HKEY Key = 0;
  DWORD D;
  if (RegCreateKeyEx(HKEY_LOCAL_MACHINE,tmp,0,"",REG_OPTION_NON_VOLATILE,KEY_ALL_ACCESS,NULL,&Key,&D) == ERROR_SUCCESS)
    {
      BOOL  Ok = TRUE;
      DWORD V;
      V = 1;
      if (RegSetValueEx(Key,"Type",        0,REG_DWORD,(LPBYTE)&V,sizeof V)      != ERROR_SUCCESS) Ok = FALSE;
      V = 2;
      if (RegSetValueEx(Key,"Start",       0,REG_DWORD,(LPBYTE)&V,sizeof V)      != ERROR_SUCCESS) Ok = FALSE;
      char *p = "Extended Base";
      if (RegSetValueEx(Key,"Group",       0,REG_SZ,   (LPBYTE)p, strlen(p) + 1) != ERROR_SUCCESS) Ok = FALSE;
      V = 1;
      if (RegSetValueEx(Key,"ErrorControl",0,REG_DWORD,(LPBYTE)&V,sizeof V)      != ERROR_SUCCESS) Ok = FALSE;
      if (!Ok) printf("Error creating registry entries! ");
      RegCloseKey(Key);
    }
  else
    printf("Cannot create key '%s'! ",tmp);
  printf("done.\n");
  if (GetEnvironmentVariable("SystemRoot",tmp,sizeof tmp))
    {
      LoadString(0,1003,tmp1,sizeof tmp1);
      strcat(tmp,"\\system32\\drivers\\");
      strcat(tmp,tmp1);
      if (!CopyFile(tmp1,tmp,FALSE)) goto L_CopyErr;
    }
  else
    {
L_CopyErr:
      printf("Couldn't copy driver '%s' to '%s'!\n",tmp1,tmp);
    }
  printf("Please reboot the machine now...\n");
}
