D
deadeye
Unregistered / Unconfirmed
GUEST, unregistred user!
用下面这个方法,读到的数据每个字节都是零
我试过用move把几个byte copy出来
可以看到数据是有的,不是全零
function OleVariantToMemoryStream(OV: OleVariant): TMemoryStream;
var
Data: PByteArray;
Size: integer;
begin
Result := TMemoryStream.Create;
try
Size := VarArrayHighBound (OV, 1) - VarArrayLowBound(OV, 1) + 1;
if Size = 0 then
begin
if Result <> nil then Result.Free;
Result := nil;
exit;
end;
Data := VarArrayLock(OV);
try
Result.Position := 0;
Result.WriteBuffer(Data^, Size);
finally
VarArrayUnlock(OV);
end;
except
VarArrayUnlock(OV);
Result.Free;
Result := nil;
end;
end;
我试过用move把几个byte copy出来
可以看到数据是有的,不是全零
function OleVariantToMemoryStream(OV: OleVariant): TMemoryStream;
var
Data: PByteArray;
Size: integer;
begin
Result := TMemoryStream.Create;
try
Size := VarArrayHighBound (OV, 1) - VarArrayLowBound(OV, 1) + 1;
if Size = 0 then
begin
if Result <> nil then Result.Free;
Result := nil;
exit;
end;
Data := VarArrayLock(OV);
try
Result.Position := 0;
Result.WriteBuffer(Data^, Size);
finally
VarArrayUnlock(OV);
end;
except
VarArrayUnlock(OV);
Result.Free;
Result := nil;
end;
end;