OSDN Git Service

AppliStation,チケット #23338 AVGをアンインストールしようとするとエラーが発生してしまう 対策
[applistation/AppliStation.git] / AppliStation / AppliStation.Util / GUIUtils.cs
index 9403dfe..bd2a8ff 100644 (file)
@@ -36,14 +36,16 @@ namespace AppliStation.Util
                }\r
                \r
                /// <summary>\r
-               /// シェルからフォルダアイコンを生成して返す\r
+               /// ã\82·ã\82§ã\83«ã\81\8bã\82\89ã\83\95ã\82©ã\83«ã\83\80ã\83¼ã\82¢ã\82¤ã\82³ã\83³ã\82\92ç\94\9fæ\88\90ã\81\97ã\81¦è¿\94ã\81\99\r
                /// </summary>\r
-               /// <returns>フォルダアイコン</returns>\r
-               public static Icon GetShellIconForFolder()\r
+               /// <returns>ã\83\95ã\82©ã\83«ã\83\80ã\83¼ã\82¢ã\82¤ã\82³ã\83³</returns>\r
+               public static Icon ShellIconForFolder\r
                {\r
-                       // Vista以降ならば、SHGetStockIconInfo(SIID_FOLDER, SHGSI_ICON, &sInfo); をP/Invoke呼び出しするのが王道かと\r
-                       string windir = Environment.GetEnvironmentVariable("windir");\r
-                       return NativeMethods.ExtractIcon(null, Path.Combine(windir, @"system32\shell32.dll"), 3);\r
+                       get {\r
+                               // Vista以降ならば、SHGetStockIconInfo(SIID_FOLDER, SHGSI_ICON, &sInfo); をP/Invoke呼び出しするのが王道かと\r
+                               string windir = Environment.GetEnvironmentVariable("windir");\r
+                               return NativeMethods.ExtractIcon(null, Path.Combine(windir, @"system32\shell32.dll"), 3);\r
+                       }\r
                }\r
                \r
                #endregion\r
@@ -56,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