-
Feb 6th, 2005, 03:54 PM
#1
Global Shell menu extension [resolved]
Is it possible to create a shell menu extension (file or folder right-click menu) to allow opening it with my application?
Last edited by baja_yu; Mar 12th, 2005 at 10:02 PM.
-
Feb 6th, 2005, 04:09 PM
#2
Re: Global Shell menu extension
Yes, it is. It take some registry hacks and adding some shell extensions. I just came accross it about two
weeks ago. Let me searh for the link. Be back.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum.
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it!
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6
-
Feb 6th, 2005, 04:12 PM
#3
-
Feb 6th, 2005, 08:43 PM
#4
Re: Global Shell menu extension
Thanks manavo for the example, but I couldnt get it to work. What values exactly would I need to add the the registry to make this happen? And more importantly in what format? I must be doing something wrong...
-
Feb 6th, 2005, 11:24 PM
#5
Re: Global Shell menu extension
In the second link's thread there is a demo project attachment that you should
download. It has all you need and its very good.
Direct link to actual post with demo attachment
HTH
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum.
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it!
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6
-
Feb 9th, 2005, 07:35 PM
#6
Re: Global Shell menu extension
Thanks, I got it working partially like I wanted to. The only thing I couldnt do is make it work for any file/folder type.
I tried editing the .reg file so it registers the context menu in the "*" instead of "exefile" key but that didn't help, they still only worked for exe files.
Any ideas?
-
Feb 9th, 2005, 08:28 PM
#7
Re: Global Shell menu extension
To add a context menu for any folder, Put the CLSID of your context menu handler in
HKEY_CLASSES_ROOT\Directory\shellex\ContextMenuHandlers\yourprogram (default) {YourCLSID}
You're also supposed to be able to add to the context menu for the Explorer Background in,
HKEY_CLASSES_ROOT\Directory\Background\shellex\ContextMenuHandlers\yourprogram (default) {YourCLSID}
But I've never gotten this one to work.
...
-
Feb 9th, 2005, 08:45 PM
#8
Re: Global Shell menu extension
Thanks. But what about files? I have added it to the "*" and it still only worked for exe file...
-
Feb 10th, 2005, 11:52 AM
#9
Re: Global Shell menu extension
Anyone else have any ideas?
-
Feb 10th, 2005, 12:37 PM
#10
Re: Global Shell menu extension
How about:
HKEY_CLASSES_ROOT\*\OpenWithList\MyProg.exe
...
-
Feb 10th, 2005, 09:39 PM
#11
Re: Global Shell menu extension
Yes but that will subordinate it to the Open with item which does not always show. It only shows for unknown file types and for all when you hold Shift when opening the menu.
-
Feb 11th, 2005, 05:07 AM
#12
Re: Global Shell menu extension
I got it to work for all file types and folders by adding references to these keys:
HKEY_CLASSES_ROOT\*\shellex\ContextMenuHandlers\AppName
HKEY_CLASSES_ROOT\Directory\shellex\ContextMenuHandlers\AppName
HKEY_CLASSES_ROOT\Drive\shellex\ContextMenuHandlers\AppName
HKEY_CLASSES_ROOT\Folder\shellex\ContextMenuHandlers\AppName
Now, I just have to find a way to make it detect when multiple (a group) files are selected and I'm set
-
Mar 12th, 2005, 08:46 PM
#13
Re: Global Shell menu extension (almost resolved)
Ok... I've got it... the solution to multiple selections that is:
Use the code in the link RobDog posted... then, replace the existing procedure with this one:
VB Code:
Private Sub IShellExtInit_Initialize(ByVal pidlFolder As Long, ByVal lpdobj As Long, ByVal hKeyProgID As Long) Dim strVal As String Dim pIDataObj As IUnknown Dim oIDataObj As IDataObject Dim FmtEtc As FORMATETC Dim pMedium As STGMEDIUM Dim szTemp As String Dim iFile As Long Dim rc As Long CopyMemory pIDataObj, lpdobj, 4 Set oIDataObj = pIDataObj ' oIDataObj now stores the object required CopyMemory pIDataObj, 0&, 4 ' Set the format to get the data in... With FmtEtc .cfFormat = CF_HDROP .ptd = 0 .dwAspect = DVASPECT_CONTENT .lindex = -1 .tymed = TYMED_HGLOBAL End With ' ... and store it in our medium oIDataObj.GetData ByVal VarPtr(FmtEtc), ByVal VarPtr(pMedium) rc = Err.LastDllError 'Check for errors Dim filename As String 'the dropped filename Dim numOfDroppedFiles As Long 'the number of dropped files Dim curFile As Long 'the current file number SelectedFile = "" 'get the total number of files numOfDroppedFiles = DragQueryFile(pMedium.hGlobal, True, filename, Len(filename)) For curFile = 1 To numOfDroppedFiles 'get the file name filename = String(260, 0) rc = DragQueryFile(pMedium.hGlobal, curFile - 1, filename, Len(filename)) DoEvents 'at this pointer you can do what you want with the filename 'the filename will be a full qualified path If curFile = 1 Then SelectedFile = Left$(filename, rc) Else SelectedFile = SelectedFile & "|" & Left$(filename, rc) End If DoEvents Next curFile 'we are now done with the structure, tell windows to discard it DoEvents rc = ReleaseStgMedium(pMedium) Set oIDataObj = Nothing DoEvents End Sub
Thanks to everyone that helped.
Last edited by baja_yu; Nov 24th, 2009 at 10:39 PM.
-
Jun 19th, 2005, 06:24 PM
#14
New Member
Re: Global Shell menu extension [resolved]
The demo example posted here is wonderful! Thank you so much for making & posting it! This is totally awesome, I am so happy to have found this sample, it rocks!!
It is very easy to use. I was a bit confused about how you get a DLLs GUID and how to make my own project...(I have never made a dll before), but figured that out pretty soon when i googled for dll progid and had a general read about them.
Thanks a bunch for this demo.
Last edited by Clawsy; Jun 19th, 2005 at 06:33 PM.
-
Jan 9th, 2008, 05:53 PM
#15
Frenzied Member
Re: Global Shell menu extension (almost resolved)
Originally Posted by baja_yu
Ok... I've got it... the solution to multiple selections that is:
Use the code in the link I posted... then, replace the existing procedure with this one:
VB Code:
Private Sub IShellExtInit_Initialize(ByVal pidlFolder As Long, ByVal lpdobj As Long, ByVal hKeyProgID As Long)
Dim strVal As String
Dim pIDataObj As IUnknown
Dim oIDataObj As IDataObject
Dim FmtEtc As FORMATETC
Dim pMedium As STGMEDIUM
Dim szTemp As String
Dim iFile As Long
Dim rc As Long
CopyMemory pIDataObj, lpdobj, 4
Set oIDataObj = pIDataObj
' oIDataObj now stores the object required
CopyMemory pIDataObj, 0&, 4
' Set the format to get the data in...
With FmtEtc
.cfFormat = CF_HDROP
.ptd = 0
.dwAspect = DVASPECT_CONTENT
.lindex = -1
.tymed = TYMED_HGLOBAL
End With
' ... and store it in our medium
oIDataObj.GetData ByVal VarPtr(FmtEtc), ByVal VarPtr(pMedium)
rc = Err.LastDllError 'Check for errors
Dim filename As String 'the dropped filename
Dim numOfDroppedFiles As Long 'the number of dropped files
Dim curFile As Long 'the current file number
SelectedFile = ""
'get the total number of files
numOfDroppedFiles = DragQueryFile(pMedium.hGlobal, True, filename, Len(filename))
For curFile = 1 To numOfDroppedFiles
'get the file name
filename = String(260, 0)
rc = DragQueryFile(pMedium.hGlobal, curFile - 1, filename, Len(filename))
DoEvents
'at this pointer you can do what you want with the filename
'the filename will be a full qualified path
If curFile = 1 Then
SelectedFile = Left$(filename, rc)
Else
SelectedFile = SelectedFile & "|" & Left$(filename, rc)
End If
DoEvents
Next curFile
'we are now done with the structure, tell windows to discard it
DoEvents
rc = ReleaseStgMedium(pMedium)
Set oIDataObj = Nothing
DoEvents
End Sub
Thanks to everyone that helped.
I am in need of similar to the same thing. I created an exe and am able to get it to work for context menu. Only problem is when it fires off, it fires off multiple instance of the same exe because multiple files are selected.
I posted a similar thread earlier today:
http://www.vbforums.com/showthread.php?t=503943
baja_yu or anyone, can you show me where to plug this procedure in and what to feed into it? I noticed pidlFolder and hKeyProgID are not used in the procedure.
I'll Be Back!
T-1000
Microsoft .Net 2005
Microsoft Visual Basic 6
Prefer using API
-
Jun 12th, 2009, 08:25 AM
#16
New Member
Re: Global Shell menu extension
nice one to play with. Any way to add item to the Desktop context menu? Any one one have a .net port of these?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|