Link to home
Start Free TrialLog in
Avatar of stellarguy
stellarguy

asked on

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


Avatar of Nass89
Nass89
Flag of United States of America image

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!
ASKER CERTIFIED SOLUTION
Avatar of Jaime Olivares
Jaime Olivares
Flag of Peru image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of stellarguy
stellarguy

ASKER

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
   

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
 


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!
>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.
Still waiting for author's feed back, think have provided a valid solution