procedure TForm1.Button1Click(Sender: TObject);
var
p: Pointer;
str: string;
size: Integer;
begin
str := Edit1.Text;
size := (Length(str) + 1 ) * SizeOf(Char);
p := GetMemory(size);
ZeroMemory(p, size);
CopyMemory(p, @str[1], size);
ShowMessage(PChar(p));
FreeMemory(p);
end;