Microsoft KB Archive/236376

{|
 * width="100%"|

BUG: SHGetFileInfo Fails to Retrieve Attributes with SHGFI_ATTR_SPECIFIED

 * }

Q236376

This article discusses a Beta release of a Microsoft product. The information in this article is provided as-is and is subject to change without notice.

No formal product support is available from Microsoft for this Beta product. For information about obtaining support for a Beta release, please see the documentation included with the Beta product files, or check the Web location from which you downloaded the release.

-

The information in this article applies to:


 * Microsoft Win32 Application Programming Interface (API), on platform(s):
 * Microsoft Windows NT Server version 4.0
 * Microsoft Windows NT Workstation version 4.0

-

SYMPTOMS
When calling SHGetFileInfo with SHGFI_ATTR_SPECIFIED, the file object's attributes are not retrieved correctly. This occurs only when calling the ANSI version of SHGetFileInfo (SHGetFileInfoA) on Windows NT 4.0 or Windows 2000 beta 3.

CAUSE
On Windows NT 4.0 and Windows 2000, SHGetFileInfoA calls SHGetFileInfoW but fails to copy the dwAttributes of the SHFILEINFOA structure to the SHFILEINFOW structure that is passed to SHGetFileInfoW. The dwAttributes member of the SHFILEINFOW structure remains uninitialized, so the attributes retrieved are not predictable.

RESOLUTION
To avoid this problem, you should call SHGetFileInfoW directly. This resolution works only on Windows NT and Windows 2000. On Windows 95 or Windows 98, SHGetFileInfoW is not implemented, and therefore you need to detect the operating system at run time and call the appropriate function.

An alternative resolution is to use IShellFolder::GetAttributesOf to retrieve the attributes for a file object and not SHGetFileInfo.

STATUS
Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article.

Additional query words:

Keywords : kbLib kbOSWinNT400bug kbSDKPlatform kbSDKWin32 kbShellGrp kbOSWin95bug kbOSWin98bug kbDSupport

Issue type : kbbug

Technology : kbAudDeveloper kbWin32sSearch kbWin32API