Platform SDK: Performance Monitoring

PdhCollectQueryData

The PdhCollectQueryData function collects the current raw data value for all counters in the specified query and updates the status code of each counter.

[C++] 
PDH_STATUS PdhCollectQueryData(
  HQUERY hQuery  
);
[Visual Basic] 
PdhCollectQueryData(
  ByVal QueryHandle as Long  
)
as Long

Parameters

[C++] hQuery
[in] A handle to the query from which to collect data.
[Visual Basic] QueryHandle
[in] The ID of the query to update. This must be a value returned by a call to PdhOpenQuery.

Return Values

If the function succeeds, it returns ERROR_SUCCESS. Otherwise, the function returns a PDH error value.

The following are possible PDH error values.

Error value Description
PDH_INVALID_HANDLE The query handle is not valid.
PDH_NO_DATA The query does not currently have any counters.

[C++] PDH error values are defined in PDHMsg.h.

[Visual Basic] PDH error values are defined in PDHDefs.txt.

Remarks

The PdhCollectQueryData function can succeed, but may not have collected data for all counters. Always check the status code of each counter in the query before using the data.

Requirements

  Windows NT/2000: Requires Windows NT 4.0 or later.
  Header: Declared in Pdh.h (C/C++).
  Library: Use Pdh.lib.

See Also

PdhOpenQuery