krisbg
14th December 2005 19:24 UTC
Hot to get install drive?
I want to use the sysGetDiskFreeSpaceEx function to get the free space at the install path. But this function seems to accept only drive letters and not directories. Is there a way to get only the drive letter for the path that the user has chosen to install like $INSTDIR?
goldy1064
14th December 2005 20:00 UTC
...
StrCpy $R0 $INSTDIR 2 0
...
This would copy C: to $R0 if $INSTDIR were C:\Program Files\foo.
Instructor
14th December 2005 20:19 UTC
Name "Output"
OutFile "Output.exe"
!include "FileFunc.nsh"
!insertmacro DriveSpace
Section
${DriveSpace} "$INSTDIR" "/D=F /S=M" $R0
IfErrors +2
MessageBox MB_OK "$$R0={$R0}"
SectionEnd
krisbg
16th December 2005 10:09 UTC
Thanks to both of you for the replies!
The suggestion of goldy1064 is the easiest, but will not work in a case when a network device with a longer root name is chosen.
The suggestion of Instructor is elegant one, but still it can not work if the target folder does not exist as it is usually. So after searching I found the ${GetRoot} function from the FileFunc plug-in which gives the root element of a path. This way and together with the ${DriveSpace} function it worked, because the root element is implied to always exist. I think it will work also with
System::Call '${sysGetDiskFreeSpaceEx}(r1,.r2,,.)'
combined with ${GetRoot}.
Instructor
16th December 2005 10:55 UTC
it can not work if the target folder does not exist
Yep, you are right, I miss that. Good that you found ${GetRoot}.