找回密码
 加入我们

QQ登录

只需一步,快速开始

搜索
查看: 3967|回复: 0

【开源】进程PID取窗口句柄

[复制链接]

1214

主题

352

回帖

11

精华

管理员

菜鸟

积分
93755

贡献奖关注奖人气王精英奖乐于助人勋章

发表于 2009-7-23 19:15:54 | 显示全部楼层 |阅读模式
<p><font face="Verdana">//进程PID取窗口句柄</font></p>
<p><font face="Verdana">function GetHwndFromProcess(ProcessId: DWORD): HWND;<br/>function _EnumWindowsProc(P_HWND: Cardinal; lParam: Cardinal): Boolean;<br/>&nbsp;&nbsp;&nbsp; stdcall;<br/>var<br/>&nbsp;&nbsp;&nbsp; PID: DWORD;<br/>begin<br/>&nbsp;&nbsp;&nbsp; GetWindowThreadProcessId(P_HWND, @PID);<br/>&nbsp;&nbsp;&nbsp; if PCardinal(lParam)^ &lt;&gt; PID then<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Result := True<br/>&nbsp;&nbsp;&nbsp; else<br/>&nbsp;&nbsp;&nbsp; begin<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Result := False;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; PCardinal(lParam + 4)^ := P_HWND;<br/>&nbsp;&nbsp;&nbsp; end;<br/>end;</font></p>
<p><font face="Verdana">var<br/>Buffer: array[0..1] of Cardinal;<br/>begin<br/>&nbsp;&nbsp;&nbsp; Result := 0;<br/>&nbsp;&nbsp;&nbsp; Buffer[0] := ProcessId;<br/>&nbsp;&nbsp;&nbsp; Buffer[1] := 0;<br/>&nbsp;&nbsp;&nbsp; EnumWindows(@_EnumWindowsProc, Integer(@Buffer));<br/>&nbsp;&nbsp;&nbsp; if Buffer[1] &gt; 0 then&nbsp; Result := Buffer[1];<br/>end;<br/></font></p>
【VB】QQ群:1422505加的请打上VB好友
【易语言】QQ群:9531809  或 177048
【FOXPRO】QQ群:6580324  或 33659603
【C/C++/VC】QQ群:3777552
【NiceBasic】QQ群:3703755
您需要登录后才可以回帖 登录 | 加入我们

本版积分规则

快速回复 返回顶部 返回列表