本文整理自网络,侵删。
string字符串转换Byte[]字节数组
procedure TForm1.Button1Click(Sender: TObject);var s:string; P:PChar; B:array of Byte;begin s:='Hello'; SetLength(B,Length(S)+1); P:=PChar(S); CopyMemory(B,p,Length(S)+1); Showmessage(Char(B[0]));end;procedure TForm1.Button1Click(Sender: TObject);var s:string; ab:array of byte; i:integer;begin s:='this is a test'; SetLength(ab,Length(s)); for i:=1 to length(s) do ab[i]:=byte(s[i]);end; b: array[1..7] of byte;
s: string;
SetLength(s, 7);
Move(b[1],s[1], 7 );
完美转换
来源:https://blog.csdn.net/xyzhan/article/details/87269775
相关阅读 >>
Delphi timagelist 中使用 透明 png 图标
Delphi xe firemonkey的stylebook皮肤控件的使用
更多相关阅读请进入《Delphi》频道 >>