windows 如何获取与进程关联的 GDI 对象

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/251343/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 11:32:51  来源:igfitidea点击:

How to get GDI objects associated to a process

windowscommand-line

提问by Naga

I am investigating GDI leaks issue in one of our smart-client application. I am looking for a tool (like tasklist) to get the GDI objects associated to a process. I can see the GDI objects in taskmanager, But my requirement to capture it periodically somewhere. For example in a text file.

我正在调查我们的智能客户端应用程序之一中的 GDI 泄漏问题。我正在寻找一种工具(如tasklist)来获取与进程关联的 GDI 对象。我可以在任务管理器中看到 GDI 对象,但我需要定期在某处捕获它。例如在文本文件中。

采纳答案by ChrisN

It should be quite straightforward to write a program to periodically log the number of GDI handles in use by a process, using the GetGuiResourcesAPI function.

使用GetGuiResourcesAPI 函数编写一个程序来定期记录进程使用的 GDI 句柄的数量应该非常简单。

回答by ChrisN

The totally free Process Explorer ( http://www.sysinternals.com) allows you to graphically inspect this and a zillion other aspects related to running processes. Add GDI Objectsto the columns to display and you're off and running. The column GDI Objectscan be found in the Process Memorytab in the Select Columnsdialog.

完全免费的 Process Explorer ( http://www.sysinternals.com) 允许您以图形方式检查这一点以及与运行进程相关的无数其他方面。添加GDI Objects到要显示的列中,您就可以开始运行了。GDI Objects可以Process MemorySelect Columns对话框的选项卡中找到该列。

NOTE: Microsoft acquired their tools and I believe Mark Russinovich now works for Microsoft. Sysinternals tools don't typically require any installation other than to copy them to somewhere convenient and should be in your toolbox if they aren't already.

注意:微软收购了他们的工具,我相信 Mark Russinovich 现在为微软工作。Sysinternals 工具通常不需要任何安装,只需将它们复制到方便的地方,如果它们还没有,则应该在您的工具箱中。

回答by user290924

Use GDIView, a free tool from NirSoft.

使用NirSoft 的免费工具GDIView

Their description:

他们的描述:

GDIView is a unique tool that displays the list of GDI handles (brushes, pens, fonts, bitmaps, and others) opened by every process. It displays the total count for each type of GDI handle, as well as detailed information about each handle. This tool can be useful for developers that need to trace GDI resources leak in their software.

GDIView 是一个独特的工具,可以显示每个进程打开的 GDI 句柄(画笔、钢笔、字体、位图等)列表。它显示每种类型的 GDI 句柄的总数,以及有关每个句柄的详细信息。此工具对于需要跟踪其软件中的 GDI 资源泄漏的开发人员非常有用。

You can save the list of GDI counters as regular, tab-delimited, comma-delimited, and tabular text files, as well as horizontal or vertical HTML file or an XML file.

您可以将 GDI 计数器列表保存为常规、制表符分隔、逗号分隔和表格文本文件,以及水平或垂直 HTML 文件或 XML 文件。