mlm
27th April 2003 09:24 UTC
String manipulation for registry
During my installation I set a registry key in the following way:
ReadRegStr $R0 HKCU ${VS6_INCLUDE_DIRS_KEY} "Include Dirs"
WriteRegStr HKCU ${VS6_INCLUDE_DIRS_KEY} "Include Dirs" "${myDir};$R0"
The key value is a listing of directories for visual studio to look in for include files. First of all, I don't know if this is the best way of doing this, but it seems to work without any problems.
My problem is during the uninstall. I need to remove my directory paths from the key value. I thought at first I could just store the original $R0 and set the key value back to the original value, but if the user has added other paths to the key value after my installation, then it will remove those values also.
So during uninstall I need to get the current value and then remove the paths I added (if it still exists of course). I'm having problems figuring out how to implement this.
thanks in advance,
mlm (aka digitalda)
Joel
27th April 2003 17:02 UTC
Well...
For set way it's only this:
WriteRegStr HKLM "SOFTWARE\${MUI_PRODUCT}" "InstallPath" "$INSTDIR"
If you don't problems, go for it :D
Now, to remove it:
DeleteRegKey HKLM "SOFTWARE\${MUI_PRODUCT}"
; or
DeleteRegValue HKLM "SOFTWARE\${MUI_PRODUCT}" "InstallPath"
Helps?
kichik
27th April 2003 17:27 UTC
My Path Manipulation functions do something very similar, they may help.
mlm
27th April 2003 19:24 UTC
kichik,
Can you expain what's going on in StrStr. This script is exactly what I need, but I don't know enough to change it for my needs.
I don't understand the initial push, then Exch, and subsequent manipulation of the stack. I read what these opeations do, but I don't understand why you do them.
thanks,
mlm (aka digitalda)
kichik
27th April 2003 23:33 UTC
All of the Pushes, Pops and Exchs are meant for the function to receive arguments, return values and keep global registers' original values. I'll add some more information tomorrow if needed.
mlm
28th April 2003 04:00 UTC
I've gone ahead and used this script: http://nsis.sourceforge.net/archive/...b.php?page=197
It works beautifully. But it would still be nice to understand the logic of your script, kichik. I would like to write some of my own stuff in the future and I think it is important to understand. Any input on your script would be appreciated.
thanks,
mlm (aka digitalda)
kichik
28th April 2003 16:37 UTC
This article on the archive might assist you understanding the stack better. As for my clumsy old StrStr it pushes the value of $0 on the top of the stack (Push $0), exchanges the top two values of the stack - $0 value with string to find (Exch), pops the value on the top of the stack (the value that was on top of the stack before we started - the string to find) into $0 (Pop $0), pushes the value of $1 on the top of the stack (Push $1), exchanges the top value on the stack with the one 2 below it - $1 value with the string to look in (Exch 2), pops the value on the top of the stack into $1 - the string to look in (Pop $1) and finally exchanges the top two values on the stack ($0's value with $1's value - $1 is now on the top). That leaves us with $1's value and $0's value on the stack and the string to search in, and the string to search for in $0 and $1. Now we can play with $0 and $1, change their values and when we're done we can get their old values from the stack so the user's old value wouldn't change.
I don't think that helped much... heh :)
There is an easier way to do this (StrStr in the docs for example).
It's always easier, for me at least, when I draw the stack. You can easily see what's going on that way. Maybe DumpState can help you too.