演示等待通过CreateProcess创建的进程结束
2013-08-08 21:03
351 查看
功能:演示等待通过CreateProcess创建的进程结束 #include <stdio.h> #include <Windows.h> int main() { STARTUPINFO si; PROCESS_INFORMATION pi; memset( &si, 0x00, sizeof(si) ); si.cb = sizeof(si); memset( &pi, 0x00, sizeof(pi) ); // Start the child process. if ( CreateProcess( L"c:\\windows\\system32\\cmd.exe", // No module name (use command line) NULL, // Command line NULL, // Process handle not inheritable NULL, // Thread handle not inheritable FALSE, // Set handle inheritance to FALSE 0, // No creation flags NULL, // Use parent's environment block NULL, // Use parent's starting directory &si, // Pointer to STARTUPINFO structure &pi ) ) { DWORD oldTime =GetTickCount(); DWORD dwRetun=0; WaitForSingleObject(pi.hProcess,INFINITE); DWORD newTime=GetTickCount(); DWORD dwTime=(newTime-oldTime)/1000; GetExitCodeProcess(pi.hProcess,&dwRetun); printf("程序运时长: dwTime = %d 退出时返回值: %d\n", dwTime, dwRetun); getchar(); } return 0; }
相关文章推荐
- Linux下利用fork()创建子进程并使父进程等待子进程结束
- 创建进程CreateProcess,结束进程 TerminateProcess
- C程序完成:父进程创建一个子进程,父进程对子进程设置一个报警信号,然后父进程等待子进程的结束,如果此时报警信号先到,就终止子进程。
- 通过回调函数阻止进程创建(验证结束,方案完全可行)
- 通过“CreateProcess”创建新的“进程”
- 使用createprocess()创建进程打开其他文件方法
- 创建进程并等待其退出
- VC++ 创建进程并等待其退出
- delphi 如何等待进程树的结束
- 详解CreateProcess调用内核创建进程的过程
- 通过HOOK控制进程的创建
- C++通过TerminateProess结束进程实例
- fork新建进程——父进程等待子进程结束
- windows下创建进程,CreateProcess()详解及用法
- shell同时启多个进程,并等待所有子进程结束,再做接下来的操作,最好能获取每个子进程的退出状态
- CreateProcess创建的子进程的命令行参数
- 进程控制编程之僵尸进程、守护进程创建、进程等待
- CreateProcess创建一个隐藏进程
- Linux系统编程——进程的控制:结束进程、等待进程结束
- 创建新进程,然后等待结果