procedure VariantToBuff(Const Data: OleVariant;
Bufointer;
Var Len:Integer);
var
P: Pointer;
begin
Len:=VarArrayHighBound(Data, 1)+1;
Buf:=AllocMem(Len);
P := VarArrayLock(Data);
Try
if Len>0 then
CopyMemory(Buf,P,Len);
Finally
VarArrayUnlock(Data);
end;
end;
function BuffToVariant(Var Buf;
Len:Integer): OleVariant;
var
P: Pointer;
begin
Result := VarArrayCreate([0, Len -1],Varbyte);
P := VarArrayLock(Result);
Try
if Len>0 then
CopyMemory(P, PChar(@Buf),Len);
Finally
VarArrayUnlock(Result);
end;
end;