8

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.

galop1n
  • 8,573
  • 22
  • 36
  • 1
    [This](http://stackoverflow.com/questions/40033608/enable-windows-10-developer-mode-programmatically) may help you. Looks like a registry thing and can be done via powershell, so maybe you could use that info to construct your own method in code and post as an answer. – Adrian Sanguineti Dec 19 '16 at 21:59
  • @Adrian Yes, it was that simple, i answered to my question for later reference to whom may need it. – galop1n Dec 19 '16 at 22:37

1 Answers1

10

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;
}
galop1n
  • 8,573
  • 22
  • 36