Q:  How can I turn a memo's contents into a PChar?

A:  See also How do I fill a TMemo from a PChar?
 

function GetMemoSize(TheMemo: TObject): integer;
var i: integer;
begin
  result := 0;
  with (TheMemo as TMemo).lines do
    for i := count - 1 downto 0 do
      result := result + length(strings[i]);
end;

procedure TForm1.Button1Click(Sender: TObject);
var
  buf: PChar;
  SizeOfBuf: word;
begin
  memo1.lines.LoadFromFile('c:\autoexec.bat');
  SizeOfBuf := GetMemoSize(memo1) + 1;  {add 1 for the null terminator}
  buf := AllocMem(SizeOfBuf);
  memo1.GetTextBuf(buf, SizeOfBuf);
  memo2.SetTextBuf(Buf);
  FreeMem(buf, SizeOfBuf);
end;