DefineAlias Method

Applies to TestComplete 15.70, last modified on December 17, 2024

Description

The IDefineDLL.DefineAlias method assigns an alias to the specified routine located in a DLL. You can call the routine from a dynamic link library by using the routine name or alias.

A library may contain several functions that have similar names and perform similar actions. However, applications may call these functions from the DLL by a common name that differs from the original function names, but is mapped to these names. The common function name is automatically replaced with the appropriate original function name when compiling the application. For example, User32.dll contains two functions, DrawTextExA and DrawTextExW. However, in application code you usually call both these functions by the same name, DrawTextEx, in spite of the fact that there is actually no function named DrawTextEx in the DLL, and depending on whether the application works with ANSI or Unicode strings, the appropriate function (DrawTextExA or DrawTextExW) is called from the DLL. Thus, you can create an alias equal to such a common function name in your test in order to call the routine from your script in the same manner as you call it in other programs (by the common name).

Declaration

IDefineDLLObj.DefineAlias(ProcAlias, ProcName)

IDefineDLLObj An expression, variable or parameter that specifies a reference to an IDefineDLL object
ProcAlias [in]    Required    String    
ProcName [in]    Required    String    
Result None

Applies To

The method is applied to the following object:

Parameters

The method has the following parameters:

ProcAlias

The alias name to be created for the ProcName routine.

ProcName

The name of the routine to which the ProcAlias alias will be assigned.

Result Value

None.

Example

For instance, the GDI32.DLL includes the CreateFontA function. To call it using the CreateFont alias, add the following string to your script:

JavaScript, JScript

DefDLL.DefineAlias("CreateFont", "CreateFontA");

Python

DefDLL.DefineAlias("CreateFont", "CreateFontA")

VBScript

DefDLL.DefineAlias "CreateFont", "CreateFontA"

DelphiScript

DefDLL.DefineAlias('CreateFont', 'CreateFontA');

C++Script, C#Script

DefDLL["DefineAlias"]("CreateFont", "CreateFontA");

See Also

Calling DLL Functions From Tests - Tutorial
DefineProc Method
DLL Object
IDLLAccessProcess Object

Highlight search results