title: CReateProcess() API causing Unhandled exception. C++ std:: alternative API for CreateProcess
body: <p>I've a Vc++ code an A.EXE project (MBCS) and a static library project (Unicode). The static library (*.lib) project has the code like below which tries to launch a different exe (pwrtest.exe for example) from within it. BUt the code is crashing when the CReateProcess() statement is executed. </p>
  
  <blockquote>
    <p>Error is  "Unhandled Eception at  (ntdll.dll) in "A.EXE":
    ::Access Vioaltion reading location 0xCCCCCCCC</p>
  </blockquote>
  
  <p>I made sure that the values in appPath &amp; workdir are correct.
  They are values like this ::
  c:\Users\abcd\xyz\somedirectory\abc etc...
  with directory names separated by double slashes "\".</p>
  
  <p>I really don't understand what is the problem.</p>
  
  <p>Also I've put a try catch statement but when I step in to code (F10) on the line CreateProcess() it immidiately crashes and throws exception as above. 
  So it's not even coming to catch statement.</p>
  
  <p><strong>As Create process() is a C API &amp; C types are always prone to memory elaks etc.. , just wondering if there is a C++ STD:: library counterpart (some container function API) which is much simpler but doing the job of CreateProcess() C API.</strong></p>
  
  <pre><code> PROCESS_INFORMATION pI;
      STARTUPINFO         sI;
      LPTSTR              appPath;
      LPTSTR              workDir;
  
      wchar_t cwd[_MAX_PATH];
      GetCurrentDirectory(_MAX_PATH, cwd);
      wchar_t TestEXEPath[_MAX_PATH];
      wcscpy(TestEXEPath, cwd);
  
      wcscat(TestEXEPath, L"\\somedircetory\\abc\\pwrtest.exe /sleep /c:1");
  
      appPath = TestEXEPath;
      wchar_t workDirForTestEXE[_MAX_PATH];
      wcscpy(workDirForTestEXE, cwd);
      wcscat(workDirForTestEXE, L"\\somedirectory\\abc");
      workDir = workDirForTestEXE;
  
      try
      {
          if (!CreateProcess(NULL, appPath, NULL, NULL, FALSE, 0, NULL, workDir, &amp;sI, &amp;pI))
          {
              ......
          }
          {
              ......
          }
      }
      catch (exception&amp; exType)
      {
          std::cout &lt;&lt; "ExType is" &lt;&lt; exType.what() &lt;&lt; endl;
      }
  </code></pre>