Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

CWinApp::RegisterShellFileTypes() broken in Vista

11 views
Skip to first unread message

David Wilkinson

unread,
Sep 18, 2006, 4:18:32 PM9/18/06
to
Actually, it seems that CWinApp::RegisterShellFileTypes() was always
broken if the application did not have administrator privileges, but
this will be far more common in Windows Vista, because the default
account type does not give administrator privileges to ordinary programs.

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

Tom Serface

unread,
Sep 18, 2006, 4:41:17 PM9/18/06
to
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

"David Wilkinson" <no-r...@effisols.com> wrote in message
news:%23vg3a%2312GH...@TK2MSFTNGP04.phx.gbl...

David Wilkinson

unread,
Sep 19, 2006, 6:33:08 AM9/19/06
to
Tom Serface wrote:

> 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

0 new messages