Skip to content
⌘ NSIS Forum Archive

Available Disk Space on Components page.

6 posts

gadagkar#

Available Disk Space on Components page.

Hi,
Is there a way to display the available space on the
Components page instead of the Directory page since I am
not using the Directory page (MUI)?

Thanks in advance.

Rishi.
dandaman32#
NSIS doesn't show the available space on the Components page because the user has not yet selected a drive to install the program on at that point in the installer. If you wanted to put a disk space counter on the Components page, you could use System.dll to get the available space on C: and then use SendMessage to set the text on the Components page. However this might require modifying the UI file with Resource Hacker or similar.

Here's a simple example of setting the text:

!define MUI_PAGE_CUSTOMFUNCTION_SHOW SetText

Function SetText
; Here you want to put code to get the abount of disk space available on C:.
; This example assumes that the value is stored in $0, and that the value is in MB.
FindWindow $0 "#32770" "" $HWNDPARENT
GetDlgItem $0 $0 1023
SendMessage $0 0xC 0 "STR:Space Required: replace_with_space_required$\nSpace Available: $0MB"
FunctionEnd
-dandaman32
minhht#
Originally Posted by dandaman32 View Post
NSIS doesn't show the available space on the Components page because the user has not yet selected a drive to install the program on at that point in the installer. If you wanted to put a disk space counter on the Components page, you could use System.dll to get the available space on C: and then use SendMessage to set the text on the Components page. However this might require modifying the UI file with Resource Hacker or similar.

Here's a simple example of setting the text:

!define MUI_PAGE_CUSTOMFUNCTION_SHOW SetText

Function SetText
; Here you want to put code to get the abount of disk space available on C:.
; This example assumes that the value is stored in $0, and that the value is in MB.
FindWindow $0 "#32770" "" $HWNDPARENT
GetDlgItem $0 $0 1023
SendMessage $0 0xC 0 "STR:Space Required: replace_with_space_required$\nSpace Available: $0MB"
FunctionEnd
-dandaman32
Hi dandaman32, in the quot, you mentioned "use System.dll to get the available space". Could you guide me to do that? Thank so much
jpderuiter#
minhht#
Originally Posted by jpderuiter View Post
Hi jp deruiter, thank for your link.
Would you mind helping me for another problem?
I want to add a text "Space avaialble" under the text "Space required" in the component page. I tried to customize the page with MUI_PAGE_CUSTOMFUNCTION_SHOW.

!define MUI_INSTALLOPTIONS_INITDIALOG CreateLabel
Function CreateLabel
${NSD_CreateLabel} 2u 110u 66u 13u "Space available:"
FunctionEnd
But it didn't work to me.