title: Way to pass argv[] to CreateProcess()
body: <p>My C Win32 application should allow passing a full command line for another program to start, e.g.</p>
  
  <pre><code>myapp.exe /foo /bar "C:\Program Files\Some\App.exe" arg1 "arg 2"
  </code></pre>
  
  <p><code>myapp.exe</code> may look something like</p>
  
  <pre><code>int main(int argc, char**argv)
  {
    int i;
  
    for (i=1; i&lt;argc; ++i) {
       if (!strcmp(argv[i], "/foo") {
          // handle /foo
       } else if (!strcmp(argv[i], "/bar") {
          // handle /bar
       } else {
          // not an option =&gt; start of a child command line
          break;
       }
    }
  
    // run the command
    STARTUPINFO si;
    PROCESS_INFORMATION pi;
    // customize the above...
  
    // I want this, but there is no such API! :(
    CreateProcessFromArgv(argv+i, NULL, NULL, FALSE, 0, NULL, NULL, &amp;si, &amp;pi);
  
    // use startup info si for some operations on a process
    // ...
  }
  </code></pre>
  
  <p>I can think about some workarounds:</p>
  
  <ul>
  <li>use <a href="http://msdn.microsoft.com/en-us/library/ms683156.aspx" rel="noreferrer"><code>GetCommandLine()</code></a>
  and find a substring corresponding to argv[i]</li>
  <li>write something similar to <a href="http://msdn.microsoft.com/en-us/library/system.diagnostics.processstartinfo.arguments%28VS.90%29.aspx#1" rel="noreferrer"><code>ArgvToCommandLine()</code></a> also mentioned in <a href="https://stackoverflow.com/questions/2611044/process-start-pass-html-code-to-exe-as-argument/2611075#2611075">another SO question</a></li>
  </ul>
  
  <p>Both of them lengthy and re-implement cumbersome windows command line parsing logic, which is already a part of <a href="http://msdn.microsoft.com/en-us/library/bb776391.aspx" rel="noreferrer"><code>CommandLineToArgvW()</code></a>.</p>
  
  <p>Is there a "standard" solution for my problem? A standard (Win32, CRT, etc.) implementation of workarounds counts as a solution.</p>