Home > Backend Development > C#.Net Tutorial > C# operates external Internet Explorer browser

C# operates external Internet Explorer browser

大家讲道理
Release: 2016-11-10 14:51:31
Original
2445 people have browsed it

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);  
    }  
}
Copy after login

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template