参考一下把
function TCommClient.Send(aData: TStream; const aDestination: String; aTTL: Integer): Integer;
var
V : Variant;
P : Pointer;
L : Integer;
begin
Result := -1;
try
//进行类型转换, 将COM不支持的TStream类型转换为字节数组来传送
L := aData.Size;
if L > 0 then
begin
V := VarArrayCreate([0, L-1], varByte);
P := VarArrayLock(V);
try
aData.Seek(0, soFromBeginning);
aData.ReadBuffer(P^, L);
finally
VarArrayUnlock(V);
end;
if Active then Result := FServer.Send(V, aDestination, aTTL);
end;
except
on E: Exception do
TLogFile.WriteLn('发送数据出错, 错误信息="%s"', [E.Message]);
end;
end;