[robot]設定web browser元件的ie版本

  • 624
  • 0
  • 2015-09-18

摘要:[robot]設定web browser元件的ie版本


public partial class Form1 : Form
{
	public Form1()
	{
		var appName = Process.GetCurrentProcess().MainModule.ModuleName;
		//11000是ie11,10000是ie10,9000是ie9,....其他更多版本設定請看微軟官網
		//https://msdn.microsoft.com/en-us/library/ee330730(v=vs.85).aspx#browser_emulation
		Registry.SetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_BROWSER_EMULATION", appName, 11000, RegistryValueKind.DWord);
		InitializeComponent();
		webBrowser1.Navigate("http://maps.nlsc.gov.tw/");
		//webBrowser1.Navigate("http://browser-version.com/");
		
	}
}

 

if you call .exe by iis(ex:if you call exe by wcf), 

then maybe you have to new a application pool in iis and make this pool execute as a supervisor

and set .exe has the supervisor authority(right click your mouse and choose property and choose security), and (Registry.SetValue) won't fail.

參考文章:

[C#]設定WebBrowser Control運行的User Agent版本

http://www.dotblogs.com.tw/larrynung/archive/2012/10/15/77505.aspx