adding customapp to explorer rightclick

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.
expertfanAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

DrDamnitCommented:
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
DrDamnitCommented:
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
DrDamnitCommented:
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
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

DrDamnitCommented:
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
DrDamnitCommented:
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
DrDamnitCommented:
0
DrDamnitCommented:
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
expertfanAuthor Commented:
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
DrDamnitCommented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
expertfanAuthor Commented:
DrDamnit, thanks !! this works great.
0
DrDamnitCommented:
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
Tim MuncktonCommented:
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.