/*以下代码在win2k源码中寻找到的 位于win2k/privata/ntos/w32/ntoser/client/winmgrc.c Ln255*/
/***************************************************************************/
* GetWindowThreadProcessId
* Get's windows process and thread ids.
* 24-Jun-1991 ScottLu Created.
/***************************************************************************/
DWORD GetWindowThreadProcessId(
HWND hwnd,
LPDWORD lpdwProcessId)
{
PTHREADINFO ptiWindow;
DWORD dwThreadId;
if ((ptiWindow = PtiWindow(hwnd)) == NULL)
return 0;
/*
* For non-system threads get the info from the thread info structure
*/
if (ptiWindow == PtiCurrent()) {
if (lpdwProcessId != NULL)
*lpdwProcessId = HandleToUlong(NtCurrentTeb()->ClientId.UniqueProcess);
dwThreadId = HandleToUlong(NtCurrentTeb()->ClientId.UniqueThread);
} else {
/*
* Make this better later on.
*/
if (lpdwProcessId != NULL)
*lpdwProcessId = HandleToUlong(NtUserQueryWindow(hwnd, WindowProcess));
dwThreadId = HandleToUlong(NtUserQueryWindow(hwnd, WindowThread));
}
return dwThreadId;
}
/*
#define windowthread 0x1
#define windowprocess 0x0
*/