title: get the full path from a PID using delphi
body: <p>I need to get the full path from a PID.</p>
  
  <p>I've checked this question <a href="https://stackoverflow.com/questions/1933113/c-windows-how-to-get-process-path-from-its-pid">C++ Windows - How to get process path from its PID</a> 
  and I wrote the following code:</p>
  
  <pre><code> function GetFullPathFromPID(PID: DWORD): string;
   var
      hProcess: THandle;
      ModName : Array[0..MAX_PATH + 1] of Char;
   begin
     Result:='';
      hProcess := OpenProcess(PROCESS_ALL_ACCESS,False, PID);
      try
        if hProcess &lt;&gt; 0 then
         if GetModuleFileName(hProcess, ModName, Sizeof(ModName))&lt;&gt;0 then
           Result:=ModName
          else
           ShowMessage(SysErrorMessage(GetLastError));
      finally
       CloseHandle(hProcess);
      end;
   end;
  </code></pre>
  
  <p>but always return this message:</p>
  
  <blockquote>
    <p>the specified module could not be found</p>
  </blockquote>
  
  <p>How can I get the full path from a PID?</p>