运行Windows程序并检测它何时以C结尾
发布时间:2020-12-13 20:44:13 所属栏目:Windows 来源:网络整理
导读:假设我运行一个应用程序,一段时间后这个应用程序将被用户关闭.是否有可能找出程序何时退出?我可以在运行该应用程序时获取它的进程ID吗? 这是 here的引用: #include windows.h#include stdio.h#include tchar.h#include conio.hvoid _tmain( int argc,TCHA
假设我运行一个应用程序,一段时间后这个应用程序将被用户关闭.是否有可能找出程序何时退出?我可以在运行该应用程序时获取它的进程ID吗?
这是
here的引用:
#include <windows.h> #include <stdio.h> #include <tchar.h> #include <conio.h> void _tmain( int argc,TCHAR *argv[] ) { STARTUPINFO si; PROCESS_INFORMATION pi; STARTUPINFO sj; PROCESS_INFORMATION pj; ZeroMemory( &si,sizeof(si) ); si.cb = sizeof(si); ZeroMemory( &pi,sizeof(pi) ); ZeroMemory( &sj,sizeof(sj) ); sj.cb = sizeof(sj); ZeroMemory( &pj,sizeof(pj) ); // Start the child process p1.exe. Make sure p1.exe is in the // same folder as current application. Otherwise write the full path in first argument. if(!CreateProcess(L".p1.exe",NULL,FALSE,&sj,&pj)) { printf( "Hello CreateProcess failed (%d)n",GetLastError() ); getch(); return; } // Start child process p2.exe. Make sure p2.exe is in the // same folder as current application. Otherwise write the full path in first argument. if(!CreateProcess(L".p2.exe",&si,&pi)) { printf( "CreateProcess2 failed (%d)n",GetLastError() ); getch(); return; } // Wait until child processes exit. WaitForSingleObject( pi.hProcess,INFINITE ); WaitForSingleObject( pj.hProcess,INFINITE ); // Close process and thread handles. CloseHandle( pi.hProcess ); CloseHandle( pi.hThread ); CloseHandle( pj.hProcess ); CloseHandle( pj.hThread ); getch(); } (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- win7旗舰版系统 64位安装vs2015的条件
- WinAPI 字符及字符串函数(5): IsCharAlpha - 是否是个字母
- 怎么把电脑桌面上的CAD图纸转换成BMP格式图纸?
- windows下升级PHP到5.3.3的过程及注意事项
- windows-8.1 – 升级到“Windows 10”后返回“Windows 8.1”
- windows-phone-8.1 – 如何以编程方式检查Windows Phone 8.
- 创建唯一的文件名Windows批处理
- window.onerror和javascript控制台错误
- windows – 当你插入一个新的USB设备时会发生什么?
- windows – 两个具有相同用户名的可信域 – 我们可以合并吗