如何得到句柄?(100分)

  • 主题发起人 月光宝盒
  • 开始时间

月光宝盒

Unregistered / Unconfirmed
GUEST, unregistred user!
系统只运行两个程序(包括本身的程序), <br>如何找另一程序的句柄(假设不知程序的名字)? <br>
 
枚举主窗口句柄:<br><br>查阅可视窗口标题 <br><br>下面只是举出一个例子提供参考:运用API函数GetWindow()配合GetWindowText()逐一查出各视窗的标题 <br><br>1. File | New Project 开始一个新的工程<br>2. 在 Form1 中安排 Button 与 Memo 各一<br>3. 在 Button1 的 OnClick 事件中撰写程式如下:<br>procedure TForm1.Button1Click(Sender: Tobject);<br>var<br>&nbsp; hCurrentWindow: HWnd;<br>&nbsp; szText: array[0..254] of char;<br>begin<br>&nbsp; hCurrentWindow := GetWindow(Handle, GW_HWNDFIRST);<br>&nbsp; while hCurrentWindow &lt;&gt; 0 do<br>&nbsp; begin<br>&nbsp; &nbsp; if GetWindowText(hCurrentWindow, @szText, 255)&gt;0 <br> &nbsp;then Memo1.Lines.Add(StrPas(@szText));<br>&nbsp; &nbsp; hCurrentWindow:=<br> &nbsp;GetWindow(hCurrentWindow, GW_HWNDNEXT);<br>&nbsp; end;<br>end;<br><br>
 
同意以上答案
 
多人接受答案了。
 

Similar threads

顶部