Solved

Add entry to explorer's context menu query?

Posted on 2004-09-29
10
397 Views
Last Modified: 2013-11-20
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
Comment
Question by:stellarguy
  • 3
  • 2
  • 2
10 Comments
 
LVL 5

Expert Comment

by:Nass89
ID: 12178984
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
 
LVL 55

Accepted Solution

by:
Jaime Olivares earned 125 total points
ID: 12179913
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
 

Author Comment

by:stellarguy
ID: 12214988
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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

Author Comment

by:stellarguy
ID: 12215016
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
 
LVL 5

Expert Comment

by:Nass89
ID: 12216115
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
 
LVL 55

Expert Comment

by:Jaime Olivares
ID: 12216928
>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
 
LVL 55

Expert Comment

by:Jaime Olivares
ID: 12560530
Still waiting for author's feed back, think have provided a valid solution
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Decoding 32 bit binary streams 6 31
Windows Drag & Drop Location 2 85
bobThere java chalenge 45 82
Detect file exist or not 3 77
In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now