// Collection of code snippets by Arne Vajhøj 
// (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
#include <windows.h>
#include <stdio.h>
#include <string.h>

void getinfo(char *key, char *name, char *info)
{
  HKEY hk;
  if(RegOpenKeyEx(HKEY_LOCAL_MACHINE, key, 0, KEY_READ, &hk) == ERROR_SUCCESS)
  {
    DWORD valuelen,type;
    BYTE value[1024];
    valuelen = sizeof(value);
    if(RegQueryValueEx(hk, name, NULL, &type, value, &valuelen) == ERROR_SUCCESS)
    {
        strcpy(info,(char *)value);
    }
  }
  RegCloseKey(hk);
}

int main(int argc, char **argv)
{
    char info[12345];
    strcpy(info,"");
    getinfo("SOFTWARE\\Microsoft\\Windows\\CurrentVersion", "DevicePath", info);
    printf("%s\n", info);
    return 0;
}
