How to detect if developer mode is active on windows 10?

2.5k views Asked by At

ID3D12Device::SetStablePowerState function call is only available if developer mode is turned on in the system. If not, it triggers a device removal.

Is there anĀ API to detect if the developer mode is on, so far i found nothing on msdn allowing an application to query it.

1

There are 1 answers

1
galop1n On BEST ANSWER

It appears a simple registry key hold the information, here a simple function to query the developer mode status.

bool IsDeveloperModeEnabled() {
  HKEY hKey;
  auto err = RegOpenKeyExW(HKEY_LOCAL_MACHINE,LR"(SOFTWARE\Microsoft\Windows\CurrentVersion\AppModelUnlock)",0,KEY_READ,&hKey);
  if (err!=ERROR_SUCCESS)
     return false;
  DWORD value{};
  DWORD dwordSize = sizeof(DWORD);
  err = RegQueryValueExW(hKey,L"AllowDevelopmentWithoutDevLicense",0,NULL,reinterpret_cast<LPBYTE>(&value),&dwordSize);
  RegCloseKey(hKey);
  if (err!=ERROR_SUCCESS)
    return false;
  return value != 0;
}