如何GetGuiResources的所有系统进程? [英] How to GetGuiResources for all system processes?

查看:627
本文介绍了如何GetGuiResources的所有系统进程?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在Windows XP系统中测量所有使用的GDI对象。我发现了一个GetGuiResources(__在HANDLE hProcess,__in DWORD uiFlags)方法(与GR_GDIOBJECTS标志)。我调用它的过程,我从WinBase.h中定义的方法GetCurrentProcess()。

I need to measure all used GDI objects in a Windows xp system. I found a GetGuiResources(__in HANDLE hProcess, __in DWORD uiFlags) method (with the GR_GDIOBJECTS flag). I call it for the process which I get from the method GetCurrentProcess() defined in WinBase.h.

我不知道如何调用它为其他系统进程,我得到的System :: Diagnostics :: Process :: GetProcesses(),因为这个函数返回一个Process指针数组,GetGuiResources需要一个HANDLE。

I don't know how to call it for other system processes, which I get by System::Diagnostics::Process::GetProcesses(), because that function returns an array of Process pointers, and GetGuiResources takes a HANDLE.

知道一个解决方案?如何将Process指针转换为Handle或为所有正在运行的系统进程获取HANDLE?

Does anybody know a solution for that? How can I transform Process pointer to a Handle or get HANDLEs for all running system processes?

感谢您的帮助!

推荐答案

使用 Id 属性GetProcesses()返回的数组的每个Process对象可以获取每个进程的ID。然后,通过ID,您可以通过获取处理OpenProcess API。请记得使用关闭句柄关闭句柄。

Using the Id property of each Process object of the array returned by GetProcesses() you can get the ID of each process. Then, from an ID, you can get a handle via the OpenProcess API. Remember to close the handle with CloseHandle when you don't need it anymore.

请注意,您不能使用 Handle 属性的Process对象,因为它只适用于

Note that you can't use the Handle property of the Process objects, because it works only for the objects returned by Process.Start.

顺便说一下,请记住,对于新项目,您应该使用新的C ++ / CLI语言,而不是旧的托管C ++扩展。

By the way, keep in mind that for new projects you should use the new C++/CLI language instead of the old Managed C++ extensions.

这篇关于如何GetGuiResources的所有系统进程?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆