Archive: message box when space disk is too small


message box when space disk is too small
Hello,
after a long time without post, i come to ask some help.
Several months ago, i've written a program needing 2 CDroms.
Today, i need to make un upgrade of this program.
Space disk is my problem. The program will install 575 Mo of data.
So i put an AddSize 580000 on my section, but even if i put Addsize 10000000, the program start.

As Install directory address is present in a part of Registry database, my program start without any choice.
I make a lot of CopyFiles command like this one

CopyFiles /silent "$EXEDIR\DATA\Anims\GB\*.*" "$INSTDIR\data\Anims\GB"

So, i need to open a message box if space disk is too small and next to close the program.

if you have an idea, thinks for your help


You could try looking at the sysGetDiskFreeSpaceEx example of the System plugin in Contrib\System\System.nsi. This would allow you to manually determine if there is enough disk space free. There is a little more information on using the System plugin (not for disk space checking though) in the NSIS Archive.


thinks for your help but i don't understand not very well how to use it.


The System.nsi, along with the System plugin are very undocumented and there are only a few persons who really know how to deal with it.
The essence is that you use this line: "System::Call '${sysGetDiskFreeSpaceEx}(i r1, .r3, .r4, .r5)'" along with some other instructions to get the free space on the disk in bytes, substract the number of needed bytes from it and then check whether the result is negative (< 0). If so, there isn't enough space left.
This is the online version of the sample where Sunjammer referred to: System.nsi


Try this example out:-

OutFile "FreeSpace.exe"
!define sysGetDiskFreeSpaceEx 'kernel32::GetDiskFreeSpaceExA(t, *l, *l, *l) i'

; $0 - space required in kb
; $1 - path to check
; $2 - 0 = ignore quotas, 1 = obey quotas
; trashes $2
function CheckSpaceFunc
IntCmp $2 0 ignorequota
; obey quota
System::Call '${sysGetDiskFreeSpaceEx}(r1,.r2,,.)'
goto converttokb
; ignore quota
ignorequota:
System::Call '${sysGetDiskFreeSpaceEx}(r1,.,,.r2)'
converttokb:
; convert the large integer byte values into managable kb
System::Int64Op $2 / 1024
Pop $2
; check space
System::Int64Op $2 > $0
Pop $2
functionend

section -
StrCpy $0 12345; kb u need
StrCpy $1 'c:\' ; check drive c: for space
Call CheckSpaceFunc
IntCmp $2 1 okay
MessageBox MB_OK "Error: Not enough disk space"
okay:
sectionend

thinks for your help.
i 've just written a vb program doing the same thing.
if someone is interrested, just ask me


Where you able to make a VB program that is a plugin for NSIS? I'm interested!


I use it as a program started with exeWait command
Next, as i use an emplacement in HKCU registry, it write a command that i read with my nsis installer


With ExecWait you can read the return value. I don't know how to return a value to the OS with VB, but if you find it a way it will be much simpler than writing and reading from the registry.