Luca Brasi Guest
|
Posted: Thu Mar 17, 2005 4:48 pm Post subject: importing type library |
|
|
I'm a newcomer in COM programming, so maybe I ask stupid question (sorry).
I have imported my type library from a COM dll created with vc++ 7. In my
header file I have the following comment:
// COCLASS DEFAULT INTERFACE CREATOR
// CoClass : magicdemoclass
// Interface: TCOMImagicdemoclass
// **************************************
with the interface Imagicdemoclass defined like this:
interface Imagicdemoclass : public IDispatch
{
public:
// [1] property MWFlags
virtual HRESULT STDMETHODCALLTYPE get_MWFlags(Mwcomutil_tlb::IMWFlags**
ppvFlags/*[out,retval]*/) = 0;
// [1] property MWFlags
virtual HRESULT STDMETHODCALLTYPE set_MWFlags(Mwcomutil_tlb::IMWFlags*
ppvFlags/*[in]*/) = 0;
// [2] Method mymagic
virtual HRESULT STDMETHODCALLTYPE mymagic(long nargout/*[in]*/, VARIANT*
y/*[in,out]*/, VARIANT x/*[in]*/) = 0;
}
I access to the COM server with the following lines:
#include "magicdemo_TLB.cpp"
................
VARIANT* y;
VARIANT size;
size.vt=VT_INT;
size.intVal=10;
TCOMImagicdemoclass myobject ;
myobject = Magicdemo_tlb::Comagicdemoclass::Create();
myobject->mymagic(1,y,size);
But I always get an access violation error in module "ole32.dll", at the
line:
hr = ::CoCreateInstance(rclsid, 0, CLSCTX_SERVER, riid, ppv);
in borland file utilcls.h
The question is: in general must we use the default interface and coclass?
Is my code correct or can anybody explain my errors?
I really appreciate your help! Thanks very much!
|
|