Search code examples
c#.netcomcom-interop

Is it possible to determine the underlying COM component type from an interface pointer in .NET interop?


I'm using a COM library in .NET. The vendor has provided primary interop assemblies with documentation. However, a particular method returns an interface pointer but the documentation does not tell me what the underlying component type is (so I have no idea what other interfaces I can QI to).

Is it possible to determine what the underlying component returned from this method is if all I have is an interface pointer?


Solution

  • In general, simple answer is no. COM always hides underlying objects, it does not have refection like C#.

    If you own the code that has created it, of course you can keep track, or the object might tell you. Also, you can try some hacks, like checking the loaded dlls in your process, querying all interface, but this all depends on your specific problem.