How to GetGuiResources for all system processes?

家住魔仙堡 提交于 2019-12-12 01:35:12

问题


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.

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.

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

thanks for help in advance!


回答1:


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.

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

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.



来源:https://stackoverflow.com/questions/2494221/how-to-getguiresources-for-all-system-processes

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!