递归火山软件开发平台
标题:
检测自身是否无响应
[打印本页]
作者:
ゞ情非得已Sky
时间:
2023-12-27 23:31
标题:
检测自身是否无响应
<火山程序 类型 = "通常" 版本 = 1 />
方法 检测自身是否无响应 <类型 = 逻辑型 注释 = "检测自身程序是否无响应" 返回值注释 = "返回假 有响应 返回真 无响应" @禁止流程检查 = 真>
{
@ int id = GetCurrentProcessId();
@ HANDLE hProcess = ::OpenProcess (PROCESS_ALL_ACCESS,NULL,id);
@ ::CloseHandle(hProcess);
@ FILETIME createTime, exitTime, kernelTime, userTime;
@ if (GetProcessTimes(hProcess, &createTime, &exitTime, &kernelTime, &userTime) == 0)
@ {
@ return false;
@ }
@ ULARGE_INTEGER processTime;
@ processTime.LowPart = userTime.dwLowDateTime;
@ processTime.HighPart = userTime.dwHighDateTime;
@ ULARGE_INTEGER currentTime;
@ GetSystemTimeAsFileTime(reinterpret_cast<LPFILETIME>(¤tTime));
@ ULONGLONG elapsedTime = currentTime.QuadPart - processTime.QuadPart;
@ elapsedTime /= 10000;
@ if (elapsedTime >= 3000)
@ {
@ return true;
@ }
@ return false;
}
(, 下载次数: 26)
上传
点击文件名下载附件
作者:
xrea
时间:
2023-12-27 23:41
?程序都无响应了,怎么调用api检测?
作者:
易入门
时间:
2023-12-28 00:45
xrea 发表于 2023-12-27 23:41
?程序都无响应了,怎么调用api检测?
创建线程
作者:
urenai
时间:
2023-12-28 10:56
<火山程序 类型 = "通常" 版本 = 1 />
方法 检测自身是否无响应 <类型 = 逻辑型 注释 = "检测自身程序是否无响应" 返回值注释 = "返回假 有响应 返回真 无响应" @禁止流程检查 = 真>
{
@ int id = GetCurrentProcessId();
@ HANDLE hProcess = ::OpenProcess (PROCESS_ALL_ACCESS,NULL,id);
// @ ::CloseHandle(hProcess);
@ FILETIME createTime, exitTime, kernelTime, userTime;
@ if (GetProcessTimes(hProcess, &createTime, &exitTime, &kernelTime, &userTime) == 0)
@ {
@ return false;
@ }
@ ::CloseHandle(hProcess);
@ ULARGE_INTEGER processTime;
@ processTime.LowPart = userTime.dwLowDateTime;
@ processTime.HighPart = userTime.dwHighDateTime;
@ ULARGE_INTEGER currentTime;
@ GetSystemTimeAsFileTime(reinterpret_cast<LPFILETIME>(¤tTime));
@ ULONGLONG elapsedTime = currentTime.QuadPart - processTime.QuadPart;
@ elapsedTime /= 10000;
//@ if
//@ {
@ return (elapsedTime >= 3000);
//@ }
//@ return false;
}
欢迎光临 递归火山软件开发平台 (https://bbs.voldp.com/)
Powered by Discuz! X3.4