Example #1
0
 /// <summary>
 /// 从文件扩展名得到文件关联图标
 /// </summary>
 /// <param name="smallIcon">是否是获取小图标,否则是大图标</param>
 /// <returns>图标</returns>
 public Icon GetIcon(bool smallIcon)
 {
     SHFILEINFO fi = new SHFILEINFO();
     Icon ic = null;
     //SHGFI_ICON + SHGFI_USEFILEATTRIBUTES + SmallIcon   
     int iTotal = Win32API.SHGetFileInfo(FileName, 100, ref fi, 0, (uint)(smallIcon ? 273 : 272));
     if (iTotal > 0)
     {
         ic = Icon.FromHandle(fi.HIcon);
     }
     return ic;
 }
Example #2
0
 public static extern int SHGetFileInfo(string pszPath, uint dwFileAttributes, ref   SHFILEINFO psfi, uint cbFileInfo, uint uFlags);