• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 414
  • Last Modified:

Add entry to explorer's context menu query?

Hi all

I want to add the entry of my dialog based app's exe in the context menu of all files.

To do this what i have done is in the registry: under HKEY_CLASSES_ROOT\*\shell     i have created a new key by the name "my_exe" & then a key named "command" under the key "my_exe".

Now in the  key named "command" i set the data of  (default) as " C:\aa.exe %1".

Now as result this whenever i right click on any file i see the entry of my exe as "my_exe".

So far so good. Now i have 3 files on my desktop 1.doc, 2.txt & 3.cpp. When i double click on 1.doc file gets opened in WORD. for 2.txt file gets opened in the NOTEPAD but when i double click on the 3.cpp my_exe  is executed where as 3.cpp shud be opened in Visual Studio.

On closely watching when i right click on 1.doc in the context menu "Open"is the default command.

for  2.txt also "Open" is default command  but for 3.cpp "my_exe" is  bold ie "my_exe" becums the default command for 3.cpp.  

y is this happening. How can i stop this?

I want only when the user right clicks on a file and then select "my_exe", then only my exe shud be executed.


Waiting for suggestions
Regards


0
stellarguy
Asked:
stellarguy
  • 3
  • 2
  • 2
1 Solution
 
Nass89Commented:
Hi,
When you click on a file that its extension is known for explorer, it adds 'open' to menu and makes it bold. Bold means that explorer knows where to find the exe file to open it.
If the extension is not known for explorer it makes the first menu item in context menu bold. In your fall 'My_exe' is bold as first item.
I guess, 'CPP' extension is not defined for your explorer. To check it look under:

HKEY_CLASSES_ROOT\cppfile\Shell\Open\command

Is there any application defined?

Good Luck!
0
 
Jaime OlivaresSoftware ArchitectCommented:
There are 2 group of keys to consider:

HKEY_CLASSES_ROOT\cppfile\Shell\Edit\command
HKEY_CLASSES_ROOT\cppfile\Shell\Open\command
Both keys are the **DEFAULT** action for your CPP files

HKEY_USER\SomeUserIDhere\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.cpp\OpenWithList
Contains the list of **ALL** applications that handle this type of file
Also is repeated in HKEY_CURRENT_USER
0
 
stellarguyAuthor Commented:
Thanx Nass89 for ur comments.

>>HKEY_CLASSES_ROOT\cppfile\Shell\Open\command
>>Is there any application defined?

Yes the complete path of msdev.exe is given but still "aa.exe" is in bold
where as "open with msdev" is the second entry in the context menu.

Also i am here talking about all types of files in the system.
Is there any way with the help of which i can avoid "aa.exe" to be the default command for any file type.?

Waiting for comments
Regards
   

0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
stellarguyAuthor Commented:
Thanx  jaime_olivares for ur comments

>>HKEY_CLASSES_ROOT\cppfile\Shell\Edit\command
>>HKEY_CLASSES_ROOT\cppfile\Shell\Open\command

I cud not find these keys. The only that is available under "HKEY_CLASSES_ROOT\cppfile\Shell" is  "&Open with MSDev".

Also i am here talking about all types of files in the system.
Is there any way with the help of which i can avoid "aa.exe" to be the default command for any file type.?

I have also looked at the alternate option of writing a COM Dll & thus implemeting the IContextMenu interface.
I have through examples on Codeguru but cud not understand much.
I have no knowledge of COM.

Can u provide any link or some sode that does the above job?

Thanx & Regards
 


0
 
Nass89Commented:
Hi,
Try to rightclick over an unknown extension file. Is it same when you right click over cpp file?
As I wrote, when the extension is unknown, you see what you wrote. "The first menu item selected and open with...'.
When you add MyExe to "HCR\*\Shell", it will appear over every file. It is not avoidable.

To appear only over a desired extension, you must add it to "HCR\xxxfile\open\command".
Tto appear the "Open with", add it to HCR\xxxfile\Open with MyExe".

**xxx is the dsired extension**
Good Luck!
0
 
Jaime OlivaresSoftware ArchitectCommented:
>I cud not find these keys. The only that is available under "HKEY_CLASSES_ROOT\cppfile\Shell" is  "&Open with MSDev".

That's the same, just have to create your own key:

"HKEY_CLASSES_ROOT\cppfile\Shell\Open with MyApp".

and the respective 'command' key inside.

I don't recommend to use COM if you are not an experienced programmer.
0
 
Jaime OlivaresSoftware ArchitectCommented:
Still waiting for author's feed back, think have provided a valid solution
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now