Results 1 to 16 of 16

Thread: Global Shell menu extension [resolved]

Hybrid View

  1. #1

    Thread Starter
    Next Of Kin baja_yu's Avatar
    Join Date
    Aug 2002
    Location
    /dev/root
    Posts
    5,989

    Re: Global Shell menu extension

    Thanks. But what about files? I have added it to the "*" and it still only worked for exe file...

  2. #2

    Thread Starter
    Next Of Kin baja_yu's Avatar
    Join Date
    Aug 2002
    Location
    /dev/root
    Posts
    5,989

    Re: Global Shell menu extension

    Anyone else have any ideas?

  3. #3
    Old Member moeur's Avatar
    Join Date
    Nov 2004
    Location
    Wait'n for Free Stuff
    Posts
    2,712

    Re: Global Shell menu extension

    How about:
    HKEY_CLASSES_ROOT\*\OpenWithList\MyProg.exe

    ...

  4. #4

    Thread Starter
    Next Of Kin baja_yu's Avatar
    Join Date
    Aug 2002
    Location
    /dev/root
    Posts
    5,989

    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.

  5. #5

    Thread Starter
    Next Of Kin baja_yu's Avatar
    Join Date
    Aug 2002
    Location
    /dev/root
    Posts
    5,989

    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

  6. #6

    Thread Starter
    Next Of Kin baja_yu's Avatar
    Join Date
    Aug 2002
    Location
    /dev/root
    Posts
    5,989

    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:
    1. Private Sub IShellExtInit_Initialize(ByVal pidlFolder As Long, ByVal lpdobj As Long, ByVal hKeyProgID As Long)
    2.    
    3.        Dim strVal      As String
    4.        Dim pIDataObj   As IUnknown
    5.        Dim oIDataObj   As IDataObject
    6.        Dim FmtEtc      As FORMATETC
    7.        Dim pMedium     As STGMEDIUM
    8.        Dim szTemp      As String
    9.        Dim iFile       As Long
    10.        Dim rc          As Long
    11.    
    12.        CopyMemory pIDataObj, lpdobj, 4
    13.        Set oIDataObj = pIDataObj
    14.        ' oIDataObj now stores the object required
    15.        CopyMemory pIDataObj, 0&, 4
    16.        ' Set the format to get the data in...
    17.        With FmtEtc
    18.           .cfFormat = CF_HDROP
    19.           .ptd = 0
    20.           .dwAspect = DVASPECT_CONTENT
    21.           .lindex = -1
    22.           .tymed = TYMED_HGLOBAL
    23.           End With
    24.    
    25.        ' ... and store it in our medium
    26.        oIDataObj.GetData ByVal VarPtr(FmtEtc), ByVal VarPtr(pMedium)
    27.        rc = Err.LastDllError 'Check for errors
    28.        
    29.         Dim filename As String        'the dropped filename
    30.         Dim numOfDroppedFiles As Long 'the number of dropped files
    31.         Dim curFile As Long           'the current file number
    32.    
    33.         SelectedFile = ""
    34.  
    35.         'get the total number of files
    36.         numOfDroppedFiles = DragQueryFile(pMedium.hGlobal, True, filename, Len(filename))
    37.        
    38.         For curFile = 1 To numOfDroppedFiles
    39.             'get the file name
    40.             filename = String(260, 0)
    41.             rc = DragQueryFile(pMedium.hGlobal, curFile - 1, filename, Len(filename))
    42.             DoEvents
    43.             'at this pointer you can do what you want with the filename
    44.             'the filename will be a full qualified path
    45.             If curFile = 1 Then
    46.                 SelectedFile = Left$(filename, rc)
    47.             Else
    48.                 SelectedFile = SelectedFile & "|" & Left$(filename, rc)
    49.             End If
    50.             DoEvents
    51.         Next curFile
    52.         'we are now done with the structure, tell windows to discard it
    53.         DoEvents
    54.        
    55.         rc = ReleaseStgMedium(pMedium)
    56.         Set oIDataObj = Nothing
    57.         DoEvents
    58.     End Sub

    Thanks to everyone that helped.
    Last edited by baja_yu; Nov 24th, 2009 at 10:39 PM.

  7. #7
    New Member
    Join Date
    Jun 2005
    Posts
    1

    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.

  8. #8
    Frenzied Member
    Join Date
    Apr 2003
    Location
    The Future - Skynet
    Posts
    1,157

    Re: Global Shell menu extension (almost resolved)

    Quote 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:
    1. Private Sub IShellExtInit_Initialize(ByVal pidlFolder As Long, ByVal lpdobj As Long, ByVal hKeyProgID As Long)
    2.    
    3.        Dim strVal      As String
    4.        Dim pIDataObj   As IUnknown
    5.        Dim oIDataObj   As IDataObject
    6.        Dim FmtEtc      As FORMATETC
    7.        Dim pMedium     As STGMEDIUM
    8.        Dim szTemp      As String
    9.        Dim iFile       As Long
    10.        Dim rc          As Long
    11.    
    12.        CopyMemory pIDataObj, lpdobj, 4
    13.        Set oIDataObj = pIDataObj
    14.        ' oIDataObj now stores the object required
    15.        CopyMemory pIDataObj, 0&, 4
    16.        ' Set the format to get the data in...
    17.        With FmtEtc
    18.           .cfFormat = CF_HDROP
    19.           .ptd = 0
    20.           .dwAspect = DVASPECT_CONTENT
    21.           .lindex = -1
    22.           .tymed = TYMED_HGLOBAL
    23.           End With
    24.    
    25.        ' ... and store it in our medium
    26.        oIDataObj.GetData ByVal VarPtr(FmtEtc), ByVal VarPtr(pMedium)
    27.        rc = Err.LastDllError 'Check for errors
    28.        
    29.         Dim filename As String        'the dropped filename
    30.         Dim numOfDroppedFiles As Long 'the number of dropped files
    31.         Dim curFile As Long           'the current file number
    32.    
    33.         SelectedFile = ""
    34.  
    35.         'get the total number of files
    36.         numOfDroppedFiles = DragQueryFile(pMedium.hGlobal, True, filename, Len(filename))
    37.        
    38.         For curFile = 1 To numOfDroppedFiles
    39.             'get the file name
    40.             filename = String(260, 0)
    41.             rc = DragQueryFile(pMedium.hGlobal, curFile - 1, filename, Len(filename))
    42.             DoEvents
    43.             'at this pointer you can do what you want with the filename
    44.             'the filename will be a full qualified path
    45.             If curFile = 1 Then
    46.                 SelectedFile = Left$(filename, rc)
    47.             Else
    48.                 SelectedFile = SelectedFile & "|" & Left$(filename, rc)
    49.             End If
    50.             DoEvents
    51.         Next curFile
    52.         'we are now done with the structure, tell windows to discard it
    53.         DoEvents
    54.        
    55.         rc = ReleaseStgMedium(pMedium)
    56.         Set oIDataObj = Nothing
    57.         DoEvents
    58.     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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width