示例#1
0
 public static System.Drawing.Icon GetFileIcon(string strPath, bool bSmall)
 {
     APIsStructs.SHFILEINFO info = new APIsStructs.SHFILEINFO(true);
     APIsEnums.ShellGetFileInformationFlags flags =
         APIsEnums.ShellGetFileInformationFlags.Icon |
         (File.Exists(strPath) ? 0 : APIsEnums.ShellGetFileInformationFlags.UseFileAttributes) |
         (bSmall ? APIsEnums.ShellGetFileInformationFlags.SmallIcon : APIsEnums.ShellGetFileInformationFlags.LargeIcon);
     SHGetFileInfo(strPath,
                   FILE_ATTRIBUTE_NORMAL,
                   out info,
                   (uint)Marshal.SizeOf(info),
                   flags);
     System.Drawing.Icon icon = System.Drawing.Icon.FromHandle(info.hIcon);
     return(icon);
 }
示例#2
0
 public static extern int SHGetFileInfo(
     string pszPath,
     uint dwFileAttributes,
     out APIsStructs.SHFILEINFO psfi,
     uint cbfileInfo,
     APIsEnums.ShellGetFileInformationFlags uFlags);