保存数据到 olevariant

类别:Delphi 点击:0 评论:0 推荐:
function TTAutoTest.Getobj: OleVariant;
var t:Tdataclass;
    ms:tmemorystream;
begin
  t := TDataclass.create(nil);
  ms := Tmemorystream.create;
  try
  t.Savetostream(ms);
  result := vararraycreate([0,ms.size-1],varbyte);
  ms.position := 0;
  ms.readbuffer(varArrayLock(result)^, ms.size);
  finally
    t.free;
    ms.free;
    varArrayunlock(result);
  end;
end;

本文地址:http://com.8s8s.com/it/it4802.htm