DefineDLL Method

Applies to TestComplete 14.40, last modified on April 22, 2021

Description

Before you load the given DLL in memory, you should define the type of this DLL and types of its functions in TestComplete. The IDLLAccessProcess.DefineDLL method defines a DLL type with the specified name and returns the IDefineDLL object which is used to define the types of functions in the DLL. After you define the DLL type and types of functions, you can load the DLL into memory by calling the IDLLAccessProcess.Load method.

Declaration

IDLLAccessProcessObj.DefineDLL(TypeName)

IDLLAccessProcessObj An expression, variable or parameter that specifies a reference to an IDLLAccessProcess object
TypeName [in]    Required    String    
Result The IDefineDLL object

Applies To

The method is applied to the following object:

Parameters

The method has the following parameter:

TypeName

Name of the DLL type to be defined. TypeName can include any characters. It cannot be an empty string. To make script code more readable, it is recommended that the dll file name (excluding its extension) is used as TypeName. Also, if you use such a name for the DLL type, you may not specify the type name in a call to IDLLAccessProcess.Load (see the example below).

Result Value

The IDefineDLL object.

Example

The code below demonstrates how you can define libraries in your tests and then load them in memory directly from script code.

JavaScript, JScript

DefEnv = DLL.DefineEnvironment();
...
// The DLL type name is the same as the DLL file name
IDefDLL = DefEnv.DefineDLL("user32");
...
// We do not specify the DLL type name in the call to Load
Lib = DefEnv.Load("C:\\Windows\\System32\\user32.dll");

Python

DefEnv = DLL.DefineEnvironment()
# ...
# The DLL type name is the same as the DLL file name
IDefDLL = DefEnv.DefineDLL("user32")
# ...
# We do not specify the DLL type name in the call to Load
Lib = DefEnv.Load("C:\\Windows\\System32\\user32.dll")

VBScript

Set DefEnv = DLL.DefineEnvironment()
...
' The DLL type name is the same as the DLL file name
Set IDefDLL = DefEnv.DefineDLL("user32")
...
' We do not specify the DLL type name in the call to Load
Set Lib = DefEnv.Load("C:\Windows\System32\user32.dll")

DelphiScript

DefEnv := DLL.DefineEnvironment();
...
// The DLL type name is the same as the DLL file name
IDefDLL := DefEnv.DefineDLL('user32');
...
// We do not specify the DLL type name in the call to Load
Lib := DefEnv.Load('C:\Windows\System32\user32.dll');

C++Script, C#Script

DefEnv = DLL["DefineEnvironment"]();
...
// The DLL type name is the same as the DLL file name
IDefDLL = DefEnv["DefineDLL"]("user32");
...
// We do not specify the dll type name in the call to DLL.Load
Lib = DefEnv["Load"]("C:\\Windows\\System32\\user32.dll");

See Also

Specifics of Using 32- and 64-bit DLLs
Calling DLL Functions From Tests - Tutorial
IDefineDLL Object

Highlight search results