title: How can I get the full command line of all the processes after doing a process walk of the snapshot?
body: <p>So, my goal is to get the full command line of all the currently running processes. Towards that what I do is take a snapshot of processes using the <code>CreateToolhelp32Snapshot</code> API and then do a process walk to store the <code>PROCESSENTRY32</code> type processes in an array called <code>process_list</code>:</p>
  
  <pre><code>BOOL GetProcessList( FILE *f, PROCESSENTRY32* process_list, int process_count)
  {
    HANDLE hProcessSnap;
    HANDLE hProcess;
    PROCESSENTRY32 pe32;
    DWORD dwPriorityClass;
  
  
    hProcessSnap = CreateToolhelp32Snapshot( TH32CS_SNAPPROCESS, 0 );
    if( hProcessSnap == INVALID_HANDLE_VALUE )
    {
      return( FALSE );
    }
  
    // Set the size of the structure before using it.
    pe32.dwSize = sizeof( PROCESSENTRY32 );
  
    // Retrieve information about the first process,
    // and exit if unsuccessful
    if( !Process32First( hProcessSnap, &amp;pe32 ) )
  
    {
      CloseHandle( hProcessSnap );          // clean the snapshot object
      return( FALSE );
    }
    // Now walk the snapshot of processes, and
    // display information about each process in turn
    int i = 0;
    do
    {
      // Retrieve the priority class.
      dwPriorityClass = 0;
      hProcess = OpenProcess( PROCESS_QUERY_INFORMATION|PROCESS_VM_READ, FALSE, pe32.th32ProcessID );
  
      if( hProcess == NULL ) { }
  
      else
      {
        dwPriorityClass = GetPriorityClass( hProcess );
        if( !dwPriorityClass )
        CloseHandle( hProcess );
      }
  
      process_list[i] = pe32;
      i++;
  
    } while( Process32Next( hProcessSnap, &amp;pe32 ) &amp;&amp; i &lt;= process_count);
  
    CloseHandle( hProcessSnap );
    return( TRUE );
  }
  </code></pre>
  
  <p>Now, is it possible to traverse this array of processes and gather the full command line of each of the processes? How can I do that?</p>
  
  <p>If it is important, I will be compiling the code as a 64bit process and would need the full command line for all the processes running on the host machine.</p>