Archive: ReadINIStr and WriteINIStr


ReadINIStr and WriteINIStr
It seems that I cannot get ReadIniStr or WriteIniStr to work inside of a function call. These calls should work fine, because MUI_INSTALLOPTIONS_x...x uses it, and calling it from a function works fine.
So... is the case that the string and section need to exist in order for me to write to them?
If I cancel the installer before it completes, will the values not get written to the INI file?


It doesn't matter whether the command is inside a section or a function, there must be a bug in your script. What is the purpose of the function you are writing?


For example:

ReadIniStr $R1 ".\slavenetpaths.ini" "ManualPaths" "NumEntries"
WriteINIStr "$EXEDIR/slavenetpaths.ini" "ManualPaths" "NumEntries" "$R2"
All do not work.

However
WriteIniStr "$EXEDIR/slavenetpaths.ini" "ManualPaths" "Slave $2" "$3"
Does claims no errors even though it didn't work.

slavenetpaths.ini is in the exedir.
I notice that alot of people ReserveFile their ini, and then extract it later. Also I notice that the installoptions ini files are not updated with default values whenever I quit the installer early. Neither does it update them when I actually complete the installer...
(annoying)


I don't know why... but it just started working... (grr). I just put...
ReadIniStr $R1 ".\slavenetpaths.ini" "ManualPaths" "NumEntries"
removed some broken code around it (that had NOTHING to do with it), and I also added entries in my INI file. "NumEntries" was added. However it seems to have no problem adding and deleting the entries now. ... weird.
I'm now having a problem with:

SendMessage $1 ${CB_GETLBTEXT} $0 "STR:$3" $4

$4, of course returns the size of the string returned. BUT $3 doesn't contain anything.
StrCpy $3 " "
SendMessage $1 ${CB_GETLBTEXT} $0 "STR:$3" $4
Also doesn't work. It doesn't "fill up" $3.

SendMessage $1 ${CB_GETLBTEXT} $0 "$3" $4
Makes $4 contain -1, which is error.

This message is really expecting a POINTER to a string buffer for $3. Is there something I can do to make this work? (short of writing an external C++ program?)


I'm posting a new thread about this.


Probably the fact that you use forward strokes (/) instead of back strokes.

Edit: And you should really stop using relative paths.

e.g.
SetOutPath "C:\"
ReadINIStr $R0 ".\file.ini" ...
will only work if file.ini is in C:\

Lets say you just happened to SetOutPath $INSTDIR first, then file.ini would then have to be in $INSTDIR to work.

-Stu


Regarding your second problem, it may be that the "STR:" form of parameter for SendMessage is for passing strings in only e.g for WM_SETTEXT or similar.

You could try using the System plug-in to make the call to SendMessage, it will allow you to pass the LPSTR parameter expected by CB_GETLBTEXT.

Duncan


is there some documentation for the system plugin? How do I make calls to it regularly? (is there some sort of loading call I need to make?)


System's documentation is located at Docs\System.


Visit the wiki page of NSIS.