public static ImageSource LoadSmallIcon(string processFilePath) { var shinfo = new Shell32.SHFILEINFO(); IntPtr hBitmap = Shell32.SHGetFileInfo(processFilePath, 0, ref shinfo, Marshal.SizeOf(shinfo), Shell32.SHGFI_ICON | Shell32.SHGFI_SMALLICON); if (hBitmap == (IntPtr)0) return null; System.Drawing.Icon ico = System.Drawing.Icon.FromHandle(shinfo.hIcon); var source = ico.ToImageSource(); return source; }
public static ImageSource LoadSmallIcon(string processFilePath) { var shinfo = new Shell32.SHFILEINFO(); IntPtr hBitmap = Shell32.SHGetFileInfo(processFilePath, 0, ref shinfo, Marshal.SizeOf(shinfo), Shell32.SHGFI_ICON | Shell32.SHGFI_SMALLICON); if (hBitmap == (IntPtr)0) { return(null); } System.Drawing.Icon ico = System.Drawing.Icon.FromHandle(shinfo.hIcon); var source = ico.ToImageSource(); return(source); }
public static extern IntPtr SHGetFileInfo(string pszPath, uint dwFileAttributes, ref Shell32.SHFILEINFO psfi, int cbFileInfo, uint uFlags);