I have a program which crashes on the ShellExecute()
instruction. If I use the method system()
, all works fine but I have read that system()
was evil...
I'm using Visual Studio 2010 SP1.
So there is my function which calls ShellExecute:
ATC_GENERIC_API void __cdecl atcGenericLaunchGAG()
{
HINSTANCE ret = ShellExecute( NULL, NULL, "MyExe.exe", NULL, "C:\\Opt\\", SW_SHOW );
if( int(ret) > 32 )
{
//OK
return;
}
//NOK
}
This is the error I have:
Unhandled exception at 0x640361c3 in Aneto Sol.exe: 0xC0000005: Access violation reading location 0x0ba29bb0.
And the debugger breaks here:
void __cdecl operator delete(void* p)
{
#if !defined(_AFX_NO_DEBUG_CRT) && defined(_DEBUG)
_free_dbg(p, _NORMAL_BLOCK);
#else
free(p);
#endif
}
And that is my call stack:
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++
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.
As Cory Nelson said, the error is not in the API itself, but in MFC. There might be a ShellExecute hook that causes your application to crash.