FreeDiskSpace
From NSIS Wiki
| Author: Dr.Sweety (talk, contrib) |
[edit] Description
Based on the function CheckSpaceFree from sunjammer I created the following function which returns the free space (in kb) available for the path specified
[edit] The Script
OutFile "FreeSpace.exe" !define sysGetDiskFreeSpaceEx 'kernel32::GetDiskFreeSpaceExA(t, *l, *l, *l) i' ; $0 - Path to check (can be a drive 'C:' or a full path 'C:\Windows') ; $1 - Return value, free space in kb function FreeDiskSpace System::Call '${sysGetDiskFreeSpaceEx}(r0,.,,.r1)' ; convert the large integer byte values into managable kb System::Int64Op $1 / 1024 ; Return the free space Pop $1 functionend section - StrCpy $0 'C:\Windows' ; check how much free space is left for the path C:\Windows Call FreeDiskSpace MessageBox MB_OK "Free disk space in $0 : $1 kb" StrCpy $2 12345 ; Free space required by you (in kb) System::Int64Op $1 > $2 ; Compare the space required and the space available Pop $3 ; Get the result ... IntCmp $3 1 okay ; ... and compare it MessageBox MB_OK "Error: Not enough disk space!" okay: MessageBox MB_OK "Enough disk space available!" sectionend

