GetDiskInfo Example

InstallShield 2018 » InstallScript Language Reference

Note • To call this function in a Basic MSI installation, 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 GetDiskInfo function.

*

* This script gets the amount of free disk space on a Windows drive

* and displays that amount in a message box.

*

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

 

function OnBegin( )

    _DISK_INFO di;

    NUMBER n; // to do: something with function return values

    NUMBER nvSizeTargetHigh, nvSizeTargetLow, nUnitsTarget;

begin

 

// init. _DISK_INFO members: what drive, what info

di.szDiskPath = WINDISK;

di.nInfoToQuery = DISK_INFO_QUERY_DISK_FREE_SPACE;

 

n = GetDiskInfo(&di);

 

// change to desired unit for free space

nUnitsTarget = MBYTES;

 

n = ConvertSizeToUnits(

    di.nFreeSpaceHigh, di.nFreeSpaceLow, BYTES,

    nvSizeTargetHigh, nvSizeTargetLow, nUnitsTarget);

 

SprintfBox(INFORMATION, "Free Space",

    "Free space: %d MB",

    nvSizeTargetLow);

 

end;