InstallShield 2019 Express Edition
InstallShield requires a precise prototype for an entry-point function in a DLL called as the result of a custom action.
Flexera does not provide technical support for Windows programming or DLL debugging. You are responsible for correctly writing any DLL functions. Prototype your custom DLL functions as shown below. Any variation in return type or type and number of parameters can cause the custom action to fail.
LONG WINAPI Foo(HWND, LPTSTR , LPTSTR, LPTSTR, LPTSTR);
InstallShield uses the function prototype to pass the following information to your DLL:
1. | Parameter 1 passes the installation’s window handle. This parameter always returns NULL. |
2. | Parameter 2 passes the source directory [SRCDIR]. |
3. | Parameter 3 passes the support directory [SUPPORTDIR]. |
4. | Parameter 4 passes the main target directory [INSTALLDIR]. |
5. | Parameter 5 passes the database directory [DATABASEDIR]. |
If you are prototyping a custom action to handle the serial number entered in the Customer Information run-time dialog, then Parameter 4 will be the serial number.
The body of your DLL function can do just about anything you want. Obviously, you may have good use for the values passed to the function by the installation.
Your DLL function must return a value of type LONG as a state flag signaling the completion of the routine. If your function returns zero and you selected No for the custom action’s Ignore Exit Code setting, the installation exits. If it returns any other value, or if you selected Yes for the custom action’s Ignore Exit Code setting, the installation continues.
Sample DLL Function
This section contains sample source code. This sample contains a function, Foo(), that displays a message box showing the values that were passed to the function.
#include <windows.h>
#ifdef __cplusplus
extern "C" {
#endif
// Foo() function definition.
LONG WINAPI Foo(HWND hwnd, LPSTR szSrcDir, LPSTR szSupport, LPSTR szInst, LPSTR szDbase)
{ CHAR szTmp[1024];
int ret;
// Construct a string to display the values passed into Foo().
wsprintf(szTmp, "Extension called. hwnd=%x szSrcDir=%s szSupport=%s szInst=%s. Do you want" \
"to exit now?", hwnd, szSrcDir, szSupport, szInst);
// Display the string in a message box.
ret=MessageBox(hwnd, szTmp, "Test Extension", MB_YESNO);
if (ret==IDYES)
// Returning 0 causes the installation to end.
return(0);
else
// Returning non-zero causes the installation to continue.
return(1);
}
#ifdef __cplusplus
}
#endif
When a non-zero value is returned by your function, the installation continues. If zero is returned, the installation exits.
To be able to call the above DLL function, you must also include a definition (.def) file when you build the DLL to export the function properly. Include the following definition file with your project. The name after LIBRARY should be the name you have given your DLL.
; mydll.def : Declares the module parameters for the DLL.
LIBRARY MYDLL
DESCRIPTION 'sample Windows Dynamic Link Library'
EXPORTS
Foo @1
See Also
New DLL Custom Action Function Prototype
InstallShield 2019 Express Edition Help LibraryApril 2019 |
Copyright Information | Flexera |