怎样取得应用程序的句柄?(200分)

W

weiiguo

Unregistered / Unconfirmed
GUEST, unregistred user!
我打开了6个Notepad,请问我怎么才能分别取得这6个Notepad的句柄?有请各位大虾指点!谢谢!
 
活动的 Notepad 可以用 Screen.ActiveControl.Handle 获得;<br>可用下面代码获得 6 个,存在数组里:<br>
代码:
<br>var<br>&nbsp; I: Integer;<br>&nbsp; hWnd: Integer;<br>&nbsp; hWndArray: array [1..6] of Integer;<br>begin<br>&nbsp; hWnd := FindWindow('Notepad', nil);<br>&nbsp; hWndArray[1] := hWnd;<br>&nbsp; For I := 2 to 6 Do<br>&nbsp; &nbsp; Begin<br>&nbsp; &nbsp; &nbsp; hWndArray[I] := GetNextWindow(hWnd, GW_HWNDNEXT);<br>&nbsp; &nbsp; &nbsp; hWnd := hWndArray[I];<br>&nbsp; &nbsp; End;<br>&nbsp; ShowMessage('End');<br>
<br>如何个数(6个)未知,可用动态数组,SetLength 来设数组大小。
 
你可以用findwindow函数来获得句柄.
 
用shellexecute<br>findwindow<br>getwindow
 
多人接受答案了。
 
顶部