注册表查询示例代码


例:从注册表获取ORACLE_HOME

/* get ORACLE_HOME from register */
void func()
{
  TCHAR sOracleHome[MAX_PATH] = {0};
  DWORD nValueSize = MAX_PATH - 1;
  HKEY hSubKey;
  DWORD dwType = REG_SZ;

  if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, _T("SOFTWARE\\ORACLE\\KEY_OraDb11g_home1"), NULL, KEY_READ | KEY_WOW64_64KEY, &hSubKey) == ERROR_SUCCESS)
  {
    if (ERROR_SUCCESS == RegQueryValueEx(hSubKey, _T("ORACLE_HOME"), NULL, &dwType, (LPBYTE)sOracleHome, &nValueSize))
    {
      printf("ORACLE_HOME:%s\n", sOracleHome);      
    }
  }
  break;
}


你可能感兴趣的:(注册表查询示例代码)