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;
}