1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Accessing COM objects through ATL

Discussion in 'Win32' started by cvarga, Aug 8, 2008.

  1. cvarga

    cvarga New Member

    Joined:
    Aug 8, 2008
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    0
    I am attempting to add web browsing capabilities to my win32 application. My problem is that the CoCreateInstance method is returning a 'Class not registered' error. I'm not understanding why it would give me this error when I know that other applications on my machine are using the IWebBrowser2 interface. Here is a sample of my code...
    Code:
    #define VC_EXTRALEAN        // Exclude rarely-used stuff from Windows headers
    
    /* Class COM Methods */
    
    //#include <afxdisp.h>
    #include <comdef.h>
    #include <atlbase.h>
    #include <exdisp.h>
    
    CComModule   _Module;
    
    #include <atlcom.h>
    
    #include "iexcpp.h"
    
    /* C++ Code */
    
    extern Iex               *pIex;
    
    /*Bfun  ************************* *Efun*/
    
    bool Iex::IexCreateBrowser( char * url )
    {
       CComPtr<IWebBrowser2>   lpTBrowser;
       HRESULT                 hrl = 0;
    
       CoInitialize(NULL);
    
       //Create web browser using IWebBrowser2...
       hrl = lpTBrowser.CoCreateInstance ( IID_IWebBrowser2 ); 
    
       if(!SUCCEEDED(hrl))
          return false;
    
       if( url == NULL )
          return true;
       else
       {  hrl = lpTBrowser->Navigate2( &_variant_t( url ), &_variant_t( NULL ), &_variant_t( NULL ), &_variant_t( NULL ), &_variant_t( NULL ) );
          if(!SUCCEEDED(hrl))
             return false;
          else
          {  lpTBrowser->put_Visible( _variant_t( true ) );
             return true;
          }
       }
    }
    
    Any help would be greatly appreciated.
     
    Last edited by a moderator: Aug 9, 2008
  2. carl1

    carl1 New Member

    Joined:
    Sep 7, 2008
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    0
    You don't need ATL on anything else.
    ActiveX embedding is native in windows with OLE container Window class.
     

Share This Page