开发者

How to GetGuiResources for all system processes?

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开发者_Python百科 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!


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜