Esempio n. 1
0
 private static Icon GetSystemIcon(string path, IconSizeEnum iconsize)
 {
     try
     {
         Win32.SHFILEINFO psfi = new Win32.SHFILEINFO();
         int dwFileAttributes = 128;
         Win32.SHGFI uFlags = Win32.SHGFI.SHGFI_SYSICONINDEX;
         if (Win32.SHGetFileInfo(path, dwFileAttributes, out psfi, (uint)Marshal.SizeOf((object)psfi), uFlags) == 0)
             return (Icon)null;
         int i = psfi.iIcon;
         Guid riid = new Guid("46EB5926-582E-4017-9FDF-E8998DAA0950");
         Win32.IImageList ppv;
         Win32.SHGetImageList((int)iconsize, ref riid, out ppv);
         IntPtr picon = IntPtr.Zero;
         int flags = 1;
         ppv.GetIcon(i, flags, ref picon);
         Icon icon = (Icon)Icon.FromHandle(picon).Clone();
         Win32.DestroyIcon(psfi.hIcon);
         return icon;
     }
     catch
     {
     }
     return (Icon)null;
 }
Esempio n. 2
0
 private static Icon GetSystemIcon(string path, IconSizeEnum iconsize)
 {
     try
     {
         Win32.SHFILEINFO psfi        = new Win32.SHFILEINFO();
         int         dwFileAttributes = 128;
         Win32.SHGFI uFlags           = Win32.SHGFI.SHGFI_SYSICONINDEX;
         if (Win32.SHGetFileInfo(path, dwFileAttributes, out psfi, (uint)Marshal.SizeOf((object)psfi), uFlags) == 0)
         {
             return((Icon)null);
         }
         int              i    = psfi.iIcon;
         Guid             riid = new Guid("46EB5926-582E-4017-9FDF-E8998DAA0950");
         Win32.IImageList ppv;
         Win32.SHGetImageList((int)iconsize, ref riid, out ppv);
         IntPtr picon = IntPtr.Zero;
         int    flags = 1;
         ppv.GetIcon(i, flags, ref picon);
         Icon icon = (Icon)Icon.FromHandle(picon).Clone();
         Win32.DestroyIcon(psfi.hIcon);
         return(icon);
     }
     catch
     {
     }
     return((Icon)null);
 }
Esempio n. 3
0
 private static Icon GetIcon(string path)
 {
     try
     {
         Win32.SHFILEINFO psfi = new Win32.SHFILEINFO();
         Win32.SHGFI uFlags = (Win32.SHGFI)(256 | (int)Globals.RuntimeSettings["defaultFileIconType"]);
         if (Win32.SHGetFileInfo(path, 0, out psfi, (uint)Marshal.SizeOf((object)psfi), uFlags) == 0 || psfi.hIcon == IntPtr.Zero)
             return (Icon)null;
         Icon icon = (Icon)Icon.FromHandle(psfi.hIcon).Clone();
         Win32.DestroyIcon(psfi.hIcon);
         return icon;
     }
     catch
     {
     }
     return (Icon)null;
 }
Esempio n. 4
0
 private static Icon GetIcon(string path)
 {
     try
     {
         Win32.SHFILEINFO psfi   = new Win32.SHFILEINFO();
         Win32.SHGFI      uFlags = (Win32.SHGFI)(256 | (int)Globals.RuntimeSettings["defaultFileIconType"]);
         if (Win32.SHGetFileInfo(path, 0, out psfi, (uint)Marshal.SizeOf((object)psfi), uFlags) == 0 || psfi.hIcon == IntPtr.Zero)
         {
             return((Icon)null);
         }
         Icon icon = (Icon)Icon.FromHandle(psfi.hIcon).Clone();
         Win32.DestroyIcon(psfi.hIcon);
         return(icon);
     }
     catch
     {
     }
     return((Icon)null);
 }
Esempio n. 5
0
 public static extern int SHGetFileInfo(string pszPath, int dwFileAttributes, out Win32.SHFILEINFO psfi, uint cbfileInfo, Win32.SHGFI uFlags);