PRB: SHGetFileInfo Caches Drive Information

ID: Q235630


The information in this article applies to:
  • Microsoft Win32 Application Programming Interface (API), on platform(s):
    • Microsoft Windows versions 95, 98
    • Microsoft Windows NT 4.0


SYMPTOMS

The text and icon information supplied by SHGetFileInfo for drives does not change when the actual drive information has changed.


CAUSE

Once it retrieves text and or icon information for a drive, SHGetFileInfo caches this information and never updates it. This causes SHGetFileInfo to return invalid information for a drive that has changed since the first time that SHGetFileInfo was called. One such situation occurs when the user changes the CD that is in a CDROM drive. Subsequently, the text and icon most likely change, but SHGetFileInfo returns the original text and/or icon information.


RESOLUTION

To force SHGetFileInfo to update its cache, perform the code below. This causes the cached information to be released and reread the next time SHGetFileInfo is called.


IShellFolder   *psfDesktop;

SHGetDesktopFolder(&psfDesktop);
if(psfDesktop)
   {
   LPITEMIDLIST   pidlMyComputer;

   SHGetSpecialFolderLocation(NULL, CSIDL_DRIVES, &pidlMyComputer);
   if(pidlMyComputer)
      {
      IShellFolder   *psfMyComputer;

      psfDesktop->BindToObject(pidlMyComputer, NULL, IID_IShellFolder, (LPVOID*)&psfMyComputer);
      if(psfMyComputer)
         {
         DWORD dwAttr = SFGAO_VALIDATE;
      
         psfMyComputer->GetAttributesOf(0, NULL, &dwAttr);

         psfMyComputer->Release();
         }

      IMalloc  *pMalloc;
      SHGetMalloc(&pMalloc);
      if(pMalloc)
         {
         pMalloc->Free(pidlMyComputer);
         pMalloc->Release();
         }
      }
   psfDesktop->Release();
   } 


STATUS

This problem has been corrected in Windows 2000.

Additional query words:

Keywords : kbLib kbNTOS400 kbSDKPlatform kbShellGrp kbWinOS95 kbWinOS98
Version : winnt:4.0
Platform : winnt
Issue type : kbprb


Last Reviewed: June 25, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.