本文整理自网络,侵删。
//本示例的目的是说明Classes单元中的BinToHex和HexToBin方法。此代码会将二进制值转换为其十六进制表示形式并返回。
procedure Tfrm1.btnToStringClick(Sender: TObject);
var LStr1, LStr2: WideString;
begin { Store the text in the memo to a String variable. } LStr1 := Memo2.Lines.Text; { Set the length of the String to hold the conversion. } SetLength(LStr2, Length(LStr1) div 4); { Call the hexadecimal to binary conversion procedure. } HexToBin(PWideChar(LStr1), LStr2[1], Length(LStr1) div SizeOf(Char)); { Output the results to Memo1. } Memo1.Lines.Text := LStr2;end;
procedure Tfrm1.btToHexClick(Sender: TObject);var LStr1, LStr2: String;
begin { Store the text in the memo to a String variable. } LStr1 := Memo1.Lines.Text; { Set the length of the String to hold the conversion. } SetLength(LStr2, Length(LStr1) * 4); { Call the binary to hexadecimal conversion procedure. } BinToHex(LStr1[1], PWideChar(LStr2), Length(LStr1) * SizeOf(Char)); { Put the results in Memo2. } Memo2.Lines.Text := LStr2;end;
相关阅读 >>
Delphi http协议验证访问datasnap rest 服务器
Delphi shgetfileinfo函数获取任何文件大图标
Delphi clientdataset 与fdmemtable 创建 字段与追加记录
Delphi 数据类型cardinal 怎么转换成 string?
更多相关阅读请进入《Delphi》频道 >>