Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

adding customapp to explorer rightclick

Posted on 2006-10-27
12
Medium Priority
?
396 Views
Last Modified: 2008-01-09
friends,

when we do a right click on a file in 'windows explorer', we get options like 'notepad', 'winzip', 'edit with visual studio'.

1. now how can i add a customapplication to this list when i right click a file?

2. once this is click, what should i do in my customapplication to open this file? basically how do i get to know, which file needs to be opened.

i need vb6 code.
0
Comment
Question by:expertfan
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 9
  • 2
12 Comments
 
LVL 32

Expert Comment

by:DrDamnit
ID: 17827171
Hi expertfan,

You're trying to do something like Winzip does, when you right click a file and you get the option "Extract To...", right?

I'v been trying to figure out how to do this for 6 months. So far, I have only gotten a little information.

1. The right click is a CLSID.
2. It refers / calls / executes (pick your terminology) a DLL.

How to write the DLL and register it so that it will show up in the context menu, I have no idea. So, I'll be watching this thread. Good luck.

Cheers!
0
 
LVL 32

Expert Comment

by:DrDamnit
ID: 17827206
expertfan,

BTW... if you want to do it with a file folder on the folder list tree, you would need to do this:

1. HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Folder\shell
2. Create a key under shell, and name it what you want it to appear in the right click context menu.
3. Create another key under that called "command" (no quotes).
4. Put in the full path to the executable, followed by %1 %2 %3, etc... as needed to pass vars to the file (ex: c:\windows\system32\cmd.exe %1 will open a command prompt in that folder).

Cheers!
-Doc.
0
 
LVL 32

Expert Comment

by:DrDamnit
ID: 17827229
expertfan,

Some more information:

Winrar is the example I use. You right click a rar file, you get the context menu commands like we're looking for.

Under HKEY_LOCAL_MACHINE\SOFTWARE\Classes\WinRAR\shellex we have:

HKEY_LOCAL_MACHINE\SOFTWARE\Classes\WinRAR\shellex\ContextMenuHandlers
HKEY_LOCAL_MACHINE\SOFTWARE\Classes\WinRAR\shellex\ContextMenuHandlers\{B41DB860-8EE4-11D2-9906-E49FADC173CA}.

If you look up {B41DB860-8EE4-11D2-9906-E49FADC173CA}, you find this:

HKEY_LOCAL_MACHINE\SOFTWARE\Classes\CLSID\{B41DB860-8EE4-11D2-9906-E49FADC173CA}
HKEY_LOCAL_MACHINE\SOFTWARE\Classes\CLSID\{B41DB860-8EE4-11D2-9906-E49FADC173CA}\InProcServer32

It is this final value that has the following values:
(Default)                             REG_SZ                               C:\Program Files\WinRAR\rarext.dll
Threading Model                  REG_SZ                               Apartment

It is this dll that will process the file you right click on.

This is everything I know. Hope it can lead you or some other experts to the right place!

0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 32

Expert Comment

by:DrDamnit
ID: 17827239
expertfan,

I just found this too:
http://www.oreilly.com/catalog/vbshell/chapter/ch04.html

It may hold some clues for us.

Cheers!
-Doc
0
 
LVL 32

Expert Comment

by:DrDamnit
ID: 17827250
expertfan,

THis is how it is done in Delphi, which may also help: http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=536&lngWId=7
0
 
LVL 32

Expert Comment

by:DrDamnit
ID: 17827258
0
 
LVL 32

Expert Comment

by:DrDamnit
ID: 17827266
expertfan,

The last post has an attachement that is a VB6 project. It should be the answer we are looking for. Here are the remarks from the project:

   ' =======================
   ' VB Context Menu Handler
   ' =======================
   '
   '    by Jim White, MathImagical Systems, NSW Australia
   '
   '    email: mathimagics@yahoo.co.uk
   '
   ' cMenu class - when this DLL is registered, AND there is a reference
   '               to our ClassId in the "ContextMenuHandlers" key for some
   '               file association(s) in the registry, then Explorer will
   '               create an instance of this class when the user right-clicks a
   '               file of that type.
   '
   '               At some stage in the life cycle of the cMenu object,
   '               Explorer will invoke the IContextMenu::QueryContextMenu
   '               method, which gives us the opportunity to insert
   '               a menu option of our own (if we choose to do so).
   '
   '               If the user then clicks on the option we insert,
   '               Explorer will invoke the IContextMenu::InvokeCommand
   '               method - this is the equivalent of the "Click" event
   '               procedure for a normal VB menu.
   '
   ' There are two interfaces that must be implemented for Explorer to be
   ' able to transfer data to and from this dll. They are declared in the
   ' accompanying type libraries (.tlb files) - don't modify or lose them!
0
 

Author Comment

by:expertfan
ID: 17827773
DrDamnit,

this is cool, onclicking the context-menu, this code is showing a 'message box', but how do i invoke (or launch) an EXE?
'---------------------


Private Sub IContextMenu_InvokeCommand(ByVal lpcmi As Long)
   Dim CMI         As CMINVOKECOMMANDINFO
   CopyMemory CMI, ByVal lpcmi, Len(CMI)

   '=======================================================
   '  The user has clicked one of our context menu options!
   '=======================================================
   
   Dim Display As String
   Display = "File clicked was: " & SelectedFile & vbLf & vbLf
   If CMI.lpVerb < 3 Then
      Display = Display & "ContextMenu item ID = " & CMI.lpVerb
   Else
      Display = Display & "SubMenu item ID = " & CMI.lpVerb
    End If
   
   MessageBox 0&, Display, "MathImagics", vbInformation
End Sub
0
 
LVL 32

Accepted Solution

by:
DrDamnit earned 2000 total points
ID: 17828124
In a module, declare shellexecute:

Public Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long

the use the following command to execute the exe:

lRet = ShellExecute(Me.hwnd, "open", [PATH TO EXE], [EXE PARAMETERS], [APPLICATION DIRECTORY], SW_SHOWNORMAL)
0
 

Author Comment

by:expertfan
ID: 17878654
DrDamnit, thanks !! this works great.
0
 
LVL 32

Expert Comment

by:DrDamnit
ID: 17892237
I can't wait to try it out. I have been trying to do that forever!

...wouldn't you know, it takes serving others before you can find a means to your own end..... :-)

Glad to help.
0
 

Expert Comment

by:Tim Munckton
ID: 34049410
Hello,
I appreciate this is an old post, But the Link that DrDamnit put up from Jim White is awesome, but i cannot build the DLL due to not having VB6, do you know if it is possible to make it happen in visual studio 2010?
0

Featured Post

Independent Software Vendors: 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!

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

721 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