博瑞博客

青春是一个充满活力的季节,即便是我们失去了天使的翅膀,只要我们还有一颗青春的心,那么我们的生活依然能够如阳光般灿烂!......
现在位置:首页 > C/C++ > GetWindowThreadProcessId

GetWindowThreadProcessId

江湖    C/C++    2016-8-8    1069    0评论
GetWindowThreadProcessId,找出某个窗口的创建者(线程或进程),返回创建者的标志符。

The GetWindowThreadProcessId function retrieves the identifier of the thread that created the specified window and, optionally, the identifier of the process that created the window.
哪个线程创建了这个窗口,返回的就是这个线程的id号 (进程只有一个线程的话,那么线程标志符与进程标志符就是指同一个标志符)
可理解为找出某栋房屋的建筑工人的名字。
1.函数原型 
DWORD GetWindowThreadProcessId(
HWND hWnd,
LPDWORD lpdwProcessId
);
2.参数
hWnd[in] (向函数提供的)被查找窗口的句柄.
lpdwProcessId[out] 进程号的存放地址(变量地址) Pointer to a variable that receives the process identifier. If this parameter is not NULL, GetWindowThreadProcessId copies the identifier of the process to the variable; otherwise, it does not. (如果参数不为NULL,即提供了存放处--变量,那么本函数把进程标志拷贝到存放处,否则不动作。)
3.返回值 
The return value is the identifier of the thread that created the window.
返回线程号,注意,lpdwProcessId 是存放进程号的变量。返回值是线程号,lpdwProcessId 是进程号存放处。
当然可以把答案再放到其它地方。如
DWORD dwPID, dwTID;
dwTID = GetWindowThreadProcessId( hWnd, &dwPID );
4.函数相关信息
Header Declared in Winuser.h, include Windows.h
Import library User32.lib
Minimum operating systems Windows 95, Windows NT 3.1

评论一下分享本文赞助博瑞

赞助博瑞X

扫码赞助博瑞
联系站长
博瑞博客
挤眼亲亲咆哮开心想想可怜糗大了委屈哈哈小声点右哼哼左哼哼疑问坏笑赚钱啦悲伤耍酷勾引厉害握手耶嘻嘻害羞鼓掌馋嘴抓狂抱抱围观威武给力
提交评论

清空信息
关闭评论