BUG: SHGetFileInfo Fails to Retrieve Attributes with SHGFI_ATTR_SPECIFIED

ID: 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:


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 kbNTOS400bug kbSDKPlatform kbSDKWin32 kbShellGrp kbWinOS95bug kbWinOS98bug kbDSupport 
Version           : winnt:4.0
Platform          : winnt 
Issue type        : kbbug 

Last Reviewed: July 7, 1999