IWMSServer::get_CPUUtilization

The get_CPUUtilization method retrieves the CPU utilization of the computer on which the server is running.

HRESULT get_CPUUtilization(
  long*  pVal
);

Arguments

pVal

[out] Pointer to a long containing the percentage of CPU utilization.

Return Value

If the method succeeds, it returns S_OK. If it fails, it returns an HRESULT error code.

Return code

Number

Description

E_POINTER

0x80004003

Indicates that pVal is a NULL pointer argument.

Remarks

The parameter is returned as a percentage (0 to 100).

Example

#include <windows.h>
#include "wmsserver.h"

// Declare variables and interfaces.
IWMSServer      *pServer;

HRESULT         hr;
long            lValue;

// Initialize the COM library and retrieve a pointer
// to an IWMSServer interface.
hr = CoInitialize(NULL);
hr = CoCreateInstance(CLSID_WMSServer,
                      NULL,
                      CLSCTX_ALL,
                      IID_IWMSServer,
                      (void **)&pServer);
if (FAILED(hr)) goto EXIT;

// Retrieve a value indicating the current CPU
// load on the server.
hr = pServer->get_CPUUtilization(&lValue);
if (FAILED(hr)) goto EXIT;

EXIT:
    // TODO: Release temporary COM objects and uninitialize COM.

Requirements

Header: wmsserver.h.

Library: WMSServerTypeLib.dll.

Platform: Windows Server 2003 family, Windows Server 2008 family.

See Also

Reference

IWMSServer Interface