function HexToInt(Str:string):int64;
var
temp:int64;
i,tmp:integer;
begin
temp:=0;
for i:=1 to length(str)do
begin
case ord(str) of
48..57:tmp:=strtoint(str);
65..70,97..102:tmp:=strtoint('$'+str);
else
tmp:=0;
end;
temp:=temp+tmp*round(exp((length(str)-i)*ln(16)));
end;
result:=temp;
end;