Notice Of Closure

Please note that this website is due to close down on 15th June 2020.

In the interim I will try to move as much content as possible over to my GitHub account. Thanks to everyone who has supported the site over the years.

» Help

How to add a context menu item to Windows Explorer


To add a context menu item to Windows Explorer you have create a few entries in the system registry. First you have to get the file type's name, add the context menu item and add then the command line. Besides files you can add context menus to drives or folders.

Special extensions:

  • drive - drives.
  • folder - folders.

  sTypeName: string;
  with TRegistry.Create do
      RootKey := HKEY_CLASSES_ROOT;
      { Set the extension you want. Include the '.' character }
      OpenKey('.Extension', True);
      { Get file type name }
      sTypeName := ReadString('');
      { Create explorer extension. Instead of 'Open' put whatever you want. }
      OpenKey('' + sTypeName + 'ShellOpen', True);
      { The context menu item }
      WriteString('', 'Open in my application');

      OpenKey('' + sTypeName + 'ShellOpenCommand', True);
      { The commandline. Enter all the commandline options you need.
        Remember to use quotes for long file names with spaces. Even if your
        application's filename doesn't contain any spaces the folder that
        it's in may contain them.
        %1 - is the selected file's name. }
      WriteString('', '"' + Application.ExeName + '" "%1"');

      { Repeat this for every file type you want to add a context menu to.
        For this operation you may want to use a for loop and a constant
        string array with the file extensions. }
Author: Unknown
Added: 2007-06-02
Last updated: 2007-06-02

« Return to contents »