问题来源: http://www.cnblogs.com/del/archive/2010/04/21/1717584.html#1809298
//方法 1: 共用内存 procedure TForm1.Button1Click(Sender: TObject); var bf: record b1,b2,b3,b4: Byte end; i: Integer absolute bf; begin bf.b1 := $CC; bf.b2 := $DD; bf.b3 := $EE; bf.b4 := $FF; ShowMessageFmt('%x', [i]); //FFEEDDCC end; //方法 2: 位运算 procedure TForm1.Button2Click(Sender: TObject); var i: Integer; begin i := $CC or ($DD shl 8) or ($EE shl 16) or ($FF shl 24); //不用括号也可 ShowMessageFmt('%x', [i]); //FFEEDDCC end; //方法 3: 使用函数 procedure TForm1.Button3Click(Sender: TObject); var i: Integer; begin i := MakeLong(MakeWord($CC,$DD), MakeWord($EE,$FF)); ShowMessageFmt('%x', [i]); //FFEEDDCC end; //方法 4: 从静态数组... procedure TForm1.Button4Click(Sender: TObject); var bs: array[0..3] of Byte; P: PInteger; begin bs[0] := $CC; bs[1] := $DD; bs[2] := $EE; bs[3] := $FF; P := @bs; ShowMessageFmt('%x', [P^]); //FFEEDDCC end; //方法 5: 从动态数组... procedure TForm1.Button5Click(Sender: TObject); var bs: array of Byte; P: PInteger; begin SetLength(bs, 4); bs[0] := $CC; bs[1] := $DD; bs[2] := $EE; bs[3] := $FF; P := @bs[0]; ShowMessageFmt('%x', [P^]); //FFEEDDCC end;