Functions located in dynamic link libraries may return an IDispatch, IUnknown or another interface reference as a result value. This topic describes some specifics of calling such functions from DLLs created with Visual C++ and Delphi.
Suppose, we have the following declarations of Visual C++ and Delphi functions that return an IDispatch reference value:
Visual C++Copy Code
IDispatch __stdcall Test();
function Test(): IDispatch; stdcall;
In the stdcall calling convention, the function’s result is passed via the CPU’s EAX register. However, Visual C++ and Delphi generate different binary code for these routines. Visual C++ stores the pointer to an IDispatch return value in the EAX register, as it is adopted in the stdcall convention. The specific of Delphi is that it returns the pointer to an IDispatch value via the stack.
TestComplete uses the same calling conventions as those adopted by Visual C++. So, you are able to call a C++ function declared in the described way from your scripts, but you are not able to call a Delphi routine that is declared as it was described above. To be able to obtain an IDispatch value from your Delphi routine, declare it in the following manner:
procedure Test(var ResultObjRef : IDispatch); stdcall;
© 2012 SmartBear Software. All rights reserved.