How to get guid from unknown com object interface (e.g. connection point)?

1.7k Views Asked by At

I've got running service which is available via COM. I can connect with it by using Activator.

I connect COM library

using MyLib;

and then get my object by Instance

Activator.CreateInstance((Type.GetTypeFromProgID("RunningInstance")));

this is actually IConnectionPointContainer

there are several connection points and to get one there is

FindConnectionPoint(SomeGuidHere, out MyConnectionPoint);

if I remember correctly in cpp atl there is just __uuid(IHelloWorld)

the problem is: how to get guide of some "IHelloWorld" interface (connection point) in the Container ?

2

There are 2 best solutions below

3
Frank Pfattheicher On BEST ANSWER

Use EnumConnectionPoints() as described in this answer.

1
Brian G On

If you have a reference to the interface, you can get the GUID from the type.

typeof(IHelloWorld).GUID