function Str2Byte(param1: String): TBytes;
var
n: DWORD;
begin
n := Length(param1);
SetLength(Result, n);
move(param1[1], Result[0], n);
end;过程结束后,这个result的空间释放了吗?
var
n: DWORD;
begin
n := Length(param1);
SetLength(Result, n);
move(param1[1], Result[0], n);
end;过程结束后,这个result的空间释放了吗?
var
A: TBytes;
Str: string;
begin
A := Str2Byte('test');
SetLength(Str, High(A) + 1);
Move(str[1], A[0], High(A) + 1);
ShowMessage(Str);
end;
004A0131 8D55FC lea edx,[ebp-$04] //edx = @data,把data的内存地址作为参数给了Str2Byte
004A0134 B888014A00 mov eax,$004a0188
004A0139 E8F28EFCFF call Str2Byte //里面直接使用[edx]也就是data做为move的参数所以自己管理好data就行了