本文整理自网络,侵删。
//自定义函数,转换十六进制数为十进制数
function HexToInt(Hexa: string): LongWord;
const
ValoresHexa: array['A'..'F'] of integer = (10, 11, 12, 13, 14, 15);
var
nDecimal: LongWord;
nIndex: byte;
begin
nDecimal := 0;
Hexa := Uppercase(Hexa);
for nIndex := Length(Hexa) downto 1 do
if Hexa[nIndex] in ['0'..'9']
then nDecimal := nDecimal + StrToInt(Hexa[nIndex]) *
Trunc(Exp((Length(Hexa) - nIndex) * ln(16)))
else nDecimal := nDecimal + ValoresHexa[Hexa[nIndex]] *
Trunc(Exp((Length(Hexa) - nIndex) * ln(16)));
Result := nDecimal;
end;
相关阅读 >>
Delphi d10.x 在安卓app开发中使用jar包的注意事项
Delphi2010中Delphi class explorer妙用
更多相关阅读请进入《Delphi》频道 >>