#include "stdafx.h"
using namespace std;
enum PROCESS_RESULT{
PROCESS_NORMAL_END,
PROCESS_ABNORMAL_END,
PROCESS_UNKNOWN_END,
};
PROCESS_RESULT ListenSingleProcessFinish(HANDLE hHandle)
{
std::cout << "开始监听" << std::endl;
DWORD wait_result =::WaitForSingleObject(hHandle,INFINITE);
if (wait_result == WAIT_OBJECT_0 + 1)
{
cout << "正常退出" << endl;
return PROCESS_NORMAL_END;
}
else if (wait_result == WAIT_OBJECT_0)
{
cout << "异常退出" << endl;
return PROCESS_ABNORMAL_END;
}
else{
return PROCESS_UNKNOWN_END;
}
}
int _tmain(int argc, _TCHAR* argv[])
{
HANDLE hhanld = OpenProcess(PROCESS_ALL_ACCESS,NULL,15232);
if (hhanld !=NULL)
{
ListenSingleProcessFinish(hhanld);
}
system("pause");
return 0;
}