09.12.2012 Views

InstallShield 2012 Express Edition User Guide - Knowledge Base ...

InstallShield 2012 Express Edition User Guide - Knowledge Base ...

InstallShield 2012 Express Edition User Guide - Knowledge Base ...

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Chapter 10: Customizing Installation Behavior<br />

Using Custom Actions<br />

new custom action that you are adding to your project, it is recommended that you use an MSI DLL<br />

custom action instead of a standard DLL, since an MSI DLL action offers more flexible scheduling<br />

options.<br />

Once your DLL is ready, you must design a custom action to call the entry-point function. To learn how<br />

to create the custom action, see Adding a DLL Custom Action to Your Project.<br />

Classic DLL Custom Action Function Prototype<br />

<strong>InstallShield</strong> requires a precise prototype for an entry-point function in a DLL called as the result of a<br />

custom action.<br />

Flexera Software does not provide technical support for Windows programming or DLL debugging. You<br />

are responsible for correctly writing any DLL functions. Prototype your custom DLL functions as shown<br />

below. Any variation in return type or type and number of parameters can cause the custom action to<br />

fail.<br />

LONG WINAPI Foo(HWND, LPTSTR , LPTSTR, LPTSTR, LPTSTR);<br />

<strong>InstallShield</strong> uses the function prototype to pass the following information to your DLL:<br />

1. Parameter 1 passes the installation’s window handle. This parameter always returns NULL.<br />

2. Parameter 2 passes the source directory [SRCDIR].<br />

3. Parameter 3 passes the support directory [SUPPORTDIR].<br />

4. Parameter 4 passes the main target directory [INSTALLDIR].<br />

5. Parameter 5 passes the database directory [DATABASEDIR].<br />

If you are prototyping a custom action to handle the serial number entered in the Customer Information<br />

run-time dialog, then Parameter 4 will be the serial number.<br />

The body of your DLL function can do just about anything you want. Obviously, you may have good use<br />

for the values passed to the function by the installation.<br />

Your DLL function must return a value of type LONG as a state flag signaling the completion of the<br />

routine. If your function returns zero and you selected No for the custom action’s Ignore Exit Code<br />

setting, the installation exits. If it returns any other value, or if you selected Yes for the custom action’s<br />

Ignore Exit Code setting, the installation continues.<br />

Sample DLL Function<br />

This section contains sample source code. This sample contains a function, Foo(), that displays a<br />

message box showing the values that were passed to the function.<br />

#include <br />

#ifdef __cplusplus<br />

extern "C" {<br />

#endif<br />

// Foo() function definition.<br />

LONG WINAPI Foo(HWND hwnd, LPSTR szSrcDir, LPSTR szSupport, LPSTR szInst, LPSTR szDbase)<br />

{ CHAR szTmp[1024];<br />

int ret;<br />

// Construct a string to display the values passed into Foo().<br />

wsprintf(szTmp, "Extension called. hwnd=%x szSrcDir=%s szSupport=%s szInst=%s. Do you want" \<br />

<strong>InstallShield</strong> <strong>2012</strong> <strong>Express</strong> <strong>Edition</strong> <strong>User</strong> <strong>Guide</strong> ISE-1800-UG01 225

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!