Archive: Registry functions and variables?


Registry functions and variables?
Hi.

Is it (or will it be) possible to use real variables for the registry functions? This isn't working

Var RegRoot

StrCpy $RegRoot HKLM
WriteRegStr $RegRoot "PathToSomewhere" "ValueName" "Value"

but I could need something like this for my version comparison. I save the setup's current version number to prevent that a user can install an older version if a newer version is already installed. The problem is: I have a few setups, you can use without Admin privileges. In this situation, I need to save the version into the HKCU path.
But let's say there are two Administrators: Admin #1 installs my application, Admin #2 removes it. Then Admin #1 still has the version number in his HKCU path. :(

Therefore I need a way to change the registry root, depending on the logged user's privileges. If he/she is an Admin, I can use HKLM - otherwise I use HKCU.
A work-around: I have to write different macros for saving, comparing and removing the version number, depending on the user's privileges. But this is inefficient, IMHO, because the code is the same. Just the registry root differs.

Is there a solution for me?
Thanks for reading.

Mathias.

It's not the user variable. HKLM/HKCU/etc is a compile time setting.

You should use:

StrCmp $RegRoot HKLM 0 +2
WriteRegStr HKLM "PathToSomewhere" "ValueName" "Value"

StrCmp $RegRoot HKCU 0 +2
WriteRegStr HKCU "PathToSomewhere" "ValueName" "Value"


Hey, this is a good idea. Why didn't I ... ;)
Thanks for cleaning up my head, man! :)