Version 2 performance counters were introduced in Windows Vista because the performance counters architecture was changed to simplify the process for providing counter data to consumers. Applications will use either Version 1 or Version 2 performance counter providers.
Consider a scenario where the PdhGetCounterInfo API is used to retrieve the information about Version 2 performance counters. First you call PdhAddCounter to add a Version 2 performance counter. Then, you call the PdhGetCounterInfo function to get the information. In this scenario, the szExplainText field in the PDH_COUNTER_INFO structure which is returned by PdhGetCounterInfo will be set to NULL. This issue does not apply to Version 1 performance counters.
This issue occurs because the PdhAddCounter and PdhGetCounterInfo functions don't handle the explain text of Version 2 performance counters properly.
To work around this issue, retrieve the explain text of Version 2 performance counters directly by using the registry functions.
For example: you can follow these steps:
- Retrieve text strings for counter names from the HKEY_PERFORMANCE_NLSTEXT registry key:
RegQueryValueEx(HKEY_PERFORMANCE_NLSTEXT, L"Counter", NULL, NULL, (LPBYTE)pBufferCounter, &dwBufferSize);
- Retrieve text strings for the explain text from the HKEY_PERFORMANCE_NLSTEXT registry key:
RegQueryValueEx(HKEY_PERFORMANCE_NLSTEXT, L"Help", NULL, NULL, (LPBYTE)pBufferHelp, &dwBufferSize);
- Retrieve the last index used from the following registry:
HKEY_LOCAL_MACHINE,L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Perflib", 0,KEY_READ, &hkey
RegQueryValueEx(hkey, L"Last Help", NULL, 0, (LPBYTE)&dwEntries,&dwSize);
- Use pBufferCounter and pBufferHelp to locate the desired explain text. After locating the index number for the desired counter name from pBufferCounter, increase that index value by one to determine the index of the associated explain text within pBufferHelp. If you need to associate counter names and explain text with counter objects, you can retrieve the object information from the HKEY_PERFORMANCE_DATA registry key: The GUIDs identifying Version 2 performance counter providers are listed in the registry under "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\WindowsNT\CurrentVersion\Perflib\_V2Providers". You can find the counter object names as the value named NeutralName for each GUID.
RegQueryValueEx(HKEY_PERFORMANCE_DATA, L"Global", NULL, NULL, pBuffer, &dwSize);
For more information about the registry functions, go to Using the Registry Functions to Consume Counter Data.
Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the "Applies to" section.
Article ID: 4010202 - Last Review: 2017, ഫെബ്രു 6 - Revision: 11
Windows 10, Windows 8.1, Windows 7, Windows Vista, Windows 8, Windows Server 2016, Windows Server 2012 Datacenter, Windows Server 2012 Foundation, Windows Server 2012 Standard, Windows Server 2012 R2 Essentials, Windows Server 2012 R2 Standard, Windows Server 2012 R2 Foundation, Windows Server 2008 R2 Enterprise, Windows Server 2008 R2 Standard, Windows Server 2008 R2 Datacenter, Windows Server 2008 Enterprise, Windows Server 2008 Datacenter, Windows Server 2008 Standard