如何根据pID获取一个窗口句柄
展开全部
HWND* hWnd = new HWND[255];
int iLength = 0;
GetHwndByPid(PE.th32ProcessID, &hWnd, &iLength);
//进程ID取窗口句柄
bool CxxxxDlg::GetHwndByPid(DWORD ProcessId, HWND** hWnd, int* iLength)
{
bool bRet = false;
*iLength = 0;
WindowInfo WinInfo1[255];
DWORD aa=EnumWindowInfo(WinInfo1);
for(int i=0; i<aa; i++)
{
if (WinInfo1[i].dwProcessId == ProcessId)
{
bRet = true;
(*hWnd)[(*iLength)] = WinInfo1[i].hwnd1;
(*iLength)++;
if (NULL == ::GetWindowLong(WinInfo1[i].hwnd1, GWL_HWNDPARENT))
{
//return WinInfo1[i].hwnd1;
}
}
}
return bRet;
}
int iLength = 0;
GetHwndByPid(PE.th32ProcessID, &hWnd, &iLength);
//进程ID取窗口句柄
bool CxxxxDlg::GetHwndByPid(DWORD ProcessId, HWND** hWnd, int* iLength)
{
bool bRet = false;
*iLength = 0;
WindowInfo WinInfo1[255];
DWORD aa=EnumWindowInfo(WinInfo1);
for(int i=0; i<aa; i++)
{
if (WinInfo1[i].dwProcessId == ProcessId)
{
bRet = true;
(*hWnd)[(*iLength)] = WinInfo1[i].hwnd1;
(*iLength)++;
if (NULL == ::GetWindowLong(WinInfo1[i].hwnd1, GWL_HWNDPARENT))
{
//return WinInfo1[i].hwnd1;
}
}
}
return bRet;
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询