title: In c++, how to disable windows UAC control by program?
body: <p>In program C++, how to change the windows UAC to always notify or never notify.
  Manually, I should change like this:</p>
  
  <p><img src="https://i.stack.imgur.com/smZYE.png" alt="enter image description here"></p>
  
  <p><img src="https://i.stack.imgur.com/JJFgB.png" alt="enter image description here"></p>
  
  <p>I found C# code from Internet:</p>
  
  <pre><code>const string UACkey = @"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System";
  const string Subkey = "EnableLUA";
  RegistryUtilities.SetValue(UACkey, Subkey, **1**, Microsoft.Win32.RegistryValueKind.DWord, RegistryUtilities.WOW64Key.Key64);
  </code></pre>
  
  <p>Does somebody know how to change into c++ code?</p>
  
  <p>I tried to change the Registry with c++， but it does not work.</p>
  
  <pre><code>HKEY hKey = NULL;
  LONG lResult = 0;
  BOOL fSuccess = TRUE;
  DWORD dwSize;
  
  const size_t count = MAX_PATH*2;
  wchar_t szValue[count] = {};
  
  lResult = RegOpenKeyExW(HKEY_CURRENT_USER, L"HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Policies\\System",  0, (KEY_WRITE | KEY_READ),  &amp;hKey);
  
  
  fSuccess = (lResult == 0);
  
  if (fSuccess)
  {
      dwSize = (wcslen(szValue)+1)*2;
      lResult = RegSetValueExW(hKey, L"EnableLUA", 0, REG_SZ, (BYTE*)szValue, dwSize);
      fSuccess = (lResult == 0);
  }
  
  if (hKey != NULL)
  {
      RegCloseKey(hKey);
      hKey = NULL;
  }
  </code></pre>