GetValidDrivesList Example

InstallShield 2015 ยป 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 GetValidDrivesList function.

*

* GetValidDrivesList is called twice: once to return a list of

* removable drives that have a minimum of 120,000 bytes free,

* then again to return a list of fixed drives that have a

* minimum of 1,000,000 bytes free.

*

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

 

#define TITLE         "GetValidDrivesList Example"

#define MSG_REMOVABLE "Removable drives with 120,000 bytes free:"

#define MSG_FIXED     "Fixed drives with 1,000,000 bytes free."

#define MSG_ERR       "GetValidDrivesList failed."

 

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

#include "Ifx.h"

 

export prototype ExFn_GetValidDrivesList(HWND);

 

function ExFn_GetValidDrivesList(hMSI)

    LIST   listID;

begin

 

    // Create a list to hold the removable drive names.

    listID = ListCreate (STRINGLIST);

    

    // Get removable drives with at least 120,000 bytes free.

    if (GetValidDrivesList (listID, REMOVEABLE_DRIVE, 120000) < 0) then

        // Report an error; then terminate.

        MessageBox (MSG_ERR, SEVERE);

        abort;

    else

        // Display the list of removable drives.

        SdShowInfoList (TITLE, MSG_REMOVABLE, listID);

    endif;

    

    // Destroy the list of removable drives.

    ListDestroy (listID);

    

    // Create a list to hold the fixed drive names.

    listID = ListCreate (STRINGLIST);

    

    // Get fixed drives with at least one million bytes free.

    if (GetValidDrivesList (listID, FIXED_DRIVE, 1000000) < 0) then

        // Report an error; then terminate.

        MessageBox (MSG_ERR, SEVERE);

        abort;

    else

        // Display the list of fixed drives.

        SdShowInfoList (TITLE, MSG_FIXED, listID);

    endif;

 

end;