OSDN Git Service

AppliStation,チケット #23338 AVGをアンインストールしようとするとエラーが発生してしまう 対策
[applistation/AppliStation.git] / AppliStation / AppliStation.Util / GUIUtils.cs
index ee3f014..bd2a8ff 100644 (file)
@@ -58,31 +58,28 @@ namespace AppliStation.Util
                public static Icon GetIconForPackage(InstalledPackage pkg)\r
                {\r
                        Icon ico = null;\r
-                       string iconPath = pkg.UninstallInfo.IconPath;\r
-                       if (! string.IsNullOrEmpty(iconPath)) {\r
-                               try {\r
+                       try {\r
+                               string iconPath = pkg.UninstallInfo.IconPath;\r
+                               if (! string.IsNullOrEmpty(iconPath)) {\r
                                        ico = ExtractIcon(null, iconPath);\r
-                               } catch (FileNotFoundException) {\r
-                                       ico = null;\r
-                               }\r
-                       } else if ((pkg.Type == InstallerType.ARCHIVE)\r
-                                  ||(pkg.Type == InstallerType.ITSELF)) {\r
-                               string progGrp = Path.Combine(NaGet.Env.ArchiveProgramGroup, pkg.Name);\r
-                               if (Directory.Exists(progGrp)) {\r
-                                       string[] lnkFiles = Directory.GetFiles(progGrp, "*.lnk");\r
-                                       \r
-                                       if (lnkFiles.Length >= 1) {\r
-                                               try {\r
+                               } else if ((pkg.Type == InstallerType.ARCHIVE)\r
+                                          ||(pkg.Type == InstallerType.ITSELF)) {\r
+                                       string progGrp = Path.Combine(NaGet.Env.ArchiveProgramGroup, pkg.Name);\r
+                                       if (Directory.Exists(progGrp)) {\r
+                                               string[] lnkFiles = Directory.GetFiles(progGrp, "*.lnk");\r
+                                               \r
+                                               if (lnkFiles.Length >= 1) {\r
                                                        using (NaGet.InteropServices.ShellLink link = new NaGet.InteropServices.ShellLink(lnkFiles[0])) {\r
                                                                if (File.Exists(link.GetPath(0))) {\r
                                                                        ico = Icon.ExtractAssociatedIcon(link.GetPath(0));\r
                                                                }\r
                                                        }\r
-                                               } catch (System.Runtime.InteropServices.COMException) {\r
-                                                       // ShellLinkのオープンあるいは、リンク先解決に失敗した場合\r
                                                }\r
                                        }\r
                                }\r
+                       } catch (System.Runtime.InteropServices.COMException) {\r
+                               // ShellLinkのオープンあるいは、リンク先解決に失敗した場合\r
+                       } catch (Exception) {\r
                        }\r
                        return ico;\r
                }\r