Register shell extension

This is a discussion on Register shell extension within the Windows Programming forums, part of the Platform Specific Boards category; hi! i wanted to ask, how to register a shell extension. i simply don't get where to put what key ...

  1. #1
    Registered User Devils Child's Avatar
    Join Date
    Jan 2008
    Posts
    244

    Register shell extension

    hi!
    i wanted to ask, how to register a shell extension. i simply don't get where to put what key and where to get the clsid from...

    i need a shell extension that says something like "use this file with my program" in the context menu of all files.

    thx

  2. #2
    Captain Crash brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,248
    Quote Originally Posted by Devils Child View Post
    hi!
    i wanted to ask, how to register a shell extension. i simply don't get where to put what key and where to get the clsid from...

    i need a shell extension that says something like "use this file with my program" in the context menu of all files.

    thx
    http://msdn.microsoft.com/en-us/libr...97(VS.85).aspx

    See part on "Registering Shell Extension Handlers"

    Also see:

    http://msdn.microsoft.com/en-us/libr...01(VS.85).aspx

    Which deals more with adding context menu choices for ALL filesystem objects. The information on how to register these handlers is at:

    http://msdn.microsoft.com/en-us/libr...81(VS.85).aspx

    Your extension must also (of course) be registered with the COM registry. Normally you'd take care of that during installation by calling out to "regsvr32" but you can do it programmatically if you want.
    Code:
    //try
    //{
    	if (a) do { f( b); } while(1);
    	else   do { f(!b); } while(1);
    //}

  3. #3
    Registered User Devils Child's Avatar
    Join Date
    Jan 2008
    Posts
    244
    thanks for the reply.
    i found such MSDN links when searching and the were neither helpful nor readable.
    and also: i don't know how to generate these GUIDs and what they are. i'm using Smart Install Maker to create a setup of a project i programmed in C#.

  4. #4
    Registered User
    Join Date
    Mar 2005
    Location
    Mountaintop, Pa
    Posts
    1,059
    Maybe this CodeGuru link can be of some help.

  5. #5
    Registered User Devils Child's Avatar
    Join Date
    Jan 2008
    Posts
    244
    thats just code, and i dont even write in c++

    what i really need is to know where to create what registry key/value to make my program pop up in the context menu of all files.

  6. #6
    Registered User Devils Child's Avatar
    Join Date
    Jan 2008
    Posts
    244
    for example: i look what other programs are doing and try to copy their behaviour:

    Code:
    [HKEY_CLASSES_ROOT\*\shellex\ContextMenuHandlers\MyProgram]
    @="{00000000-1122-2233-3344-0123456789AB}"
    
    [HKEY_CLASSES_ROOT\CLSID\{00000000-1122-2233-3344-0123456789AB}]
    
    [HKEY_CLASSES_ROOT\CLSID\{00000000-1122-2233-3344-0123456789AB}\InProcServer32]
    @="C:\\Program Files\\MyProgram\\MYPROGRAM.EXE"
    "ThreadingModel"="Both"
    and it doesn't work. there is nothing coming up in the context menu

  7. #7
    Registered User
    Join Date
    Jan 2008
    Posts
    287
    If you have no idea what a CLSID is and don't what what a GUID is or how to generate it, then I'm going to make the logical conclusion that you have no idea what COM is. Therefore, you have no idea what you need to do to make a shell extension. It is quite a bit more complicated than just adding a registry entry.

    First, let me point out that writing shell extensions in managed .NET code is STRONGLY advised against by programmers that are much smarter than I. Just look at these:

    http://blogs.msdn.com/junfeng/archiv...18/494572.aspx (Junfeng Zhang)
    http://blogs.msdn.com/oldnewthing/ar...8/1317290.aspx (Raymond Chen)
    http://social.msdn.microsoft.com/for...-8e962124043e/ (Jesse Kaplan)

    That said, I'm guessing you will probably ignore the warnings and insist on doing things your way anyhow. I mean hell, what do they know? In that case, you may want to read this article that explains exactly how you write a COM interoperable .NET component that can be used as a shell extension.

    http://www.theserverside.net/tt/arti...hellExtensions

    Also, those links that brewbuck provided are EXACTLY what you need for your project, so I find this line quite humorous:
    i found such MSDN links when searching and the were neither helpful nor readable.

  8. #8
    Registered User Devils Child's Avatar
    Join Date
    Jan 2008
    Posts
    244
    so i better let this idea of my project go.
    thanks for help guys^^

  9. #9
    Registered User
    Join Date
    Jan 2008
    Posts
    287
    Well I don't know if you should abandon the idea. If it was me, I'd still do it and say screw all the smart programmers. At least it would give you a chance to deal with how COM works, which would be a valuable learning experience if you plan on doing a lot of Windows development. You would also get experience implementing the appropriate COM interfaces required for shell extensions.

    Just do it knowing that in the general sense, it's the wrong answer. For your purposes it may work out completely fine. And if some time in the future you decide to learn a non-managed COM-capable language, you can do it the right way.

    That article I linked provides a decent explanation of everything you need to do, and you can supplement it with the MSDN links that brewbuck gave. Just like anything else, once you learn it, its not hard anymore. And as an added bonus, when you tell other people that you know COM, they'll grovel at your feet and worship your awesomeness.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. brace-enclosed error
    By jdc18 in forum C++ Programming
    Replies: 53
    Last Post: 05-03-2007, 05:49 PM
  2. Installing Thumbnail shell extension ?
    By glennpierce in forum Windows Programming
    Replies: 0
    Last Post: 07-20-2006, 09:38 AM
  3. execv extension list for shell
    By newbie29 in forum C Programming
    Replies: 1
    Last Post: 02-21-2005, 11:56 AM
  4. What shell is more powerful?
    By xddxogm3 in forum Tech Board
    Replies: 10
    Last Post: 07-24-2004, 10:47 PM
  5. System.ini Shell Problems
    By (TNT) in forum Windows Programming
    Replies: 2
    Last Post: 08-26-2001, 01:05 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21