HICON hSmallIcon = NULL;
HICON hBigIcon = NULL;
CComPtr
CComPtr
LPITEMIDLIST DrivePidl = NULL;
HRESULT hr = SHGetDesktopFolder(&DesktopPtr);
BSTR bstr = strFilename.AllocSysString();
hr = DesktopPtr->ParseDisplayName(NULL, NULL,(LPOLESTR)bstr,NULL, &DrivePidl, NULL);
::SysFreeString(bstr);
LPCITEMIDLIST pidlRelative = NULL;
hr = SHBindToParent (DrivePidl, IID_IShellFolder, (LPVOID*)&psfDrives, &pidlRelative);
CComPtr
hr = psfDrives->GetUIObjectOf(NULL, 1, &pidlRelative,
IID_IExtractIcon, NULL, (LPVOID*)&DiskIcon);
DiskIcon->GetIconLocation(0,szFileName,MAX_PATH,&IconIndex,&uFlags);
DiskIcon->Extract(szFileName,IconIndex,&hBigIcon,&hSmallIcon,MAKELONG(16,16));
No comments:
Post a Comment