title: Using CreateProcess to invoke an exe file?
body: <p>Been trying to invoke the Truecrypt exe from my Visual Studio C++ application, but <code>CreateProcess</code> just isn't working. <code>GetLastError()</code> shows <code>127</code>.<br>
  The objective is to invoke the exe <strong>without showing the command window</strong>. Please help. I've tried searching and also reading the <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/ms682425%28v=vs.85%29.aspx" rel="nofollow">CreateProcess parameter explanation</a>.  </p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;iostream&gt;
  #include&lt;Windows.h&gt;
  
  int main( void )
  {
      HANDLE StdInHandles[2]; 
      HANDLE StdOutHandles[2]; 
      HANDLE StdErrHandles[2]; 
  
      CreatePipe(&amp;StdInHandles[0], &amp;StdInHandles[1], NULL, 4096); 
      CreatePipe(&amp;StdOutHandles[0], &amp;StdOutHandles[1], NULL, 4096); 
      CreatePipe(&amp;StdErrHandles[0], &amp;StdErrHandles[1], NULL, 4096); 
  
      STARTUPINFO si;   memset(&amp;si, 0, sizeof(si));  // zero out
  
      si.dwFlags =  STARTF_USESTDHANDLES; 
      si.hStdInput = StdInHandles[0];  // read handle
      si.hStdOutput = StdOutHandles[1];  // write handle 
      si.hStdError = StdErrHandles[1];  // write handle 
      PROCESS_INFORMATION pi; 
      std::cout&lt;&lt; CreateProcess("\"C:\\Program Files\\TrueCrypt\\cmd.exe\\TrueCrypt.exe\"", " //b" , NULL, NULL, FALSE, CREATE_NO_WINDOW , NULL, NULL, &amp;si, &amp;pi)&lt;&lt; "\n" &lt;&lt; GetLastError() &lt;&lt; "\n";
      std::cin.get();
  }
  </code></pre>