A
aiken
Unregistered / Unconfirmed
GUEST, unregistred user!
下面的怎么会出错呢?
procedure TForm1.Button1Click(Sender: TObject);
type
OleVariantArray = array[0..65535] of OleVariant;
POleVariantArray = ^OleVariantArray;
var
pVariants: POleVariantArray;
a: Variant;
b: String;
begin
pVariants := POleVariantArray(CoTaskMemAlloc(5 * sizeof(OleVariant)));
if pVariants = nil then Exit;
b := 'Hello world!';
a := b;
pVariants[0] := a; //这一句
button1.Caption := pVariants[0];
if pVariants <> nil then CoTaskMemFree(pVariants);
end;
procedure TForm1.Button1Click(Sender: TObject);
type
OleVariantArray = array[0..65535] of OleVariant;
POleVariantArray = ^OleVariantArray;
var
pVariants: POleVariantArray;
a: Variant;
b: String;
begin
pVariants := POleVariantArray(CoTaskMemAlloc(5 * sizeof(OleVariant)));
if pVariants = nil then Exit;
b := 'Hello world!';
a := b;
pVariants[0] := a; //这一句
button1.Caption := pVariants[0];
if pVariants <> nil then CoTaskMemFree(pVariants);
end;