FreeDiskSpace: Difference between revisions
From NSIS Wiki
Jump to navigationJump to search
No edit summary |
No edit summary |
||
Line 25: | Line 25: | ||
StrCpy $2 12345 ; Free space required by you (in kb) | StrCpy $2 12345 ; Free space required by you (in kb) | ||
System::Int64Op $ | System::Int64Op $1 > $2 ; Compare the space required and the space available | ||
Pop $3 ; Get the result ... | Pop $3 ; Get the result ... | ||
Revision as of 09:10, 29 September 2006
Author: Dr.Sweety (talk, contrib) |
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
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