Microsoft KB Archive/235630

{|
 * width="100%"|

PRB: SHGetFileInfo Caches Drive Information

 * }

Q235630

-

The information in this article applies to:


 * Microsoft Win32 Application Programming Interface (API), on platform(s):
 * Microsoft Windows 98
 * Microsoft Windows 95
 * Microsoft Windows NT Server version 4.0
 * Microsoft Windows NT Workstation version 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 kbOSWinNT400 kbSDKPlatform kbShellGrp kbOSWin95 kbOSWin98

Issue type : kbprb

Technology : kbAudDeveloper kbWin32sSearch kbWin32API