I am relatively new to COM programming and I am trying to get access to third party DCOM component (EXE module) from my client program on C++(VC6). I suppose that this component was written in VB6. First I have made a simple client program on VB6 and it work smooth with DCOM component.

Below is the example of client's VB6 code, which Iíam tring translate to: VC++

Private cDevConnector As DevControlC.DevControlConnector
Private WithEvents cCtrl As DevControlC.DevControl

Set cDevConnector = New DevControlC.DevControlConnector
Set cCtrl = cDevConnector.DevControl
Call cCtrl.DevControlInitialize

Iíve used OLE View utility to get interfaceís definitions (idl, tlb, h files) from the component and use these data.

Below is the example of my C++ code:

void InitCOMInterface(HWND hWnd)
CoInitialize(NULL) ;
DevControlC::_DevControlConnectorPtr pDevConnector = NULL;
DevControlC::_DevControlPtr pCtrl;

HRESULT hr = pDevConnector.CreateInstance (__uuidof (DevControlC:evControlConnector));

if (FAILED(hr)) {

pCtrl = pDevConnector ->GetDevControl ();
if (NULL!= pCtrl) {

short status;
hr = pObj->SemControlInitialize (&status);
//here error rises...

CoUninitialize() ;

I can get pointer to _DevControl interface (pCtrl) via _DevControlConnector interface (I canít call it directly because of its properties). The error arises when Iíam trying to call DevControlInitialize() method of the _DevControl interface. The error message is:

"File: i386/chkesp.c
Line: 42
The value of ESP was not properly saved across a function call. This is usually a result of calling a function declared with one calling convention with a function pointer declared with a different calling convention."

The _ DevControl:evControlInitialize() method is declared in header file (header was extracted from component by OLE View utility ) as:

#if defined(__cplusplus) && !defined(CINTERFACE)

_ DevControl : public IDispatch
virtual /* [id] */ HRESULT STDMETHODCALLTYPE DevControlInitialize(
/* [retval][out] */ short __RPC_FAR *__MIDL_0047) = 0;

What is wrong in my call of DevControlInitialize() method. Thank you in advance.