如何从 Windows 任务管理器(“应用程序”选项卡)获取应用程序 +他们在德尔福硬盘上的位置
我想获取正在运行并在 Windows 任务管理器的“应用程序”选项卡(不是“进程”选项卡)中可见的程序列表,并获取它们在 HDD 上的位置?
我需要在 Delphi 中完成它。有人可以帮忙吗?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
据我所知,任务管理器中的“应用程序”选项卡是顶级窗口的列表,这些窗口不属于其他窗口,没有父窗口,也不是工具窗口。在我的 Process Info 中,我有一个名为 AppInfo.pas 的单元,它返回具有此类特征的窗口列表,并且该列表与您在任务管理器中看到的内容相匹配。以下是作为 EnumWindows API 函数的回调函数编写的代码的主要部分:
完整的源代码,您可以参考 AppInfo.pas。
这些只是窗口。如果您想获取每个项目对应的 EXE 文件的路径,您应该首先找到拥有该窗口的进程,使用 GetWindowThreadProcessID API 函数。这就是我在上面的代码中所做的。获得进程 ID 后,您可以从中获取进程句柄,并枚举其模块。第一个模块是主 EXE 文件。我在 TProcessInfo 组件中实现了该组件,该组件与 AppInfo.pas 包含在同一包中。
As far as I know, Application tab in Task Manager is a list of top-level windows which are not owned by other windows, have no parent, and are not tool windows. In my Process Info, I have a unit called AppInfo.pas which returns a list of windows with such characteristics, and the list matches what you see in Task Manager. Here is the main part of the code which is written as a call-back function for EnumWindows API function:
For the full source code, you can refer to AppInfo.pas.
These are just windows. If you want to get path of EXE file corresponding to each item, you should first find the process which is owning this window, using GetWindowThreadProcessID API function. That is what I did in the above code. Once you have the process ID, you can get a process handle from it, and enumerate its modules. The first module is the main EXE file. I implemented that in my TProcessInfo component which is included in the same package with AppInfo.pas.
这是一个完整的独立解决方案(不再有损坏的链接)
Here is a complete standalone solution (no more broken links)