JulianPugh
asked on
CreateProcess / Command Line Parsing MFC SDI
Want to use CreateProcess to launch another MFC SDI application the First Parameter and passing a file path in the second parameter for the launched program to load. Making the call as follows:
PROCESS_INFORMATION procInfo;
BOOL processStarted;
memset(&suInfo, 0, sizeof(suInfo));
suInfo.cb = sizeof(suInfo);
// Kick off the Next Program
processStarted =
CreateProcess(
"C:\\Program Files\\BuildCustomCatalog\ \Chass_Hea der_New\\C hass_Heade r_New.exe" ,
"C:\\CCBuild\\Commands_New \\9778_W_1 _4B974338. txt",
NULL, // process security attributes
NULL, // thread security attributes
FALSE, // handle inheritance flag
NORMAL_PRIORITY_CLASS, // handle inheritance flag
NULL, // pointer to new environment block
NULL, // pointer to current directory name
&suInfo, // pointer to STARTUPINFO
&procInfo); // pointer to PROCESS_INFORMATION
}
The launched program chokes on this call. If I execute the CreateProcess call using NULL for parameter 2 (Command Line Argument i.e. pass no command line argument), the launched program has no problem. The launched program seems to choke at the "if (!ProcessShellCommand(cmdI nfo)) return FALSE;" call in the CWinApp InitInstance() function when a file path is included in the command line;
Any ideas would be appreciated.
Thanks,
Julian
PROCESS_INFORMATION procInfo;
BOOL processStarted;
memset(&suInfo, 0, sizeof(suInfo));
suInfo.cb = sizeof(suInfo);
// Kick off the Next Program
processStarted =
CreateProcess(
"C:\\Program Files\\BuildCustomCatalog\
"C:\\CCBuild\\Commands_New
NULL, // process security attributes
NULL, // thread security attributes
FALSE, // handle inheritance flag
NORMAL_PRIORITY_CLASS, // handle inheritance flag
NULL, // pointer to new environment block
NULL, // pointer to current directory name
&suInfo, // pointer to STARTUPINFO
&procInfo); // pointer to PROCESS_INFORMATION
}
The launched program chokes on this call. If I execute the CreateProcess call using NULL for parameter 2 (Command Line Argument i.e. pass no command line argument), the launched program has no problem. The launched program seems to choke at the "if (!ProcessShellCommand(cmdI
Any ideas would be appreciated.
Thanks,
Julian
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Alex,
Passed the exe file path and file to load in the second CreateProcess parameter, as you suggested, and everything works perfectly fine. I really appreciate your help.
thanks,
Julian
Passed the exe file path and file to load in the second CreateProcess parameter, as you suggested, and everything works perfectly fine. I really appreciate your help.
thanks,
Julian
When you say the program chokes what do you mean? Throws an exception? Asserts? Hangs forever?
You are calling ProcessShellCommand() after the following commands:
// Parse command line for standard shell commands, DDE, file open
CCommandLineInfo cmdInfo;
ParseCommandLine(cmdInfo);
And after your document has been setup.
The CWinApp::ProcessShellComma
case CCommandLineInfo::FileOpen
if (!OpenDocumentFile(rCmdInf
bResult = FALSE;
break;
Can your document's OpenDocumentFile handle the file name?
Good Luck,
Steve