Пример #1
0
 /// <summary>
 ///     Get icon for executable
 /// </summary>
 /// <param name="path">path to the exe or dll</param>
 /// <param name="index">index of the icon</param>
 /// <param name="useLargeIcon">true to use the large icon, if available</param>
 /// <returns>Bitmap with the icon or null if something happended</returns>
 private static Bitmap GetExeIcon(string path, int index, bool useLargeIcon = true)
 {
     if (!File.Exists(path))
     {
         return(null);
     }
     try
     {
         var appIcon = IconHelper.ExtractAssociatedIcon <Bitmap>(path, index, useLargeIcon);
         if (appIcon != null)
         {
             return(appIcon);
         }
         return(Shell32.GetFileExtensionIcon <Bitmap>(path, useLargeIcon ? IconSize.Large : IconSize.Small, false));
     }
     catch (Exception exIcon)
     {
         Log.Error().WriteLine(exIcon, "error retrieving icon: ");
     }
     return(null);
 }