Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 484
Kawaii-Hachii Avatar asked Nov 18 '11 12:11

Kawaii-Hachii


2 Answers

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.

like image 154
David Heffernan Avatar answered Nov 13 '22 18:11

David Heffernan


At "HKEY_CLASSES_ROOT\*\shell" add key "open with my app" and then add "command" and set Default (REG_SZ) to what you want to run (%1 parameter - filename)

like image 2
BugTheLady Avatar answered Nov 13 '22 17:11

BugTheLady