Archive: Problems reading&writing from ini and logical code


Problems reading&writing from ini and logical code
Hi, first of all.

I have some problems with the programm I'm writing.


Var WORD_DIR
Installdir "$WORD_DIR\${PROGRAM}${VERSION}"

Function .onInit
!insertmacro MUI_INSTALLOPTIONS_EXTRACT_AS "Word.ini" "Wordverzeichnis"
Functionend

Function Wordverzeichnis
; Tries to find the newes Word- version
ReadRegStr $0 HKLM Software\Microsoft\Office\11.0\Word ""
ReadRegstr $1 HKLM Software\Microsoft\Office\10.0\Word ""
; etc... to be added when it even works

${If} $0 != ""
ReadRegStr $WORD_VERSION HKLM Software\Microsoft\Office\11.0\Word\InstallRoot "Path"
${ElseIf} $1 != ""
ReadRegStr $WORD_VERSION HKLM Software\Microsoft\Office\10.0\Word\InstallRoot "Path"
${EndIf}

!insertmacro MUI_INSTALLOPTIONS_WRITE "Word.ini" "Field 1" "State" $WORD_VERSION
!insertmacro MUI_INSTALLOPTIONS_DISPLAY "Wordverzeichnis"
ReadINIStr $WORD_DIR "Word.ini" "Field 1" "State"
FunctionEnd

(hope that are all the important bits)

Now, the problem is
a)
it doesn't read the word directory from the registry(cause I know I have Word 11 on the PC) or at least doesn't write it into the ini. It still states the defaut directory. Is the logical code wrong, or the registry stuff?
b)
it doesn't read the final directory. When I state a directory on the custompage, and go to the next page (normal directory page) it shows $WORD_DIR/Programmname. Did I use the variable wrong?

I'd be very grateful for any help. But please keep explanations simple, I'm pretty new to this. :)

You are extracting the file as Wordverzeichnis, but writing to Word.ini. Write to Wordverzeichnis.


ok, thanks, that helps.
But I still seem to use Word_Dir wrong, it doesn't excange it for the value in Installdir. Any ideas?

Another minor question occured to me: Is it possible to use a langstring in a define without messing it up?


Ok, I think it must have to do with the fact that it doesn't save the specified directory when I klick "Next". Is there a way to do that and then define that directory as $instdir (just like on the normal directory page)?


Just read directly into $INSTDIR and then append your extra folder name on the end with StrCpy.
I believe that once $INSTDIR is evaluated it will no longer contain variable references and that is why changing $WORD_DIR does not change $INSTDIR.

Stu


I'm not sure I understand how you mean that. Could you give me a codeline for that? Thanks.


Page Custom Wordverzeichnis WordverzeichnisLeave

...

Function WordverzeichnisLeave
!insertmacro MUI_INSTALLOPTIONS_READ $INSTDIR Wordverzeichnis "Field 1" "State"
StrCpy $INSTDIR `$INSTDIR\${PROGRAM}${VERSION}`
FunctionEnd


Notice that I have moved it to the Leave function as well as you cannot get the value any other way.

Stu

Great, thanks, now it's working as it was supposed to. :)