From 5c8de59975b32a48ed3be1030f1ab18a5b4a95c2 Mon Sep 17 00:00:00 2001 From: Martin Cirillo Date: Tue, 16 Aug 2016 16:56:19 -0300 Subject: [PATCH] Making GetIconFilePath method protected virtual in order to have the possibility to override it There was an issue when the icons were deleted from the temp folder (due to mantainance tasks), generic icons were placed instead. This way we can use icons from a location we know they won't be deleted. --- .../SharpIconOverlayHandler.cs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/SharpShell/SharpShell/SharpIconOverlayHandler/SharpIconOverlayHandler.cs b/SharpShell/SharpShell/SharpIconOverlayHandler/SharpIconOverlayHandler.cs index e3c4a7c6..e30b5ed4 100644 --- a/SharpShell/SharpShell/SharpIconOverlayHandler/SharpIconOverlayHandler.cs +++ b/SharpShell/SharpShell/SharpIconOverlayHandler/SharpIconOverlayHandler.cs @@ -73,8 +73,9 @@ int IShellIconOverlayIdentifier.GetOverlayInfo(IntPtr pwszIconFile, int cchMax, try { + int? iconIndex = null; // Get the icon file path. - var iconFilePath = GetIconFilePath(); + var iconFilePath = GetIconFilePath(out iconIndex); // If we have no file, we must fail. if (string.IsNullOrEmpty(iconFilePath)) @@ -98,6 +99,11 @@ int IShellIconOverlayIdentifier.GetOverlayInfo(IntPtr pwszIconFile, int cchMax, // Set the flags, specifying we'll provide a path. pdwFlags = ISIOI.ISIOI_ICONFILE; + if (iconIndex != null) + { + pdwFlags |= ISIOI.ISIOI_ICONINDEX; + pIndex = iconIndex.Value; + } return WinError.S_OK; } @@ -153,9 +159,12 @@ int IShellIconOverlayIdentifier.GetPriority(out int pPriority) /// /// Gets the icon file path, creating the icon file if needed. /// - /// The icon file path. - private string GetIconFilePath() + /// Index value used to identify the icon in a file that contains multiple icons. + /// The fully qualified path of the file containing the icon. The .dll, .exe, and .ico file types are all acceptable. + protected virtual string GetIconFilePath(out int? index) { + index = null; + // If we're not in debug mode and we've already created the temporary icon file, // we can return it. If we're in debug mode, we'll always create it. #if !DEBUG