int get_computer_name(BYTE *computer_name, DWORD *computer_name_lg)

{

   HKEY hKey;

   if (RegOpenKeyEx(HKEY_LOCAL_MACHINE,

               "SYSTEM\\CurrentControlSet\\Control\\ComputerName\\ComputerName",

               0, KEY_QUERY_VALUE, &hKey ) != ERROR_SUCCESS)

      return FALSE;

   if (RegQueryValueEx(hKey, "ComputerName", NULL, NULL,

                       (LPBYTE) computer_name,

                       (LPDWORD) computer_name_lg) != ERROR_SUCCESS) {

      RegCloseKey(hKey);

      return FALSE;

   }

   RegCloseKey(hKey);

   return TRUE;

}


테스트는 안해봄. 

+ Recent posts