Archive: Modify an .ini file with data from the registry


Modify an .ini file with data from the registry
Hi. I have a hard time modifying an ini file with data from the registry. Here is the .ini file (it's called setup_gc42.iss ):

[InstallShield Silent]
Version=v6.00.000
File=Response File
[File Transfer]
OverwrittenReadOnly=NoToAll
[{8C1C7C31-AE1E-4EA9-A108-80F23ED7AE1B}-DlgOrder]
Dlg0={8C1C7C31-AE1E-4EA9-A108-80F23ED7AE1B}-SdWelcome-0
Count=4
Dlg1={8C1C7C31-AE1E-4EA9-A108-80F23ED7AE1B}-SdAskDestPath-0
Dlg2={8C1C7C31-AE1E-4EA9-A108-80F23ED7AE1B}-SdStartCopy-0
Dlg3={8C1C7C31-AE1E-4EA9-A108-80F23ED7AE1B}-SdFinish-0
[{8C1C7C31-AE1E-4EA9-A108-80F23ED7AE1B}-SdWelcome-0]
Result=1
[{8C1C7C31-AE1E-4EA9-A108-80F23ED7AE1B}-SdAskDestPath-0]
szDir=C:\PathTo\MyProgram
Result=1
[{8C1C7C31-AE1E-4EA9-A108-80F23ED7AE1B}-SdStartCopy-0]
Result=1
[{8C1C7C31-AE1E-4EA9-A108-80F23ED7AE1B}-SdFinish-0]
Result=1
bOpt1=0
bOpt2=0

I want to replace the value of szDir with the correct path that I will read from the user's registry. The thing is that when I try to do that it writes at the bottom of the .ini file this:

[{8C1C7C31-AE1E-4EA9-A108-80F23ED7AE1B}-SdAskDestPath-0]
szDir=C:\PathReadFromRegistry\MyProgram

I don't want to do that. I want to replace that line, not to add it to the end. How do I do that ?


If you want it in a specific place, don't use WriteINIStr. Use one of the line replacement functions from the Archive. For example:

http://nsis.sourceforge.net/archive/....php?pageid=17
http://nsis.sourceforge.net/archive/...php?pageid=256
http://nsis.sourceforge.net/archive/...php?pageid=381


Thanks kichik. I made it work.