title: ShellExecute crashes
body: <p>I have a program which crashes on the <code>ShellExecute()</code> instruction. If I use the method <code>system()</code>, all works fine but I have read that <code>system()</code> was evil...</p>
  <p>I'm using Visual Studio 2010 SP1.</p>
  <p>So there is my function which calls ShellExecute:</p>
  <pre><code>ATC_GENERIC_API void __cdecl atcGenericLaunchGAG()
  {
      HINSTANCE ret = ShellExecute( NULL, NULL, &quot;MyExe.exe&quot;, NULL, &quot;C:\\Opt\\&quot;, SW_SHOW );
      if( int(ret) &gt; 32 )
      {
          //OK
          return;
      }
      //NOK
  }
  </code></pre>
  <p>This is the error I have:</p>
  <pre><code>Unhandled exception at 0x640361c3 in Aneto Sol.exe: 0xC0000005: Access violation reading location 0x0ba29bb0.
  </code></pre>
  <p>And the debugger breaks here:</p>
  <pre><code>void __cdecl operator delete(void* p)
  {
  #if !defined(_AFX_NO_DEBUG_CRT) &amp;&amp; defined(_DEBUG)
      _free_dbg(p, _NORMAL_BLOCK);
  #else
      free(p);
  #endif
  }
  </code></pre>
  <p>And that is my call stack:</p>
  <pre><code>mfc100d.dll!operator delete(void * p)  Line 347 + 0xc bytes C++
  mfc100d.dll!operator delete[](void * p)  Line 360 + 0x9 bytes C++
  mfc100d.dll!CPlex::FreeDataChain()  Line 43 + 0xf bytes C++
  mfc100d.dll!CMapPtrToPtr::RemoveAll()  Line 87 C++
  mfc100d.dll!CMapPtrToPtr::FreeAssoc(CMapPtrToPtr::CAssoc * pAssoc)  Line 147 C++
  mfc100d.dll!CMapPtrToPtr::RemoveKey(void * key)  Line 252 C++
  mfc100d.dll!CHandleMap::RemoveHandle(void * h)  Line 230 C++
  </code></pre>
  <p>Is there somebody who already has had this kind of error with ShellExecute or who can explain to me why ShellExecute crashes like that ? Thank you for your help.</p>