问题描述
如何从进程ID获取主窗口句柄?
我要将此窗口置于前端。
$我不相信Windows (相对于.NET)提供了一个直接的方式来获得。
我知道的唯一方法是枚举所有顶级窗口 EnumWindows()
,然后找到每个属于 GetWindowThreadProcessID()
的进程。这听起来间接和低效,但它并没有你所期望的那么糟 - 在一个典型的情况下,你可能有十几个顶级窗口走过...
How to get main window handle from process id?
I want to bring this window to the front.
It works well in "Process Explorer".
I don't believe Windows (as opposed to .NET) provides a direct way to get that.
The only way I know of is to enumerate all the top level windows with EnumWindows()
and then find what process each belongs to GetWindowThreadProcessID()
. This sounds indirect and inefficient, but it's not as bad as you might expect -- in a typical case, you might have a dozen top level windows to walk through...
这篇关于如何从进程id获取主窗口句柄?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!