SdFilesInUse Example

InstallShield 2018 » InstallScript Language Reference

Project • The InstallScript MSI project type support the SdFilesInUse function.

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

*

*  InstallShield Example Script

*

*  Demonstrates the SdFilesInUse function. SdFilesInUse displays

*  a list box dialog that lists applications that are locking

*  files.

*

*  Keep displaying SdFilesInUse if Notepad.exe is running

*  and user clicks Retry.

*

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

 

#include "ifx.h"

 

 

function OnFirstUIBefore( )

    // ...other variables...

    LIST listID;

    NUMBER nReturn;

begin

 

    // ...display other dialogs...

 

// display file-locked dialog only if Notepad.exe running

if (Is(FILE_LOCKED, WINDIR ^ "Notepad.exe")) then

    // create a string list

    listID = ListCreate(STRINGLIST);

 

    // if an error occurred, report it; then terminate.

    if (listID = LIST_NULL) then

        MessageBox("Unable to create list.", SEVERE);

        abort;

    endif;

 

    ListAddString(listID, "Notepad.exe", AFTER);

 

    AskAgain:

 

    // display the Files in Use dialog.

    nReturn = SdFilesInUse("", "The following applications are currently locking files.", "", listID);

 

    // if user clicks RETRY, show locked-file dialog again;

    // otherwise, let the file-transfer process handle it, which might require a reboot

    if (nReturn = IDRETRY) then

        if (Is(FILE_LOCKED, WINDIR ^ "Notepad.exe")) then

            goto AskAgain;

        endif;

    endif;

 

    // remove the list from memory

    ListDestroy(listID);

endif;

 

end;