Candy.Client.ViewModels.ApplicationViewModel.GetIcon C# (CSharp) Méthode

GetIcon() private static méthode

private static GetIcon ( string filePath, int size ) : System.Windows.Media.Imaging.BitmapSource
filePath string
size int
Résultat System.Windows.Media.Imaging.BitmapSource
        private static BitmapSource GetIcon(string filePath, int size)
        {
            if (!File.Exists(filePath)) return null;

            IntPtr hbitmap;
            IShellItem iShellItem;
            var iIdIShellItem = new Guid("43826d1e-e718-42ee-bc55-a1e261c37bfe");
            SHCreateItemFromParsingName(filePath, IntPtr.Zero, iIdIShellItem, out iShellItem);
            ((IShellItemImageFactory)iShellItem).GetImage(new SIZE(size, size), 0x0, out hbitmap);

            var image = Imaging.CreateBitmapSourceFromHBitmap(hbitmap, IntPtr.Zero, Int32Rect.Empty, null);
            image.Freeze();
            return image;
        }