[DllImport(“user32”, EntryPoint = “GetWindowThreadProcessId”)]
private static extern int GetWindowThreadProcessId(IntPtr hwnd, out int pid);
函数原型:
DWORD GetWindowThreadProcessId(HWND hWnd,LPDWORD lpdwProcessId);
参数说明:
hWnd:传入的窗口句柄;lpdwProcessId:返回的进程ID地址。
返回值:
函数返回的是窗口所属线程ID。
使用例子:
DWORD ProcessID;
DWORD ThreadID;
ThreadID=GetWindowThreadProcessId(hWnd,&ProcessID);