Cerf
25th November 2005 20:25 UTC
Disabling "Destination Folder" page
Hello there,
I Searched the forum, but couldn't find the how to. I am a little new to NSIS. So please excuse if it's a very simple question.
I have an app that comes with several modules, each can be installed separately but if there is one of the modules already installed the other ones *HAVE* to be in the same folder, so I better disable the Destination Folder page or dialog.
I have used the NSIS examples and this forum to build the script, but I can't figure out how can I check if the InstallDirRegKey is present and then don't let the user mess with install dir.
Thanks in advance,
Cërf.
Cerf
25th November 2005 22:08 UTC
I found something Here but I don't think it performs the check about installRegKey being present.
Afrow UK
26th November 2005 11:35 UTC
Use ReadRegStr.
E.g.
!define InstallDirRegKey '"HKCU" "Software\MyApp" "InstallDir"'
InstallDirRegKey ${InstallDirRegKey}
!define MUI_PAGE_CUSTOMFUNCTION_PRE DirectoryPre
!insertmacro MUI_PAGE_DIRECTORY
Function DirectoryPre
ReadRegStr $R0 ${InstallDirRegKey}
StrCmp $R0 "" +2
Abort # Skip page
FunctionEnd
Edit: If you want to disable the directory field only, then your code would be different...
!define InstallDirRegKey '"HKCU" "Software\MyApp" "InstallDir"'
InstallDirRegKey ${InstallDirRegKey}
!define MUI_PAGE_CUSTOMFUNCTION_SHOW DirectoryShow
!insertmacro MUI_PAGE_DIRECTORY
Function DirectoryShow
FindWindow $R1 "#32770" "" $HWNDPARENT
ReadRegStr $R0 ${InstallDirRegKey}
StrCmp $R0 "" NoDisable
GetDlgItem $R2 $R1 1019 # Dir box
EnableWindow $R2 0
GetDlgItem $R2 $R1 1001 # Browse button
EnableWindow $R2 0
Goto End
NoDisable:
GetDlgItem $R2 $R1 1019 # Dir box
EnableWindow $R2 1
GetDlgItem $R2 $R1 1001 # Browse button
EnableWindow $R2 1
End:
FunctionEnd
There's code in there to re-enable them again just in case.
-Stu
Cerf
28th November 2005 14:45 UTC
Hey there Stu,
Thanks for the reply!
I'm using the "skip" code, but now I am facing the embarrasing problem of not knowing how to assing a value to $INSTDIR when no other installation have been detected.
Thanks again!
Cërf.
dotdavid
19th May 2006 16:05 UTC
StrCpy $INSTDIR "C:\Your\Default\Path"
?
Red Wine
19th May 2006 18:48 UTC
Use InstallDir as always, so if there is not other installation and the directory page is going to be visible, the browse field would prompt users with what you have entered in InstallDir.