Passing Complex Structures To A .Dll: An Example - Symantec WISESCRIPT EDITOR 7.0 SP2 - FOR NS V1.0 Manual

Hide thumbs Also See for WISESCRIPT EDITOR 7.0 SP2 - FOR NS V1.0:
Table of Contents

Advertisement

Passing Complex Structures to a .DLL: An Example

WiseScript Editor Reference
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
Parameter in the C function
name (first element of
EMPLOYEE structure)
salary (second element of
EMPLOYEE structure)
on page 40.
Parameter type in
WiseScript
string pointer
long
Passing Type in
WiseScript
First element of a
structure
Contained within
structure
42

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the WISESCRIPT EDITOR 7.0 SP2 - FOR NS V1.0 and is the answer not in the manual?

Questions and answers

Table of Contents