DCOM的出接口对应多个接收器问题(200分)

  • 主题发起人 主题发起人 陈东海
  • 开始时间 开始时间

陈东海

Unregistered / Unconfirmed
GUEST, unregistred user!
我的一个相当与聊天的一个小程序(局域网下)
[注:有人说可以用别的方法实现聊天程序,我也知道,只为学习COM:)],
用delphi6做的,ConnectKind:=(ckRunningOrNew)时没问题
但是当把ConnectKind:=(ckRemote)后,把DCOM Server放在别的机器上后出现
了客户端发送消息,服务器端只把此消息返回到发消息的客户端,而别的客户
端没有接收到此消息,本来以为是DCOM权限配置有问题,后来发现不是,
因为在本机上将RemoteMachine:='本机名'后(即用本机的DCOM Server)
也出现此问题,令我百思不得其解,望赐教。
关键代码段如下:

TEventIntf = class(TAutoObject, IConnectionPointContainer, IEventIntf)
private
{ Private declarations }
FConnectionPoints: TConnectionPoints;
FConnectionPoint: TConnectionPoint;
FEvents: IEventIntfEvents;
{ note: FEvents maintains a *single* event sink. For access to more
than one event sink, use FConnectionPoint.SinkList, and iterate
through the list of sinks. }
FObjectID:integer;
public
procedure Initialize; override;
destructor Destroy;override;
protected
{ Protected declarations }
property ConnectionPoints: TConnectionPoints read FConnectionPoints
implements IConnectionPointContainer;
procedure EventSinkChanged(const EventSink: IUnknown); override;
procedure SendText(const Text: WideString); safecall;
function GetEnumerator:IEnumConnections;
end;
function TEventIntf.GetEnumerator:IEnumConnections;
var
Container:IConnectionPointContainer;
ConnectionPoint:IConnectionPoint;
begin

OleCheck(QueryInterface(IConnectionPointContainer,Container));

OleCheck(Container.FindConnectionPoint(AutoFactory.EventIID,ConnectionPoint));

ConnectionPoint.EnumConnections(Result);
end;

procedure TEventIntf.SendText(const Text: WideString);
var
Enum:IEnumConnections;
ConnectData:TConnectData;
Fetched:Cardinal;
begin
Enum:=GetEnumerator;
if Enum<>nil then
begin
while Enum.Next(1,ConnectData,@Fetched)=S_OK do
begin
if ConnectData.pUnk<>nil then
(ConnectData.pUnk as IEventIntfEvents).OnText(Text);//返回消息给各个客户端
end;
end;
end;
 
200分都没人要,好吧,
请问斑竹,我自己解决了能否把分数收回?
 

Similar threads

S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
后退
顶部