我使用此代码在我的wpf应用程序中允许浏览器功能仿真:
string executablePath = Environment.GetCommandLineArgs()[0];
MessageBox.Show(executablePath);
string executableName = System.IO.Path.GetFileName(executablePath);
MessageBox.Show(executableName);
MessageBox.Show("Is64BitOperatingSystem : " + Environment.Is64BitOperatingSystem);
string key = string.Empty;
if (Environment.Is64BitOperatingSystem)
key = @"SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION";
else
key = @"SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_BROWSER_EMULATION";
RegistryKey registrybrowser = Registry.CurrentUser.OpenSubKey(key, true);
MessageBox.Show(registrybrowser.ToString());
if (registrybrowser == null)
{
RegistryKey registryFolder = Registry.CurrentUser.OpenSubKey
(@"SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl", true);
MessageBox.Show(registryFolder.ToString());
registrybrowser = registryFolder.CreateSubKey("FEATURE_BROWSER_EMULATION");
}
registrybrowser.SetValue(executableName, 0x02710, RegistryValueKind.DWord);
registrybrowser.Close();当我试图在Windows XP (SP2,FW4)上运行我的应用程序时,registrybrowser对象是空的,因为我想是因为找不到密钥。如何在Windows XP上设置此功能模拟?
发布于 2014-02-21 18:21:56
我的Windows XP上没有FeatureControl注册表项。下面是如何修复它:
string executablePath = Environment.GetCommandLineArgs()[0];
string executableName = System.IO.Path.GetFileName(executablePath);
string key = @"SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION";
RegistryKey registrybrowser = Registry.CurrentUser.OpenSubKey(key, true);
if (registrybrowser == null)
{
RegistryKey registryFolder = Registry.CurrentUser.OpenSubKey(@"SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl", true);
if (registryFolder == null)
{
RegistryKey registryFolderParent = Registry.CurrentUser.OpenSubKey(@"SOFTWARE\Microsoft\Internet Explorer\Main", true);
registryFolderParent.CreateSubKey("FeatureControl");
registryFolder = Registry.CurrentUser.OpenSubKey(@"SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl", true);
}
registrybrowser = registryFolder.CreateSubKey("FEATURE_BROWSER_EMULATION");
}
registrybrowser.SetValue(executableName, 0x2AF9, RegistryValueKind.DWord);
registrybrowser.Close();https://stackoverflow.com/questions/21913081
复制相似问题