Solved

Customise Windows Explorer Pop-up Menu

Posted on 1997-05-01
5
168 Views
Last Modified: 2010-04-06
I would like to customise Windows Explorer's pop-up menu (i.e. the menu displayed when the right mouse button is clicked on a folder or file name) to include an option for my program.  An example of a program that does this is WinZip.  I would also like to be able to remove my program from the menu!

I was not sure whether to ask this question in Delphi Programming or Windows Programming.  I asked it in Delphi Programming because I have intermediate Delphi skills but no C++.  

I think the answer to this will involve manipulating the Windows 95/NT registry.  I have used Delphi's TRegistry component a little.
0
Comment
Question by:SimonORorke
  • 3
  • 2
5 Comments
 
LVL 2

Accepted Solution

by:
alona041797 earned 200 total points
ID: 1335830
To add a menu item for a specific file type add the following:

Under: HKCR\[File Type]\shell\[Menu Option]\Command
Add: (default) = command to excute (%1 is the filename)

Example:
  Under: HKCR\.abc\shell\ABCApp\Command
  Add: (default) = "C:\ABC\RUNABC.EXE %1"

Note: [File Type] can be 'Directory' or 'Drive'.

For more info add a comment with exactly what you want.
0
 
LVL 2

Expert Comment

by:alona041797
ID: 1335831
I fogot to mention that if [Menu Item] is 'Open' you set the default command.
0
 

Author Comment

by:SimonORorke
ID: 1335832
This is the first time I have used Expert Echange.  Was this question really worth 200 points?  

One thing still puzzles me, though I do not really need to know any more.  It seems the "Add to &Zip" item must get on to the Explorer pop-up menu a different way than Alona describes.  I could not find it anywhere in the registry, so I could not use it as an example.  That is why I had to ask this question.
0
 
LVL 2

Expert Comment

by:alona041797
ID: 1335833
WinZip uses a different method. It uses a context-menu handler. This means that a small portion of WinZip code is executed whenever you right-click a file. In this code WinZip checks if the file is an archive file even if it doesn't have a regular extention. This is declared in:
       HKCR\*\ShellEx\ContextMenuHandlers\WinZip

Usually, you don't need this extended syntax.
0
 

Author Comment

by:SimonORorke
ID: 1335834
So the reason I could not figure out WinZip's method was that it uses an illegible binary value instead of a string value.  This must be the code, or the address of the code, that checks if the file is an archive.  I just tried removing/changing the extension from a zip archive and actually the logic of the code is a little different from what Alona describes above.  It cannot detect an archive that does not have an associated extension.  The point is that it sets the menu item to "Add to Zip" for a non-archive and to "Extract to" for an archive, which it recognises by its extension.

Fortunately I do not need to use this more complicated method.  In the case of my program, I just want the menu item to appear for drives and directories only.  Alona explained how to do this in the answer.

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

911 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

21 Experts available now in Live!

Get 1:1 Help Now