Platform SDK: Performance Monitoring |
The PdhAddCounter function initializes a counter structure for the specified counter in the specified query.
PDH_STATUS PdhAddCounter( HQUERY hQuery, LPCTSTR szFullCounterPath, DWORD_PTR dwUserData, HCOUNTER *phCounter );
If a wildcard character is specified in the szFullCounterPath parameter, all counter names matching the wildcard character are added to the query.
If the function succeeds, it returns ERROR_SUCCESS, creates a new counter, and returns a handle to the counter in the buffer pointed to by phCounter.
If the function fails, the return value is a PDH error status defined in PDHMsg.h. The following are possible error values.
Error value | Description |
---|---|
PDH_CSTATUS_BAD_COUNTERNAME | The counter name path string could not be parsed or interpreted. |
PDH_CSTATUS_NO_COUNTER | The specified counter was not found. |
PDH_CSTATUS_NO_COUNTERNAME | An empty counter name path string was passed in. |
PDH_CSTATUS_NO_MACHINE | A machine entry could not be created. |
PDH_CSTATUS_NO_OBJECT | The specified object could not be found. |
PDH_FUNCTION_NOT_FOUND | The calculation function for this counter could not be determined. |
PDH_INVALID_ARGUMENT | One or more arguments are invalid. |
PDH_INVALID_HANDLE | The query handle is not valid. |
PDH_MEMORY_ALLOCATION_FAILURE | A memory buffer could not be allocated. |
Windows NT/2000: Requires Windows NT 4.0 or later.
Header: Declared in Pdh.h.
Library: Use Pdh.lib.
Unicode: Implemented as Unicode and ANSI versions on Windows NT/2000.