Red de conocimiento informático - Material del sitio web - Cómo obtener el identificador de ventana según pID

Cómo obtener el identificador de ventana según pID

HWND* hWnd = new HWND[255];

int iLength = 0;

GetHwndByPid(PE.th32ProcessID, &hWnd, &iLength

// Proceso); ID (ID de proceso). th32ProcessID, &hWnd, &iLength);

// ID de proceso para obtener un identificador de ventana

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

{

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;

}

}

}

}

devolver bRet;

}