title: CreateProcess() fails with an access violation
body: <p>My aim is to execute an external executable in my program. First, I used <code>system()</code> function, but I don't want the console to be seen to the user. So, I searched a bit, and found <code>CreateProcess()</code> function. However, when I try to pass a parameter to it, I don't know why, it fails. I took this code from MSDN, and changed a bit: </p>
  
  <pre><code>#include &lt;windows.h&gt;
  #include &lt;stdio.h&gt;
  #include &lt;tchar.h&gt;
  
  void _tmain( int argc, TCHAR *argv[] )
  {
      STARTUPINFO si;
      PROCESS_INFORMATION pi;
  
      ZeroMemory( &amp;si, sizeof(si) );
      si.cb = sizeof(si);
      ZeroMemory( &amp;pi, sizeof(pi) );
      /*
      if( argc != 2 )
      {
          printf("Usage: %s [cmdline]\n", argv[0]);
          return;
      }
      */
      // Start the child process. 
      if( !CreateProcess( NULL,   // No module name (use command line)
          L"c:\\users\\e\\desktop\\mspaint.exe",        // 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;
      }
  
      // Wait until child process exits.
      WaitForSingleObject( pi.hProcess, INFINITE );
  
      // Close process and thread handles. 
      CloseHandle( pi.hProcess );
      CloseHandle( pi.hThread );
  }
  </code></pre>
  
  <p>However, this code crated access violation somehow. Can I execute mspaint without showing user the console? </p>
  
  <p>Thank you very much. </p>