Code
procedure TForm1.Button1Click(Sender: TObject);
var
A: array of Integer;
P: PLongint;
I: Integer;
begin
SetLength(A, 3);
GetMem(P, SizeOf(PLongint)* 3);
P^ := 3;
Inc(p);
P^ := 33;
Inc(p);
P^ := 333;
Dec(p);
Dec(p);
// CopyMemory(A, p, SizeOf(PLongint) * 3); 俩个方法都可以
Move(P^, a[0], SizeOf(PLongint) * 3);
for I := Low(A) to High(A) do
Memo1.Lines.Add(IntToStr(A[i]));
end;
procedure TForm1.Button2Click(Sender: TObject);
var
A: array of Integer;
P: PLongint;
begin
SetLength(A, 3);
A[0] := 1;
A[1] := 2;
A[2] := 3;
P := PLongint(A);
Dec(P);
ShowMessage(IntToStr(p^)); // 长度
Dec(P);
ShowMessage(IntToStr(p^)); // 计算器
end;
procedure TForm1.Button1Click(Sender: TObject);
var
A: array of Integer;
P: PLongint;
I: Integer;
begin
SetLength(A, 3);
GetMem(P, SizeOf(PLongint)* 3);
P^ := 3;
Inc(p);
P^ := 33;
Inc(p);
P^ := 333;
Dec(p);
Dec(p);
// CopyMemory(A, p, SizeOf(PLongint) * 3); 俩个方法都可以
Move(P^, a[0], SizeOf(PLongint) * 3);
for I := Low(A) to High(A) do
Memo1.Lines.Add(IntToStr(A[i]));
end;
procedure TForm1.Button2Click(Sender: TObject);
var
A: array of Integer;
P: PLongint;
begin
SetLength(A, 3);
A[0] := 1;
A[1] := 2;
A[2] := 3;
P := PLongint(A);
Dec(P);
ShowMessage(IntToStr(p^)); // 长度
Dec(P);
ShowMessage(IntToStr(p^)); // 计算器
end;