您的位置:首页 > 其它

创建进程和退出进程

2011-04-23 17:00 190 查看
bool CCreateProcessDlg::ProcessExec(LPCTSTR fileName)
{

if(!CreateProcess(fileName,NULL,NULL,NULL,NULL,CREATE_NEW_CONSOLE,NULL,NULL,NULL,&processInfo))
{
return FALSE;
}

//CloseHandle(processInfo.hThread);
//CloseHandle(processInfo.hProcess);

return TRUE;
}
void CCreateProcessDlg::OnBnClickedButtonExec()
{
// TODO: Add your control notification handler code here
ProcessExec(_T("iesample"));
}

void CCreateProcessDlg::OnBnClickedButtonExit()
{
// TODO: Add your control notification handler code here
DWORD exitCode;
//ExitProcess(exitCode);

if(TerminateProcess(processInfo.hProcess,exitCode))
{
MessageBox(_T("exit iesample.exe success"));
if(ExitProcess(exitCode))
{
MessageBox(_T("exit CreateProcess.exe success"));
}
else
{
MessageBox(_T("exit CreateProcess.exe success"));
}
}
else
{
MessageBox(_T("exit iesample.exe fail"));
}

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: