本文介绍了如何获取我的可执行文件的运行状态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
其实我有两个可执行文件。如果第一个被打破,一些指示将显示在第二个可执行文件中,如红色按钮,如果第一个正在运行,它会在第二个exe中显示绿色按钮。如何才能获得我的可执行文件的运行状态。
Actually i have two executable. if first one is breaked, some indication is to be shown in the second executable like red button and if first one is running, it shows green button in the second exe. how it will be possible to get the running status of my executable.
推荐答案
// Take a snapshot of all processes in the system.
HANDLE hProcessSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
if(hProcessSnap == INVALID_HANDLE_VALUE)
return FALSE;
// Set the size of the structure before using it.
PROCESSENTRY32 pe32;
pe32.dwSize = sizeof(PROCESSENTRY32);
// Retrieve information about the first process, and exit if unsuccessful
if(!Process32First(hProcessSnap, &pe32))
{
CloseHandle(hProcessSnap);// Must clean up the snapshot object!
return FALSE;
}
BOOL found = FALSE;
// Now walk the snapshot of processes
do
{
if(!_tcsicmp(pe32.szExeFile, _T("FIRST.EXE")))
{
version = _T("MD3");
found = TRUE;
break;
}
} while(Process32Next(hProcessSnap, &pe32));
CloseHandle(hProcessSnap);
return found;
这篇关于如何获取我的可执行文件的运行状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!