Fixed a problem with loading the icon from a share, also preventing a NullPointerReference in the MainForm

git-svn-id: http://svn.code.sf.net/p/greenshot/code/trunk@2418 7dccd23d-a4a3-4e1f-8c07-b4c1b4018ab4
This commit is contained in:
RKrom 2013-01-08 10:20:31 +00:00
parent b9a1bd76b5
commit 5ce65ab191
3 changed files with 48 additions and 8 deletions

View file

@ -276,6 +276,7 @@ namespace GreenshotPlugin.Core {
}
}
/// <summary>
/// Get the icon belonging to the process
/// </summary>
@ -289,11 +290,9 @@ namespace GreenshotPlugin.Core {
string filename = ProcessPath;
if (!iconCache.ContainsKey(filename)) {
Image icon = null;
if (File.Exists(filename)) {
using (Icon appIcon = Icon.ExtractAssociatedIcon(filename)) {
if (appIcon != null) {
icon = appIcon.ToBitmap();
}
using (Icon appIcon = Shell32.ExtractAssociatedIcon(filename)) {
if (appIcon != null) {
icon = appIcon.ToBitmap();
}
}
iconCache.Add(filename, icon);