Advertisement
Guest User

Untitled

a guest
Oct 2nd, 2014
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.46 KB | None | 0 0
  1. try
  2. {
  3. string installkey = @"SOFTWAREMicrosoftInternet ExplorerMainFeatureControlFEATURE_BROWSER_EMULATION";
  4. string entryLabel = "YourExe.exe";
  5. string develop = "YourExe.vshost.exe";//This is for Visual Studio Debugging...
  6. System.OperatingSystem osInfo = System.Environment.OSVersion;
  7.  
  8. string version = osInfo.Version.Major.ToString() + '.' + osInfo.Version.Minor.ToString();
  9. uint editFlag = (uint)((version == "6.2") ? 0x2710 : 0x2328); // 6.2 = Windows 8 and therefore IE10
  10.  
  11. Microsoft.Win32.RegistryKey existingSubKey = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(installkey, false); // readonly key
  12.  
  13. if (existingSubKey.GetValue(entryLabel) == null)
  14. {
  15. existingSubKey = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(installkey, true); // writable key
  16. existingSubKey.SetValue(entryLabel, unchecked((int)editFlag), Microsoft.Win32.RegistryValueKind.DWord);
  17. }
  18. if (existingSubKey.GetValue(develop) == null)
  19. {
  20. existingSubKey = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(installkey, true); // writable key
  21. existingSubKey.SetValue(develop, unchecked((int)editFlag), Microsoft.Win32.RegistryValueKind.DWord);
  22. }
  23. }
  24. catch
  25. {
  26. MessageBox.Show("You Don't Have Admin Previlege to Overwrite System Settings");
  27. }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement