/// <summary> /// Get icon for executable /// </summary> /// <param name="path">path to the exe or dll</param> /// <param name="index">index of the icon</param> /// <returns>Bitmap with the icon or null if something happended</returns> private static Bitmap GetExeIcon(string path, int index) { if (!File.Exists(path)) { return(null); } try { using (Icon appIcon = ImageHelper.ExtractAssociatedIcon(path, index, conf.UseLargeIcons)) { if (appIcon != null) { return(appIcon.ToBitmap()); } } using (Icon appIcon = Shell32.GetFileIcon(path, conf.UseLargeIcons ? Shell32.IconSize.Large : Shell32.IconSize.Small, false)) { if (appIcon != null) { return(appIcon.ToBitmap()); } } } catch (Exception exIcon) { LOG.Error("error retrieving icon: ", exIcon); } return(null); }
/// <summary> /// Internaly used to create an icon /// </summary> /// <param name="path">path to the exe or dll</param> /// <param name="index">index of the icon</param> /// <returns>Bitmap with the icon or null if something happended</returns> public static Bitmap GetExeIcon(string path, int index) { if (!File.Exists(path)) { return(null); } try { using (Icon appIcon = ImageHelper.ExtractAssociatedIcon(path, index, false)) { if (appIcon != null) { return(appIcon.ToBitmap()); } } } catch (Exception exIcon) { LOG.Error("error retrieving icon: ", exIcon); } return(null); }