本帖最后由 冥界3大法王 于 2024-2-28 21:29 编辑
无费话,上代码:
编码页,不是我家编的,那是从Delphi帮助中前往微软网站上获得的。
[Delphi] 纯文本查看 复制代码
function FileToHex(const AFileName: string): string; //转换函数是本论坛热心 坛友编的
var
Stream: TFileStream;
Buffer: array[0..255] of Byte;
BytesRead: Integer;
begin
Result := '';
try
try
Stream := TFileStream.Create(AFileName, fmOpenRead);
while True do
begin
BytesRead := Stream.Read(Buffer, SizeOf(Buffer));
if BytesRead = 0 then
Break;
for var I := 0 to BytesRead - 1 do
Result := Format('%s %.2x', [Result, Buffer[I]]);
end;
Result := Trim(Result);
except
on E: Exception do
ShowMessage('Error reading file: ' + E.Message);
end;
finally
Stream.Free;
end;
end;
procedure TForm7.得到输入的字串后遍历方式生成编码对应的机器码列表Click(Sender: TObject);
var
PQ: Integer;
strQ: string;
begin
for PQ := 1 to ListBox1.Items.Count - 1 do
begin
RichViewEdit1.SaveText('c:\Hello1.txt', 0, ListBox1.Items[PQ].ToInteger);
strQ := FileToHex('c:\Hello1.txt');
ListBox4.Items.Add(strQ);
ListBox4.Update;
end;
end;
总是不能保证,所有的结果,一对一全部对应上,这是何故? |