This is what I did:
LPMALLOC malloc;
LPITEMIDLIST pidl;
SHFILEINFO FileInfo;
SFGAOF sfGao;
if (SUCCEEDED(SHGetMalloc(&malloc))
{
if (SUCCEEDED(SHParseDisplayName(strDirPath, NULL, &pidl, SFGAO_FOLDER, &sfGao)))
{
SHGetFileInfo((LPCWSTR)(PCHAR(pidl)), 0, &FileInfo, sizeof(FileInfo), SHGFI_PIDL | SHGFI_ICON);
CDC* pDC = GetWindowDC();
pDC->DrawIcon(10, 10, FileInfo.hIcon);
ReleaseDC(pDC);
}
malloc->Free(pidl);
}
malloc->Release();
Here is the problem: I found that with this approach I can easily get the folder icon. But I could not get my open icon when I set the fourth method parameter SHGetFileInfoas SHGFI_PIDL | SHGFI_OPENICON. hIconof FileInfoalways NULL, and I don't know why.
Can someone tell me how to fix this problem?
source
share