Cicode Programming Reference > Cicode Function Categories > DLL Functions Introduction > DLLCallEx

DLLCallEx

Calls a DLL function, and passes the specified arguments to that function.

You need to first open the DLL with the DLLOpen function.

Only one call to the DLLCallEx() function can be made at a time, which means runtime will wait for the called function to return before doing anything else. If the called function takes too long to return, it won't let other tasks execute. Therefore, care needs to be taken so that one call returns before the next is made.

Good programming practice requires that functions which are not expected to complete in a short time are run as separate Windows threads and return a value immediately to CitectSCADA.

Syntax

DLLCallEx(hFunction,vParameters)

hFunction:

The DLL function handle, returned from DLLOpen().

vParameters:

A variable length parameter list of method arguments. The parameters will be passed to the function in the order that you enter them. Specifying too few or too many parameters will generate an Invalid Argument hardware error. An Invalid Argument hardware error will also be generated if you specify a parameter to the DLL function with the wrong type.

Return Value

The result of the function. If the DLL function returns a string then your Cicode return variable should be of type STRING. All other types will be INT.

Related Functions

DLLOpen, DLLClose

Example

/* This function is called when CitectSCADA starts up, 
to initialize all 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 CitectSCADA. *
STRING
FUNCTION AnsiUpper(STRING sString)
STRING sResult;
sResult = DLLCallEx(hAnsiUpper, sString);
RETURN sResult;
END
/* Allocate memory and return memory handle */
INT
FUNCTION GlobalAlloc(INT Mode, INT Length)
INT hMem;
hMem = DLLCallEx(hGlobalAlloc, Mode, Length);
RETURN hMem;
END

See Also

DLL Functions