var Str, tStr: String; hFile: TextFile; Len: Integer; Buf: PChar; begin AssignFile(hFile,'File Name'); Reset(hFile); while not Eof(hFile) do begin ReadLn(hFile,tStr); Str:=Str+tStr; end; Len:=Length(Str) div 2; GetMem(Buf,Len); HexToBin(PChar(Str),Buf,Len); //Buf里即为想要的数据 //做你想做的事 FreeMem(Buf); end;
因此你只有自己写代码来进行转换了。读入每一个字节,然后使用StrToInt(delphi7)就可以了。
s: char;
i: Integer;s:='2E';
i:=strtoint('0x'+s);
showmessage(inttostr(i));
显示46
你最好把tt.hex的内容贴出来,看看有没有人帮你写出代码来。
Str, tStr: String;
hFile: TextFile;
Len: Integer;
Buf: PChar;
begin
AssignFile(hFile,'File Name');
Reset(hFile);
while not Eof(hFile) do
begin
ReadLn(hFile,tStr);
Str:=Str+tStr;
end; Len:=Length(Str) div 2;
GetMem(Buf,Len);
HexToBin(PChar(Str),Buf,Len); //Buf里即为想要的数据 //做你想做的事 FreeMem(Buf);
end;
数据存储肯定是2进制的,无论内存还是硬盘。
只不过显示的时候有区别而已。
比如一个文本文件,内容为一个字节 '1'
表示为16进制为0x31,表示为8位2进制为00110001,表示为Asc码为'1';
Windows 32位系统内存中一般存储为0x31 0x00 0x00 0x00