When the System unit has a tptrwrapper structure, it provides a very small function: a pointer (pointer) and a pointer address (nativeint) conversion. Obviously, the previously used Integer (p) or PTR (number) has been After not applicable with 64-bit, then use tptrwrapper should be more convenient and more insurance option. Found in the new source Delphi, almost the tptrwrapper as a pointer to use.
{Tptrwrapper fully functional test}procedure tform1.formcreate (sender:tobject);
var
num:integer;
P:pointer;
Address:nativeint;
Pw1,pw2,pw3:tptrwrapper;
B:boolean;
Begin
P: = @num;
Establishment Method 1
PW1: = Tptrwrapper.create (p);
Address: = PW1. Tointeger; Tointeger
//Establishment Method 2
PW2: = tptrwrapper.create (address);
Pinteger (PW2. ToPointer) ^: = 123; ToPointer
showmessage (inttostr (num));//123
//Establish Method 3
PW3: = Tptrwrapper.nilvalue;
Equal operation
B: = PW1 = PW2;
ShowMessage (Booltostr (b, True));
NotEqual operation
B: = PW1 <> PW3;
ShowMessage (Booltostr (b, True));
As the structure of the tptrwrapper, its starting position is stored in the pointer
p: = pointer (PW1);
ShowMessage (IntToStr (Pinteger (p) ^)); 123
//Even so, you can directly convert a number of addresses, or pointers directly to Tptrwrapper
PW3: = Tptrwrapper (address);
ShowMessage (IntToStr (PW3)); similar to 1244823end;