bnicer
2nd March 2007 11:49 UTC
registry access (vista?)
Hello All!
I have two questions. One should be a quickie:
1) What would be the most simple and elegant way to determine whether a user has write access to the registry (for example, to create an uninstall entry) at the beginning of the setup?
I have been reading some strange posts on this forum that deal with putting shortcuts on the desktop and placing them in the startmenu group under Vista. I haven't had a chance to try out Vista. My second question (based on XP) is:
2) What exactly are the differences/problems?
If still possible, I would use "UserInfo::GetAccountType" together with "SetShellVarContext". Will I be okay?
To expand on this a little, an administrator will have a checkbox for installing shortcut icons for all users or for the current user. Other users must make do with installing the icons for themselves only.
Comperio
2nd March 2007 15:45 UTC
For #1:
A quick test would be to write something to the registry and then check for errors. If errors, you probably don't have access. (You should then probably try to delete what you just wrote just to keep things clean.)
For #2:
I wouldn't see a problem with what you suggest.
Finally for Vista:
You should make sure you include RequestExecutionLevel and set it to something other than "none". The reason is that this will add a manifest into the install and guarantee that the registry virtulization feature in Vista is disabled.
If you have not done so already, you should really read up on UAC (user account control) in Vista.
Also search the forums for Vista-related info. There's been quite a few threads about that lately.
bnicer
2nd March 2007 16:06 UTC
Thx. I'll take your advice and do some more reading.
Is what you are basically saying that you would only need an extra line of code and everything will work in Windows Vista as it does in XP?
If it gets much more complicated, maybe it would be best to just upgrade to Vista and test the scenarios. So I ask.
Comperio
3rd March 2007 01:10 UTC
Is what you are basically saying that you would only need an extra line of code and everything will work in Windows Vista as it does in XP?
For the most part, yes. But as I'm finding on my own, there may be a few quirky things you could run into as a result of UAC and some of Vista's virtualization (used for registry and folders under certain situtions where the user doens't have full permissions.)
You may find that having a Vista machine to play with might help spot potential problems. ;)
bnicer
4th March 2007 18:09 UTC
In preparing myself for the transition to Vista, I'm attempting something probably pretty asinine, but if getting this to work in XP is possible, I'd be happy temporarily.
Run setup 2x:
2 installations
2 destinations
2 uninstallers
for which there are 2 registry entries
under HKLM and the other is under HKCU.
The problem is telling the uninstaller which installation to uninstall, the HKLM one or the HKCU one. The uninstall registry values that specify the install path can be read at runtime, but there are 2. Which one refers to the path you want to remove when clicking on the uninstaller?
Put differently, how does the uninstaller retrieve a variable for the particular instance that is unique?
It occurs to me to include a file with one or the other setup. If found, the uninstaller would target the right instance, however isn't there an easier way?
The uninstall file needs to know which registry entry it was installed with.
Maybe I can figure something out to do that, but if someone has any suggestions, that would be superb.
Thx.
bnicer
4th March 2007 19:47 UTC
A neat trick might be to have uninst.exe return its own location. Then you could compare the location to the registry uninstall string.
IfThisFileExists???
bnicer
5th March 2007 02:22 UTC
I've been looking too hard.
$INSTDIR\uninst.exe is the uninstaller location. I thought $INSTDIR had to be stored somewhere, but the uninstaller remembers it. That means for every install path the uninstaller generated is distinct, and you can read the registry to check the install path. If $INSTDIR\uninst.exe and the uninstall string are a match, the correct instance will be uninstalled.
Phew...
I gather, perhaps mistakenly, that among Vista's quirks, it may be expedient to write uninstall keys to HKCU; I'm keeping my fingers crossed this will be useful later.