Declare Action

Describes a routine that is defined in an external Dynamic Link Library (DLL).

After the Declare action the routine can be called with the Call action.

Parameters

Library  -  (Required)

Specifies the name of the  Dynamic Link Library (DLL) that contains the routine to be executed.

Procedure  -  (Required)

Specifies the name of the routine as it is defined in the DLL.

Alias  -  (Optional)

Specifies an alternate name that you can use in the Call action.

Returns  -  (Required)

Specifies the data type of the return value from the routine executed.

Arguments  -  (Optional)

Describes the parameters required by the external routine. Each argument is defined as follows:

ByVal|ByRef name As type.

The types supported are Byte, Boolean, Integer, Long, Single, Double, String, String *, WString, and WString *.

Example

The following example calls the WritePrivateProfileString routine from the Kernel32.dll file.

Declare (Kernel32.dll, WritePrivateProfileStringA, WritePrivateProfileString, Boolean, ByVal Section as String, ByVal Key As String, ByVal Value As String, ByVal File As String)

Call (WritePrivateProfileString, "Section", "Key", "Data", "myapp.ini", rc)

Notes on Creating Exported DLL functions in Visual C++

This section provides some information for creating an exported DLL that meets the Newlook requirements using Microsoft Visual C++. Other C++ compilers may or may not support the keywords used in this section.

Newlook requires that the function receiving the arguments also maintain the stack. The Visual C++ keyword that can perform the correct stack maintenance is _stdcall.

The _stdcall keyword decorates the function name with a preceding underscore and appends '@n' where n is the number of bytes required to contain the function's arguments and the return value. For example, if you create a function called GetWindowSize and use the _stdcall keyword to provide stack maintenance, the function is defined as follows:

int GetWindowSize (int nIndex)

The following is the exported name result:

_GetWindowSize@8

Note the preceding underscore that is added by the _stdcall keyword.

To export the file, you can either use the _declspec(dllexport) keyword or a DEF file EXPORT section. The _declspec(dllexport) keyword exports the function but maintains the name decoration. The following example shows how to implement both the _stdcall and _declspec(dllexport) keyword on a function called DisplayMessage:

_delcspec(dllexport) long _stdcall DisplayMessage (LPSTR szMessage)

A DEF file also exports the function name and removes the name decoration. The following example shows how the EXPORT section of a DEF file is implemented for a function called DisplayMessage:

EXPORTS
      DisplayMessage

See Also

Call Action


© 2004-2021 looksoftware. All rights reserved.