Platform SDK: Performance Monitoring |
The PdhLookupPerfIndexByName function returns the counter index corresponding to the specified counter name.
PDH_FUNCTION PdhLookupPerfIndexByName( LPCTSTR *szMachineName, LPCTSTR szNameBuffer, LPDWORD pdwIndex );
If the function succeeds, it returns ERROR_SUCCESS.
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_INVALID_ARGUMENT | An argument is not correct or is incorrectly formatted. |
The general counter path format is as follows:
\\machine\object(parent/instance#index)\counter
The parent, instance, index, and counter components of the format may contain either a valid name or a wildcard character. The machine, parent, instance, and index components are not necessary for all counters.
The counter paths you must use is determined by the counter itself. For example, the LogicalDisk object has an instance index, so you must provide the #index, or a wildcard. Therefore, you could use the following format:
\LogicalDisk(*/*#*)\*
In comparison, the Process object does not require an instance index. Therefore, you could use the following format:
\Process(*)\ID Process
The following is a list of the possible formats:
Windows NT/2000: Requires Windows 2000.
Header: Declared in Pdh.h.
Library: Use Pdh.lib.
Unicode: Implemented as Unicode and ANSI versions on Windows 2000.