Mega Code Archive

 
Categories / Delphi / Examples
 

Show values in a hexadecimal representation

Title: show values in a hexadecimal representation? function HexB(b: Byte): string; const HexChar: array[0..15] of char = '0123456789ABCDEF'; begin HexB := HexChar[b shr 4] + HexChar[b and $0F]; end; function HexW(w: Word): string; begin HexW := HexB(Hi(w)) + HexB(Lo(w)); end; function HexL(l: Longint): string; var HL: HiLo absolute l; begin HexL := HexW(HL.HiWord) + HexW(HL.LoWord); end; function HexP(p: Pointer): string; var HL: HiLo absolute p; begin HexP := HexW(HL.HiWord) + ':' + HexW(HL.LoWord); end;