The problem I need to solve is to use the MFC function ProcessShellCommand()in InitInstance() CWinAppto process the Open file with a specific path when the application to open the file is launched by another application.
I have an MFC MDI (Multiple Document Interface) application that is launched by another command-line application, using ShellExecute(), containing the path to the file to open. When compiling with Visual Studio 2005, I do not see a problem with the running application. When compiling with Visual Studio 2013, an application that crashes and I never see the application window.
Starting in the debugger, I see a dialog box with an error that has the name "Microsoft Visual C ++ Runtime Library" with the error message "Debugging error with error!". setting the mfc120ud.dll file and the src \ mfc \ filelist.cpp line file: 221
At this point, I can connect to the application, then click the Retry button in the dialog box. Then, as I continue, I see a Visual Studio error dialog from an unhandled exception that is apparently being thrown KernelBase.dll.
Unhandled exception in 0x76EBC54F in NHPOSLM.exe file: Microsoft C ++ Exception: CInvalidArgException in memory location 0x0014F094.
If I click the Continue button, this time I get another "Debug check failed" from the line src \ mfc \ filelist.cpp: 234
Sleep() Debug->Attach to process Visual Studio 2013 .
- , ProcessShellCommand() , , set, . , , .
ProcessShellCommand View Frame Windows, :
, ProcessShellCommand() , . , , .
, , , ProcesShellCommand() , .
CCommandLineInfo cmdInfo;
if( !ProcessShellCommand( cmdInfo ) )
return FALSE;
ParseCommandLine( cmdInfo );
if( cmdInfo.m_nShellCommand != CCommandLineInfo::FileNew )
{
if (!ProcessShellCommand( cmdInfo ) )
return FALSE;
}
, , , . , , MFC SDI (Single Document Interface) MFC- MDI (Multiple Document Interface), , , New, Open.
, , , , , . , , .
, , - , .
ProcessShellCommand() . CWinApp:: ProcessShellCommand, :
InitInstance CCommandLineInfo
ParseCommandLine.ParseCommandLine CCommandLineInfo::ParseParam ,
.ParseParam CCommandLineInfo,
ProcessShellCommand.ProcessShellCommand .
, InitInstance(), :
CMultiDocTemplate* pDocTemplate;
pDocTemplate = new CMultiDocTemplate(
IDR_NEWLAYTYPE,
RUNTIME_CLASS(CNewLayoutDoc),
RUNTIME_CLASS(CChildFrame),
RUNTIME_CLASS(CNewLayoutView));
AddDocTemplate(pDocTemplate);
CMainFrame* pMainFrame = new CMainFrame;
if (!pMainFrame->LoadFrame(IDR_MAINFRAME))
return FALSE;
m_pMainWnd = pMainFrame;
CLOMCommandLineInfo cmdInfo;
cmdInfo.lang = LANG_ENGLISH;
cmdInfo.sublang = SUBLANG_ENGLISH_US;
ParseCommandLine(cmdInfo);
BOOL success = pMainFrame->ProcessCmdLineLang(cmdInfo.lang, cmdInfo.sublang);
if(!success){
AfxMessageBox(IDS_CMDLINE_LANG_NF,MB_OK,0);
}
if (!ProcessShellCommand(cmdInfo))
return FALSE;
pMainFrame->ShowWindow(SW_SHOWNORMAL);
pMainFrame->UpdateWindow();
, ProcessShellCommand() , . , MDI. , VS 2005 VS2013.
, codeproject, Debug Assertion Error Visual Studio 2010, , , src\mfc\filelist.cpp, , .
cmdInfo, , (*((CCommandLineInfo*)(&(cmdInfo)))).m_strFileName, L "C:\Users\rchamber\Documents\ailan_221.dat". , , ShellExecute().
. . , L "C:\\Users\\rchamber\\Documents\\ailan_221.dat", , -, , .
3/23/2016 -
. Visual Studio 6.0, Visual Studio 2005. InitInstance() CWinApp , .