示例#1
0
  public static System.Drawing.Icon GetSystemLargeIcon(string filename)
  {
      const int FILE_ATTRIBUTE_NORMAL = 128;
      SHFILEINFO shFileInfoLargeIcon = new SHFILEINFO();
      /*
       * We are trapping the . so that we can find a file associated with a extension
       * without giving the file location
       */
  	uint dwFileAttributes = filename.Contains(".") ? 0u : FILE_ATTRIBUTE_NORMAL;
 		WindowsAPI.SHGetFileInfo(filename, dwFileAttributes, ref shFileInfoLargeIcon, (uint) Marshal.SizeOf(shFileInfoLargeIcon), WindowsAPI.SHGFI_ICON | WindowsAPI.SHGFI_LARGEICON | WindowsAPI.SHGFI_USEFILEATTRIBUTES);
  	return System.Drawing.Icon.FromHandle(shFileInfoLargeIcon.hIcon);
  }
示例#2
0
 public static System.Drawing.Icon GetSystemIcon(string filename)
 {
     SHFILEINFO shFileInfoSmallIcon = new SHFILEINFO();
     IntPtr hSmallIcon = WindowsAPI.SHGetFileInfo(filename, 0, ref shFileInfoSmallIcon, (uint)Marshal.SizeOf(shFileInfoSmallIcon), WindowsAPI.SHGFI_ICON | WindowsAPI.SHGFI_SMALLICON | WindowsAPI.SHGFI_USEFILEATTRIBUTES);
     return System.Drawing.Icon.FromHandle(shFileInfoSmallIcon.hIcon);
 }
示例#3
0
 public static extern IntPtr SHGetFileInfo(string pszPath,
     uint dwFileAttributes,
     ref SHFILEINFO psfi,
     uint cbSizeFileInfo,
     uint uFlags);