GetGuiResourcesThe GetGuiResources function retrieves the count of handles to graphical user interface (GUI) objects in use by the specified process. DWORD GetGuiResources( HANDLE hProcess, DWORD uiFlags );Parameters hProcess [in] Handle to the process. The handle must have the PROCESS_QUERY_INFORMATION access right. For more information, see Process Security and Access Rights. uiFlags [in] GUI object type. This parameter can be one of the following values. Value Meaning GR_GDIOBJECTS Return the count of GDI objects. GR_USEROBJECTS Return the count of USER objects. Return Values If the function succeeds, the return value is the count of handles to GUI objects in use by the process. If no GUI objects are in use, the return value is zero.If the function fails, the return value is zero. To get extended error information, call GetLastError.Res A process without a graphical user interface does not use GUI resources, therefore, GetGuiResources will return zero.Requirements Client: Included in Windows XP and Windows 2000 Professional. Server: Included in Windows Server 2003 and Windows 2000 Server. Header: Declared in Winuser.h; include Windows.h. Library: Use User32.lib.
HMODULE hModule,
HRSRC hResInfo );
DWORD GetGuiResources(
HANDLE hProcess,
DWORD uiFlags
);Parameters
hProcess
[in] Handle to the process. The handle must have the PROCESS_QUERY_INFORMATION access right. For more information, see Process Security and Access Rights.
uiFlags
[in] GUI object type. This parameter can be one of the following values. Value Meaning
GR_GDIOBJECTS Return the count of GDI objects.
GR_USEROBJECTS Return the count of USER objects. Return Values
If the function succeeds, the return value is the count of handles to GUI objects in use by the process. If no GUI objects are in use, the return value is zero.If the function fails, the return value is zero. To get extended error information, call GetLastError.Res
A process without a graphical user interface does not use GUI resources, therefore, GetGuiResources will return zero.Requirements
Client: Included in Windows XP and Windows 2000 Professional.
Server: Included in Windows Server 2003 and Windows 2000 Server.
Header: Declared in Winuser.h; include Windows.h.
Library: Use User32.lib.
// 有关不同平台的相应值的最新信息,请参考 MSDN。
#ifndef WINVER
#define WINVER 0x0500 //为 Windows 2000 及更新版本改变为适当的值。
#endif#ifndef _WIN32_WINNT // 允许使用 Windows 2000或更高版本的特定功能。
#define _WIN32_WINNT 0x0500 //为Windows 2000 及更新版本改变为适当的值。
#endif #ifndef _WIN32_WINDOWS // 允许使用 Windows 2000或更高版本的特定功能。
#define _WIN32_WINDOWS 0x0500 //为 Windows Me 及更新版本改变为适当的值。
#endif
VERIFY(hInst != NULL);
GetGui *p = (GetGui*)::GetProcAddress(hInst, "GetGuiResources");HANDLE hHandle = ::OpenProcess(PROCESS_QUERY_INFORMATION, FALSE,
::GetCurrentProcessId());DWORD dwReturn = p(hHandle, 0);
TCHAR buf[20];
AfxMessageBox(ltoa(dwReturn, buf, 10));::CloseHandle(hHandle);
::FreeLibrary(hInst);通过函数指针
这样是实现了, 取得的值为 18左右
这应该是当前进程占用的资源百比分吧, 如果我想得到系统剩余的资源又该怎么办
谢谢!