Microsoft KB Archive/888609

= SetupDiGetDeviceRegistryProperty function returns an incorrect RequiredSize value on DBCS characters in Windows 2000 =

Article ID: 888609

Article Last Modified on 5/12/2007

-

APPLIES TO


 * Microsoft Windows 2000 Advanced Server
 * Microsoft Windows 2000 Server
 * Microsoft Windows 2000 Professional Edition

-





SYMPTOMS
If a call occurs to the SetupDiGetDeviceRegistryProperty function on a double-byte character set (DBCS) character in Microsoft Windows 2000, the function may unexpectedly generate the following error message:

ERROR_INSUFFICIENT_BUFFER

This symptom occurs if the buffer size that was passed to the function was the required size (RequiredSize) value that was returned by the previous call to the same function. Similar functions that return a RequiredSize out parameter, such as the SetupDiGetClassRegistryProperty function, may also return the incorrect RequiredSize value.

Note Examples of double-byte character set (DBCS) languages are Japanese, Korean, and Simplified Chinese.



CAUSE
This problem occurs because the size-conversion logic does not calculate the required buffer size correctly if there are DBCS characters. When a call occurs to the SetupDiGetDeviceRegistryProperty function on DBCS characters, the size that is returned (RequiredSize) is not large enough.



WORKAROUND
To work around this problem, use one of the following methods.

Method 1
When you compile your program, compile the source as Unicode so that wide versions of the functions are called directly.

Method 2
Before you call the SetupDiGetDeviceRegistryProperty function, create a buffer that is large enough to handle the function call. If the function still generates the error message, you can repeatedly add static increments to the buffer size until the function no longer generates the error message.

Method 3
If a call occurs to the SetupDiGetDeviceRegistryProperty function and the function returns the required buffer size in the PDWORD RequiredSize out parameter, double the returned RequiredSize value when you create the buffer.



STATUS
Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the &quot;Applies to&quot; section.



MORE INFORMATION
For more information about the SetupDiGetDeviceRegistryProperty function, visit the following Microsoft Developer Network (MSDN) Web site:

http://msdn2.microsoft.com/en-us/library/aa363456.aspx

For more information about Unicode and character sets, visit the following MSDN Web site:

http://msdn2.microsoft.com/en-us/library/ms776440.aspx

Keywords: kbprb kbtshoot KB888609

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.