WiseScript Package Editor Reference
128
WiseScript Actions
Passing Complex Structures to a .DLL: An Example
You can use a Call DLL Function to call a .DLL. In addition to passing simple parameters,
such as integers and strings, to a .DLL, you can also pass complex structures
(sometimes called records in Pascal or Visual Basic). For each parameter, you select a
passing type. For non-structure parameters, select Normal from Passing Type in the
DLL Parameter Settings dialog box. However, for structure elements (also referred to as
members), select First element of structure for the first item in the structure, or
Contained within structure for subsequent items. A structure ends if there are no
more parameters, or if the next parameter is set to Normal or First element of a
structure.
Note
The following code samples are in the C programming language.
Suppose that you have a function in a .DLL that processes information for a new
employee. The return value of the function is a simple integer indicating success or
failure. The function accepts three parameters: a structure that contains three
elements, an integer, and another structure that contains two elements. The calling
statement for the .DLL is:
int NewEmployee (EMPLOYEE*, int, DEPARTMENT*);
where EMPLOYEE* is a pointer to a structure, int is a simple integer, and DEPARTMENT*
is a pointer to a structure.
In this example, the layout of the EMPLOYEE structure is as follows:
typedef structure EMPLOYEE {
LPSTR name;
LONG salary;
CHAR title[50];
}
The layout of the DEPARTMENT structure is as follows:
typedef structure DEPARTMENT {
LPSTR deptname;
LPSTR deptnum;
}
To call the function NewEmployee from an installation script, you add six parameters in
the Call DLL Function dialog box: the three elements of the first structure, the integer,
and the two elements of the second structure.
To add parameters, see
DLL Parameter Settings
on page 126.
Parameter in the C function
Parameter type in
WiseScript
Passing Type in
WiseScript
name (first element of
EMPLOYEE structure)
string pointer
First element of a
structure
salary (second element of
EMPLOYEE structure)
long
Contained within
structure