ionut_y
3rd January 2007 07:35 UTC
Force user to select only drive letter
I have an application that works on a drive folder like
c:\myapp, d:\myapp, e:\myapp ..... how can I replace MUI_PAGE_DIRECTORY with a combobox for selecting only drives letter available.I'm new with nsis and please I want a small script file to see that.For 2 days I'm looking for a solution.
Many thanks !!
Red Wine
3rd January 2007 07:45 UTC
Already discussed here:
http://forums.winamp.com/showthread....hreadid=262165
ionut_y
3rd January 2007 07:59 UTC
Originally posted by Red Wine
Already discussed here:
http://forums.winamp.com/showthread....hreadid=262165
Thanks for answer.... but this is not what i'm looking for, user can also chose a subdir ...and i want to force it to choose only drive letter from a combo.
Red Wine
3rd January 2007 08:07 UTC
Nope, this is exactly what you're looking, though, feel free to build a custom page with a combo, find all available HDD with GetDrives, and add them to ListItems.
ionut_y
3rd January 2007 08:18 UTC
Originally posted by Red Wine
Nope, this is exactly what you're looking, though, feel free to build a custom page with a combo, find all available HDD with GetDrives, and add them to ListItems.
Thanks again ...this is my problem...i don't know how i can do it.I use nsis for 3 days,I wand i script for exemple.Thanks !
Backland
3rd January 2007 11:45 UTC
I dont think there is one available, but the concept is very simple:
Enumerate the drives with the plugin, and add them to your custom page's combo with the WriteINIStr. You should probably start by looking through the InstallOptions examples provided with NSIS. It looks a bit daunting at first, but its quite simple.
Red Wine
3rd January 2007 12:37 UTC
Take this as a starting point :-)
!define APPNAME "My Application"
Name '${APPNAME}'
OutFile 'test.exe'
LicenseData '${NSISDIR}\License.txt'
LicenseBkColor 0xFFFFFF
ShowInstDetails show
AllowRootDirInstall true
!include FileFunc.nsh
!insertmacro GetDrives
Page License
Page Custom CustomCreate CustomLeave
Page InstFiles
Section "boo"
SetOutPath '$INSTDIR'
SectionEnd
Function CustomCreate
WriteIniStr '$PLUGINSDIR\custom.ini' 'Settings' 'NumFields' '2'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 1' 'Type' 'Label'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 1' 'Left' '5'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 1' 'Top' '5'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 1' 'Right' '-6'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 1' 'Bottom' '17'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 1' 'Text' \
'Select Installation drive:'
StrCpy $R2 0
StrCpy $R0 ''
${GetDrives} "HDD" GetDrivesCallBack
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 2' 'Type' 'DropList'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 2' 'Left' '30'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 2' 'Top' '25'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 2' 'Right' '-31'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 2' 'Bottom' '105'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 2' 'State' '$R1'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 2' 'ListItems' '$R0'
push $0
InstallOptions::Dialog '$PLUGINSDIR\custom.ini'
pop $0
pop $0
FunctionEnd
Function CustomLeave
ReadIniStr $0 '$PLUGINSDIR\custom.ini' 'Field 2' 'State'
StrCpy '$INSTDIR' '$0'
FunctionEnd
Function GetDrivesCallBack
IntCmp $R2 '0' def next next
def:
StrCpy $R1 '$9${APPNAME}'
next:
IntOp $R2 $R2 + 1
StrCpy $R0 '$R0$9${APPNAME}|'
Push $0
FunctionEnd
Function .onInit
InitPluginsDir
GetTempFileName $0
Rename $0 '$PLUGINSDIR\custom.ini'
FunctionEnd
ionut_y
3rd January 2007 13:32 UTC
Originally posted by Red Wine
Take this as a starting point :-)
!define APPNAME "My Application"
Name '${APPNAME}'
OutFile 'test.exe'
......................
Thanks very much ... is seems ok. I'll start learnig nsis deeply.
Red Wine
3rd January 2007 17:41 UTC
You're welcome!
Just added a wiki page with the complete example that calculates the free space of every drive and adds only those drives that they have enough space for the uncompressed installation.