Setting up file associations for Windows 10 in Inno Setup

2,171 views
Skip to first unread message

Albert Wiersch

unread,
Feb 14, 2020, 10:01:18 PM2/14/20
to innosetup
I've always hated dealing with file associations.... and they confuse me.

What is the current (modern/Windows 10) way to associate file types (like txt, html, php) files with one's app?

Is there a way to have one's software listed in the File Explorer 'Open with' list for certain file types like txt, html, php, etc?

Is there some web page or documentation page that clearly explains all the fine(r) details with file associations in Windows 10?

Basically, at a minimum, I want my software to be listed in the 'Open with' list for certain file types in File Explorer (you know, when right-clicking on certain file types where it will show an 'Open with' submenu option).

Perhaps I'd also like to (for certain file types), add a 'direct' menu option 'Open with MyApp' when a user right-clicks on certain file extensions (like txt, html, php, etc). These file types are not specific only to my app... but to multiple apps.... but I want the user(s) to have some easy options to open these file types with my app.

Thanks,
Albert

Martijn Laan

unread,
Feb 15, 2020, 1:58:53 AM2/15/20
to inno...@googlegroups.com
Op 15-2-2020 om 04:01 schreef Albert Wiersch:
What is the current (modern/Windows 10) way to associate file types (like txt, html, php) files with one's app?

See http://www.jrsoftware.org/isfaq.php#assoc and also the Example3.iss example script.

Greetings,
Martijn

Jernej Simončič

unread,
Feb 15, 2020, 5:09:25 AM2/15/20
to Albert Wiersch on [innosetup]
On Saturday, February 15, 2020, 04:01:17, Albert Wiersch wrote:

> What is the current (modern/Windows 10) way to associate file types (like
> txt, html, php) files with one's app?

Here's a way that works for Windows 7 and newer:

;setup for associations
Root: HKA; Subkey: "Software\Classes\Applications\myprogram.exe"; Flags: uninsdeletekey
Root: HKA; Subkey: "Software\Classes\Applications\myprogram.exe"; ValueType: string; ValueName: "FriendlyAppName"; ValueData: "My Program"
Root: HKA; Subkey: "Software\Classes\Applications\myprogram.exe\DefaultIcon"; ValueType: string; ValueName: ""; ValueData: "{app}\myprogram.exe,1"
Root: HKA; Subkey: "Software\Classes\Applications\myprogram.exe\shell\open\command"; ValueType: string; ValueName: ""; ValueData: """{app}\myprogram.exe"" ""%1"""
Root: HKA; Subkey: "Software\RegisteredApplications"; ValueType: string; ValueName: "My Program x.y"; ValueData: "Software\My Program x.y\Capabilities"; Flags: uninsdeletevalue
Root: HKA; Subkey: "Software\My Program x.y"; Flags: uninsdeletekey
Root: HKA; Subkey: "Software\My Program x.y\Capabilities"; ValueType: string; ValueName: "ApplicationName"; ValueData: "My Program"
Root: HKA; Subkey: "Software\My Program x.y\Capabilities"; ValueType: string; ValueName: "ApplicationIcon"; ValueData: "{app}\myprogram.exe,0"
Root: HKA; Subkey: "Software\My Program x.y\Capabilities"; ValueType: string; ValueName: "ApplicationDescription"; ValueData: "Short description (shown in Windows 7 File Associations Control Panel)"

;associate .xyz with myprogram.exe (repeat for every file type)
Root: HKA; Subkey: "Software\Classes\.xyz\OpenWithProgids"; ValueType: string; ValueName: "MyProgram.xyz"; ValueData: ""; Flags: uninsdeletevalue
Root: HKA; Subkey: "Software\Classes\MyProgram.xyz"; ValueType: string; ValueName: ""; ValueData: "My Program x.y"; Flags: uninsdeletekey
Root: HKA; Subkey: "Software\Classes\MyProgram.xyz\DefaultIcon"; ValueType: string; ValueName: ""; ValueData: "{app}\myprogram.exe,1"
Root: HKA; Subkey: "Software\Classes\MyProgram.xyz\shell\open\command"; ValueType: string; ValueName: ""; ValueData: """{app}\myprogram.exe"" ""%1"""
Root: HKA; Subkey: "Software\Classes\Applications\myprogram.exe\SupportedTypes"; ValueType: string; ValueName: ".xyz"; ValueData: ""
Root: HKA; Subkey: "Software\My Program x.y\Capabilities\FileAssociations"; ValueType: string; ValueName: ".xyz"; ValueData: "MyProgram.xyz"


--
< Jernej Simončič ><><><><>< https://eternallybored.org/ >

Spend sufficient time confirming the need and the need will disappear.
-- Ed's Fifth Rule of Procrastination

Albert Wiersch

unread,
Feb 15, 2020, 5:30:12 PM2/15/20
to innosetup

Great! Thank you. I will "pattern" based on this and see how it works.

For the icons, I see some values are "{app}\myprogram.exe,0" and some are "{app}\myprogram.exe,1". Any particular reason for this?

Thanks,
Albert

Jernej Simončič

unread,
Feb 15, 2020, 5:58:15 PM2/15/20
to Albert Wiersch on [innosetup]
On Saturday, February 15, 2020, 23:30:12, Albert Wiersch wrote:

> For the icons, I see some values are "{app}\myprogram.exe,0" and some are
> "{app}\myprogram.exe,1". Any particular reason for this?

I used ,0 in places that should show the application icon, and ,1
where the filetype icon is required (filetype icon is shown by
Explorer, application icon is shown in Windows' associations
settings).

You should also customize ValueData in
Root: HKA; Subkey: "Software\Classes\MyProgram.xyz"; ValueType: string; ValueName: ""; ValueData: "My Program x.y"; Flags: uninsdeletekey
to include file type description.

--
< Jernej Simončič ><><><><>< https://eternallybored.org/ >

Of two possible events, only the undesired one will occur.
-- Garfinkle's Law of Quality

Albert Wiersch

unread,
Feb 15, 2020, 6:07:30 PM2/15/20
to innosetup

So is it OK if I just use ",0" for all the icons?

Here is what mine looks like for .html... does it look OK? I'm going to test it soon with an actual install. Just one file association for now but I'm going to add a lot more. Thanks again.

;setup for associations
Root: HKA; Subkey: "Software\Classes\Applications\{#CMDLINEPROCEXE}"; Flags: uninsdeletekey
Root: HKA; Subkey: "Software\Classes\Applications\{#CMDLINEPROCEXE}"; ValueType: string; ValueName: "FriendlyAppName"; ValueData: "CSS HTML Validator {#CHVVERSION}"
Root: HKA; Subkey: "Software\Classes\Applications\{#CMDLINEPROCEXE}\DefaultIcon"; ValueType: string; ValueName: ""; ValueData: "{app}\{#CMDLINEPROCEXE},0"
Root: HKA; Subkey: "Software\Classes\Applications\{#CMDLINEPROCEXE}\shell\open\command"; ValueType: string; ValueName: ""; ValueData: """{app}\{#CMDLINEPROCEXE}"" -o ""%1"""
Root: HKA; Subkey: "Software\RegisteredApplications"; ValueType: string; ValueName: "{#CHVAPPID}"; ValueData: "Software\{#CHVAPPID}\Capabilities"; Flags: uninsdeletevalue
Root: HKA; Subkey: "Software\{#CHVAPPID}"; Flags: uninsdeletekey
Root: HKA; Subkey: "Software\{#CHVAPPID}\Capabilities"; ValueType: string; ValueName: "ApplicationName"; ValueData: "CSS HTML Validator {#CHVVERSION}"
Root: HKA; Subkey: "Software\{#CHVAPPID}\Capabilities"; ValueType: string; ValueName: "ApplicationIcon"; ValueData: "{app}\{#CMDLINEPROCEXE},0"
Root: HKA; Subkey: "Software\{#CHVAPPID}\Capabilities"; ValueType: string; ValueName: "ApplicationDescription"; ValueData: "CSS HTML Validator {#CHVEDITIONLONG} {#CHVVERSION}{#CHV64BITWSPACEANDPAR}"

;associate .html with {#CMDLINEPROCEXE} (repeat for every file type)
Root: HKA; Subkey: "Software\Classes\.html\OpenWithProgids"; ValueType: string; ValueName: "{#CHVAPPID}.html"; ValueData: ""; Flags: uninsdeletevalue
Root: HKA; Subkey: "Software\Classes\{#CHVAPPID}.html"; ValueType: string; ValueName: ""; ValueData: "{#CHVAPPID}"; Flags: uninsdeletekey
Root: HKA; Subkey: "Software\Classes\{#CHVAPPID}.html\DefaultIcon"; ValueType: string; ValueName: ""; ValueData: "{app}\{#CMDLINEPROCEXE},0"
Root: HKA; Subkey: "Software\Classes\{#CHVAPPID}.html\shell\open\command"; ValueType: string; ValueName: ""; ValueData: """{app}\{#CMDLINEPROCEXE}"" -o ""%1"""
Root: HKA; Subkey: "Software\Classes\Applications\{#CMDLINEPROCEXE}\SupportedTypes"; ValueType: string; ValueName: ".html"; ValueData: ""
Root: HKA; Subkey: "Software\{#CHVAPPID}\Capabilities\FileAssociations"; ValueType: string; ValueName: ".html"; ValueData: "{#CHVAPPID}.html"

Jernej Simončič

unread,
Feb 15, 2020, 6:53:33 PM2/15/20
to Albert Wiersch on [innosetup]
On Sunday, February 16, 2020, 00:07:30, Albert Wiersch wrote:

> So is it OK if I just use ",0" for all the icons?

You can, but I'd advise against it - you should make a dedicated icon
for filetypes, otherwise the files will look just like your
application icon.

--
< Jernej Simončič ><><><><>< https://eternallybored.org/ >

Nobody loves a winner who wins all the time.
-- Trump's Quirk of Human Nature

Albert Wiersch

unread,
Feb 15, 2020, 8:29:40 PM2/15/20
to innosetup

Thinking about it some more.... I don't really care about "overriding" the icons for HTML, CSS, PHP, TXT, etc files so what if I just leave those icons out? I don't care if the icons for those files stay the same... in fact, I'd probably prefer that they do stay the same.

I'll comment out the icon lines that use ",1" and see what happens.

Thanks,
Albert

fer...@gmail.com

unread,
Feb 17, 2020, 7:54:15 AM2/17/20
to innosetup
If you don't have a custom filetype icon, it's actually better to avoid setting those keys at all, yeah. When the filetype icon isn't "overridden" by setting the registry key for a custom icon, Windows will generate a default one automatically. (It's just your application icon on a sheet of paper.) Which is usually exactly what you want.

Albert Wiersch

unread,
Feb 17, 2020, 10:58:53 AM2/17/20
to innosetup

Thanks! Good to know. I'm back at work and will finally be trying all this very soon.

Albert Wiersch

unread,
Feb 17, 2020, 12:38:06 PM2/17/20
to innosetup

A lot of helpful information. Thank you!

I did come across an issue for ".json" files. It seems there was no program already associated to json files so Windows used my program icon for the file and did not list it under the 'Open with' submenu in the 'usual' way for other files that already had associations to various programs. The 'Type' of the file, per File Explorer, matched the entry for this line:
Root: HKA; Subkey: "Software\Classes\{#CHVAPPID}.json"; ValueType: string; ValueName: ""; ValueData: "JSON Document"; Flags: uninsdeletekey

Which did not have a value of "JSON Document" at first... so I changed it to "JSON Document" and now it looks correct in File Explorer. I did not know the value should be 'human friendly' (like "JSON Document") so I was using my program app ID before. So it seems good now although I am not sure I want my program icon used for .json files but it's no big deal.

Now another question...

What if I want to add an 'Edit with CSS HTML Validator' to the File Explorer context menu for .html files? For example, if you install Notepad++ then it adds 'Edit with Notepad++' to the context menu. How is it doing this? My application is only listed in the 'Open with' submenu, which is good, but what if I also want to add a more direct menu option like 'Edit with CSS HTML Validator'?

Thanks,
Albert

fer...@gmail.com

unread,
Feb 18, 2020, 12:36:41 AM2/18/20
to innosetup


On Monday, February 17, 2020 at 12:38:06 PM UTC-5, Albert Wiersch wrote:

What if I want to add an 'Edit with CSS HTML Validator' to the File Explorer context menu for .html files? For example, if you install Notepad++ then it adds 'Edit with Notepad++' to the context menu. How is it doing this? My application is only listed in the 'Open with' submenu, which is good, but what if I also want to add a more direct menu option like 'Edit with CSS HTML Validator'?

I can only offer a suggested approach (because honestly I have no idea what the answer is)... but if it were me looking to add that feature, what I'd do is use regedit to search the registry for the string "Edit with Notepad++". Basically just poke around and see what keys are used to implement that feature.

It'll definitely at least involve some set of registry keys in a standard location and format, same as creating a file association. Armed with the registry location(s) involved, you should be able to use that info to chase down the official Microsoft documentation on how to implement the required functionality. (Just search their docs site for the most distinctive/critical-sounding of the key names, basically.)

fer...@gmail.com

unread,
Feb 18, 2020, 12:50:29 AM2/18/20
to innosetup
(If that exact string doesn't appear, you may  have to do a dump of every key containing the string "Notepad++" and look for one that sounds like it defines an "ActionEdit" or whatever.

As an additional representative example (and one of a different form, which could be doubly enlightening), doesn't VLC install a context-menu option for media files, to "Play in VLC" or whatever? That'd be another potential search string, to locate the registry keys involved.

Albert Wiersch

unread,
Feb 26, 2020, 1:16:53 PM2/26/20
to innosetup

I finally got around to working on this again and I'm not having much luck but I did find some information on how Notepad++ adds an "Edit with &Notepad++" option... but I don't understand it enough to use it with my app and I can't find any official documentation.

(By the way, to find this in the registry after installing Notepad++, search for "Edit with &Notepad++"... note the use of the "&" character because otherwise it won't find anything.)

This person posted the registry entries here:

What is this CLSID stuff? And InprocServer32?

Can anyone help to translate the above to something generic for use in Inno Setup iss files? Or provide a helpful link that explains all this?

Thank you!

fer...@gmail.com

unread,
Feb 27, 2020, 10:05:24 AM2/27/20
to innosetup
The explanation from Peter Jones a few replies up actually gives some pretty good starting points for figuring out how to interpret all of that

But in my registry, here are some of the instances of Notepad++ that I could find:

  • HKCR\*\shellex\ContextMenuHandlers, includes ANotepad++64, which includes (Default)={B298D29A-A6ED-11DE-BA8C-A68E55D89593}. But if I go to that handler
    at HKCR\CLSID\{B298D29A-A6ED-11DE-BA8C-A68E55D89593}\InprocServer32, I see (Default)=C:\Program Files (x86)\Notepad++\NppShell_06.dll – so it’s a reference to a DLL, rather than an .exe… maybe you missed that one for conversion from x86 to 64bit.
    • also found in HKLM\SOFTWARE\Classes\*\shellex\ContextMenuHandlers\ANotepad++64 and HKLM\SOFTWARE\Classes\CLSID\{B298D29A-A6ED-11DE-BA8C-A68E55D89593}\InprocServer32 – I believe if you change the first, the HKLM version will automatically update (or vice versa)
    • you may have other CLKID associated with it, as well…
  • You probably found HKCR\Applications\notepad++.exe and all it’s subkeys and data/value pairs
  • I have some instances in HKCR\Local Settings\Software\Microsoft\Windows\Shell\MuiCache, but they all include the notepad++.exe, so you probably found them (and MuiCache just lists recently used applications, which shouldn’t affect anything anyway)
  • HKCR\SystemFileAssociations\... hierarchy has some subkeys with notepad++.exe: ...\text\...\txtfile
  • HKCU\Software\Classes\Applications\notepad++.exe\ has a hierarchy you’ll want to check
  • HKCU\Software\Microsoft\Windows\CurrentVersion\ApplicationAssociationToasts mentions with notepad++.exe with some extensions, as do the HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.***\OpenWithList, where .*** matfches the extensions from the Toasts…

So CLSID{B298D29A-A6ED-11DE-BA8C-A68E55D89593} is just the GUID for the registry class associated with the ContextMenuHandler that NotePad++ installs (ANotepad++64) to hook up the "Edit with Notepad++" functionality, which is then implemented in a DLL (NppShell_06.dll) that it installs, and which is (launched by?launched via? launched inside?) InprocServer32 to perform the open-for-editing action.

This is all COM stuff, and the MSDN docs on the Component Object Model would be a good starting point to look for info. They even have a whole section on CLSID:

A CLSID is a globally unique identifier that identifies a COM class object. If your server or container allows linking to its embedded objects, you need to register a CLSID for each supported class of objects.
Reply all
Reply to author
Forward
0 new messages