问题来源: http://www.cnblogs.com/del/archive/2008/11/08/1329543.html#2016234

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;

posted on 2011-01-21 17:43  万一  阅读(2006)  评论(1编辑  收藏  举报