Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Two COM EXE server problems. Please Help!!

5 views
Skip to first unread message

Holger Zwingmann

unread,
Aug 8, 2003, 5:28:32 PM8/8/03
to
Hi all!

I am using Delphi 7 and created an EXE COM server by adding an Automation
Object to my application. I enabled event support, used apartement
threading, multiple instancing and implemented the following to fire the
events:

// procedure to fire the CreatedNode Event for all connected
// clients
procedure TCStorage.Fire_NodeCreated(const parentNode, newNode: WideString);
var
I: Integer;
EventSinkList: TList;
begin
if FConnectionPoint <> nil then
begin
EventSinkList :=FConnectionPoint.SinkList;
for I := 0 to EventSinkList.Count - 1 do
begin
if Assigned(EventSinkList[I]) then
begin
(IUnknown(EventSinkList[I]) as
ICSTorageEvents).NodeCreated(parentNode,newNode);
end;
end;
end;
end;


Furthermor, I registered the server in the ROT using:


procedure TCStorage.Initialize;
begin
inherited Initialize;
...
OleCheck(RegisterActiveObject(Self, Class_CStorage,
ActiveObject_Weak, FROTCookie));
...
end;

Problems:
1) When connection to the server with clients implemented in Delphi (using
import type library to create a component), everything seems to be fine:
Initialize is called only once; when the last clients dissconnects, the
server goes down, ... BUT: Only one cliente gets events. I checked the
FConnectionPoint.SinkList and it only contains one client.

2) When a client written in VB tries to connect to a running server using
"with events" and the getObject method, the method always fails and creates
a new server. If "with events" is not used, the client can connect. On the
other hand, clients written in Delphi can connect to a server created by a
VB client and can trigger events the VB client receives.

Please help!

Regards,
Holger.

Holger Zwingmann

unread,
Aug 8, 2003, 6:52:27 PM8/8/03
to
The solution

The wizard only creates support for a single client. Thus, one has to change
ckSingle to ckMulti in the Initialize method. This solve all problems. Here
is the code generated by the wizard:

procedure TCTest.Initialize;
begin
inherited Initialize;
FConnectionPoints := TConnectionPoints.Create(Self);
if AutoFactory.EventTypeInfo <> nil then
FConnectionPoint := FConnectionPoints.CreateConnectionPoint(
AutoFactory.EventIID, ckSingle, EventConnect)
else FConnectionPoint := nil;
end;

... and here is my changed code supporting events for multiple clients and
ROT registration:

procedure TCTest.Initialize;
begin
inherited Initialize;
FConnectionPoints := TConnectionPoints.Create(Self);
if AutoFactory.EventTypeInfo <> nil then
FConnectionPoint := FConnectionPoints.CreateConnectionPoint(
AutoFactory.EventIID, ckMulti, EventConnect)
// <-- changed ckSingle to ckMulti!!
else FConnectionPoint := nil;

OleCheck(RegisterActiveObject(Self, Class_CStorage,
ActiveObject_Weak, FROTCookie));
end;

destructor TCTest.Destroy;
begin
OleCheck(RevokeActiveObject(FROTCookie, nil));
inherited;
end;


Cheers,
Holger.

"Holger Zwingmann" <holger.z...@p3-solutions.de> schrieb im Newsbeitrag
news:3f341624$1...@newsgroups.borland.com...

0 new messages