Added GetIKnownFolder and Name extension methods.

pull/83/head
David Hall 2019-11-21 16:34:33 -07:00
parent ce3dc1a0fe
commit 5658b9aad1
1 changed files with 22 additions and 1 deletions

View File

@ -24,6 +24,11 @@ namespace Vanara.PInvoke
return path;
}
/// <summary>Retrieves the IShellItem associated with a <see cref="KNOWNFOLDERID"/>.</summary>
/// <param name="id">The known folder.</param>
/// <returns>The <see cref="IShellItem"/> instance.</returns>
public static IKnownFolder GetIKnownFolder(this KNOWNFOLDERID id) => new IKnownFolderManager().GetFolder(id.Guid());
/// <summary>Retrieves the IShellItem associated with a <see cref="KNOWNFOLDERID"/>.</summary>
/// <param name="id">The known folder.</param>
/// <returns>The <see cref="IShellItem"/> instance.</returns>
@ -61,7 +66,23 @@ namespace Vanara.PInvoke
/// <summary>Retrieves the name associated with a <see cref="KNOWNFOLDERID"/>.</summary>
/// <param name="id">The known folder.</param>
/// <returns>The name.</returns>
public static string Name(this KNOWNFOLDERID id) => id.GetRegistryProperty<string>("Name");
public static string Name(this KNOWNFOLDERID id) => id.GetIKnownFolder().Name();
/// <summary>Retrieves the name associated with a <see cref="IKnownFolder"/>.</summary>
/// <param name="kf">The known folder.</param>
/// <returns>The name.</returns>
public static string Name(this IKnownFolder kf)
{
var fd = kf.GetFolderDefinition();
try
{
return fd.pszName.ToString();
}
finally
{
FreeKnownFolderDefinitionFields(fd);
}
}
/// <summary>Retrieves the PIDL associated with a <see cref="KNOWNFOLDERID"/>.</summary>
/// <param name="id">The known folder.</param>