PRB: SHGetFileInfo Caches Drive Information (235630)
The information in this article applies to:
- Microsoft Win32 Application Programming Interface (API), when used with:
- Microsoft Windows NT Server 4.0
- Microsoft Windows NT Workstation 4.0
This article was previously published under Q235630 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.
Modification Type: | Minor | Last Reviewed: | 12/20/2004 |
---|
Keywords: | kbprb kbShellGrp KB235630 |
---|
|