mirror of https://github.com/dahall/Vanara.git
Added KnownFolderIdExt.GetIShellFolder method
parent
c31890cf6a
commit
79947cad6f
|
@ -1,6 +1,7 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Vanara.Extensions;
|
using Vanara.Extensions;
|
||||||
|
using Vanara.InteropServices;
|
||||||
using static Vanara.PInvoke.Shell32;
|
using static Vanara.PInvoke.Shell32;
|
||||||
|
|
||||||
namespace Vanara.PInvoke
|
namespace Vanara.PInvoke
|
||||||
|
@ -24,11 +25,21 @@ namespace Vanara.PInvoke
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Retrieves the IShellItem associated with a <see cref="KNOWNFOLDERID"/>.</summary>
|
/// <summary>Retrieves the IKnownFolder 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="IKnownFolder"/> instance.</returns>
|
||||||
public static IKnownFolder GetIKnownFolder(this KNOWNFOLDERID id) => new IKnownFolderManager().GetFolder(id.Guid());
|
public static IKnownFolder GetIKnownFolder(this KNOWNFOLDERID id) => new IKnownFolderManager().GetFolder(id.Guid());
|
||||||
|
|
||||||
|
/// <summary>Retrieves the IShellFolder associated with a <see cref="KNOWNFOLDERID"/>.</summary>
|
||||||
|
/// <param name="id">The known folder.</param>
|
||||||
|
/// <returns>The <see cref="IShellFolder"/> instance.</returns>
|
||||||
|
public static IShellFolder GetIShellFolder(this KNOWNFOLDERID id)
|
||||||
|
{
|
||||||
|
using var desktop = ComReleaserFactory.Create(new ShellDesktop() as IShellFolder);
|
||||||
|
using var pidl = id.PIDL();
|
||||||
|
return desktop.Item.BindToObject<IShellFolder>(pidl);
|
||||||
|
}
|
||||||
|
|
||||||
/// <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>
|
||||||
|
|
Loading…
Reference in New Issue