建立的MFC工程,在编译时出现"建立空文档失败"的错误,应该如何解决,报错地方的代码如下:
BOOL CExchApp::InitInstance()
{
HWND A=FindWindow(NULL,"for Exch");
if(A!=NULL)
{
SetForegroundWindow(A);
CloseHandle(A);
return false;
}
AfxEnableControlContainer();
#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(CExchDoc),RUNTIME_CLASS(CMainFrame),RUNTIME_CLASS(CExchView));
AddDocTemplate(pDocTemplate);
CCommandLineInfo cmdInfo; // Parse command line for standard shell commands, DDE, file open
ParseCommandLine(cmdInfo);
if (!ProcessShellCommand(cmdInfo)) // 在这报错
return FALSE;
m_pMainWnd->ShowWindow(SW_SHOW);
m_pMainWnd->UpdateWindow();
m_pMainWnd->SetWindowText("for Exch");
m_pMainWnd->CenterWindow();
return TRUE;
}

解决方案 »

  1.   

    编译能通过,但是调试时会在if (!ProcessShellCommand(cmdInfo)) 这个位置弹对话框"建立空文档失败",
      

  2.   

    你是不是用了  richedit控件?
    用了的话一般要在InitInstance()
    里用AfxInitRich初始化:
      

  3.   

    俺遇到的这种情况,是由于装完了vc6的sp6之后,debug版本的一些dll被替换了,release可以运行,将原来的dll替换回来,debug版本就能运行了。如果楼主跟俺的情况一致,不妨试试。