views:

154

answers:

3

I'm in the process of doing some COM interop from a C# application and I can't seem to find the answer to this.

I was wondering where I could find in the Win32 documentation which concreate implementions that exists of a COM interface. For example I know (thanks to goodgle) that IShellLinkW is implemented by a class that's identified by CLSID_ShellLink, that IObjectArray is implemented by CLSID_EnumerableObjectCollection and so on.

However how am I supposed to know? I have the Windows SDK (latest) version installed and I can't seem to wrap my head around how I was supposed to figure that out based on the information in the docs?

+1  A: 

Why do you need to know? The import utilities like tlbimp.exe are figuring out the necessary details from the exe or dll type info and creating wrappers that cover this for you.

Look at the TlbImp example at COM Interop Part 1: C# Client Tutorial:

Remus Rusanu
I'm doing some manual interop declarations but far most I want to know, because I like to know how things work under the covers.. so the question remains.. taking a given com interface, how do I know which concreate classes that implementes them, so I know what to create..
TheCodeJunkie
PE images enabled for COM have a resource inside that describes the CLSIIDs and IIDs supported (the TypeLib). Tools like regsrv can add the necessray info in the registry, tools like TlbImp use it to create a wrapper lib or managed dll. Installers also contain this information in their database (see http://msdn.microsoft.com/en-us/library/aa372092%28VS.85%29.aspx) and add the encessary info to the registry.
Remus Rusanu
Let's for get the whole managed interop scenario, it's not relevant to the question (it was just some background) and I know all about the IDL files, typelibs, import tools and so onHow would I, as a new and aspiring C++ developer, know about the concrete classes? Say I read the docs and see IShellLinkW interface and go "Hmm cooool, I want to use that!", then how would I know to create an instance of CLSID_ShellLink? Or more obscure, go from IObjectArray/IObjectColleciton -> CLSID_EnumerableObjectCollection?It has to be mentioned somewhere in the docs, but where? :) thanks
TheCodeJunkie
You read `Inside OLE`, `Inside OLE2` and `Essential COM`.
Remus Rusanu
Because Microsoft just decided not to document it themselves? ;)
TheCodeJunkie
You tell me ;) . But I gotta ask: why would a decent person expose itself to the Wrath of COM in 2009? Is Shell extension relevant at all these days?
Remus Rusanu
A: 

most of standard COM objects IIDs and CLSIDs are listed in uuid.lib, included in Windows SDK. So you may write a simple app printing them for you.

Also, you can open regedit, go to HKCR\Interface and analyze records there.

elder_george
A: 

I dont think what you want is possible without loading every COM object in the system and asking it for a list of classes it has and what Interfaces they implement. This information as far as I am aware is not stored in the Registry (the place all external COM info is stored).

If you could give a concrete example of what you are trying to achieve their may be an alternative way. If you simply want to know what interfaces are implemented by a particular class or .dll you can do that with a viewer such as oleview

Toby Allen