Jump to content


 


Register a free account to unlock additional features at BleepingComputer.com
Welcome to BleepingComputer, a free community where people like yourself come together to discuss and learn how to use their computers. Using the site is easy and fun. As a guest, you can browse and view the various discussions in the forums, but can not create a new topic or reply to an existing one unless you are logged in. Other benefits of registering an account are subscribing to topics and forums, creating a blog, and having no ads shown anywhere on the site.


Click here to Register a free account now! or read our Welcome Guide to learn how to use this site.

Photo

Creating a Context Menu Entry


  • Please log in to reply
10 replies to this topic

#1 Andrew

Andrew

    Bleepin' Night Watchman


  • Moderator
  • 8,259 posts
  • OFFLINE
  •  
  • Gender:Not Telling
  • Location:Right behind you
  • Local time:07:42 AM

Posted 11 October 2009 - 04:00 AM

So, I've written a nifty little app that does a cool thing using magic and Lucky Charms. Trouble is it's fairly useless unless I can cause it to be invoked from Explorer's context menu.

All I need to know is how to create a handler, in the registry preferably, that only shows up when a file is right-clicked (not a folder) and launches my program with the file's path as an argument.

Any help is appreciated.

BC AdBot (Login to Remove)

 


#2 groovicus

groovicus

  • Security Colleague
  • 9,963 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Centerville, SD
  • Local time:08:42 AM

Posted 11 October 2009 - 11:09 AM

I know how to add an option ot the context menu, but I don't know how to make it aware of the file type in order to determine whether or not it should be visible; I have a hunch that one would have to alter the right-click handler. I saw this a while back that looks promising that may give you an idea of how to do it, but I have never messed with it.

#3 Billy O'Neal

Billy O'Neal

    Visual C++ STL Maintainer


  • Malware Response Team
  • 12,304 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Redmond, Washington
  • Local time:07:42 AM

Posted 11 October 2009 - 11:20 AM

Does it need to operate on any file or only certain types you're looking for?

What language is the app written in?

Billy3
Twitter - My statements do not establish the official position of Microsoft Corporation, and are my own personal opinion. (But you already knew that, right?)
Posted Image

#4 Andrew

Andrew

    Bleepin' Night Watchman

  • Topic Starter

  • Moderator
  • 8,259 posts
  • OFFLINE
  •  
  • Gender:Not Telling
  • Location:Right behind you
  • Local time:07:42 AM

Posted 11 October 2009 - 05:27 PM

It needs to operate on any and all files of all types, but not directories. The app is written in RealBasic, which is similar in most respects to VB.

I'll take a look at FileMenu Tools. If need be, I'll create the handler with it and reverse engineer what it did to do it :thumbsup: Thanks guys!

#5 Romeo29

Romeo29

    Learning To Bleep


  • Members
  • 3,194 posts
  • OFFLINE
  •  
  • Gender:Not Telling
  • Location:127.0.0.1
  • Local time:09:42 AM

Posted 11 October 2009 - 08:36 PM

These are the manual steps. You can convert them into a function :

Lets assume your program is installed in path C:\Magic\Magic.exe

1. Create a subkey under HKCR\*\shell of any name you like. Lets say Magic, so final subkey you create would be HKCR\*\shell\Magic
2. Set the default value under this subkey to any name you want to appear in right-click context-menu say, Do Magic
3. Create a subkey command under the newly created key in step 1.
4. Set default value under this command key to path name of exe followed by %1. In this case "C:\Magic\Magic.exe" %1. The inverted commas are necessary only if path contains space.

You will immediately see the changes in context menu, no restart etc. is necessary. This way of handling context menu is used when you have to pass parameters directly to EXE. The newer extended way with GUID's is used when you have a special DLL to handle context menu.

EDIT: If you want to add context menu only to a particular type file just replace HKCR\* with extension of that type. For example, for text files (.txt), follow the process under the key HKCR\.txt\. The HKCR\* is for all types of files.

Edited by Romeo29, 11 October 2009 - 08:38 PM.


#6 groovicus

groovicus

  • Security Colleague
  • 9,963 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Centerville, SD
  • Local time:08:42 AM

Posted 11 October 2009 - 08:50 PM

That's cool! Can a person use regex expressions to limit the particular files, or can one just include an array of files one wants associated with the key?

#7 Andrew

Andrew

    Bleepin' Night Watchman

  • Topic Starter

  • Moderator
  • 8,259 posts
  • OFFLINE
  •  
  • Gender:Not Telling
  • Location:Right behind you
  • Local time:07:42 AM

Posted 11 October 2009 - 08:55 PM

Exactly what I was looking for! Thanks!

#8 Andrew

Andrew

    Bleepin' Night Watchman

  • Topic Starter

  • Moderator
  • 8,259 posts
  • OFFLINE
  •  
  • Gender:Not Telling
  • Location:Right behind you
  • Local time:07:42 AM

Posted 12 October 2009 - 12:35 AM

Everything works perfectly now.

#9 Romeo29

Romeo29

    Learning To Bleep


  • Members
  • 3,194 posts
  • OFFLINE
  •  
  • Gender:Not Telling
  • Location:127.0.0.1
  • Local time:09:42 AM

Posted 12 October 2009 - 11:34 AM

That's cool! Can a person use regex expressions to limit the particular files, or can one just include an array of files one wants associated with the key?

In my opinion, regex is not allowed, you have to repeat process for each type of file you want.

Everything works perfectly now.


Nifty app :thumbsup:

#10 Billy O'Neal

Billy O'Neal

    Visual C++ STL Maintainer


  • Malware Response Team
  • 12,304 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Redmond, Washington
  • Local time:07:42 AM

Posted 12 October 2009 - 11:44 AM

I'll have to take a look. :grin: This is the one I use, but it doesn't do virus total.

Billy3

Edited by Billy O'Neal, 12 October 2009 - 11:45 AM.

Twitter - My statements do not establish the official position of Microsoft Corporation, and are my own personal opinion. (But you already knew that, right?)
Posted Image

#11 Andrew

Andrew

    Bleepin' Night Watchman

  • Topic Starter

  • Moderator
  • 8,259 posts
  • OFFLINE
  •  
  • Gender:Not Telling
  • Location:Right behind you
  • Local time:07:42 AM

Posted 12 October 2009 - 04:30 PM

Nifty app :thumbsup:

I'll have to take a look. :grin: This is the one I use, but it doesn't do virus total.

Thanks!

I had been using MD5 Context Menu (still do, actually) but it was a pain to have to Copypasta each checksum manually.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users