在浏览器里安装完插件,可以正常使用,但在WebBrowser里面无法显示或使用,这个时候要在Windows的注册表中设置嵌入WebBrowser程序的IE默认使用版本,这个过程可以手工来做,但最好是在程序初始化的时候自动把注册表设置好
private void IeReg()
{
try
{
int bit = ComFn.GetOSBit();
bool isExists32 = false;
//SOFTWARE\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_BROWSER_EMULATION
Microsoft.Win32.RegistryKey retkey32 = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_BROWSER_EMULATION", true);
foreach (string strName in retkey32.GetSubKeyNames())
{
if (strName == "福禄OA.exe")
{
isExists32 = true;
break;
}
}
if (!isExists32)
retkey32.SetValue("福禄OA.exe", "9999", Microsoft.Win32.RegistryValueKind.DWord);
if (bit != 32)
{
bool isExists64 = false;
Microsoft.Win32.RegistryKey retkey64 = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_BROWSER_EMULATION", true);
foreach (string strName in retkey64.GetSubKeyNames())
{
if (strName == "福禄OA.exe")
{
isExists64 = true;
break;
}
}
if (!isExists64)
retkey64.SetValue("福禄OA.exe", "9999", Microsoft.Win32.RegistryValueKind.DWord);
}
}
catch (Exception exception)
{
MsgBox.Error(exception.Message);
LogMng.GetLog().PrintError(ClassName, "c_btnReg_Click", exception);
return;
}
finally
{
}
}
就是修改注册表的以下路径
SOFTWARE\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_BROWSER_EMULATION
上例是,比如运行带WebBrowser的程序叫“福禄OA.exe”,设置使用最高的IE版本号 “9999”,注册值类型是”DWord”