相关函数可参考MFC帮助文档; 高水平的大山pclass自觉的酒窝/p {
公共:
CExeCommandLine (
{m_si.CB=sizeof(m_si ); //窗口隐藏cmd窗口;
m _ si.dwflags=startf _ use show window|startf _ usestdhandles;
m_si.wShowWindow=SW_HIDE;
(} ~CExeCommandLine () ) ) )。
{
TerminateExe (;
} private:
STARTUPINFO m_si;
PROCESS_INFORMATION m_pi; 公共:
ool execmd (字符串矩阵) )。
{
//开始the child process。
if (! createprocess (空,//nomodulename ) usecommandline )。
strexecmd.getbuffer(0),//Command line。
空值,//Process handle not inheritable。
空值,//Thread handle not inheritable。
FALSE,//Set handle inheritance to FALSE。
0,//no创建标志。
NULL,//use parent ' s环境块。
空值,//Use parent's starting directory。
m_si,//pointertostartupinfostructure。
m _ pi//pointertoprocess _ information structure。
)
{
//error exit (' createprocess failed.' ); 返回0;
}strExecmd.ReleaseBuffer (; 高山p返回真; } BOOL TerminateExe () ) )。
{
if(m_pi.hprocessm_pi.hthread ) )。
{
DWORD dwEC=0; BOOL b=GetExitCodeProcess (
m_pi.hProcess,//handle to the process
dwec//终端状态
); 是if(b )
{
}//close process and thread handles。
closehandle(m_pi.hprocess;
closehandle(m_pi.hthread;
}
m_si.CB=sizeof(m_si ); 返回真;
};