FindFile Example

InstallShield 2016 » InstallScript Language Reference

Note • To call this function in a Basic MSI setup, you must first create a custom action for the entry-point function, execute the custom action in a sequence or as the result of a dialog's control event, and then build the release.

/*--------------------------------------------------------------*\

*

* InstallShield Example Script

*

* Demonstrates the FindFile function.

*

* FindFile is called to search for the file Config.sys in the

* root of drive C.

*

\*--------------------------------------------------------------*/

 

#define FILE_SPEC "Config.sys"

#define SEARCH_DIR "C:\\"

 

#define TITLE_TEXT "FindFile Example"

 

// Include Ifx.h for built-in InstallScript function prototypes.

#include "Ifx.h"

 

export prototype ExFn_FindFile(HWND);

 

function ExFn_FindFile(hMSI)

   STRING svResult;

begin

 

   if (FindFile (SEARCH_DIR, FILE_SPEC, svResult) < 0) then

      MessageBox ("FindFile failed.", SEVERE);

   else

      SprintfBox (INFORMATION, TITLE_TEXT, "Found: %s in %s.", svResult,

                 SEARCH_DIR);

   endif;

 

end;