Go4Expert (http://www.go4expert.com/)
-   Win32 (http://www.go4expert.com/forums/win32/)
-   -   Accessing COM objects through ATL (http://www.go4expert.com/forums/accessing-com-objects-atl-t12788/)

cvarga 8Aug2008 23:03

Accessing COM objects through ATL
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.

carl1 9Sep2008 14:50

Re: Accessing COM objects through ATL
You don't need ATL on anything else.
ActiveX embedding is native in windows with OLE container Window class.

All times are GMT +5.5. The time now is 04:03.