Results 1 to 7 of 7

Thread: Adding Context Menus to Windows Explorer

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Mar 2011
    Posts
    118

    Adding Context Menus to Windows Explorer

    I have a project that adds a lot of context menus to Windows Explorer for certain items. Currently, when the project loads I add something like:
    Code:
    HKCR\<myfiletype>\shell\<myextension>\command
    to the registry for a number of items, and I remove the entries when the project unloads. It works quite well!

    The problem is that the extensions I add have grown in numbers and I would like to add them all to a SUB menu, which isn't possible by the methods I am using. As I have read, I need to create a shell extension / context menu handler to create my own custom sub menu. Various sources have led me to believe this isn't do-able in VB6...

    Then I stumbled upon SHLEXT.tlb by Eduardo Morcillo on vbaccellerator, but I cannot find any code samples for actually using it. On his own mvps site I couldn't even find the tlb itself, but found a sample ctxmenu.dll, but no samples on using that.

    I found a different sample in VB5 on microsoft.com somewhere but it looks a little complex to a beginner like myself, and the caveat is that Windows would need to be restarted for the changes to be noticeable. That isn't an option for me. Probably that is just MS speak for killing the Explorer.exe process and restarting it, which I could easily automate, but that isn't an attractive option to do every time my program is executed.

    I figure the gurus here probably already have written or provided a sample using the SHLEXT.tlb or similar. Can someone point me to a code sample that utilizes one of these methods to add one simple context menu to explorer, preferably a submenu

  2. #2
    Frenzied Member
    Join Date
    Nov 2005
    Posts
    1,834

    Re: Adding Context Menus to Windows Explorer

    Take a look at the thread below. Post #24 contains a demo project.

    http://www.vbforums.com/showthread.p...hreadid=183880

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Mar 2011
    Posts
    118

    Re: Adding Context Menus to Windows Explorer

    Great, thanks!

  4. #4
    PowerPoster
    Join Date
    Jul 2010
    Location
    NYC
    Posts
    5,719

    Re: Adding Context Menus to Windows Explorer

    I have a related question, so I'll ask here instead of a new thread.

    The registry entry shows how to add it for .exe files; but how can it be changed to add the menu to all files?

    Oh and regarding Morcillo's context menu example, you are talking about adding a right click option in Windows Explorer right? I have the code sample on that and it only uses olelib.tlb. Attaching the example.
    Attached Files Attached Files
    Last edited by fafalone; May 16th, 2012 at 02:58 PM.

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Mar 2011
    Posts
    118

    Re: Adding Context Menus to Windows Explorer

    Works fine on XP......

    But on Win7, I import the reg file, register the DLL, etc. No joy though. Even tried restarting explorer, no love.

    Any ideas?

  6. #6

    Thread Starter
    Lively Member
    Join Date
    Mar 2011
    Posts
    118

    Re: Adding Context Menus to Windows Explorer

    Quote Originally Posted by fafalone View Post
    I have a related question, so I'll ask here instead of a new thread.

    The registry entry shows how to add it for .exe files; but how can it be changed to add the menu to all files?

    Oh and regarding Morcillo's context menu example, you are talking about adding a right click option in Windows Explorer right? I have the code sample on that and it only uses olelib.tlb. Attaching the example.
    In the .reg file change "exefile" to "AllFileSystemObjects"

  7. #7

    Thread Starter
    Lively Member
    Join Date
    Mar 2011
    Posts
    118

    Re: Adding Context Menus to Windows Explorer

    Well as it turns out, it you cannot register a 32bit context menu handler on a 64bit system which is what my OS is - after some research it looks like there is NO WAY to get a VB6 context menu handler to work on a 64bit version of Windows... DRAT!

    I have yet to test the context menu handler DLL on a 32bit Win7 to see if that at least will work...

    But at least I did find ways to add submenus in Windows 7 (unsure if it will work on Vista but likely so) even though it won't work on XP... http://msdn.microsoft.com/en-us/libr...(v=vs.85).aspx

    So I guess my solution is to use the context menu handler with my app for Windows XP, or all 32 bit systems perhaps, and then use the registry method I found above for use on Vista/7 x64.... Sigh more coding required.

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