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")); } }
posted on 2011-04-23 17:00 王亮1 阅读(149) 评论(0) 编辑 收藏 举报