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 application in the list is customized for that file type (i.e., not simply the name and icon of the executable).
This is because the binary is a general binary that runs many different apps, depending on its command-line arguments (similar topython.exe
or javaws.exe
). I don't want the "Open With" menu to show "Python" or "Java", I want it to show the name and icon for the application that is being passed on the command-line.
I know how to add file associations (by creating a ProgID in HKEY_CLASSES_ROOT
, and adding the ProgID name to either OpenWithProgids or HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts
), but I cannot find any way to change the name or icon of the application as it appears in the "Open With" menu for files of that type. Is this possible?
(Edited to clarify my existing understanding of adding file associations.)
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With