程序中打开IE浏览器并访问指定地址
最简单的方法
Process.Start("iexplore.exe"); //直接打开IE浏览器(打开默认首页)
Process.Start("iexplore.exe", "http://www.baidu.com"); //直接打开IE浏览器,打开指定页
1、首先,需要添加com组件的引用
- 加入对Microsoft Internet Controls的引用;
- 加入对Microsoft HTML Object Library的引用;(其实就是的mshtml)
SHDocVw.ShellWindows shellWindows = new SHDocVw.ShellWindowsClass();
object objFlags = 1;
object objTargetFrameName = "";
object objPostData = "";
object objHeaders = "";
SHDocVw.InternetExplorer webBrowser1 = (SHDocVw.InternetExplorer)shellWindows.Item(shellWindows.Count - 1);
webBrowser1.Navigate("http://www.siniswift.com", ref objFlags, ref objTargetFrameName, ref objPostData, ref objHeaders);