2 Replies - 284 Views - Last Post: 06 October 2013 - 09:42 AM

#1 Cataliyst  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 23-August 13

Execute Program while clicking "Edit With MyProgram.exe"

Posted 06 October 2013 - 08:47 AM

Hi everyone,

How i can execute my program and load clicked text file text inside my program?

Example:Posted Image
Is This A Good Question/Topic? 0
  • +

Replies To: Execute Program while clicking "Edit With MyProgram.exe"

#2 GunnerInc  Icon User is online

  • "Hurry up and wait"
  • member icon




Reputation: 858
  • View blog
  • Posts: 2,279
  • Joined: 28-March 11

Re: Execute Program while clicking "Edit With MyProgram.exe"

Posted 06 October 2013 - 09:03 AM

Not really a C# question, moving on over to 'Computer Support > Software Support > Windows"
Was This Post Helpful? 0
  • +
  • -

#3 GunnerInc  Icon User is online

  • "Hurry up and wait"
  • member icon




Reputation: 858
  • View blog
  • Posts: 2,279
  • Joined: 28-March 11

Re: Execute Program while clicking "Edit With MyProgram.exe"

Posted 06 October 2013 - 09:42 AM

This is called a "Context Menu" and it is added/created in the registry.

There are two places in the Registry you can add the info for a context menu -
HKEY_CLASSES_ROOT - system wide and will be seen/used by all users.
HKEY_CURRENT_USER - only seen/used by you.

To modify HKCR - you need to start Regedit as Admin or logon as Admin (Your not using your computer as Admin all the time now are you?)

File extensions are classes, start up Regedit and navigate to "HKEY_CURRENT_USER\Software\Classes"

Before we continue a little disclaimer:

I nor DiC take no responsibility in any damages that occur by you modifying the registry incorrectly make a backup of your Registry first /system restore point.

Did you open "HKEY_CURRENT_USER\Software\Classes"?

Navigate to ".txt" ("HKEY_CURRENT_USER\Software\Classes\.txt") and expand that key. Take notice of what the "default" value is, on my machine it is "txtfile".

Now navigate the key which is named in the default value:
"HKEY_CURRENT_USER\Software\Classes\txtfile"

right click on the "shell" key then click New > Key and Name the newly created key anything.

Click on the new key and double click the default value and type in the text you want displayed on context menu for text files

Now right click on the new key and click New > Key and name this new key "command"
The path to your program will be the default value, add a %1 to the end of the path in quotes so explorer will pass the selected file to your program.

Attached Image

To use the passed file, make sure your program can accept command line parameters.

For more info, search for "add context menu to explorer"

*** EDIT ***
If you want your context menu item to display for ALL file extensions, you would do the same as above but for the "*" key:
"HKEY_CURRENT_USER\Software\Classes\*\shell"

Attached image(s)

  • Attached Image

Was This Post Helpful? 2
  • +
  • -

Page 1 of 1