using System.Runtime.InteropServices.ComTypes; // Assuming variable 'comObject' holds COM component object IConnectionPointContainer connectionPointContainer = comObject as IConnectionPointContainer; IEnumConnectionPoints enumConnectionPoints; connectionPointContainer.EnumConnectionPoints(out enumConnectionPoints); IConnectionPoint[] connectionPoints = new IConnectionPoint[1]; while (true) { uint fetched = 0; enumConnectionPoints.Next(1, connectionPoints, out fetched); if (fetched == 0) { break; } // TODO: Process connection point... }
using System.Runtime.InteropServices.ComTypes; // Assume variable 'comObject' holds COM component object IConnectionPointContainer connectionPointContainer = comObject as IConnectionPointContainer; Guid guid = typeof(IMyEvent).GUID; // Assuming IMyEvent interface has been defined in .NET code. IConnectionPoint connectionPoint; connectionPointContainer.FindConnectionPoint(ref guid, out connectionPoint); // Advise uint cookie; IMyEvent myEventHandler = new MyEventHandler(); connectionPoint.Advise(myEventHandler, out cookie); // Unadvise connectionPoint.Unadvise(cookie);These examples use the System.Runtime.InteropServices.ComTypes package library.