- \r
- private static Icon getIconForPackage(InstalledPackage pkg)\r
- {\r
- string iconPath = pkg.UninstallInfo.IconPath;\r
- if (! string.IsNullOrEmpty(iconPath)) {\r
- if (iconPath.EndsWith(",0") || iconPath.EndsWith(",-0")) {\r
- iconPath = iconPath.Substring(0, iconPath.LastIndexOf(','));\r
- }\r
- if (File.Exists(iconPath)) {\r
- return Icon.ExtractAssociatedIcon(iconPath);\r
- }\r
- } else if (pkg.Type == InstallerType.ARCHIVE) {\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
- return Icon.ExtractAssociatedIcon(link.GetPath(0));\r
- }\r
- }\r
- }\r
- }\r
- }\r
- return null;\r
- }\r
- \r