Shell Context menu (aka Win Explorer context menu) in my app?.. how?

Hi all..

I have for a time now tried to take advantage of some of the implementations the Shell32 api can offer regards to file management, mainly i have been successful. The one thing i have not been able to do is implement the explorer context menu in my applications. I want to be able to get the same context menu Windowns explorer shows, with all the addins that may include (eg. winrar-addin, sendto, openwith and so forth) in my application. I have found code for this in both C++ and som e VB like apps, but nothing in C#. I would be extreamly glad if someone who knows how to do this could post a small app where this is done or perhaps post a link to a site where this information can be found!!

If its still unclear what i mean:

1. i have a app that has a listview where files/folders are displayed (explorer like app)
2. right-click on a file/folder displays the same context menu Explorer would show for that
specific file/folder
3 Thats it :D
and i am using VS C# 2003

/
homer: "...i am not a praying man but if you are up there please help me superman..."



Answer this question

Shell Context menu (aka Win Explorer context menu) in my app?.. how?

  • xeondev

    I think it is (2), but only for .NET applications. From what I've seen, the problem is getting the shell's interfaces defined in your app. Shell32.dll exports just a few of them, none of the ones you need to make a context menu handler working. .NET makes it easy enough to work with COM components, but only if you have a type library available. There is no type library for shell interfaces that I've found. This is not at all an issue with native C++ apps, you simply #include <shlobj.h>

    I think what we need here is a Primary Interop Assembly for the shell, similar to the ones that MSFT has released for Office. Hey MSFT, are you listening


  • Abdel1

    Thanks for taking a look at my dilema m8.. but I have seen those tutorials before and they dont really give me the tools i need for solving my problem...


  • Aleniko29139

    Yay ! Sounds like a bunch of problems solved already !
    Talking way above my head though dude ! :o)

    I'll definately stay tuned to this one though, the amount of web pages I've trawled through trying to find a solution to this, would be fantastic If you get it working...


  • Blast

    Yes, this kind of VB6 code (CopyMemory, GUID tricks) doesn't convert well. Interestingly though, there was a little nugget in that archive, ishf_ex.tlb, a tool library with the necessary shell interface definitions (IContextMenu, IShellView etc). A .tlb like that isn't normally enough to let the IDE create a Runtime Callable Wrapper. But I found a trick. I've got an obscure tool, regtlib.exe, that lets you register a tool library. Once I did that, I could add a reference to ishf_ex.tlb and got the RCW and the interface definitions. Holy cow!

    This gives me a bunch of ideas to get other shell interfaces into a .NET project. I previously generated tool libraries with MIDL but could never get them converted an RCW. I need to play with this new-found treasure for a while, stay tuned. If you want to play yourself and don't have regtlib.exe (can't remember where I got it) drop me an email. You'll find the address in my profile, |Monkeytail| = @


  • Kevin S Won

    hOmeR J,

    Did you have any luck with this
    Its absolutly doing my head in now, 6 Billion articles on how to add context menu "extensions" but not ONE that shows you how to show the menu in the first place !!

    From what I've read, creating extensions in the first place, adding all the neccessary entries to the registry, defining the handler etc so they show up on the shell context menu, is the difficult bit.... So either (1) its so easy that nobody has ever felt the need to report how they did it and we're both missing something, or (2) Its not possible, only it clearly is cos lots of other stuff does it....

    Been going round in circles for weeks now with this. I'd really like to be able to do it without delving into COM. Best result for me would be to be able to drop an object onto my form, pass it an array of filenames and type : MyShellContext.show.

    Grrr




  • Polarbear541

    I ran into this thread. That's quite conclusive to me, especially with Raymond Chang chiming in, no .NET for shell extension handlers...


  • netpicker9

    Hi all..

    I have been out off commission for a week now.. Tried to recap what’s been going on and its really nice to see that others have finally caught up to this problem as well :D

    I thought that I was just missing something really simple.. Not that I understand all that’s being said so far.. :S it’s a little beyond my skills..

     I have found an article though that claims to do what I am looking for. The problem is its written in VS 2005 and uses partial classes and other funky stuff not found in vs 2003 .Net.. I am having some problems converting it.. maybe it can help you guys on your way to find a solution..

    http://www.codeproject.com/shell/shellcontextmenu.asp

    Check it out..

     


  • mrshrinkray

    A few C# shell projects are here, nothing that jumps out as "that's what you want" though. The shell API is quite unfriendly to .NET...


  • Flap

    Thanks for your reply, not the news I was hoping for :o(

    I have since found this (Sorry, cant get the linky insert to work)
    http://btmtz.mvps.org/shellmenu/

    Its in VBClassic, works a treat, but the code importer into dotnet throws like a million errors that are beyond my skills to sort through....

  • Fl&amp;#225;vioOliveira

    Hello!!... Heeellloooo... helloooo.... (echo) hehe.. Where did you guys go Any luck yet Found anything interesting .. Cause I am drawing blanks here...
  • Shell Context menu (aka Win Explorer context menu) in my app?.. how?