判断当前进程是否存在界面

c++

Posted by YiMiTuMi on October 9, 2022

判断当前进程是否存在界面

//函数接受一个进程ID
BOOL NonExistentInterface(DWORD dwPid)
{
	BOOL bExist = FALSE;

	//获取窗体列表中的第一个窗口  
	HWND pWnd = ::FindWindow(NULL, NULL);
	while (NULL != pWnd)
	{
		//通过窗口句柄m_hWnd获取进程PID  
		DWORD dwPID = 0;
		DWORD dwThreadID = GetWindowThreadProcessId(pWnd, &dwPID);
		
		if (dwPID == dwPid)
		{
			//存在
			bExist = TRUE;
		}

		pWnd = ::GetNextWindow(pWnd, GW_HWNDNEXT);
	}

	return bExist;
}

薰衣草 – 等待爱情