示例#1
0
 /// <summary>   
 /// 获取文件夹图标
 /// </summary>   
 /// <returns>图标</returns>   
 public static Icon GetDirectoryIcon()
 {
     SHFILEINFO _shfileinfo = new SHFILEINFO();
     IntPtr _iconIntPtr = Shell32.SHGetFileInfo(@"", 0, ref _shfileinfo, Marshal.SizeOf(_shfileinfo), SHGFI.ICON | SHGFI.LARGEICON);
     if (_iconIntPtr.Equals(IntPtr.Zero)) return null;
     Icon _icon = System.Drawing.Icon.FromHandle(_shfileinfo.hIcon);
     return _icon;
 }
示例#2
0
 /// <summary>   
 /// 获取文件图标
 /// </summary>   
 /// <param name="p_Path">文件全路径</param>   
 /// <returns>图标</returns>   
 public static Icon GetFileIcon(string p_Path)
 {
     SHFILEINFO _shfileinfo = new SHFILEINFO();
     IntPtr _iconIntPtr = Shell32.SHGetFileInfo(p_Path, 0, ref _shfileinfo, Marshal.SizeOf(_shfileinfo), SHGFI.ICON | SHGFI.LARGEICON | SHGFI.USEFILEATTRIBUTES);
     if (_iconIntPtr.Equals(IntPtr.Zero)) return null;
     Icon _icon = System.Drawing.Icon.FromHandle(_shfileinfo.hIcon);
     return _icon;
 }
示例#3
0
 /// <summary>
 /// 根据 PIDL 获取显示名称.
 /// x86 ONLY.
 /// </summary>
 public static string GetNameByPIDL(IntPtr pidl)
 {
     SHFILEINFO info = new SHFILEINFO();
     Shell32.SHGetFileInfo(pidl, 0, ref info, Marshal.SizeOf(typeof(SHFILEINFO)), SHGFI.PIDL | SHGFI.DISPLAYNAME | SHGFI.ICONLOCATION);
     return info.szDisplayName;
 }
示例#4
0
 public static extern IntPtr SHGetFileInfo(string pszPath, FILE_ATTRIBUTE dwFileAttributes, ref SHFILEINFO sfi, int cbFileInfo, SHGFI uFlags);