> After quick research at MSDN I learned that a COM object is a
> structure in which the first field is a pointer to a vector of methods
> (a virtual table pointer).  So, when is the vtable initialized?
The Constructor does it. Sine you dont have direct access to the constructor you 
should use CoCreateInstance with the right CLSID to get
a objectpointer. Just like you do in windows.
If you know what dll you like to use you can also call DLLGetClassObject of that dll.

> Should I load methods with GetProcAddress() and put them into vtable?
No, never. Using the vtable directly does not help. Dont try that.

> Do I have to use macros ICOM_* defined in include/wine/obj_base.h
> file?  From what I understood they are helpful when you compile your
> own COM-based code to replace native COM DLLs such like Direct3D.
If you use a c compiler define a *.h file like the ones in include/wine/obj_*.h for 
your object and use the macros like 
IFineReader_Functionxx(This, param1...) to call these.
If you've done it right your code looks like:

IMyObject   *pMO; 
HRESULT        hr = S_OK ; 
     
hr = CoCreateInstance(  CLSID_MyObject,  
                        NULL,  
                        CLSCTX_INPROC_SERVER,  
                        IID_IMyInterface,  
                        (LPVOID*)&pMO); 
 
if(SUCCEEDED(hr)) 
{ 
   hr = IMyObject_MyFunction(pMO, myargument1 ); 
   IMyObject_Release(pMO); 
} 
         

Ciao

Juergen

Reply via email to