title: Concat PChar with string in Delphi
body: <p>I need to construct a string and send it via <code>PostMessage</code>, ie.</p>
  
  <pre><code>FileName := String_1 + String_2 + String_3;
  PostMessage(FWndHandle, WM_BLA_BLA, NotifyData^.Action, LParam(FileName));
  </code></pre>
  
  <p>but something isn't working. Plus, FileName is a PChar. The code looks like this:</p>
  
  <pre><code>var
     FileName : PChar;
     Directory_Str : String;
     AnotherString : String;
  begin
      // Get memory for filename and fill it with data
      GetMem(FileName, NotifyData^.FileNameLength + SizeOf(WideChar));
      Move(NotifyData^.FileName, Pointer(FileName)^, NotifyData^.FileNameLength);
      PWord(Cardinal(FileName) + NotifyData^.FileNameLength)^ := 0;
  
      // TODO: Contact string before sending message
      // FileName := AnotherString + Directory_Str + FileName;
  
      PostMessage(FWndHandle, WM_BLA_BLA, NotifyData^.Action, LParam(FileName));
  
      ...
  end;
  </code></pre>
  
  <p>Now I need to do contact another string to the variable <code>FileName</code> before calling <code>PostMessage</code>, ie.</p>
  
  <pre><code>FileName := AnotherString + Directory_Str + FileName;
  PostMessage(FWndHandle, WM_BLA_BLA, NotifyData^.Action, LParam(FileName));
  </code></pre>
  
  <p>This would work if FileName was a string, which is not the case here.</p>
  
  <p><strong>Anyone knows how to do that with PChar?</strong> I tried these methods, works sometimes but always something breaks at the end:</p>
  
  <pre><code>StrPCopy(FileName, FDirectory + String(FileName));
  </code></pre>
  
  <p>OR</p>
  
  <pre><code>FileName := PChar(AnotherString + Directory_Str + FileName);
  </code></pre>