Old 22nd February 2008, 23:50   #1
MarcL
Junior Member
 
Join Date: Feb 2008
Location: Zurich, Switzerland
Posts: 3
Send a message via ICQ to MarcL
Installation directory

Hi all

I have searched through the forum, asked google and read through the NSIS User Manual but couldn't find an answer. But I have to warn you, I'm not a software developer, I only have a bit experience with C and HTML.

I have a little problem with the directory of my installation. I read out a path and would like to add a sting to the installation path.

When I try it with Installdirregkey, I can't use variables and therefore I'm not able to add anything to the install path.

If I use ReadRegStr, I can add it to the variable $0, but I cant get the content of it outside the function:
code:
Function .onInit
ReadRegStr $0 HKLM "Software\Microsoft\Microsoft Games\Flight Simulator\9.0\" "EXE Path"
FunctionEnd


code:
InstallDir $0

I get a blank destination back, and not the Path I would like to have. If I put in a messagebox in the function, it works fine.

I'm pretty sure it's a silly question, but actually I'm really blocked.


Kind regards

Marc Laederach
MarcL is offline   Reply With Quote
Old 23rd February 2008, 00:40   #2
Mr Inches
Member
 
Join Date: Jan 2006
Location: Canberra, Australia
Posts: 76
You should use variables to preserve values between functions and sections.

For what you are trying to do, you can use a user defined one or the built-in INSTDIR variable.

For example:
code:

Function .onInit
ReadRegStr $INSTDIR HKLM "Software\Microsoft\Microsoft Games\Flight Simulator\9.0\" "EXE Path"
FunctionEnd

; INSTDIR should still contain the value set in .onInit unless the user changed in a directory page.
Section Main
DetailPrint "$INSTDIR"
SectionEnd


OR
code:

Var MyInstallDir

Function .onInit
ReadRegStr $MyInstallDir HKLM "Software\Microsoft\Microsoft Games\Flight Simulator\9.0\" "EXE Path"
FunctionEnd

Section Main
InstallDir $MyInstallDir
DetailPrint "$INSTDIR"
SectionEnd



Duncan
Mr Inches is offline   Reply With Quote
Old 23rd February 2008, 01:06   #3
MarcL
Junior Member
 
Join Date: Feb 2008
Location: Zurich, Switzerland
Posts: 3
Send a message via ICQ to MarcL
Hi Duncan

Thank you very much for your help, you could solve one of my problems! I forgot to write the string I want to add to the path I read out from the registry: The path should be "$INSTDIR\Addon Scenery\FreeZ", so I should get $INSTDIR from the registry and add "\Addon Scenery\FreeZ" to it, but it doesn't work. Perhaps it has to do something with the order?


Kind regards

Marc Laederach
MarcL is offline   Reply With Quote
Old 23rd February 2008, 08:09   #4
Red Wine
Forum King
 
Red Wine's Avatar
 
Join Date: Mar 2006
Location: Ath. GR
Posts: 2,078
code:
Function .onInit
ReadRegStr $0 HKLM "Software\Microsoft\Microsoft Games\Flight Simulator\9.0\" "EXE Path"
StrCpy $INSTDIR "$0\Addon Scenery\FreeZ"
FunctionEnd


Quick AVI Creator - Quick and easy convert from DVD/MPEG/AVI/MKV to AVI/MP4/MKV
Quick AVI Creator entirely edited with NSIS and entirely upgraded to Unicode NSIS
Red Wine is offline   Reply With Quote
Old 23rd February 2008, 17:39   #5
MarcL
Junior Member
 
Join Date: Feb 2008
Location: Zurich, Switzerland
Posts: 3
Send a message via ICQ to MarcL
Thanks, works pretty good!!


Kind regards

Marc Laederach
MarcL is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump