如何取道一个进程(process)所开的所有窗口(form)的句柄,及如何得到一个窗口所对应的进程的ProcessId(50分)

  • 主题发起人 主题发起人 zign
  • 开始时间 开始时间
http://delphi.twart.com/DELPHI/D32FREE/TWINLIST.ZIP<br>能列出目前系統中全部啟動視窗 (Active Windows)的元件 ( 附原始程式碼)<br><br>http://delphi.twart.com/DELPHI/D32FREE/WNDLISTVIEW.ZIP<br>是個改良版的 TListView 元件,顯示目前系統中全部視窗的資訊( 1.0 版,<br>附原始程式碼 )
 
用API函数getwindowthreadprocessid可以做到第2点。<br>下面是MSDN中对这个函数的说明:<br>GetWindowThreadProcessId<br>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. <br><br>DWORD GetWindowThreadProcessId(<br>&nbsp; HWND hWnd, &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // handle to window<br>&nbsp; LPDWORD lpdwProcessId &nbsp;// address of variable for process identifier<br>);<br>&nbsp;<br>Parameters<br>hWnd <br>Handle to the window. <br>lpdwProcessId <br>Pointer to a 32-bit value that receives the process identifier. If this parameter is not NULL, GetWindowThreadProcessId copies the identifier of the process to the 32-bit value; otherwise, it does not. <br>Return Values<br>The return value is the identifier of the thread that created the window<br>看得懂这些英文吧,我就不翻译过来了。至于第1个,不知有什么好办法没有。我是用一个循环<br>去找创建这些窗口的进程的ID,找到符合的就列出来!
 
多人接受答案了。
 
后退
顶部