I would like to associate a file type in Windows with a particular application, but I need to make it so when the user opens the \"Open With\" menu, the name and icon of the app
It's slightly complicated, but basically you need to create a ProgID to refer to the application itself, then add a OpenWithProgIDs key to the extension.
More detail on setting up a ProgID is here.
I have a partial solution which allows the name to be set (but not the icon or company name).
It is possible to register an application in Windows. This is very similar to creating a ProgID, but it allows you to set the FriendlyAppName. For some reason, you can't set the FriendlyAppName on a ProgID. Unfortunately, FriendlyAppName is not a string, but a reference to a resource in a .DLL or .EXE file. Go figure.
So:
HKEY_CLASSES_ROOT\Applications\whatever.exe
(whatever should be a unique name specific to the virtual application -- it does not need to be the name of a real executable, but it does need to end in .exe
or another executable extension).
Now the application will appear in the "Other Programs" dropdown of the "Choose default program" dialog, but not in the "Open With" menu. To properly associate it, you need to:
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts
(it can also be in HKEY_CURRENT_USER
, but I have found that the FileExts
version overrides, and Windows creates one there if the user manually creates a file association, so best to use that one).
whatever.exe
you created above. This should be a value whose name is an arbitrary letter and whose value is the fake exe name.MRUList
value includes the letter you assigned to the fake executable in the previous step.Applications\whatever.exe
". This is optional, but there needs to be something set here (if UserChoice is missing, nothing will work).Lastly, hit it with a SHChangeNotify to refresh Windows' icon and shortcut cache. (I'm not sure if this is necessary after all; I just noticed that it helps to make Windows notice the changes you're making.)
Now on the "Open With" menu for the file type, you should see an entry for the custom string you put in the dummy .dll. It will still have the icon of the real binary mentioned in the shell command, but you can at least control the name. Why, why is this so hard?
I will leave this question open for awhile in case there are better answers.