System-wide File Right Click Option

  • 14 years ago
    I thought I saw a post doing this with a mp3 file type, but I can't seem to find it now ;;  Anyway, I'd like to a right click menu option to a file type.  For example, right click on a .txt file and you see Open, Print, Edit then more options depending on the installed software(convert to .zip, make a pdf, etc.).

    I would like to add a line that will call my program using the file I right clicked on in the passed field Command.  I am thinking I need to add a registry setting to

    HKEY_CLASSES_ROOT\.xxx

    Though I do not know the syntax or exactly what I need to add.  I would assume at some point I need to add a command /paht/to/exe %1.

    Any help is greatly appreciated.









  • 14 years ago

    Just bumping this thread back to the first page for one more pass through.  Any ideas?

  • 14 years ago

    Hi,

    I still find it a bit complicated, but with the help of the guys who created the free install program Inno Setup, I was able to figure it out for my app.  See a summary of the steps below:

    In HKEY_CLASSES_ROOT:

    Create a key for the file extension (e.g. .abc)  Type is REG_SZ, name is default, value is the internal name for your app.  Note that this should be unique to avoid overwriting an existing app's values.  E.g. MyApp.SpecialFile

    Create a key for your app using the unique name from above (e.g. MyApp.SpecialFile).  Type is REG_SZ, default name, value is the file type description you want to see in Explorer (e.g. My Application Special File)

    In that key, create a subkey DefaultIcon.  Type is REG_SZ, default name, value is the full path to your app, followed by a comma and a number.  (E.g. "C:\Program Files\MyApp\MyApp.exe,0")



    "DefaultIcon" is the registry key that specifies the filename containing the icon to associate with the file type. ",0" tells Explorer to use the first icon from MyApp.exe. (",1" would mean the second icon, etc.)

    At the same level as the DefaultIcon key, create another key called shell.  In that key, create a subkey open, and in that key, create a subkey command.

    The type for all three keys is REG_SZ and the name for them is the default value.  The value is blank for all but the command key.  There you use the command-line way to open your app with the selected file.  (E.g. "C:\Program Files\MyApp\MyApp.exe" "%1")

    Hope this helps,

    Erwin

    PS. Note that this assumes that you have created your app to accept a parameter during startup !

  • 14 years ago

    Thanks, that is what I was looking for.  I will have to play with it some though.  It does change the description and icon in explorer, but does not add a menu item in the right click.  Atleast I'm looking in the right area.

    /Tril

    EDIT => Ok, wasn't that much to change.  To get the right click to work, I don't add the OPEN key.  So it looks like .xxx\Shell\Command where Shell will hold the value for the right click menu and command holds the /path/to/exe %1.  Thanks for the help!!





Post a reply

Enter your message below

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.” - Rich Cook