Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 328
galop1n Avatar asked Dec 19 '16 21:12

galop1n


1 Answers

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;
}
like image 74
galop1n Avatar answered Nov 01 '22 08:11

galop1n