----急:执行外部exe文件,捕捉输出到文件????----

huizhuo 2004-08-27 04:53:20
我是这样写的,可文件里什么都没有.
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();
...全文
72 回复 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

7,539

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 VC.NET
社区管理员
  • VC.NET社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧