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;
Length(S)+1 可以拷贝字符串最后的 #0
var
str:string;
B:array of byte;
begin
str:='string';
setlength(b,length(str));
move(byte(str[1]),B,length(str));
end;
move(byte(str[1]),B[0],length(str));
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;