Link to home
Start Free TrialLog in
Avatar of ycomp
ycomp

asked on

Accesing a COM object (created by Delphi) from VC++

Hi,

If a COM object is written in Delphi, it should be accessible by VC++ , right?

A customer is asking something about an error he is getting... something about different calling conventions between C++ and pascal.

But shouldn't this be handled correctly simply because my Delphi COM object is a COM object?
Avatar of Wim ten Brink
Wim ten Brink
Flag of Netherlands image

No, the calling convention determines how method parameters are passed between caller and callee. It is likely that the Delphi COM methods are defined as either safecall or stdcall, while the C++ code is expecting the other calling convention. The result? A wrong calling convention.
The COM object should have a type library and VC++ should create code with the proper calling convention to these Delphi methods, but apparantly something goes wrong.
Avatar of gwalkeriq
gwalkeriq

Yes, I've accessed COM objects writtin in Delphi from VC++ before.

However, customer must be using it as a COM object, not a DLL call. There are different calling conventions between VC++ & Delphi when you interface via DLL's, basically you cannot (easily at least) using object interfaces, only undecorated (classless) functions and procedures.

As COM interfaces, there is no problem.
Avatar of ycomp

ASKER

so alex, are you saying that it is common for this to happen even though there is a type library?
ASKER CERTIFIED SOLUTION
Avatar of gwalkeriq
gwalkeriq

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial