expertfan
asked on
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.
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.
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\SOFTWAR E\Classes\ Folder\she ll
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.ex e %1 will open a command prompt in that folder).
Cheers!
-Doc.
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\SOFTWAR
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.ex
Cheers!
-Doc.
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\SOFTWAR E\Classes\ WinRAR\she llex we have:
HKEY_LOCAL_MACHINE\SOFTWAR E\Classes\ WinRAR\she llex\Conte xtMenuHand lers
HKEY_LOCAL_MACHINE\SOFTWAR E\Classes\ WinRAR\she llex\Conte xtMenuHand lers\{B41D B860-8EE4- 11D2-9906- E49FADC173 CA}.
If you look up {B41DB860-8EE4-11D2-9906-E 49FADC173C A}, you find this:
HKEY_LOCAL_MACHINE\SOFTWAR E\Classes\ CLSID\{B41 DB860-8EE4 -11D2-9906 -E49FADC17 3CA}
HKEY_LOCAL_MACHINE\SOFTWAR E\Classes\ CLSID\{B41 DB860-8EE4 -11D2-9906 -E49FADC17 3CA}\InPro cServer32
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!
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\SOFTWAR
HKEY_LOCAL_MACHINE\SOFTWAR
HKEY_LOCAL_MACHINE\SOFTWAR
If you look up {B41DB860-8EE4-11D2-9906-E
HKEY_LOCAL_MACHINE\SOFTWAR
HKEY_LOCAL_MACHINE\SOFTWAR
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!
expertfan,
I just found this too:
http://www.oreilly.com/catalog/vbshell/chapter/ch04.html
It may hold some clues for us.
Cheers!
-Doc
I just found this too:
http://www.oreilly.com/catalog/vbshell/chapter/ch04.html
It may hold some clues for us.
Cheers!
-Doc
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
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
THese are specific to VB:
http://www.vbforums.com/showpost.php?p=1884517&postcount=5
http://www.vbforums.com/showthread.php?s=&threadid=183880 (important stuff starts at #12)
This may actually be the answer: http://www.vbforums.com/attachment.php?attachmentid=15901
http://www.vbforums.com/showpost.php?p=1884517&postcount=5
http://www.vbforums.com/showthread.php?s=&threadid=183880 (important stuff starts at #12)
This may actually be the answer: http://www.vbforums.com/attachment.php?attachmentid=15901
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::QueryContext Menu
' 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::InvokeComman d
' 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!
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::QueryContext
' 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::InvokeComman
' 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!
ASKER
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
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
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
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
DrDamnit, thanks !! this works great.
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.
...wouldn't you know, it takes serving others before you can find a means to your own end..... :-)
Glad to help.
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?
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?
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!