views:

159

answers:

3

I've got a file extension and I'd like to get the name of the application (if there is one) that will be invoked when I ShellExecute a file of that type. This is a WTL/C++ app. Is there any sample code out there that does this?

Thanks!

A: 

Sorry, no code, but some useful information. See this related question: how-does-vista-generate-the-icon-for-documents-associated-to-my-application

It asked about icons, but it turns out the program associated to an extension is stored in the same place in the registry as the icon for that extension.

Cheeso
That is not always the case. Namespace Extensions that implement the IContextMenu interface can also introduce new dynamic verbs for file extensions, and can also affect the default action performed for statically registered verbs. ShellExecuteEx() takes IContextMenu into account, whereas ShellExecute() does not.
Remy Lebeau - TeamB
Ahh, good to know!
Cheeso
+2  A: 

twk,

You're probably looking for the Win32 AssocQueryStringByKey Function.
http://msdn.microsoft.com/en-us/library/bb773473(VS.85).aspx

The ASSOCSTR value that specifies the type of string that is to be returned:

typedef enum {
    ASSOCSTR_COMMAND = 1,
    ASSOCSTR_EXECUTABLE,
    ASSOCSTR_FRIENDLYDOCNAME,
    ASSOCSTR_FRIENDLYAPPNAME,
    ASSOCSTR_NOOPEN,
    ASSOCSTR_SHELLNEWVALUE,
    ASSOCSTR_DDECOMMAND,
    ASSOCSTR_DDEIFEXEC,
    ASSOCSTR_DDEAPPLICATION,
    ASSOCSTR_DDETOPIC,
    ASSOCSTR_INFOTIP,
    ASSOCSTR_QUICKTIP,
    ASSOCSTR_TILEINFO,
    ASSOCSTR_CONTENTTYPE,
    ASSOCSTR_DEFAULTICON,
    ASSOCSTR_SHELLEXTENSION,
    ASSOCSTR_DROPTARGET,
    ASSOCSTR_DELEGATEEXECUTE,
    ASSOCSTR_MAX
} ASSOCSTR;

My guess is that you want ASSOCSTR_FRIENDLYAPPNAME.

Robert Harvey
A: 

It's a Win32 FAQ since 1995 (Shell, see Google Groups, Win32)

Well, domi, I'm glad you set us straight.
Robert Harvey