Paul-Jan
Paul-Jan

Reputation: 17278

How to find out file association that's not in HKCR

Context

For a given file extension, I need to find out the ProgID(?) of the file association (e.g. Word.Document for .docx). I need his (a) to recognize specific associated software (e.g. Adobe versus Nuance) and handle accordingly before they can open a document, and (b) to make Outlook display the correct icon for virtual files (message class IPM.Document.[ProgID]).

The current solution

I simply read out the (Default) entry of the registry key at HKEY_CURRENT_ROOT\[extension]

The problem

On some machines, for some file types, the (Default) entry in HKCR is empty., However, the Windows Explorer (shell) shows the appropriate icon, and definitely has a working file associations when opening the file.

Clearly, I am not using the right approach to retrieving the file association. Is there a ASSOCSTR I am missing that I can pass to AssocQueryString that will return this information, or any other call or standard documentation on file associations on MSDN that I am overlooking?

Upvotes: 1

Views: 673

Answers (1)

Jonathan Potter
Jonathan Potter

Reputation: 37202

Since Windows Vista (I think) there has been the ability for the user to override the normal HKCR file association system, via the key

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\ .extension\UserChoice\

You need to check this key for the ProgId value and use that if it exists, and treat HKCR\extension as a default fallback only.

Upvotes: 3

Related Questions