使用ListView如何达到Windows资源管理器中显示文件夹和文件一样的功能?不同类型的文件的图标不一样,使用本机关联的文件类型图标!
文件夹容易找到图标,但是我不可能为每一种文件都准备一个图标吧!!应该怎么实现?
文件夹容易找到图标,但是我不可能为每一种文件都准备一个图标吧!!应该怎么实现?
解决方案 »
- Symbol mc3190条码部署问题
- 如何在datagridveiw中使用重写事件后的DataGridViewTextBoxCell
- 如何批量改字体?
- 正则表达式问题(问题看起来有点怕人,其实不复杂,大家帮我看下)
- C#统计数组中的元素
- C#读取XML文件并验证登陆(简单问题,勿笑)
- 如何在console中实现将输入的字符显示为*号
- 求一对节点对应多数据表的界面方案(严重欢迎进入)
- 与oracle数据库建立连接后,如何返回这个session的sid呢?
- 调用自己写的ATL(COM)组件,但是报没有注册类
- 谁有用微软speech语音开发包开发的程序~~~
- 关于利用socket发送长文件的问题:有掉包现象??需求解决办法(50)
郁闷!!大哥请帖一下代码吧!!谢谢!!
public struct SHFILEINFO
{
public IntPtr hIcon;
public int iIcon;
public int dwAttr;
public string szDisplayName;
public string szTypeName;
}[System.Runtime.InteropServices.DllImport("shell32")]
private static extern int SHGetFileInfo(string pszPath, int dwFileAttr, ref SHFILEINFO psfi, int cbFileInfo, int uFlags);
//copy from shellapi.h
const int SHGFI_ICON = 0x000000100; // get icon
const int SHGFI_DISPLAYNAME = 0x000000200; // get display name
const int SHGFI_TYPENAME = 0x000000400; // get type name
const int SHGFI_ATTRIBUTES = 0x000000800; // get attributes
const int SHGFI_ICONLOCATION = 0x000001000; // get icon location
const int SHGFI_EXETYPE = 0x000002000; // return exe type
const int SHGFI_SYSICONINDEX = 0x000004000; // get system icon index
const int SHGFI_LINKOVERLAY = 0x000008000; // put a link overlay on icon
const int SHGFI_SELECTED = 0x000010000; // show icon in selected state
const int SHGFI_ATTR_SPECIFIED = 0x000020000; // get only specified attributes
const int SHGFI_LARGEICON = 0x000000000; // get large icon
const int SHGFI_SMALLICON = 0x000000001; // get small icon
const int SHGFI_OPENICON = 0x000000002; // get open icon
const int SHGFI_SHELLICONSIZE = 0x000000004; // get shell size icon
const int SHGFI_PIDL = 0x000000008; // pszPath is a pidl
const int SHGFI_USEFILEATTRIBUTES = 0x000000010; // use passed dwFileAttribute[System.Runtime.InteropServices.DllImport("user32")]
private static extern bool DestroyIcon(IntPtr hIcon);
......SHFILEINFO fileInfo = new SHFILEINFO();SHGetFileInfo(strFileName,
0,
ref fileInfo,
Marshal.SizeOf(fileInfo),
SHGFI_ICON | SHGFI_SMALLICON);Icon icon = Icon.FromHandle(fileInfo.hIcon);DestroyIcon(fileInfo.hIcon);......
const int SHGFI_ICON = 0x000000100; // get icon
const int SHGFI_DISPLAYNAME = 0x000000200; // get display name
const int SHGFI_TYPENAME = 0x000000400; // get type name
const int SHGFI_ATTRIBUTES = 0x000000800; // get attributes
const int SHGFI_ICONLOCATION = 0x000001000; // get icon location
const int SHGFI_EXETYPE = 0x000002000; // return exe type
const int SHGFI_SYSICONINDEX = 0x000004000; // get system icon index
const int SHGFI_LINKOVERLAY = 0x000008000; // put a link overlay on icon
const int SHGFI_SELECTED = 0x000010000; // show icon in selected state
const int SHGFI_ATTR_SPECIFIED = 0x000020000; // get only specified attributes
const int SHGFI_LARGEICON = 0x000000000; // get large icon
const int SHGFI_SMALLICON = 0x000000001; // get small icon
const int SHGFI_OPENICON = 0x000000002; // get open icon
const int SHGFI_SHELLICONSIZE = 0x000000004; // get shell size icon
const int SHGFI_PIDL = 0x000000008; // pszPath is a pidl
const int SHGFI_USEFILEATTRIBUTES = 0x000000010; // use passed dwFileAttribute