function Int2Hex(Value: Integer): string;
var
iTemp: Integer;
i: Integer;
begin
Result := '';
i := 0;
while i<4 do
begin
case i of
0: iTemp := Value shr 24 and $FF;
1: iTemp := Value shr 16 and $FF;
2: iTemp := Value shr 8 and $FF;
3: iTemp := Value and $FF;
end;
if not Boolean(iTemp) then Result := Result + '00'
else begin
Result := Result + HexArr[iTemp div 16];
Result := Result + HexArr[iTemp mod 16];
end;
Inc(i);
end;
end;
測試:ShowMessage(Int2Hex(-1)); //顯示FFFFFFFF
ShowMessage(Int2Hex(MAXINT)); //顯示7FFFFFFF
希望大家多提意見,個人覺得挺簡潔明了了,呵呵,很明顯每步在做什麼