BUG: The RegQueryValueExA() Function May Return an Incomplete List of Performance Objects (259394)



The information in this article applies to:

  • Microsoft Win32 Application Programming Interface (API), when used with:
    • the operating system: Microsoft Windows NT 4.0

This article was previously published under Q259394

SYMPTOMS

When you call the ANSI version of the RegQueryValueEx function with HKEY_PERFORMANCE_DATA to retrieve "Global" performance data, the function may not return the complete list of all performance objects. If the application supplies a big enough buffer, RegQueryValueEx may succeed with ERROR_SUCCESS, but the buffer may contain only a partial list of performance objects.

RESOLUTION

Instead, use the Unicode version of the RegQueryValueEx function. You can do this by calling the RegQueryValueExW function explicitly (note the trailing "W"). Pass a Unicode string for lpValueName, which is the second parameter.

STATUS

Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article. This bug has been fixed in Microsoft Windows 2000 and later versions.

MORE INFORMATION

This behavior is seen only when the application uses the ANSI version of RegQueryValueEx. The Unicode version of RegQueryValueEx correctly returns all the performance objects when retrieving the "Global" performance data.

The performance data block that is returned by the RegQueryValueExA function (ANSI version) is the same as RegQueryValueExW (Unicode version). Therefore, an application can call RegQueryValueExW explicitly, even from an ANSI build. This method requires that you pass a Unicode string for lpValueName, which is the second parameter of RegQueryValueExW.

Performance Data Helper (PDH) functions use the Unicode version of RegQueryValueEx to retrieve the performance data, and therefore an application can also use PDH to collect the complete list of all performance objects.

REFERENCES

For additional information about how to convert an ANSI string to Unicode, click the article number below to view the article in the Microsoft Knowledge Base:

138813 HOWTO: Convert from ANSI to Unicode and Unicode to ANSI for OLE


Modification Type:MajorLast Reviewed:10/30/2003
Keywords:kbAPI kbBug kbKernBase kbPerfMon KB259394