如何由窗口句柄得到对应的进程ID
已得到窗口的句柄hwnd
怎么得到hwnd相对应的进程ID
如果用
DWORD GetWindowThreadProcessId(
HWND hWnd,
LPDWORD lpdwProcessId );
得到的是本窗口的父窗口的进程ID,即创建本窗口的窗口的进程ID
如打开了多个IE浏览器,可以获得每一个窗口的hwnd,所有的IE窗口通过GetWindowThreadProcessId方法获得的lpdwProcessId 是同一个值
这样我就不能指定的根据进程ID来杀死特定的某一个IE浏览器
我希望是得到窗口本身的进程ID
以下是GetWindowThreadProcessId方法在MSDN中的说明:
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.
Return Values
The return value is the identifier of the thread that created the window.