在调试别人的程序(以下是InitInstance函数) // CG: The following block was added by the Splash Screen component.
\
{
\
CCommandLineInfo cmdInfo;
\
ParseCommandLine(cmdInfo);
\\
CSplashWnd::EnableSplashScreen(cmdInfo.m_bShowSplash);
\
}
AfxInitRichEdit();
AfxEnableControlContainer(); // Standard initialization
// If you are not using these features and wish to reduce the size
// of your final executable, you should remove from the following
// the specific initialization routines you do not need.#ifdef _AFXDLL
Enable3dControls(); // Call this when using MFC in a shared DLL
#else
Enable3dControlsStatic(); // Call this when linking to MFC statically
#endif // Change the registry key under which our settings are stored.
// TODO: You should modify this string to be something appropriate
// such as the name of your company or organization.
SetRegistryKey(_T("Local AppWizard-Generated Applications")); LoadStdProfileSettings(); // Load standard INI file options (including MRU) // Register the application's document templates. Document templates
// serve as the connection between documents, frame windows and views. CSingleDocTemplate* pDocTemplate;
pDocTemplate = new CSingleDocTemplate(
IDR_MAINFRAME,
RUNTIME_CLASS(CSEGDDoc),
RUNTIME_CLASS(CMainFrame), // main SDI frame window
RUNTIME_CLASS(CSEGDView));
AddDocTemplate(pDocTemplate); // Parse command line for standard shell commands, DDE, file open
CCommandLineInfo cmdInfo;
ParseCommandLine(cmdInfo);
// Dispatch commands specified on the command line
// if (!ProcessShellCommand(cmdInfo))
// return FALSE;
try{
m_pMainWnd->ShowWindow(SW_SHOW);
m_pMainWnd->UpdateWindow();
}
// catch(...)
catch( CException* e )
{
TRACE("InitInstance Error!\n");
AfxMessageBox("系统初始化出错!");
}
return TRUE;一旦运行到showwindow那行的时候就会跳出unhandled exception mfc42d.dll access violation的对话框,若是继续执行则会跳到winocc.cpp中BOOL CWnd::ShowWindow(int nCmdShow)
{
ASSERT(::IsWindow(m_hWnd));-----》黄色箭头移动到这里了。 if (m_pCtrlSite == NULL)
return ::ShowWindow(m_hWnd, nCmdShow);
else
return m_pCtrlSite->ShowWindow(nCmdShow);
}
请问导致以上现象是什么原因,怎么解决?
\
{
\
CCommandLineInfo cmdInfo;
\
ParseCommandLine(cmdInfo);
\\
CSplashWnd::EnableSplashScreen(cmdInfo.m_bShowSplash);
\
}
AfxInitRichEdit();
AfxEnableControlContainer(); // Standard initialization
// If you are not using these features and wish to reduce the size
// of your final executable, you should remove from the following
// the specific initialization routines you do not need.#ifdef _AFXDLL
Enable3dControls(); // Call this when using MFC in a shared DLL
#else
Enable3dControlsStatic(); // Call this when linking to MFC statically
#endif // Change the registry key under which our settings are stored.
// TODO: You should modify this string to be something appropriate
// such as the name of your company or organization.
SetRegistryKey(_T("Local AppWizard-Generated Applications")); LoadStdProfileSettings(); // Load standard INI file options (including MRU) // Register the application's document templates. Document templates
// serve as the connection between documents, frame windows and views. CSingleDocTemplate* pDocTemplate;
pDocTemplate = new CSingleDocTemplate(
IDR_MAINFRAME,
RUNTIME_CLASS(CSEGDDoc),
RUNTIME_CLASS(CMainFrame), // main SDI frame window
RUNTIME_CLASS(CSEGDView));
AddDocTemplate(pDocTemplate); // Parse command line for standard shell commands, DDE, file open
CCommandLineInfo cmdInfo;
ParseCommandLine(cmdInfo);
// Dispatch commands specified on the command line
// if (!ProcessShellCommand(cmdInfo))
// return FALSE;
try{
m_pMainWnd->ShowWindow(SW_SHOW);
m_pMainWnd->UpdateWindow();
}
// catch(...)
catch( CException* e )
{
TRACE("InitInstance Error!\n");
AfxMessageBox("系统初始化出错!");
}
return TRUE;一旦运行到showwindow那行的时候就会跳出unhandled exception mfc42d.dll access violation的对话框,若是继续执行则会跳到winocc.cpp中BOOL CWnd::ShowWindow(int nCmdShow)
{
ASSERT(::IsWindow(m_hWnd));-----》黄色箭头移动到这里了。 if (m_pCtrlSite == NULL)
return ::ShowWindow(m_hWnd, nCmdShow);
else
return m_pCtrlSite->ShowWindow(nCmdShow);
}
请问导致以上现象是什么原因,怎么解决?
应该是CMainFrame创建失败
CCommandLineInfo cmdInfo;
ParseCommandLine(cmdInfo);
在MFC种,ParseCommandLine需要框架已经被建立,而你这段代码加在最前方,很显然不满足这个条件
楼主看看call stack,看看是在InitInstance那行调用进入你那个异常点的,很怀疑你这个splash window component是否可以这么用
同时,ParseCommandLine(cmdInfo); 前面的注释掉看看.
你的意思是改成这样?最前面的那个cmdinfo的两行代码注释掉了,但是运行到showwindow的时候仍然报同样的错误。 CCommandLineInfo cmdInfo;
ParseCommandLine(cmdInfo);
// Dispatch commands specified on the command line
// if (!ProcessShellCommand(cmdInfo))
// return FALSE;
try{
m_pMainWnd->ShowWindow(SW_SHOW);
m_pMainWnd->UpdateWindow(); m_pMainWnd->ShowWindow(SW_SHOW);
m_pMainWnd->UpdateWindow(); CSplashWnd::EnableSplashScreen(cmdInfo.m_bShowSplash);
引用 1 楼 conry 的回复:
CMainFrame的代码都加什么东西了
应该是CMainFrame创建失败
我在CMAINFrame的构造函数以及oncreate的首行语句均下了断点,可是并没有执行到那就已经报错了
鼠标晃过去看看值 就是报错也有个value的吧 0x00000000?
m_hWnd CXX0033: Error: error in OMF type information