DLL.DefineDLL Method

Applies to TestComplete 14.93, last modified on October 12, 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 DLL.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 DLL.Load method.

Note: If you call DefineDLL twice or more times with the same dll type name as the input parameter, the method will not define a new dll type. It will return a reference to an existing IDefineDLL object that was created earlier. Thus, there is no need to store a reference to the created object in a variable, as you can obtain a reference to the object at any time later by calling DefineDLL with the same input parameter.

Declaration

DLL.DefineDLL(TypeName)

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

The name of the dll type to be defined or the name of the existing dll type a reference to which you need to obtain. 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 DLL.Load. For instance,

JavaScript, JScript

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

Python

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

VBScript

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

DelphiScript

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

C++Script, C#Script

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

Result Value

An IDefineDLL object that corresponds to the created dll type or a reference to an existing IDefineDLL object if the specified dll type has already been defined.

See Also

Calling DLL Functions From Tests - Tutorial
IDefineDLL Object

Highlight search results