- SvCom
- Shell+
- PerfUtils


- SvCom
- Shell+
- PerfUtils


- Order now


- Contact directly

Embarcadero Technology Partner

    Adding COM-object methods  

Let's add methods to the COM-object interfaces. We'll implement a very simple server with very simple callback - the client application will have one button to send some text message to the server. The server will receive this message and broadcat it to all clients using registered callback interfaces.

First of all add the HandleEventNotification method to the IComObjectWithEventsEvents dispinterface. Add one EventMessage parameter of WideStringType. Note again, this interface should be implemented by client, not server, so we just declare the interface but do not implement it.

Now add the RaiseEvent method to the IComObjectWithEvents interface. Add one WideString parameter to it, set its name to "Text". The implementation of this method will look like this one:

procedure TComObjectWithEvents.RaiseEvent(const Text: WideString);
var i: Integer;
    U: IUnknown;
    E: IComObjectWithEventsEvents;
    with FConnectionPoint.SinkList do
        for i:=0 to Count-1 do
            if not Assigned(U) then continue;
            E:=U as IComObjectWithEventsEvents;
            E.HandleEventNotification('Event is raised with message: '+Text);
    if Assigned(FEvents) then
        FEvents.HandleEventNotification('Event is raised with message: '+Text);

The RaiseEvent method is available for client application so it can pass the text message to the server. As you can see server processes it easy - it iterates through registered callbacks and calls HandleEventNotification for every registered callback instance.

The server application is ready for tests. Install it as usual - if you wish to test it in service mode immediately then run it once with /reinstall switch. If you wish to trace it in IDE first then run it with /reinstall /debug switches one time and then execute it with /debug switch from IDE.

Let's create the client application now...

<< . index . 1 . 2 . 3 . 4 . >>
SvCom links:

- Overview
- Download
- Purchase
- Tutorial
- What's new
- For registered users
- Support


© 1998-2003. Alexey Dynnikov
© 2003-2016. ALDYN Software
© Design: Adonis i-cafe.