function BTDW(b: array of BYTE)
WORD;
var dw,tdw: DWORD;
begin
// b[0]*(2^24)+b[1]*(2^16)+b[2]*(2^8)+b[3]
dw:=0;
tdw:=0;
tdw:=b[0]; dw:= dw+(tdw shl 24);
tdw:=b[1]; dw:=dw+(tdw shl 16);
tdw:=b[2]; dw:=dw+(tdw shl 8);
dw:=dw+b[3];
result := dw;
end;
procedure DWTB(dw: DWORD;var b: array of BYTE);
var tdw: DWORD;
begin
tdw:=$000000ff;
b[0]:=(dw and (tdw shl 24))shr 24;
b[1]:=(dw and (tdw shl 16))shr 16;
b[2]:=(dw and (tdw shl 8))shr 8;
b[3]:=(dw and tdw);
end;
procedure TForm1.Button1Click(Sender: TObject);
var b: array[0..3]of byte;
v,i: integer;
begin
v:=100;
DWTB(v,b);
for i:= 0 to 3 do caption:=caption+format('/%x',[b
]); //注意我是以16进制显示的
end;
procedure TForm1.Button2Click(Sender: TObject);
var b: array[0..3]of byte;
v,i: integer;
begin
b[0]:=0;
b[1]:=0;
b[2]:=0;
b[3]:=$64;
i:= BTDW(b);
caption:=inttostr(i);
end;