Author Topic: COM CLient Test Application for Internet Explorer using IWebBrowser2 interface  (Read 1659 times)

administrator

  • Administrator
  • Full Member
  • *****
  • Posts: 69
It will be interesting to create an Internet Explorer as a COM control and naviage to a page which you are interested through coding.

For more details on this, please visit at: http://softwareandfinance.com/VCPP_COM_IE_Client.php

{
    ::CoInitialize(NULL);
    IWebBrowser2 *browser = NULL;

    if( browser == NULL)
    {
        HRESULT hRes = CoCreateInstance(CLSID_InternetExplorer, NULL, CLSCTX_LOCAL_SERVER,
                           IID_IWebBrowser2, (void**)&browser);
        if(FAILED(hRes))
        {
            MessageBox("Failed to create Internet Explorer Control");
            return;
        }
    }

    {
       VARIANT vEmpty;
       VariantInit(&vEmpty);

       UpdateData(TRUE);

       USES_CONVERSION;
       BSTR bstrURL = SysAllocString(A2OLE((const char*) "http://www.softwareandfinance.com"));

       HRESULT hr = browser->Navigate(bstrURL, &vEmpty, &vEmpty, &vEmpty, &vEmpty);
       if (SUCCEEDED(hr))
       {
           browser->put_Visible(VARIANT_TRUE);
       }
       else
       {
           browser->Quit();
       }

       SysFreeString(bstrURL);
       browser->Release();
       browser = NULL;
   }
}

 


Disclaimer: This web site is for educational and informational purposes only. Click here to read the Disclaimer.
Content copyright 2010-2014. Kathiresan. All rights reserved.
This page is using SMF version 2.0.1