R – Windows Registry file association menu


I have recently(today) began meddeling with my registry from within Delphi. 🙂
all is working well and my custom file type now opens with my program, but there are 2 issues i can't solve.

1) I wanted the option to "open with" from all file types so i added

  reg := TRegistry.Create;
  reg.RootKey := HKEY_CLASSES_ROOT;
  reg.LazyWrite := false;
  reg.OpenKey('*\OpenWithList\EncryptionSystem', true);
  reg.WriteString('','C:\Program Files\EncryptionSystem\EncryptionSystem.exe "%1"');

If I look in the registry using regedit it's sure there as it should seem to be but when I right click on a file and select Open With it's not there…

So I then added this

  reg.OpenKey('*\shell\Encrypt\command', true);
  reg.WriteString('','C:\Program Files\EncryptionSystem\EncryptionSystem.exe "%1"');

This does work for every file but the option is right at the top with "open" and "edit".
I kinda want it to appear in a menu subsection like most programs do…
I realised that i needed to play with shellext but i did not understand the structure of how these worked withing the context menu handlers… I'd learnt all I had from reading the registry anyway… I know the name for the shellext appears later after the ".*" but as for the meaning of the big jibberish keys I have no idea.

Best Solution

It looks like the "Open with" menu is not populated by that registry key alone. It's trumped by an extension-specific list stored by Explorer at the following location:


I'd venture a guess that the list you're adding your application to is only used if Explorer doesn't have anything better to use — so only for files that don't already have their own "Open with" lists defined.

Also, it looks like an "Open with" registry entry is supposed to have a different form from the one you're using. The key should be the name of the EXE file, such as ExcryptionSystem.exe. The default value for that key, if present, should be an empty string. I'm basing this just on what I see in the registry on my own system.

You should take a look at the File Types MSDN article, part of the Introduction to File Associations.