Exemple #1
0
 public static BitmapSource ExtractAssociatedIcon(string path, bool large)
 {
     ShellFileSystemInfo info = new ShellFileSystemInfo();
     NativeMethods.SHGetFileInfo(path, 0, ref info, Marshal.SizeOf(info), SHGetFileInfoFlags.Icon | (large ? SHGetFileInfoFlags.LargeIcon : SHGetFileInfoFlags.SmallIcon));
     using (Icon icon = Icon.FromHandle(info.IconHandle))
     using (Bitmap bitmap = icon.ToBitmap())
         return BitmapConverter.ToBitmapSource(bitmap);
 }
Exemple #2
0
 public static extern IntPtr SHGetFileInfo(string path, uint attributes, ref ShellFileSystemInfo info, int fileInfoSize, SHGetFileInfoFlags flags);
Exemple #3
0
 public static extern IntPtr SHGetFileInfo(string path, uint attributes, ref ShellFileSystemInfo info, int fileInfoSize, SHGetFileInfoFlags flags);