title: Delphi's Sharemem - When it is not needed
body: <p>I know that when I share <code>strings</code> between a Delphi APP and a Delphi DLL I need to add <code>Sharemem</code> in both app and dll project source as the first unit in uses clause.</p>
  
  <p>But, if the dll exports function that accept only <code>Pchars</code> but inside some of the dll methods I use <code>strings</code>, should I use sharemem as well? Let me shown a sample code:</p>
  
  <pre><code>procedure ShowMyCustomMessage(aMessage : Pchar);
  var
    vUselessString : string;
  begin
    vUselessString := aMessage;
    ShowMessage(vUselessString);
  end;
  
  exports
    ShowMyCustomMessage;
  </code></pre>
  
  <p>In that simple and useless case, the dll is accepting a <code>Pchar</code> but inside the exported method the dll creates a <code>string</code> var. Should I add <code>ShareMem</code> as well?</p>
  
  <p>What about <code>WideString</code>? Does passing <code>WideString</code> parameters require the use of <code>Sharemem</code>?</p>