FormatMessage Example

InstallShield 2012 Spring » 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 FormatMessage function.

//

//  To demonstrate, deliberately call XCopyFile with a nonexistent source

//  directory, which should cause the function to fail. To provide system

//  details about the error, call FormatMessage and display the message

//  string in a MessageBox.

//

//---------------------------------------------------------------------------

 

function OnBegin( )

    NUMBER nReturn;

begin

 

// call XCopyFile on a nonexistent directory

nReturn = XCopyFile("C:\\no_such_directory", "C:\\destination", COMP_NORMAL);

 

// when XCopyFile fails, display the error message and exit the installer

if (nReturn < 0) then

    MessageBox(FormatMessage(nReturn), SEVERE);

    abort;

endif;

 

end;