Retrieving Counter Names and Explanations

Object type names, counter names, object explanations, and counter explanations are not made directly available in the performance data structures. Instead, the performance data structures contain indices you can use to locate where the names and explanations for each object and counter can be found. The ObjectNameTitleIndex and ObjectHelpTitleIndex members of the PERF_OBJECT_TYPE structure contain the indices to the object name and explanation, respectively. The CounterNameTitleIndex and CounterHelpTitleIndex members of the PERF_COUNTER_DEFINITION structure contain the indices to the counter name and explanation, respectively.

To access the names and explanations, read the Counter and Help values in the following registry key.

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT
\CurrentVersion\Perflib\
langid

The langid is the ASCII representation of the 3-digit hexadecimal language identifier. For example, the U.S. English langid is 009. In a non-English version of Windows NT, counters are stored in both the native language of the system and in English.

The data is stored as MULTI_SZ strings. This data type consists of a list of Unicode strings, each terminated with UNICODE_NULL. The last string is followed by an additional UNICODE_NULL. The strings are listed in pairs. The first string of each pair is the Unicode string of the index, and the second string is the actual name of the index. The Counter data uses only even-numbered indexes, while the Help data has odd-numbered indexes. For example, the Counter data contains the following object and counter name strings.

2    System
4    Memory
6    % Processor Time
 

The Help data contains the following counter explanations.

3    The System object type includes those counters that...
5    The Memory object type includes those counters that...
7    Processor Time is expressed as a percentage of the...
 

To retrieve a name or explanation for an object type or counter, given its index, an application should perform the following steps.

  1. If the system is remote, call the RegConnectRegistry function.
  2. Use the RegOpenKeyEx function to open the registry key containing the name and explanation text.
  3. Use the RegQueryValueEx function, specifying either Counter or Help as the name of the value to query.
  4. Convert the index into Unicode or ASCII, depending on whether your application is Unicode or ASCII.
  5. Search the MULTI_SZ data for the appropriate index.
  6. Retrieve the string following the matching index. The string contains the name or explanation.

If you are going to be looking up a number of counters, you should build a table for faster and easier lookup. For an example, see Displaying Object, Instance, and Counter Names.