Amoeba.Windows.ObjectToImageConverter.IconUtilities.FileAssociatedImage C# (CSharp) Метод

FileAssociatedImage() публичный статический Метод

public static FileAssociatedImage ( string path, bool isLarge, bool isExist ) : System.Windows.Media.Imaging.BitmapSource
path string
isLarge bool
isExist bool
Результат System.Windows.Media.Imaging.BitmapSource
            public static BitmapSource FileAssociatedImage(string path, bool isLarge, bool isExist)
            {
                var fileInfo = new SHFILEINFO();
                uint flags = SHGFI_ICON;
                if (!isLarge) flags |= SHGFI_SMALLICON;
                if (!isExist) flags |= SHGFI_USEFILEATTRIBUTES;

                try
                {
                    SHGetFileInfo(path, 0, ref fileInfo, (uint)Marshal.SizeOf(fileInfo), flags);

                    if (fileInfo.hIcon == IntPtr.Zero)
                    {
                        return null;
                    }
                    else
                    {
                        return System.Windows.Interop.Imaging.CreateBitmapSourceFromHIcon(fileInfo.hIcon, new Int32Rect(0, 0, 16, 16), BitmapSizeOptions.FromEmptyOptions());
                    }
                }
                finally
                {
                    if (fileInfo.hIcon != IntPtr.Zero)
                    {
                        DestroyIcon(fileInfo.hIcon);
                    }
                }
            }
ObjectToImageConverter.IconUtilities