Get File Size using the system plugin
From NSIS Wiki
| Author: Joel (talk, contrib) |
[edit] The Script
; My first script that uses system.dll :D ; Input a file to retrive is version ; to finish the script, just need the division with fractional decimals. :( OutFile "FileSize.exe" Name "Get File Size" Caption "Get File Size" XPStyle "on" Function "FileSize" Exch $R0 ;Grab the Inputed path file System::Call 'kernel32::_lopen(t "$R0", i 0) i .r0' ; Call the API to open the file System::Call 'kernel32::GetFileSize(i $0, i) i .r1' ; Call API to read file size IntOp $2 $1 / 1024 ; $1 is in bytes, let's converted to KBs MessageBox MB_OK|MB_ICONINFORMATION "File: $R0 $\r$\nSize: $2 KB" ; Display the info. System::Call 'kernel32::_lclose(i $0) i' ; API to close the opened file Quit ; Close NSIS FunctionEnd Function ".onInit" Push "${NSISDIR}\makensis.exe" ; Input full path of the file Call "FileSize" ; Call the function FunctionEnd Section "-boo" ; SectionEnd

