From 9fe4a53014aad416df6ea807b0a9de0fe07c30b2 Mon Sep 17 00:00:00 2001 From: David Hall Date: Sun, 6 Jan 2019 19:03:05 -0700 Subject: [PATCH] Fixed IKnownFolderManager.GetFolderIds extension method --- PInvoke/Shell32/ShObjIdl.IKnownFolder.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/PInvoke/Shell32/ShObjIdl.IKnownFolder.cs b/PInvoke/Shell32/ShObjIdl.IKnownFolder.cs index 226209aa..71108f2e 100644 --- a/PInvoke/Shell32/ShObjIdl.IKnownFolder.cs +++ b/PInvoke/Shell32/ShObjIdl.IKnownFolder.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Linq; using System.Runtime.InteropServices; using Vanara.InteropServices; @@ -949,7 +950,7 @@ namespace Vanara.PInvoke // https://docs.microsoft.com/en-us/windows/desktop/api/shobjidl_core/nf-shobjidl_core-iknownfoldermanager-getfolderids HRESULT // GetFolderIds( KNOWNFOLDERID **ppKFId, UINT *pCount ); [PInvokeData("shobjidl_core.h", MSDNShortId = "3ac09fc4-15c4-4346-94ad-2a4617c463d1")] - public static IEnumerable GetFolderIds(this IKnownFolderManager mgr) { mgr.GetFolderIds(out var mem, out var c); return mem.ToEnumerable((int)c); } + public static IEnumerable GetFolderIds(this IKnownFolderManager mgr) { mgr.GetFolderIds(out var mem, out var c); return mem.ToEnumerable((int)c).Select(g => AssociateAttribute.TryEnumLookup(g, out var kf) ? kf : 0); } /// Extension method to simplify using the method. /// Type of the interface to get. @@ -958,7 +959,7 @@ namespace Vanara.PInvoke /// Flags that specify special retrieval options. This value can be 0; otherwise, one or more of the KNOWN_FOLDER_FLAG values. /// /// Receives the interface pointer requested in . - public static T GetShellItem(this IKnownFolder fv, [In] KNOWN_FOLDER_FLAG dwFlags) where T : class => (T)fv.GetShellItem(dwFlags, typeof(T).GUID); + public static T GetShellItem(this IKnownFolder fv, [In] KNOWN_FOLDER_FLAG dwFlags) where T : class => (T)fv.GetShellItem(dwFlags, typeof(T).GUID); /// Defines the specifics of a known folder. [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]