SHFILEINFOW fileInfo;
//得到系统ImageList句柄,第一个参数必须为空字符串
auto hdl = SHGetFileInfo(L"", 0, &fileInfo, sizeof(fileInfo), SHGFI_SYSICONINDEX | SHGFI_SMALLICON);
auto img_list = CImageList::FromHandle((HIMAGELIST)hdl);
m_directory.SetImageList(img_list, TVSIL_NORMAL); //给CTreeView控件设置图标列表
WIN32_FIND_DATAW file;
CString strPath = L"."; //当前目录
HANDLE h = FindFirstFile(strPath + L"\\*",&file);
if (h != INVALID_HANDLE_VALUE)
{
do
{
auto hdl = SHGetFileInfo(strPath + L"\\" + file.cFileName, 0, &fileInfo, sizeof(fileInfo), SHGFI_SYSICONINDEX | SHGFI_SMALLICON);
m_directory.InsertItem(file.cFileName,fileInfo.iIcon, fileInfo.iIcon);
} while (FindNextFile(h, &file));
}
FindClose(h);
MFC实现以系统图标显示的文件管理器
最新推荐文章于 2023-11-24 09:46:23 发布