Search code examples
delphishellwindows-explorercontextmenu

Delphi add menu item in Windows Explorer right click


How to add a right click context menu in Windows Explorer for all kind of file extension?

From what I read on the internet, I read a way to do this for certain file extension.

My question, how can we do this for all kind of file extension?

I saw some software did this, for example: WinRar, Notepad++, etc.

PS: I am targeting Delphi 7.0 compatible code.

Thank you.


Solution

  • The simplest way to do this is to add a registry entry like this:

    HKEY_CLASSES_ROOT
      *
        shell
          YourAppName
            Command      C:\Full\Path\To\Your\App.exe "%1"
    

    When the user clicks on this menu item your app will be executed and passed the file name as the first command line argument.

    Whilst you can write a shell extension for this, that is more difficult. What's more, if you are using Delphi 7 then you will not be able to write a shell extension for 64 bit Windows.