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.