Home > Software engineering >  C operation error: the exception in the mail. Exe: 0 xc0000005: Access Violation.
C operation error: the exception in the mail. Exe: 0 xc0000005: Access Violation.

Time:10-27

Compile all, is to run when the exception in the mail. The exe: 0 xc0000005: Access Violation. Play box, seek help from a great god,

 # include "stdafx. H" 

# ifdef AFX_CORE1_SEG
# pragma code_seg (AFX_CORE1_SEG)
# endif

/////////////////////////////////////////////////////////////////////////////
//Standard WinMain implementation
//Can be replaced as long as' AfxWinInit 'is called the first

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

Int nReturnCode=1;
CWinThread * pThread=AfxGetThread ();
CWinApp * pApp=AfxGetApp ();

//AFX internal initialization
if (! AfxWinInit (hInstance, hPrevInstance, lpCmdLine, nCmdShow))
Goto InitFailure;

//App global initializations (rare)
If (pApp!=NULL & amp; & ! PApp - & gt; InitApplication ())
Goto InitFailure;

//Perform specific initializations
if (! PThread - & gt; InitInstance ())
{
If (pThread - & gt; M_pMainWnd!=NULL)
{
TRACE0 (" Warning: Destroying non - NULL m_pMainWnd \ n ");
PThread - & gt; M_pMainWnd - & gt; DestroyWindow ();
}
NReturnCode=pThread - & gt; ExitInstance ();
Goto InitFailure;
}
NReturnCode=pThread - & gt; The Run ();

InitFailure:
# ifdef _DEBUG
//Check for missing AfxLockTempMap calls
If (AfxGetModuleThreadState () - & gt; M_nTempMapLock!=0)
{
The lock count TRACE1 (" Warning: Temp map non - zero % (ld). \ n ",
AfxGetModuleThreadState () - & gt; M_nTempMapLock);
}
AfxLockTempMaps ();
AfxUnlockTempMaps (1);
# endif

AfxWinTerm ();
Return nReturnCode;
}

When something goes wrong yellow pointer to the if (! PThread - & gt; InitInstance ())
{
If (pThread - & gt; M_pMainWnd!=NULL)!!!!!!

To see a lot of information on the Internet, but still not solve,

CodePudding user response:

Your pThread may be empty, in front of you the thread has a problem, or not in this position is available

CodePudding user response:

What about the how to change
I added a pThread=(pThread *) in front malloc (pThread); But hint (pThread *) right parenthesis is wrong
O guide

CodePudding user response:

Check first oneself correctly, try the call stack, and then find a source to go online to check the reason, general this kind of mistake is the cause of the pointer is null, the hope can help you,

CodePudding user response:

 # include "stdafx. H" 

# ifdef AFX_CORE1_SEG
# pragma code_seg (AFX_CORE1_SEG)
# endif

/////////////////////////////////////////////////////////////////////////////
//Standard WinMain implementation
//Can be replaced as long as' AfxWinInit 'is called the first



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

Int nReturnCode=1;

CWinThread * pThread=AfxGetThread ();

CWinApp * pApp=AfxGetApp ();

//AFX internal initialization
if (! AfxWinInit (hInstance, hPrevInstance, lpCmdLine, nCmdShow))
Goto InitFailure;

//App global initializations (rare)
If (pApp!=NULL & amp; & ! PApp - & gt; InitApplication ())
Goto InitFailure;

//Perform specific initializations



if (! PThread - & gt; InitInstance ())
{
If (pThread - & gt; M_pMainWnd!=NULL)
{
TRACE0 (" Warning: Destroying non - NULL m_pMainWnd \ n ");
PThread - & gt; M_pMainWnd - & gt; DestroyWindow ();
}
NReturnCode=pThread - & gt; ExitInstance ();
Goto InitFailure;
}
NReturnCode=pThread - & gt; The Run ();

InitFailure:
# ifdef _DEBUG
//Check for missing AfxLockTempMap calls
If (AfxGetModuleThreadState () - & gt; M_nTempMapLock!=0)
{
The lock count TRACE1 (" Warning: Temp map non - zero % (ld). \ n ",
AfxGetModuleThreadState () - & gt; M_nTempMapLock);
}
AfxLockTempMaps ();
AfxUnlockTempMaps (1);
# endif

AfxWinTerm ();
Return nReturnCode;

}


Don't know what to move now errors point to
If (pApp!=NULL & amp; & ! PApp - & gt; InitApplication ())
Goto InitFailure;
The

CodePudding user response:

To create a similar engineering, himself than the ~

CodePudding user response:

It should be
# include "stdafx. H"
# include "afxwin. H"

Void main ()
{
if (! AfxWinInit (: : GetModuleHandle (NULL), NULL, : : GetCommandLine (), 0))
{
//TODO: change the error code to fit your needs
_tprintf (_T (" error: [English] failed to initiate the MFC \ n "));
}
?

CodePudding user response:

The
reference

should be# include "stdafx. H"
# include "afxwin. H"

Void main ()
{
if (! AfxWinInit (: : GetModuleHandle (NULL), NULL, : : GetCommandLine (), 0))
{
//TODO: change the error code to fit your needs
_tprintf (_T (" error: [English] failed to initiate the MFC \ n "));
}
?


After I added these lines, now become CWinApp * pApp=AfxGetApp (); Wrong again, and the same problems

CodePudding user response:

nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related