//註冊表名稱
string sRegistryName = "Test.exe";//放入執行檔檔案名稱
//註冊表路徑
string sRegistryPath = "";
//判斷電腦位元數,不同位元放在不同註冊表當中
if (Environment.Is64BitOperatingSystem)
{//64位元
sRegistryPath = @"HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_BROWSER_EMULATION";
}
else
{//32位元
sRegistryPath = @"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_BROWSER_EMULATION";
}
//開啟登錄檔
RegistryKey RegKey = Registry.LocalMachine.OpenSubKey(@"Software", true);
//將程式名稱寫入註冊表 11000 代表 IE11
Registry.SetValue(sRegistryPath , sRegistryName , 11000, RegistryValueKind.DWord);
RegKey.Close();
文章標籤
全站熱搜
