Click to See Complete Forum and Search --> : NULL CWinApp pointer in release mode but not debug mode


Ed Peddycoart
April 7th, 1999, 12:49 PM
When I compile my app in debug mode, it works fine. When I compile in Release mode, it crashes. In AfxWinMain, AfxGetApp() returns 0x00000000. The values of the arguments passed to AfxWinMain are

hInstance = 0x00400000
hPrevInstance = 0x00000000
lpCmdLine = ""
nCmdShow = 1

Any suggestions? I have gone through rules 1-3 in the article Why doesn't my project work in release mode? on this site but the suggested changes did not change the results.

Ed

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
int AFXAPI AfxWinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPTSTR lpCmdLine, int nCmdShow)
{
ASSERT(hPrevInstance == NULL);

int nReturnCode = -1;
CWinApp* pApp = AfxGetApp(); // AfxGetApp() returns 0x00000000
//.
//. snipped
//.
}