title: TProcessInfo - Get fullpath of processes
body: <p>I am using this non visual open source component called <a href="http://vcldeveloper.com/products/products-components/process-info/" rel="nofollow">TProcessInfo</a> to get a list of processes, the ProcessID and the full path which I put into a ListView.</p>
  
  <p>The code I am using to do this:</p>
  
  <pre><code>procedure TForm1.FormCreate(Sender: TObject);
  var
    i: integer;
    Process: TProcessItem;
  begin
    for i := 0 to ProcessInfo1.RunningProcesses.Count -1 do
    begin
      Process := ProcessInfo1.RunningProcesses[i];
      with lv.Items.Add do
      begin
        Caption := Process.ExeFile;
        SubItems.Add(IntToStr(Process.ProcessID));
        SubItems.Add(Process.FullPath);
      end;
    end;
  end;
  </code></pre>
  
  <p>The code will always break on the last line: <code>SubItems.Add(Process.FullPath);</code> and I receive an Error Message:</p>
  
  <p>System Error. Code: 87<br>The Parameter is incorrect.</p>
  
  <p>The code that gets the FullPath in the Component is:</p>
  
  <pre><code>function TProcessItem.GetFullPath: TFileName;
  var
    hProcess: THandle;
  begin
    hProcess := OpenProcess(PROCESS_QUERY_INFORMATION or PROCESS_VM_READ,False,FProcessID);
    if hProcess &lt;&gt; 0 then
    begin
      try
        SetLength(Result,MAX_PATH);
        FillChar(Result[1],Length(Result) * SizeOf(Char), 0);
        if GetModuleFileNameEx(hProcess,0,PChar(Result),Length(Result)) &gt; 0 then
          Result := Trim(Result)
        else
         RaiseLastOSError;
      finally
        CloseHandle(hProcess)
      end;
    end
    else
      RaiseLastOSError;
  end;
  </code></pre>
  
  <p>If like the Error states - the parameter is incorrect, then how can I change this?</p>
  
  <p>** The component uses PsAPI and I am using Delphi XE2 on Windows 7 Ultimate x64 also happens on Windows XP Pro x86</p>