webbrowser使用ie10 c#winform

Bla*_*rna 4 c# registry winforms

我想强制webbrowser在我的c#winform应用程序中使用IE10.我知道还有其他这样的问题,但我已经阅读了很多这些问题,我不知道我哪里错了.

这是我的代码:

RegistryKey registrybrowser = Registry.LocalMachine.OpenSubKey
           (@"SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION", true);
        registrybrowser.SetValue("myAppName", 0x02710, RegistryValueKind.DWord); //Even with QWord
Run Code Online (Sandbox Code Playgroud)

我尝试过不同的方法来设置值:

registrybrowser.SetValue("myAppName", 1000, RegistryValueKind.DWord); //Even with QWord and String
registrybrowser.SetValue("myAppName", 1000); //even with 0x02710
Run Code Online (Sandbox Code Playgroud)

我在InitializeComponent()之前在主项目的costructor中编写它.我在.manifest文件中设置了管理员权限

感谢所有人,BlackShawarna

编辑:我发现了RegistryKey.SetValue(...); 在另一条路径中创建了一个键:

(@"SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION") 
Run Code Online (Sandbox Code Playgroud)

即使我的指示说: Registry.LocalMachine.OpenSubKey (@"SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION", true);

我认为这是因为IE10在32位模式下工作.但是我不明白为什么它写在那条路径中,即使我指定了另一条路径,最重要的是,即使我打开Registry.LocalMachine.OpenSubKey(@"Software\Wow6432Node ...."),为什么我的应用程序无法工作. );

如果我只在x64模式下运行我的程序,转到properties/build/x64,它将不会在我的原始路径中写入密钥.

ben*_*ndi 9

我有同样的问题,我的应用程序将值写入"HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_BROWSER_EMULATION".

我将LocalMachine更改为CurrentUser,现在它可以工作了.

string executablePath = Environment.GetCommandLineArgs()[0];
string executableName = System.IO.Path.GetFileName(executablePath);

RegistryKey registrybrowser = Registry.CurrentUser.OpenSubKey
   (@"SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION", true);

if (registrybrowser == null)
{
    RegistryKey registryFolder = Registry.CurrentUser.OpenSubKey
        (@"SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl", true);
    registrybrowser = registryFolder.CreateSubKey("FEATURE_BROWSER_EMULATION");
}
registrybrowser.SetValue(executableName, 0x02710, RegistryValueKind.DWord);
registrybrowser.Close();
Run Code Online (Sandbox Code Playgroud)

executableName类似于"myAppName.exe"

注意:如果DLL中的WebBrowser控件需要指定托管EXE的名称,例如 System.AppDomain.CurrentDomain.FriendlyName


小智 3

FEATURE_BROWSER_EMULATION "myAppName.exe"=10000(或 0x02710)而不是 1000。

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_BROWSER_EMULATION

HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_BROWSER_EMULATION

这个对我有用