如题:
代码如下:
void CgetfileinfoDlg::GetFileIconIndex()
{
CoInitialize(NULL);
// DWORD dwIndex;
DWORD_PTR dwRet;
LPCTSTR pszPath = "d:\\backup\\收藏夹";
SHFILEINFO fileInfo;
memset(&fileInfo,0,sizeof(fileInfo));
dwRet = ::SHGetFileInfo(pszPath,0,&fileInfo,sizeof(fileInfo),SHGFI_ICON|SHGFI_SYSICONINDEX);
if (dwRet == 0)
{
AfxMessageBox("获取文件夹信息失败",MB_OK);
return;
}
else
{
CString str;
str.Format("文件夹图标索引为:%d",fileInfo.iIcon);
AfxMessageBox(str,MB_OK);
}
DestroyIcon(fileInfo.hIcon);}
为什么每次调用 不同的图标的文件夹 fileInfo。iIcon总是返回4呢?帮忙看看^
代码如下:
void CgetfileinfoDlg::GetFileIconIndex()
{
CoInitialize(NULL);
// DWORD dwIndex;
DWORD_PTR dwRet;
LPCTSTR pszPath = "d:\\backup\\收藏夹";
SHFILEINFO fileInfo;
memset(&fileInfo,0,sizeof(fileInfo));
dwRet = ::SHGetFileInfo(pszPath,0,&fileInfo,sizeof(fileInfo),SHGFI_ICON|SHGFI_SYSICONINDEX);
if (dwRet == 0)
{
AfxMessageBox("获取文件夹信息失败",MB_OK);
return;
}
else
{
CString str;
str.Format("文件夹图标索引为:%d",fileInfo.iIcon);
AfxMessageBox(str,MB_OK);
}
DestroyIcon(fileInfo.hIcon);}
为什么每次调用 不同的图标的文件夹 fileInfo。iIcon总是返回4呢?帮忙看看^
解决方案 »
- mfc做串口上位机执行时出错,debug assert failed
- 如何只顯示一個對話框
- 关于设置定时器,在VC SDK控制台下
- 很简单的动手问题,大家快来帮忙呀!^_^
- 求救!关于映射模式的问题.
- <<visual c++项目开发实践>> 这本书怎样
- 非法操作
- 我有一modem接在PC串口上,定期向外拨号,请问用TAPI怎么实现,最好能给出VC源码,
- 无法在建立类向导的选项下添加控件变量,
- 我在一个 PropeetyPage 上自己创建了一个 CWnd 派生的窗口并在其上作图,为何加入 PropertySheet 后这个窗口没法接收键盘消息但能接收鼠标消息?
- 请问如何把画在位图上线添加到该位图文件中?
- 求教断言错误。居然发生在 SetPaneText
就是在文件夹属性里 将文件夹图标改成别的图标 再执行函数的话
应该是不一样的图标索引啊,只有在改成shell32.dll里的第一个未知文件的图标后索引才会变一下,不然全部返回4
这个索引是不是对应图标在shell32.dll中的位置呢 如果是的话 改了图标索引就应该跟着变的啊
Retrieve the index of a system image list icon. If successful, the index is copied to the iIcon member of psfi. The return value is a handle to the system image list. Only those images whose indices are successfully copied to iIcon are valid. Attempting to access other images in the system image list will result in undefined behavior.注意最后一句,will result in undefined behavior