title: Get string return value from C DLL in Delphi
body: <p>I have a legacy DLL written in C that contains a function that returns a string, and I need to access this function from Delphi. The only info I have about the DLL is the VB declare for accessing the function:</p>
  
  <p>Public Declare Function DecryptStr Lib "strlib" (Str As String) As String </p>
  
  <p>I've tried the following without success:</p>
  
  <p>Declaration:</p>
  
  <pre><code>function DecryptStr(s: PChar): PChar; cdecl; external 'strlib.dll';
  </code></pre>
  
  <p>Usage:</p>
  
  <pre><code>var
    p1, p2 : pchar;
  begin
    GetMem( p1, 255 );
    StrPCopy( p2, 'some string to decrypt' );
    p1 := DecryptStr( p2 );
  end;
  </code></pre>
  
  <p>This consistently crashes the DLL with an Access Violation. I'm at a loss.</p>
  
  <p>Any suggestions ?</p>