----急:执行外部exe文件,捕捉输出到文件????----
我是这样写的,可文件里什么都没有.
STARTUPINFO si;
PROCESS_INFORMATION pi;
ZeroMemory( &si, sizeof(si) );
si.cb = sizeof(si);
ZeroMemory( &pi, sizeof(pi) );
si.dwFlags=STARTF_USESHOWWINDOW|STARTF_USESTDHANDLES;
CFile Outputfile;
Outputfile.Open("C:\\err.txt",CFile::modeCreate | CFile::modeReadWrite);
si.hStdError = Outputfile;
// Start the child process.
if( !CreateProcess( NULL, // No module name (use command line).
_T("xmpr kxm_counter_32.med /v kxm_counter_32.vhd"), // Command line.
NULL, // Process handle not inheritable.
NULL, // Thread handle not inheritable.
FALSE, // Set handle inheritance to FALSE.
CREATE_NO_WINDOW|STARTF_USESTDHANDLES,
NULL, // Use parent's environment block.
NULL, // Use parent's starting directory.
&si, // Pointer to STARTUPINFO structure.
&pi ) // Pointer to PROCESS_INFORMATION structure.
)
{
AfxMessageBox(_T("CreateProcess failed." ), MB_OK|MB_ICONEXCLAMATION);
}
// Wait until child process exits.
WaitForSingleObject( pi.hProcess, INFINITE );
// Close process and thread handles.
CloseHandle( pi.hProcess );
CloseHandle( pi.hThread );
Outputfile.Close();