PRB: GIL_DONTCACHE Causes Incorrect Icon to Display in Namespace Extension (214599)



The information in this article applies to:

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

This article was previously published under Q214599

SYMPTOMS

Shell namespace extensions can have different icons for the various shell folders. These icons are displayed in both the tree view and the address bar of Microsoft Windows Explorer.

If the icon handler for a shell folder returns GIL_DONTCACHE as one of the bit flags for the last parameter in the implementation of the IExtractIcon::GetIconLocation function, the icons for the shell namespace extension folder may appear to be random icons.

CAUSE

This problem can occur when the GIL_DONTCACHE flag is set in IExtractIcon::GetIconLocation, without specifying both the szIconFile and piIndex parameters.

RESOLUTION

To force the shell to not cache the icons, and instead to ask the namespace extension for the appropriate icons, do not specify the GIL_DONTCACHE flag for the last parameter in the implementation of the IExtractIcon::GetIconLocation function. If the GIL_DONTCACHE flag is set, also set the szIconFile and piIndex parameters.

STATUS

This behavior is by design.

MORE INFORMATION

Steps to Reproduce Behavior

  1. Build a nonrooted namespace extension that returns different icons for different shell folders. See the "References" section for more information on how to build a namespace extension.
  2. Implement the IExtractIcon interface and return the pointer to this interface from IShellFolder::GetUIObjectOf for IID_IExtractIcon.
  3. In the implementation of IExtractIcon::GetIconLocation, specify GIL_DONTCACHE along with any other flags in the last parameter to the function.
  4. Build the project and register it.
  5. Open and refresh the Explorer window. Traverse to the newly added namespace extension.
  6. Open the root of the namespace extension and select the folders under it.
  7. Select any other level folder or a different folder, and then reselect the old folder.

    Notice that the icon for the newly selected folder may change to a seemingly random one instead of displaying the old icon.
  8. In the implementation of IExtractIcon::GetIconLocation, remove the GIL_DONTCACHE bit while returning.
  9. Restart the shell, and then repeat steps 4 to 6.
  10. Repeat step 7, which results in the correct icon being displayed.

REFERENCES

For additional information on how to build a namespace extension, click the article number below to view the article in the Microsoft Knowledge Base:

178665 SAMPLE: RegView.exe Contains Shell Namespace Extension Example


Modification Type:MinorLast Reviewed:12/20/2004
Keywords:kbIcon kbNameSpace kbprb kbShellGrp KB214599