View Full Version : Calling DLLs packed into the installation?

10-31-2003, 07:25 AM

I have a single exe installation. It contains a DLL file. Can I call the functions of this DLL from the script of the same installation exe?

If not, what's the best way to accomplish similar functionality?

Should I somehow, in the very beginning of the installation, manually export the DLL file before calling it, and then later delete the file when I won't need it anymore?

Mark at IS
10-31-2003, 08:21 AM
In the IDE, place the DLL in the appropriate target language folder in the Support Files/Billboards view.

At the beginning of the script, prototype the function using the following syntax:

prototype [CallingConvention] [ReturnType] DLLName.FunctionName( ParamType1, ParamType2, ... );

For example:

prototype BOOL MyDLL.MyFunction( INT, INT, INT );

You can specify the calling convention to be cdecl or stdcall. If a calling convention is not specified, InstallShield uses stdcall.

You can specify the return type to be any InstallScript data type except LIST. If a return type is not specified, InstallShield assumes that the DLL function returns a 4-byte value.

When declaring a DLL function call in which a wide-character string argument is expected, use the wstring data type.

Load the DLL by calling UseDLL. For example:


You do not have to load _isuser.dll, _isres.dll, or Windows API DLLs, such as User.exe, User32.dll, Gdi.exe, Gdi32.dll, Krnl386.exe, Krnl286.exe, and Kernel32.dll. Do not call UseDLL and UnUseDLL to load and unload these DLLs.
When prototyping functions from User.exe, User.exe, User32.dll, Gdi.exe, Gdi32.dll, Krnl386.exe, Krnl286.exe, or Kernel32.dll, you may use the keywords USER, GDI and KERNEL in place of the DLL filename.

Call the function as you would any other. For example:

bResult = MyFunction( nInt1, nInt2, nInt3 );

If InstallShield doesn't find the called function, it set the value of the return variable (bResult in the above example) to -1.

After all script calls to the DLL have been made, unload the DLL by calling UnUseDLL. For example:

There are three rules you must remember when calling DLL functions from your setup script: The maximum length of the DLL name is 33 characters; the maximum length of the function name is 63 characters. InstallShield cannot accept a composite parameter (that is, a parameter with a width exceeding four bytes) when calling a DLL. However, a parameter can be a pointer that points to a composite structure. A string variable whose address is stored in a pointer variable cannot be changed by passing the pointer to a DLL function. To allow a DLL function to change the value of a string variable, pass the variable itself as an argument to the function, after declaring the data type of that argument specifying the BYREF operator.