using System; Using System. The Runtime. InteropServices; The namespace EventSource { Public delegate void ClickDelegate (int x, int y); Public delegate void ResizeDelegate (); Public delegate void PulseDelegate ();
//Step 1: Defines an event sink interface (ButtonEvents) to be //implemented by the COM sink. [GuidAttribute (" 1 a585c4d - 3371-48 dc - AF8A - AFFECC1B0967 ")] [InterfaceTypeAttribute (ComInterfaceType. InterfaceIsIDispatch)] Public interface IButtonEvents { Void the Click (int x, int y); Void the Resize (); Void Pulse (); }
[Guid (b70 "51917 a2 e6c - 87-4 - B1A8-47 c47f8007e4")] Public interface MyCom_Interface { [DispId (1)] Int the Add (int param11, int param12); }
//Step 2: Connects the event sink interface to a class //by passing the namespace and the event sink interface //(" EventSource. ButtonEvents, EventSrc "). [Guid (" FE6A8C43 - D4B6-4100 - f95a57f BC6B - 06333 "), ClassInterface (ClassInterfaceType. None), ComSourceInterfaces (typeof (IButtonEvents)] Public class Button: MyCom_Interface { The public event ClickDelegate Click; The public event ResizeDelegate Resize; The public event PulseDelegate Pulse;
Public Button () { } Public void CauseClickEvent (int x, int y) { Click (x, y); } Public void CauseResizeEvent () { The Resize (); } Public void CausePulse () { Pulse (); }
Public int the Add (int param11, int param12) {
The Resize (); Return param11 + param12; } } }
CodePudding user response:
Come and help
CodePudding user response:
# import "XXX. TLB" no_namespace named_guids
//naming rules: interface Ptr p ((__uuidof (class))) MyCom_InterfacePtr p (__uuidof (Button));