CWinApp::RegisterShellFileTypes() writes to the HKCR registry hive,
which is a merge of
HKLM\SOFTWARE\Classes
and
HKCU\Software\Classes
For regedit display and reading, the HKCU value (if present) dominates.
But for writing, the value is always written to the HKLM hive unless the
HKCU key is present, in which case it is written there.
So if the keys are not present in HKCU,
CWinApp::RegisterShellFileTypes() will attempt to write to HKLM, which a
standard user cannot do. So it can never write anything, unless the keys
have been added to HKCU in some other way. There is no provision for
this in MFC.
Vista virtualization could potentially have fixed this, but it seems
that writing to HKCR is not virtualized, even though for an admin user
it is equivalent to writing to HKLM. Vista therefore reproduces the old
broken behavior, rather than making the program appear to run as it
would for an administrator.
So it seems that CWinApp::RegisterShellFileTypes() is broken in Vista
(and was before for non-admin user). The solution, I think, is to make
the relevant changes in a setup program that has administrator privileges.
David Wilkinson
One thing we'll likely have to enforce is having users install (or have
software installed) as an admin even if they are going to run in a limited
user set up. Fortunately, it only once to set up the registry.
Tom
"David Wilkinson" <no-r...@effisols.com> wrote in message
news:%23vg3a%2312GH...@TK2MSFTNGP04.phx.gbl...
> I agree. This has been a problem for me for some time. Fortunately, MFC
> doesn't gripe about not being able to update the registry, it just doesn't
> work which, of course, makes double clicking in Explorer uneventful.
>
> One thing we'll likely have to enforce is having users install (or have
> software installed) as an admin even if they are going to run in a limited
> user set up. Fortunately, it only once to set up the registry.
>
> Tom
[snip]
Tom:
Yes, I should have faced up to this issue of non-admin users a long time
ago. Fortunately, the failure of CWinApp::RegisterShellFileTypes() is
not fatal to a program.
Like you, my strategy for the future will be to have a setup program
that requires administrator status (which triggers UAC in Vista), while
making sure my app itself will run as a standard user.
David Wilkinson