CinoV

which register root that i need to use in order to have my program to open all types of file when user right click, the context Menu appear and will have my program name shown for handering any type of file the user choose.

note, I like my program to handle All File Types not just txt, doc... (not individial file type).

Pls help have been seaching for sometime to find the answer.



Re: Visual C# General Registry and Context Menu

TaylorMichaelL

It depends. A file is not an accurate term in Explorer. Explorer works with shell items. Files are only one of those items. Folders, junction points and other things are separate. To capture all "file system" files you can use HKCR\* which maps to everything. You could also use AllFileSystemObjects which, I believe, maps to any file system object (folder or file).

You would then create a new entry under Shell representing your command and the menu text to display. The actual name of the key doesn't matter a whole lot. The default value is the menu text while the Command string value is the command to run. Use %1 for the file name or %L for the long file name. Be sure to use quotes around the name. You can do a quick registry search to provide numerous examples of this key layout.

An alternative is to write a context menu shell extension but that is generally overkill.

Michael Taylor - 5/19/07

http://p3net.mvps.org





Re: Visual C# General Registry and Context Menu

CinoV

thanks for the answer, now i know how to created a new entry under Shell but now I have another problem. If i wanted to installed that program n using Window installer (that come with VS). In the registry I have created the following folder:

[HKEY_CLASSES_ROOT\*\shell\OpenWithMyProgram\command]


and in the command folder, new key

name = (Default)

value = @="c:\\windows\\notepad.exe %1"


but when i install the program, my command did not show up in the context Memu. Why

Or do you have a better suggestion.





Re: Visual C# General Registry and Context Menu

TaylorMichaelL

I'm not 100% sure you set up the key correctly. Rather than trying to verify we are using the same terminology I'm copying in an export of a REG file that you can create that would set up the necessary entry as you defined.

Code Snippet

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\*\shell\OpenWithMyProgram]

@="My Program"

[HKEY_CLASSES_ROOT\*\shell\OpenWithMyProgram\command]
@="c:\\windows\\system32\\notepad.exe \"%1\""

A few comments. I modified the actual name shown in the context menu to My Program. I modified the command line to wrap the file name in quotes otherwise long file names would not be properly parsed as command line arguments. If you copy the above code and paste it into an REG file then you can import the file into the registry to confirm the settings.

Michael Taylor - 5/21/07

http://p3net.mvps.org





Re: Visual C# General Registry and Context Menu

CinoV

thanks so much, for the above anwser. It really help a lot.