delphi 读文件到十六进制的函数(Delphi 7 下可用)


本文整理自网络,侵删。

 {函数}
function ReadFileToHex(FileName: string): string;
var
b: Byte;
begin
Result := '';
if not FileExists(FileName) then Exit;
with TMemoryStream.Create do begin
LoadFromFile(FileName);
Position := 0;
while Position < Size do
begin
ReadBuffer(b, 1);
Result := Result + Format('%.2x ', [b]);
end;
Trim(Result);
Free;
end;
end;

{调用}
procedure TForm1.Button1Click(Sender: TObject);
var
str: string;
begin
str := ReadFileToHex('c:\temp\test.txt');
ShowMessage(str);
end;

相关阅读 >>

Delphi memo1 自定义位置插入

Delphi 新版内存表 fdmemtable

Delphi tpath.combine(); {结合路径}

Delphi 获取webbrowser中的图片

Delphi 创建大窗口

Delphi线程池

Delphi xe 分割字符串太方便了

Delphi 打开网页的两种方法

Delphi hex --> string

Delphi 对话框初始地址initialdir

更多相关阅读请进入《Delphi》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...