Maison >développement back-end >Tutoriel C#.Net >C# 操作外部Internet Explorer浏览器
private void Form1_Load(object sender, EventArgs e) { object ppvComObject = null; try { Guid CLSID_ShellWindows = new Guid("9BA05972-F6A8-11CF-A442-00A0C90A8F39"); Type pComType = Type.GetTypeFromCLSID(CLSID_ShellWindows, true); ppvComObject = Activator.CreateInstance(pComType); int webCount; if ((webCount = (int)pComType.InvokeMember("Count", BindingFlags.GetProperty, null, ppvComObject, null)) > 0) { for (int i = 0; i < webCount; i++) { object webObject = pComType.InvokeMember("Item", // IWebBrowser BindingFlags.InvokeMethod, null, ppvComObject, new object[] { i }); webObject.GetType().InvokeMember("Navigate", BindingFlags.InvokeMethod, null, webObject, new object[] { "http://blog.csdn.net/u012395622" }); } } } finally { if (ppvComObject != null && Marshal.IsComObject(ppvComObject)) Marshal.ReleaseComObject(ppvComObject); } }