Accessing COM objects through ATL

cvarga's Avatar, Join Date: Aug 2008
Newbie Member
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...
#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;


   //Create web browser using IWebBrowser2...
   hrl = lpTBrowser.CoCreateInstance ( IID_IWebBrowser2 ); 

      return false;

   if( url == NULL )
      return true;
   {  hrl = lpTBrowser->Navigate2( &_variant_t( url ), &_variant_t( NULL ), &_variant_t( NULL ), &_variant_t( NULL ), &_variant_t( NULL ) );
         return false;
      {  lpTBrowser->put_Visible( _variant_t( true ) );
         return true;
Any help would be greatly appreciated.

Last edited by shabbir; 9Aug2008 at 20:51.. Reason: Code block
carl1's Avatar
Light Poster
You don't need ATL on anything else.
ActiveX embedding is native in windows with OLE container Window class.