[Expand]General Information/viewarticle/88628/
 [Expand]Using Help System/viewarticle/81465/
 [Expand]Getting Started Tutorial/viewarticle/82003/
 [Collapse]Using TestComplete/viewarticle/84431/
  [Expand]TestComplete User Interface, Projects and Settings/viewarticle/87798/
  [Expand]Creating, Recording and Running Tests/viewarticle/88044/
  [Expand]Test Results/viewarticle/80579/
  [Collapse]Enhancing Tests/viewarticle/83506/
   [Expand]Parameterizing Tests/viewarticle/84803/
   [Expand]Running Tests on Multiple Operating Systems/viewarticle/83155/
   [Expand]Testing Applications in Low-Level Mode/viewarticle/80754/
   [Expand]Handling Events/viewarticle/81959/
   [Expand]Using Variables/viewarticle/87349/
   [Expand]User Forms/viewarticle/80777/
   [Expand]Working With Files and Databases/viewarticle/82480/
   [Collapse]Using External Functions/viewarticle/84514/
     Calling Functions From .NET Assemblies/viewarticle/80911/
     Running PowerShell Scripts From TestComplete/viewarticle/86333/
     Calling Functions From Java Classes/viewarticle/81074/
    [Collapse]Calling DLL Functions From Tests/viewarticle/81100/
      Specifics of Using 32- and 64-bit DLLs/viewarticle/87449/
      Calling DLL Functions From Keyword Tests/viewarticle/89103/
      Using Custom Data Structures in DLL Function Calls/viewarticle/82716/
      Using String Parameters in DLL Function Calls/viewarticle/81187/
      Using Arrays in DLL Function Calls/viewarticle/85315/
      Returning Strings and Interface References From DLL Functions/viewarticle/88976/
      Parameter Types for C++ Routines and Structures/viewarticle/83884/
      Parameter Types for Delphi Routines and Structures/viewarticle/82733/
      Known Limitations/viewarticle/86877/
     Calling Win32 API Functions/viewarticle/85346/
   [Expand]Monitoring Performance/viewarticle/82137/
   [Expand]Tracing Exceptions, Crashes and Freezes in Tested Applications/viewarticle/88733/
   [Expand]Connected and Self-Testing Applications/viewarticle/83052/
   [Expand]Using Optical Character Recognition/viewarticle/80580/
   [Expand]Improving Object Recognition/viewarticle/87943/
    Integration With AQtime/viewarticle/80627/
    Integration With LoadComplete/viewarticle/81447/
    Using Environment Variables/viewarticle/87695/
    Working With Passwords and Other Sensitive Data/viewarticle/81374/
    Measuring Test Execution Time/viewarticle/83176/
  [Expand]Teamwork and Integration Into QA Process/viewarticle/84972/
  [Expand]Extending TestComplete/viewarticle/81408/
  [Expand]Automating TestComplete/viewarticle/88022/
  [Expand]Best Practices/viewarticle/87218/
 [Expand]Testing Types/viewarticle/85355/
 [Expand]Applications Testing/viewarticle/83383/
 [Expand]Working With Application Objects and Controls/viewarticle/81481/
 [Expand]Samples and Tutorials/viewarticle/81997/
 [Expand]Other Tools That Help You Test Better/viewarticle/82893/
 [Expand]Licensing Guide/viewarticle/88365/
Updated: 7/26/2016 Applies To: TestComplete 12 Rating: No votes Click to rate: PoorNot badAverageGoodExcellent
Calling DLL Functions From Tests

Returning Interface References From DLL Functions

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++

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;

See also
Calling DLL Functions From Tests | Calling DLL Functions From Tests - Overview

© 2016 SmartBear Software. All rights reserved.
Email Send feedback on this document