mirror of https://github.com/dahall/Vanara.git
Added GetIKnownFolder and Name extension methods.
parent
ce3dc1a0fe
commit
5658b9aad1
|
@ -24,6 +24,11 @@ namespace Vanara.PInvoke
|
||||||
return path;
|
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>
|
/// <summary>Retrieves the IShellItem associated with a <see cref="KNOWNFOLDERID"/>.</summary>
|
||||||
/// <param name="id">The known folder.</param>
|
/// <param name="id">The known folder.</param>
|
||||||
/// <returns>The <see cref="IShellItem"/> instance.</returns>
|
/// <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>
|
/// <summary>Retrieves the name associated with a <see cref="KNOWNFOLDERID"/>.</summary>
|
||||||
/// <param name="id">The known folder.</param>
|
/// <param name="id">The known folder.</param>
|
||||||
/// <returns>The name.</returns>
|
/// <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>
|
/// <summary>Retrieves the PIDL associated with a <see cref="KNOWNFOLDERID"/>.</summary>
|
||||||
/// <param name="id">The known folder.</param>
|
/// <param name="id">The known folder.</param>
|
||||||
|
|
Loading…
Reference in New Issue