非常简单啊,比如说你定义一个COM接口函数供客服端调用,带一个形参,类型为OleVariant类型,利用函数把TMemoryStream转换成OleVariant,服务器应用程序接受到以后把OleVariant转换成TMemoryStream,然后提交就OK了。
procedure VariantToStream (const v : olevariant;
Stream : TMemoryStream);
var
p : pointer;
begin
Stream.Position := 0;
Stream.Size := VarArrayHighBound (v, 1) - VarArrayLowBound (v, 1) + 1;
p := VarArrayLock (v);
Stream.Write (p^, Stream.Size);
VarArrayUnlock (v);
Stream.Position := 0;
end;
procedure StreamToVariant (Stream : TMemoryStream;
var v : OleVariant);
var
p : pointer;
begin
v := VarArrayCreate ([0, Stream.Size - 1], varByte);
p := VarArrayLock (v);
Stream.Position := 0;
Stream.Read (p^, Stream.Size);
VarArrayUnlock (v);
end;
我看没有什么问题了吧!