Please ensure Javascript is enabled for purposes of website accessibility
Powered by Zoomin Software. For more details please contactZoomin

AVEVA™ Plant SCADA

DLLOpen

  • Last UpdatedJul 18, 2023
  • 3 minute read

Opens a link to a DLL function, by loading the specified DLL library into memory and attaching it to the named function. After you open the function link, you can call the function with the DLLCall function. You pass the function number returned from the DLLOpen function as an argument in the DLLCall function.

Plant SCADA only supports DLL functions that accept arguments via stack-based calling conventions. For example, in Win32 only cdecl and stdcall are supported.

Note: A DLL compiled for 32 bit cannot be called on an alarm server operating in Extended Memory mode. To allow this to work, you will need to recompile the DLL to target 64 bit.

One accepted method for interfacing with a DLL function is to write a Cicode function file. This file contains the DLLOpen() function to initialize the functions, and one Cicode function for each DLL function, as an interface. In this way, you can hide the DLL interface in this file. Any other Cicode function will call the Cicode interface, and the call to the DLL remains transparent.

Please be aware that DLLs need to be on the path. The file extension is not required.

Note: You need to specify the arguments to the function correctly. Plant SCADA has no way of checking the number and type of arguments to the function. If you specify the number of arguments incorrectly, your computer may display unexpected behavior. You should test your interface thoroughly before using it on a live system.

UNINTENDED EQUIPMENT OPERATION

Ensure that you specify the arguments to the DLLOpen() function correctly according to the following list.

Failure to follow these instructions can result in death, serious injury, or equipment damage.

Syntax

DLLOpen(sLib, sName, sArgs)

sLib:

The DLL library name.

sName:

The function name. An underscore (_) is required in the function name for a 'C' function, but not for a Pascal function. When you call a DLL from a Cicode function, sName needs to be the same as the name defined in the .DEF file used to link the DLL. The file extension is not required.

sArgs:

The string specifying the function arguments. The first character in the string is the return value of the function.

A - Logical.

B - IEEE 8 byte floating point number.

C - Null terminated string. Maximum string length 255 characters.

D - Byte counted string. First byte contains the length of the string, maximum string length 255 characters.

H - Unsigned 2 byte integer.

I - Signed 2 byte integer.

J - Signed 4 byte integer.

Return Value

The DLL function handle, or -1 if the library or function could not be found or loaded.

DLLCall, DLLClose

Example

/* This function is called when Plant SCADA starts up,
to initialize the DLLs that are called */
INT hAnsiUpper;

INT hGlobalAlloc;

FUNCTION InitMyDLLs()

! Open DLL to AnsiUpper

hAnsiUpper = DLLOpen("USER.DLL", "AnsiUpper", "CC");

hGlobalAlloc = DLLOpen("Kernel", "GlobalAlloc", "IIJ");

END

/* This is the Cicode entry point into the DLL function call. This
function hides the DLL interface from the rest of Plant SCADA. */
STRING

FUNCTION AnsiUpper(STRING sString)

STRING sResult;

sResult = DLLCall(hAnsiUpper, "^"" + sString + "^"");

RETURN sResult;

END

/* Allocate memory and return memory handle */

INT

FUNCTION GlobalAlloc(INT Mode, INT Length)

STRING sResult;

INT hMem;

sResult = DLLCall(hGlobalAlloc, Mode : #### + "," + Length : ####);

hMem = StrToInt(sResult);

RETURN hMem;

END

See Also

DLL Functions

In This Topic
Related Links
TitleResults for “How to create a CRG?”Also Available in