进程间获取句柄或ID所用到的

 1.根据窗口ID,获得创建该窗口的线程ID和进程ID
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.

 

DWORD GetWindowThreadProcessId(         
    HWND hWnd,         //
    LPDWORD lpdwProcessId      //进程ID
);

The return value is the identifier of the thread that created the window.

 

2.定义一个CALLBACK函数作为EnumWindows函数的参数来枚举屏幕上的top-level窗口,该窗口句柄会传给CALLBACK函数作为参数
The EnumWindows function enumerates all top-level windows on the screen by passing the handle to each window, in turn, to an application-defined callback function. EnumWindows continues until the last top-level window is enumerated or the callback function returns FALSE.

 

BOOL EnumWindows(         
  WNDENUMPROC lpEnumFunc,
     LPARAM lParam       //枚举窗口时的判断依据,至于如何根据此参数来得到所需的窗口,在
                        //CALLBACK函数中进行。该参数直接传给CALLBACK函数。
);

If the function succeeds, the return value is nonzero.


BOOL   CALLBACK   EnumWindowsProc(

HWND hwnd           /*top-level窗口句柄*/,

LPARAM lParam             /*EnumWindows的第二个参数*/

)

To continue enumeration, the callback function must return TRUE; to stop enumeration, it must return FALSE.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值