title: CreateProcess not in primary thread
body: <p>I use CreateProcess() to start a other programm from my C++ code. 
  The <a href="https://msdn.microsoft.com/en-us/library/windows/desktop/ms682425%28v=vs.85%29.aspx" rel="nofollow">helppage</a> says that it</p>
  
  <blockquote>
    <p>Creates a new process and its primary thread. The new process runs in the security context of the calling process.</p>
  </blockquote>
  
  <p>I would like to have it in his own thread, so the application would keep on going. Is there any simple way to do so? I am not familar with boost and Co.</p>
  
  <p>My code: </p>
  
  <pre><code>bool startup(LPWSTR lpApplicationName)
  {
     STARTUPINFO si;
      PROCESS_INFORMATION pi;
  
      ZeroMemory( &amp;si, sizeof(si) );
      si.cb = sizeof(si);
      ZeroMemory( &amp;pi, sizeof(pi) );
  
      // Start the child process. 
      if( !CreateProcess( NULL,   // No module name (use command line)
          lpApplicationName,        // Command line
          NULL,           // Process handle not inheritable
          NULL,           // Thread handle not inheritable
          FALSE,          // Set handle inheritance to FALSE
          0,              // No creation flags
          NULL,           // Use parent's environment block
          NULL,           // Use parent's starting directory 
          &amp;si,            // Pointer to STARTUPINFO structure
          &amp;pi )           // Pointer to PROCESS_INFORMATION structure
      ) 
      {
          printf( "CreateProcess failed (%d).\n", GetLastError() );
          return false;
      }
  
      // Wait until child process exits.
      WaitForSingleObject( pi.hProcess, INFINITE );
  
      // Close process and thread handles. 
      CloseHandle( pi.hProcess );
      CloseHandle( pi.hThread );
      return true;
  }
  </code></pre>
  
  <p>and how to call the function: </p>
  
  <pre><code>int _tmain(int argc, _TCHAR* argv[])
  {
  wchar_t path[] = L"C:\\path\\to\\paridise.exe";
  startup(path);
  }
  </code></pre>