GetDiskSpaceEx Example
InstallShield 2020 ยป 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 GetDiskSpaceEx function.
*
* This script gets a fully qualified path from the end user.
* It then extracts the drive designation from the path, gets
* the amount of free space on that drive, and displays the
* amount of free space in a message box.
*
\*--------------------------------------------------------------*/
STRING szPath;
INT iResult;
#include "ifx.h"
program
// Prompt for a target path.
szPath = PROGRAMFILES;
iResult = SdAskDestPath
("Select Folder\nSelect the folder to check for available disk space.", " ", szPath, 0);
if (iResult < 0) then
MessageBox("Unable to display dialog.", SEVERE);
endif;
// Get the amount of free disk space (in kilobytes) for the specified path.
iResult = GetDiskSpaceEx(szPath, KBYTES);
if (iResult < 0) then
MessageBox("Unable to get available disk space.", SEVERE);
endif;
// Display the amount of space available.
SprintfBox(INFORMATION, "Space Available", "%d KB available on %s.", iResult, szPath);
endprogram