# Copyright CatsSoft
# ...:: INFO ::... #
Name "Test Calc Sise"
OutFile "Test Calc Sise.exe"
InstallDir "$TEMP\Test Calc Sise"
# ...:: COMPRESS ::... #
SetCompressor /SOLID /FINAL lzma
# ...:: RUN ::... #
RequestExecutionLevel user
# ...:: SHOW / HIDE ::... #
ShowInstDetails nevershow
ShowUninstDetails NeverShow
# ...:: INCLUDES ::... #
!include "MUI2.nsh"
!include "WinCore.nsh"
!include "nsDialogs.nsh"
!include "LogicLib.nsh"
!include "WinMessages.nsh"
!include "FileFunc.nsh"
# ...:: BRANDING ::... #
BrandingText /TRIMRIGHT " "
# ...:: PAGE ::... #
Page custom page1.create
Page instfiles
# ...:: LANGUAGES ::... #
!insertmacro MUI_LANGUAGE "English" # first language
# ...:: INIT ::... #
Function .onInit
FunctionEnd
# ...:: PAGE 1 ::... #
Function page1.create
# ...:: VARIABLES ::... #
var /GLOBAL Dialog
var /GLOBAL Lbl.Sise.Files
var /GLOBAL Btn_Add_Files
var /GLOBAL Lbl.Sise.Folders
var /GLOBAL Btn_Add_Folders
GetDlgItem $0 $HWNDPARENT 1
ShowWindow $0 ${SW_HIDE}
GetDlgItem $0 $HWNDPARENT 2
ShowWindow $0 ${SW_HIDE}
GetDlgItem $0 $HWNDPARENT 3
ShowWindow $0 ${SW_HIDE}
GetDlgItem $0 $HWNDPARENT 1990
ShowWindow $0 ${SW_HIDE}
GetDlgItem $0 $HWNDPARENT 1991
ShowWindow $0 ${SW_HIDE}
GetDlgItem $0 $HWNDPARENT 1992
ShowWindow $0 ${SW_HIDE}
System::Call "user32::SetWindowPos(i$HWNDPARENT,i,i,i,i 632,i 466,i 0x16)"
nsDialogs::Create /NOUNLOAD 1044
Pop $Dialog
${If} $Dialog == error
Abort
${EndIf}
System::Call "user32::MoveWindow(i$Dialog,i0,i0,i 632,i 466,i0)"
# ...:: SHOW SIZE FILES ::... #
nsDialogs::CreateControl STATIC 0x40000000|0x10000000|0x04000000|0x00000100 0x00000020 5% 20% 85% 10% ""
Pop $Lbl.Sise.Files
# ...:: BUTTON ADD FILES ::... #
nsDialogs::CreateControl /NOUNLOAD BUTTON 0x40000000|0x10000000|0x04000000|0x00010000 0 20% 75% 100u 25u ""
Pop $Btn_Add_Files
Strcpy $1 $Btn_Add_Files
GetFunctionAddress $3 ".OnClick.Add.Files"
nsDialogs::onClick /NOUNLOAD $1 $3
SendMessage $Btn_Add_Files '${WM_SETTEXT}' '0' "STR:$(^BrowseBtn) Files ..."
# ...:: SHOW SIZE FOLDERS ::... #
nsDialogs::CreateControl STATIC 0x40000000|0x10000000|0x04000000|0x00000100 0x00000020 5% 30% 85% 10% ""
Pop $Lbl.Sise.Folders
# ...:: BUTTON ADD FOLDERS ::... #
nsDialogs::CreateControl /NOUNLOAD BUTTON 0x40000000|0x10000000|0x04000000|0x00010000 0 50% 75% 100u 25u ""
Pop $Btn_Add_Folders
Strcpy $1 $Btn_Add_Folders
GetFunctionAddress $3 ".OnClick.Add.Folders"
nsDialogs::onClick /NOUNLOAD $1 $3
SendMessage $Btn_Add_Folders '${WM_SETTEXT}' '0' "STR:$(^BrowseBtn) Folder ..."
nsDialogs::Show
FunctionEnd
# ...:: ADD FILES ::... #
var MYFILES
var MYFOLDERS
var PARENTFILES
var GETFILENAME
Function ".OnClick.Add.Files"
nsDialogs::SelectFileDialog "open" "C:\" "All Files|*.*"
Pop $0
StrCmp $0 "error" +3
StrCpy $MYFILES "$0"
${GetParent} "$MYFILES" $PARENTFILES
${GetFileName} "$MYFILES" $GETFILENAME
${GetSize} "$PARENTFILES" "/M=$GETFILENAME /S=0K" $0 $1 $2
IfErrors 0 +2
StrCpy $0 $0 * 1024
IntCmp $0 100 +3 0 +3
IntCmp $0 0 +2 +2 0
IntOp $0 103 + 0
IntOp $0 $0 * 10
IntOp $0 $0 / 1024
StrCpy $1 "$0" "" -1
IntCmp $0 9 +3 +3 0
StrCpy $0 "$0" -1 ""
Goto +2
StrCpy $0 "0"
${If} $MYFILES != ""
SendMessage $Lbl.Sise.Files '${WM_SETTEXT}' '0' "STR:Estimated Files Size $0.$1 Mib"
${EndIf}
FunctionEnd
# ...:: ADD FOLDERS ::... #
Function ".OnClick.Add.Folders"
NsDialogs::SelectFolderDialog "Select directory" "C:\"
Pop $0
StrCmp $0 "error" +3
StrCpy $MYFOLDERS "$0"
${GetSize} "$MYFOLDERS" "/M=*.* /S=0K" $0 $1 $2
IfErrors 0 +2
StrCpy $0 $0 * 1024
IntCmp $0 100 +3 0 +3
IntCmp $0 0 +2 +2 0
IntOp $0 103 + 0
IntOp $0 $0 * 10
IntOp $0 $0 / 1024
StrCpy $1 "$0" "" -1
IntCmp $0 9 +3 +3 0
StrCpy $0 "$0" -1 ""
Goto +2
StrCpy $0 "0"
${If} $MYFOLDERS != ""
SendMessage $Lbl.Sise.Folders '${WM_SETTEXT}' '0' "STR:Estimated Folders Size $0.$1 Mib"
${EndIf}
FunctionEnd
# ...:: SECTION ::... #
Section "Main" SEC01
SectionEnd
# ...:: END PAGE ::... #
Function .onGUIEnd
FunctionEnd Calculate size in decimal?
How do I calculate the size of a file or folder in decimal or bits, megabits, gigabits