Completed Shell32 function adds

pull/10/head
David Hall 2018-07-26 21:11:00 -06:00
parent 4c7d9fc8db
commit 267cd7d18f
4 changed files with 2376 additions and 128 deletions

View File

@ -0,0 +1,146 @@
using System;
using System.Runtime.InteropServices;
using System.Security;
using Vanara.InteropServices;
// ReSharper disable MemberCanBePrivate.Global
// ReSharper disable UnusedParameter.Global
// ReSharper disable UnusedMember.Global
// ReSharper disable FieldCanBeMadeReadOnly.Global
// ReSharper disable InconsistentNaming
// ReSharper disable MemberHidesStaticFromOuterClass
// ReSharper disable UnusedMethodReturnValue.Global
namespace Vanara.PInvoke
{
public static partial class Shell32
{
/// <summary>Exposes methods that enable clients to access items in a collection of objects that support IUnknown.</summary>
[SuppressUnmanagedCodeSecurity]
[ComImport, InterfaceType(ComInterfaceType.InterfaceIsIUnknown), Guid("92CA9DCD-5622-4bba-A805-5E9F541BD8C9")]
[PInvokeData("Shobjidl.h", MSDNShortId = "dd378311")]
public interface IObjectArray
{
/// <summary>Provides a count of the objects in the collection.</summary>
/// <returns>The number of objects in the collection.</returns>
uint GetCount();
/// <summary>
/// Provides a pointer to a specified object's interface. The object and interface are specified by index and interface ID.
/// </summary>
/// <param name="uiIndex">The index of the object</param>
/// <param name="riid">Reference to the desired interface ID.</param>
/// <returns>Receives the interface pointer requested in riid.</returns>
[return: MarshalAs(UnmanagedType.Interface)]
object GetAt([In] uint uiIndex, [In, MarshalAs(UnmanagedType.LPStruct)] Guid riid);
}
/// <summary>
/// Extends the IObjectArray interface by providing methods that enable clients to add and remove objects that support IUnknown in a collection.
/// </summary>
[SuppressUnmanagedCodeSecurity]
[ComImport, InterfaceType(ComInterfaceType.InterfaceIsIUnknown), Guid("5632b1a4-e38a-400a-928a-d4cd63230295"), CoClass(typeof(CEnumerableObjectCollection))]
[PInvokeData("Shobjidl.h", MSDNShortId = "dd378307")]
public interface IObjectCollection
{
/// <summary>Provides a count of the objects in the collection.</summary>
/// <returns>The number of objects in the collection.</returns>
uint GetCount();
/// <summary>
/// Provides a pointer to a specified object's interface. The object and interface are specified by index and interface ID.
/// </summary>
/// <param name="uiIndex">The index of the object</param>
/// <param name="riid">Reference to the desired interface ID.</param>
/// <returns>Receives the interface pointer requested in riid.</returns>
[return: MarshalAs(UnmanagedType.Interface)]
object GetAt([In] uint uiIndex, [In, MarshalAs(UnmanagedType.LPStruct)] Guid riid);
/// <summary>Adds a single object to the collection.</summary>
/// <param name="punk">Pointer to the IUnknown of the object to be added to the collection.</param>
void AddObject([In, MarshalAs(UnmanagedType.Interface)] object punk);
/// <summary>Adds the objects contained in an IObjectArray to the collection.</summary>
/// <param name="poaSource">Pointer to the IObjectArray whose contents are to be added to the collection.</param>
void AddFromArray(IObjectArray poaSource);
/// <summary>Removes a single, specified object from the collection.</summary>
/// <param name="uiIndex">A pointer to the index of the object within the collection.</param>
void RemoveObjectAt(uint uiIndex);
/// <summary>Removes all objects from the collection.</summary>
void Clear();
}
/// <summary>
/// Exposes methods that allow implementers of a custom IAssocHandler object to provide access to its explicit Application User Model
/// ID (AppUserModelID). This information is used to determine whether a particular file type can be added to an application's Jump List.
/// </summary>
[SuppressUnmanagedCodeSecurity]
[ComImport, InterfaceType(ComInterfaceType.InterfaceIsIUnknown), Guid("36db0196-9665-46d1-9ba7-d3709eecf9ed")]
[PInvokeData("Shobjidl.h", MSDNShortId = "dd378302")]
public interface IObjectWithAppUserModelId
{
/// <summary>Sets the application identifier.</summary>
/// <param name="pszAppID">The PSZ application identifier.</param>
void SetAppID([MarshalAs(UnmanagedType.LPWStr)] string pszAppID);
/// <summary>Retrieves a file type handler's explicit Application User Model ID (AppUserModelID), if one has been declared.</summary>
/// <returns></returns>
SafeCoTaskMemString GetAppID();
}
/// <summary>Exposes methods that provide access to the ProgID associated with an object.</summary>
[SuppressUnmanagedCodeSecurity]
[ComImport, InterfaceType(ComInterfaceType.InterfaceIsIUnknown), Guid("71e806fb-8dee-46fc-bf8c-7748a8a1ae13")]
[PInvokeData("Shobjidl.h", MSDNShortId = "dd378294")]
public interface IObjectWithProgId
{
/// <summary>Sets the ProgID of an object.</summary>
/// <param name="pszProgID">A pointer to a string that contains the new ProgID.</param>
void SetProgID([MarshalAs(UnmanagedType.LPWStr)] string pszProgID);
/// <summary>Retrieves the ProgID associated with an object.</summary>
/// <returns>A pointer to a string that, when this method returns successfully, contains the ProgID.</returns>
SafeCoTaskMemString GetProgID();
}
/// <summary>
/// Provides a simple way to support communication between an object and its site in the container.
/// <para>
/// Often an object needs to communicate directly with a container site object and, in effect, manage the site object itself.Outside
/// of IOleObject::SetClientSite, there is no generic means through which an object becomes aware of its site. IObjectWithSite
/// provides simple objects with a simple siting mechanism (lighter than IOleObject) This interface should only be used when
/// IOleObject is not already in use.
/// </para>
/// <para>
/// Through IObjectWithSite, a container can pass the IUnknown pointer of its site to the object through
/// IObjectWithSite::SetSite.Callers can also retrieve the latest site passed to SetSite through IObjectWithSite::GetSite.This latter
/// method is included as a hooking mechanism, allowing a third party to intercept calls from the object to the site.
/// </para>
/// </summary>
[ComImport, InterfaceType(ComInterfaceType.InterfaceIsIUnknown), Guid("fc4801a3-2ba9-11cf-a229-00aa003d7352")]
[PInvokeData("ocidl.h")]
public interface IObjectWithSite
{
/// <summary>Enables a container to pass an object a pointer to the interface for its site.</summary>
/// <param name="pUnkSite">
/// A pointer to the IUnknown interface pointer of the site managing this object. If NULL, the object should call Release on any
/// existing site at which point the object no longer knows its site.
/// </param>
void SetSite([In, MarshalAs(UnmanagedType.IUnknown)] object pUnkSite);
/// <summary>Retrieves the latest site passed using SetSite.</summary>
/// <param name="riid">The IID of the interface pointer that should be returned in ppvSite.</param>
/// <returns>
/// Address of pointer variable that receives the interface pointer requested in riid. Upon successful return, *ppvSite contains
/// the requested interface pointer to the site last seen in SetSite. The specific interface returned depends on the riid
/// argument in essence, the two arguments act identically to those in QueryInterface. If the appropriate interface pointer is
/// available, the object must call AddRef on that pointer before returning successfully. If no site is available, or the
/// requested interface is not supported, this method must *ppvSite to NULL and return a failure code.
/// </returns>
[return: MarshalAs(UnmanagedType.IUnknown)]
object GetSite([In, MarshalAs(UnmanagedType.LPStruct)] Guid riid);
}
}
}

View File

@ -878,134 +878,6 @@ namespace Vanara.PInvoke
Guid GetJunctionCLSID();
}
/// <summary>Exposes methods that enable clients to access items in a collection of objects that support IUnknown.</summary>
[SuppressUnmanagedCodeSecurity]
[ComImport, InterfaceType(ComInterfaceType.InterfaceIsIUnknown), Guid("92CA9DCD-5622-4bba-A805-5E9F541BD8C9")]
[PInvokeData("Shobjidl.h", MSDNShortId = "dd378311")]
public interface IObjectArray
{
/// <summary>Provides a count of the objects in the collection.</summary>
/// <returns>The number of objects in the collection.</returns>
uint GetCount();
/// <summary>
/// Provides a pointer to a specified object's interface. The object and interface are specified by index and interface ID.
/// </summary>
/// <param name="uiIndex">The index of the object</param>
/// <param name="riid">Reference to the desired interface ID.</param>
/// <returns>Receives the interface pointer requested in riid.</returns>
[return: MarshalAs(UnmanagedType.Interface)]
object GetAt([In] uint uiIndex, [In, MarshalAs(UnmanagedType.LPStruct)] Guid riid);
}
/// <summary>
/// Extends the IObjectArray interface by providing methods that enable clients to add and remove objects that support IUnknown in a collection.
/// </summary>
[SuppressUnmanagedCodeSecurity]
[ComImport, InterfaceType(ComInterfaceType.InterfaceIsIUnknown), Guid("5632b1a4-e38a-400a-928a-d4cd63230295"), CoClass(typeof(CEnumerableObjectCollection))]
[PInvokeData("Shobjidl.h", MSDNShortId = "dd378307")]
public interface IObjectCollection
{
/// <summary>Provides a count of the objects in the collection.</summary>
/// <returns>The number of objects in the collection.</returns>
uint GetCount();
/// <summary>
/// Provides a pointer to a specified object's interface. The object and interface are specified by index and interface ID.
/// </summary>
/// <param name="uiIndex">The index of the object</param>
/// <param name="riid">Reference to the desired interface ID.</param>
/// <returns>Receives the interface pointer requested in riid.</returns>
[return: MarshalAs(UnmanagedType.Interface)]
object GetAt([In] uint uiIndex, [In, MarshalAs(UnmanagedType.LPStruct)] Guid riid);
/// <summary>Adds a single object to the collection.</summary>
/// <param name="punk">Pointer to the IUnknown of the object to be added to the collection.</param>
void AddObject([In, MarshalAs(UnmanagedType.Interface)] object punk);
/// <summary>Adds the objects contained in an IObjectArray to the collection.</summary>
/// <param name="poaSource">Pointer to the IObjectArray whose contents are to be added to the collection.</param>
void AddFromArray(IObjectArray poaSource);
/// <summary>Removes a single, specified object from the collection.</summary>
/// <param name="uiIndex">A pointer to the index of the object within the collection.</param>
void RemoveObjectAt(uint uiIndex);
/// <summary>Removes all objects from the collection.</summary>
void Clear();
}
/// <summary>
/// Exposes methods that allow implementers of a custom IAssocHandler object to provide access to its explicit Application User Model
/// ID (AppUserModelID). This information is used to determine whether a particular file type can be added to an application's Jump List.
/// </summary>
[SuppressUnmanagedCodeSecurity]
[ComImport, InterfaceType(ComInterfaceType.InterfaceIsIUnknown), Guid("36db0196-9665-46d1-9ba7-d3709eecf9ed")]
[PInvokeData("Shobjidl.h", MSDNShortId = "dd378302")]
public interface IObjectWithAppUserModelId
{
/// <summary>Sets the application identifier.</summary>
/// <param name="pszAppID">The PSZ application identifier.</param>
void SetAppID([MarshalAs(UnmanagedType.LPWStr)] string pszAppID);
/// <summary>Retrieves a file type handler's explicit Application User Model ID (AppUserModelID), if one has been declared.</summary>
/// <returns></returns>
SafeCoTaskMemString GetAppID();
}
/// <summary>Exposes methods that provide access to the ProgID associated with an object.</summary>
[SuppressUnmanagedCodeSecurity]
[ComImport, InterfaceType(ComInterfaceType.InterfaceIsIUnknown), Guid("71e806fb-8dee-46fc-bf8c-7748a8a1ae13")]
[PInvokeData("Shobjidl.h", MSDNShortId = "dd378294")]
public interface IObjectWithProgId
{
/// <summary>Sets the ProgID of an object.</summary>
/// <param name="pszProgID">A pointer to a string that contains the new ProgID.</param>
void SetProgID([MarshalAs(UnmanagedType.LPWStr)] string pszProgID);
/// <summary>Retrieves the ProgID associated with an object.</summary>
/// <returns>A pointer to a string that, when this method returns successfully, contains the ProgID.</returns>
SafeCoTaskMemString GetProgID();
}
/// <summary>
/// Provides a simple way to support communication between an object and its site in the container.
/// <para>
/// Often an object needs to communicate directly with a container site object and, in effect, manage the site object itself.Outside
/// of IOleObject::SetClientSite, there is no generic means through which an object becomes aware of its site. IObjectWithSite
/// provides simple objects with a simple siting mechanism (lighter than IOleObject) This interface should only be used when
/// IOleObject is not already in use.
/// </para>
/// <para>
/// Through IObjectWithSite, a container can pass the IUnknown pointer of its site to the object through
/// IObjectWithSite::SetSite.Callers can also retrieve the latest site passed to SetSite through IObjectWithSite::GetSite.This latter
/// method is included as a hooking mechanism, allowing a third party to intercept calls from the object to the site.
/// </para>
/// </summary>
[ComImport, InterfaceType(ComInterfaceType.InterfaceIsIUnknown), Guid("fc4801a3-2ba9-11cf-a229-00aa003d7352")]
[PInvokeData("ocidl.h")]
public interface IObjectWithSite
{
/// <summary>Enables a container to pass an object a pointer to the interface for its site.</summary>
/// <param name="pUnkSite">
/// A pointer to the IUnknown interface pointer of the site managing this object. If NULL, the object should call Release on any
/// existing site at which point the object no longer knows its site.
/// </param>
void SetSite([In, MarshalAs(UnmanagedType.IUnknown)] object pUnkSite);
/// <summary>Retrieves the latest site passed using SetSite.</summary>
/// <param name="riid">The IID of the interface pointer that should be returned in ppvSite.</param>
/// <returns>
/// Address of pointer variable that receives the interface pointer requested in riid. Upon successful return, *ppvSite contains
/// the requested interface pointer to the site last seen in SetSite. The specific interface returned depends on the riid
/// argument in essence, the two arguments act identically to those in QueryInterface. If the appropriate interface pointer is
/// available, the object must call AddRef on that pointer before returning successfully. If no site is available, or the
/// requested interface is not supported, this method must *ppvSite to NULL and return a failure code.
/// </returns>
[return: MarshalAs(UnmanagedType.IUnknown)]
object GetSite([In, MarshalAs(UnmanagedType.LPStruct)] Guid riid);
}
/// <summary>
/// Exposes methods that the Shell uses to retrieve flags and info tip information for an item that resides in an IShellFolder
/// implementation. Info tips are usually displayed inside a tooltip control.
@ -1676,6 +1548,108 @@ namespace Vanara.PInvoke
[PInvokeData("shobjidl_core.h", MSDNShortId = "53953a5a-04a2-4749-a03b-8cbd5ac889f1")]
public static extern HRESULT SHGetTemporaryPropertyForItem(IShellItem psi, ref PROPERTYKEY propkey, PROPVARIANT ppropvar);
/// <summary>
/// <para>Applies the default set of properties on a Shell item.</para>
/// </summary>
/// <param name="hwnd">
/// <para>Type: <c>HWND</c></para>
/// <para>A handle to the item's parent window, which receives error notifications. This value can be <c>NULL</c>.</para>
/// </param>
/// <param name="psi">
/// <para>Type: <c>IShellItem*</c></para>
/// <para>A pointer to the IShellItem object that represents the item.</para>
/// </param>
/// <param name="dwFileOpFlags">
/// <para>Type: <c>DWORD</c></para>
/// <para>Flags that customize the operation. See IFileOperation::SetOperationFlags for flag values.</para>
/// </param>
/// <param name="pfops">
/// <para>Type: <c>IFileOperationProgressSink*</c></para>
/// <para>
/// A pointer to an IFileOperationProgressSink object used to follow the progress of the operation. See IFileOperation::Advise for
/// details. This value can be <c>NULL</c>.
/// </para>
/// </param>
/// <returns>
/// <para>Type: <c>HRESULT</c></para>
/// <para>If this function succeeds, it returns <c>S_OK</c>. Otherwise, it returns an <c>HRESULT</c> error code.</para>
/// </returns>
/// <remarks>
/// <para>
/// The list of properties to set a default value comes from the <c>SetDefaultsFor</c> registry entry under the ProgID for the file
/// association of the item. The list is prefixed by "" and contains the canonical names of the properties to set the default value,
/// for example, "". The possible properties for this list are System.Author, System.Document.DateCreated, and
/// System.Photo.DateTaken. If the <c>SetDefaultsFor</c> entry does not exist on the ProgID, this function uses the default found on
/// the <c>SetDefaultsFor</c> entry of <c>HKEY_CLASSES_ROOT</c>&lt;b&gt;*.
/// </para>
/// </remarks>
// https://docs.microsoft.com/en-us/windows/desktop/api/shobjidl/nf-shobjidl-shsetdefaultproperties SHSTDAPI SHSetDefaultProperties(
// HWND hwnd, IShellItem *psi, DWORD dwFileOpFlags, IFileOperationProgressSink *pfops );
[DllImport(Lib.Shell32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("shobjidl.h", MSDNShortId = "c3ab80a3-c1f3-4223-9fe3-f7fe48c36460")]
public static extern HRESULT SHSetDefaultProperties(HandleRef hwnd, IShellItem psi, FILEOP_FLAGS dwFileOpFlags, IFileOperationProgressSink pfops);
/// <summary>
/// <para>
/// Sets a temporary property for the specified item. A temporary property is kept in a read/write store that holds properties only
/// for the lifetime of the IShellItem object, instead of writing them back into the item.
/// </para>
/// </summary>
/// <param name="psi">
/// <para>Type: <c>IShellItem*</c></para>
/// <para>A pointer to the item on which the temporary property is to be set.</para>
/// </param>
/// <param name="propkey">
/// <para>Type: <c>REFPROPERTYKEY</c></para>
/// <para>Reference to the PROPERTYKEY that identifies the temporary property that is being set.</para>
/// </param>
/// <param name="propvar">
/// <para>Type: <c>REFPROPVARIANT</c></para>
/// <para>Reference to a PROPVARIANT that contains the value of the temporary property.</para>
/// </param>
/// <returns>
/// <para>Type: <c>HRESULT</c></para>
/// <para>If this function succeeds, it returns <c>S_OK</c>. Otherwise, it returns an <c>HRESULT</c> error code.</para>
/// </returns>
/// <remarks>
/// <para>A temporary value can only be read with SHGetTemporaryPropertyForItem or by passing GPS_TEMPORARY to IShellItem2::GetPropertyStore.</para>
/// </remarks>
// https://docs.microsoft.com/en-us/windows/desktop/api/shobjidl_core/nf-shobjidl_core-shsettemporarypropertyforitem SHSTDAPI
// SHSetTemporaryPropertyForItem( IShellItem *psi, REFPROPERTYKEY propkey, REFPROPVARIANT propvar );
[DllImport(Lib.Shell32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("shobjidl_core.h", MSDNShortId = "779b1b2e-cd4b-404f-9d50-ac87b81640d2")]
public static extern HRESULT SHSetTemporaryPropertyForItem(IShellItem psi, [MarshalAs(UnmanagedType.LPStruct)] PROPERTYKEY propkey, PROPVARIANT propvar);
/// <summary>
/// <para>Deprecated. Returns a pointer to an ITEMIDLIST structure when passed a path.</para>
/// </summary>
/// <param name="pszPath">
/// <para>Type: <c>PCWSTR</c></para>
/// <para>A pointer to a null-terminated string that contains the path to be converted to a PIDL.</para>
/// </param>
/// <returns>
/// <para>Type: <c>PIDLIST_ABSOLUTE</c></para>
/// <para>Returns a pointer to an ITEMIDLIST structure if successful, or <c>NULL</c> otherwise.</para>
/// </returns>
/// <remarks>
/// <para>Prior to Windows 7, this function was declared in Shlobj.h. In Windows 7 and later versions, it is declared in Shobjidl.h.</para>
/// <para>
/// <c>Note</c> This function is available through Windows 7 and Windows Server 2003. It is possible that it will not be present in
/// future versions of Windows.
/// </para>
/// <para>An alternative to this function is as follows:</para>
/// <list type="number">
/// <item>Call SHGetDesktopFolder to obtain IShellFolder for the desktop folder.</item>
/// <item>Get the IShellFolder's bind context (IBindCtx).</item>
/// <item>Call IShellFolder::ParseDisplayName with the IBindCtx and the path.</item>
/// </list>
/// </remarks>
// https://docs.microsoft.com/en-us/windows/desktop/api/shobjidl_core/nf-shobjidl_core-shsimpleidlistfrompath PIDLIST_ABSOLUTE
// SHSimpleIDListFromPath( PCWSTR pszPath );
[DllImport(Lib.Shell32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("shobjidl_core.h", MSDNShortId = "349974c2-4ab9-4eb2-897d-a5934893ed07")]
public static extern PIDL SHSimpleIDListFromPath([MarshalAs(UnmanagedType.LPWStr)] string pszPath);
/// <summary>Clones an ITEMIDLIST structure.</summary>
/// <param name="pidl">A pointer to the ITEMIDLIST structure to be cloned.</param>
/// <returns>Returns a pointer to a copy of the ITEMIDLIST structure pointed to by pidl.</returns>

View File

@ -3,6 +3,7 @@ using System.IO;
using System.Runtime.InteropServices;
using System.Text;
using Vanara.InteropServices;
using static Vanara.PInvoke.AdvApi32;
using static Vanara.PInvoke.Kernel32;
using static Vanara.PInvoke.PropSys;
@ -328,6 +329,50 @@ namespace Vanara.PInvoke
PRINTACTION_SERVERPROPERTIES = 7,
}
/// <summary>
/// <para>
/// Specifies the state of the machine for the current user in relation to the propriety of sending a notification. Used by SHQueryUserNotificationState.
/// </para>
/// </summary>
// https://docs.microsoft.com/en-us/windows/desktop/api/shellapi/ne-shellapi-query_user_notification_state typedef enum
// QUERY_USER_NOTIFICATION_STATE { QUNS_NOT_PRESENT , QUNS_BUSY , QUNS_RUNNING_D3D_FULL_SCREEN , QUNS_PRESENTATION_MODE ,
// QUNS_ACCEPTS_NOTIFICATIONS , QUNS_QUIET_TIME , QUNS_APP } ;
[PInvokeData("shellapi.h", MSDNShortId = "b26439dd-6695-45d8-8c7f-5bbd5eaf5b54")]
public enum QUERY_USER_NOTIFICATION_STATE
{
/// <summary>A screen saver is displayed, the machine is locked, or a nonactive Fast User Switching session is in progress.</summary>
QUNS_NOT_PRESENT = 1,
/// <summary>
/// A full-screen application is running or Presentation Settings are applied. Presentation Settings allow a user to put their
/// machine into a state fit for an uninterrupted presentation, such as a set of PowerPoint slides, with a single click.
/// </summary>
QUNS_BUSY,
/// <summary>A full-screen (exclusive mode) Direct3D application is running.</summary>
QUNS_RUNNING_D3D_FULL_SCREEN,
/// <summary>The user has activated Windows presentation settings to block notifications and pop-up messages.</summary>
QUNS_PRESENTATION_MODE,
/// <summary>None of the other states are found, notifications can be freely sent.</summary>
QUNS_ACCEPTS_NOTIFICATIONS,
/// <summary>
/// Introduced in Windows 7. The current user is in "quiet time", which is the first hour after a new user logs into his or her
/// account for the first time. During this time, most notifications should not be sent or shown. This lets a user become
/// accustomed to a new computer system without those distractions. Quiet time also occurs for each user after an operating
/// system upgrade or clean installation. Applications should set the NIIF_RESPECT_QUIET_TIME flag in their notifications or
/// balloon tooltip, which prevents those items from being displayed while the current user is in the quiet-time state. Note that
/// during quiet time, if the user is in one of the other blocked modes (QUNS_NOT_PRESENT, QUNS_BUSY, QUNS_PRESENTATION_MODE, or
/// QUNS_RUNNING_D3D_FULL_SCREEN) SHQueryUserNotificationState returns only that value, and does not report QUNS_QUIET_TIME.
/// </summary>
QUNS_QUIET_TIME,
/// <summary>Introduced in Windows 8. A Windows Store app is running.</summary>
QUNS_APP,
}
/// <summary>Flags that indicate the content and validity of the other structure members in <see cref="SHELLEXECUTEINFO"/>.</summary>
[PInvokeData("Shellapi.h", MSDNShortId = "bb759784")]
[Flags]
@ -2871,6 +2916,216 @@ namespace Vanara.PInvoke
[PInvokeData("shellapi.h", MSDNShortId = "d2c4f37e-6e9d-4536-90ea-d69461c4105a")]
public static extern HRESULT SHLoadNonloadedIconOverlayIdentifiers();
/// <summary>
/// <para>Retrieves the size of the Recycle Bin and the number of items in it, for a specified drive.</para>
/// </summary>
/// <param name="pszRootPath">
/// <para>Type: <c>LPCTSTR</c></para>
/// <para>
/// The address of a <c>null</c>-terminated string of maximum length MAX_PATH to contain the path of the root drive on which the
/// Recycle Bin is located. This parameter can contain the address of a string formatted with the drive, folder, and subfolder names (C:\Windows\System...).
/// </para>
/// </param>
/// <param name="pSHQueryRBInfo">
/// <para>Type: <c>LPSHQUERYRBINFO</c></para>
/// <para>
/// The address of a SHQUERYRBINFO structure that receives the Recycle Bin information. The <c>cbSize</c> member of the structure
/// must be set to the size of the structure before calling this API.
/// </para>
/// </param>
/// <returns>
/// <para>Type: <c>HRESULT</c></para>
/// <para>If this function succeeds, it returns <c>S_OK</c>. Otherwise, it returns an <c>HRESULT</c> error code.</para>
/// </returns>
/// <remarks>
/// <para>
/// With Windows 2000, if <c>NULL</c> is passed in the parameter, the function fails and returns an E_INVALIDARG error code. In
/// earlier versions of the operating system, you can pass an empty string or <c>NULL</c>. If contains an empty string or
/// <c>NULL</c>, information is retrieved for all Recycle Bins on all drives.
/// </para>
/// </remarks>
// https://docs.microsoft.com/en-us/windows/desktop/api/shellapi/nf-shellapi-shqueryrecyclebina SHSTDAPI SHQueryRecycleBinA( LPCSTR
// pszRootPath, LPSHQUERYRBINFO pSHQueryRBInfo );
[DllImport(Lib.Shell32, SetLastError = false, CharSet = CharSet.Auto)]
[PInvokeData("shellapi.h", MSDNShortId = "a9a80486-2c99-4916-af25-10b00573456b")]
public static extern HRESULT SHQueryRecycleBin(string pszRootPath, ref SHQUERYRBINFO pSHQueryRBInfo);
/// <summary>
/// <para>Checks the state of the computer for the current user to determine whether sending a notification is appropriate.</para>
/// </summary>
/// <param name="pquns">
/// <para>Type: <c>QUERY_USER_NOTIFICATION_STATE*</c></para>
/// <para>When this function returns, contains a pointer to one of the values of the QUERY_USER_NOTIFICATION_STATE enumeration.</para>
/// </param>
/// <returns>
/// <para>Type: <c>HRESULT</c></para>
/// <para>If this function succeeds, it returns <c>S_OK</c>. Otherwise, it returns an <c>HRESULT</c> error code.</para>
/// </returns>
/// <remarks>
/// <para>
/// Applications should call <c>SHQueryUserNotificationState</c> and test the return value before displaying any notification UI that
/// is similar to the balloon notifications generated by Shell_NotifyIcon. Notifications should only be displayed if this API returns
/// QNS_ACCEPTS_NOTIFICATIONS. This informs the application whether the user is running processes that should not be interrupted.
/// Top-level windows receive a WM_SETTINGCHANGE message when the user turns presentation settings on or off, and also when the
/// user's session is locked or unlocked. Note that there are no notifications sent when the user starts or stops a full-screen application.
/// </para>
/// <para>If this function returns QUNS_QUIET_TIME, notifications should be displayed only if critical.</para>
/// </remarks>
// https://docs.microsoft.com/en-us/windows/desktop/api/shellapi/nf-shellapi-shqueryusernotificationstate SHSTDAPI
// SHQueryUserNotificationState( QUERY_USER_NOTIFICATION_STATE *pquns );
[DllImport(Lib.Shell32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("shellapi.h", MSDNShortId = "da6b3915-f4fe-4bab-9bae-9bff0b97b5a0")]
public static extern HRESULT SHQueryUserNotificationState(out QUERY_USER_NOTIFICATION_STATE pquns);
/// <summary>
/// <para>Removes the localized name of a file in a Shell folder.</para>
/// </summary>
/// <param name="pszPath">
/// <para>Type: <c>PCWSTR</c></para>
/// <para>A pointer to a null-terminated, Unicode string that specifies the fully qualified path of the target file.</para>
/// </param>
/// <returns>
/// <para>Type: <c>HRESULT</c></para>
/// <para>If this function succeeds, it returns <c>S_OK</c>. Otherwise, it returns an <c>HRESULT</c> error code.</para>
/// </returns>
/// <remarks>
/// <para>
/// When a display name string is set by SHSetLocalizedName, Windows Explorer uses that string for display instead of the file name.
/// The path to the file is unchanged.
/// </para>
/// <para>
/// Applications can use the IShellFolder::GetDisplayNameOf method to get the display (localized) name through with the
/// SIGDN_NORMALDISPLAY flag and the parsing (non-localized) name with SIGDN_DESKTOPABSOLUTEPARSING.
/// </para>
/// <para>Calling <c>SHRemoveLocalizedName</c> makes the display name identical to the parsing name.</para>
/// </remarks>
// https://docs.microsoft.com/en-us/windows/desktop/api/shellapi/nf-shellapi-shremovelocalizedname SHSTDAPI SHRemoveLocalizedName(
// PCWSTR pszPath );
[DllImport(Lib.Shell32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("shellapi.h", MSDNShortId = "ed30546f-3531-42df-9018-1a24a79a0b79")]
public static extern HRESULT SHRemoveLocalizedName([MarshalAs(UnmanagedType.LPWStr)] string pszPath);
/// <summary>
/// <para>Sets the localized name of a file in a Shell folder.</para>
/// </summary>
/// <param name="pszPath">
/// <para>Type: <c>PCWSTR</c></para>
/// <para>A pointer to a string that specifies the fully qualified path of the target file.</para>
/// </param>
/// <param name="pszResModule">
/// <para>Type: <c>PCWSTR</c></para>
/// <para>A pointer to a string resource that specifies the localized version of the file name.</para>
/// </param>
/// <param name="idsRes">
/// <para>Type: <c>int</c></para>
/// <para>An integer ID that specifies the localized file name in the string resource.</para>
/// </param>
/// <returns>
/// <para>Type: <c>HRESULT</c></para>
/// <para>If this function succeeds, it returns <c>S_OK</c>. Otherwise, it returns an <c>HRESULT</c> error code.</para>
/// </returns>
/// <remarks>
/// <para>When this string is set, Explorer displays this string instead of the file name. The path to the file is unchanged.</para>
/// <para>
/// Applications can get the display (localized) name with IShellFolder::GetDisplayNameOf with the SIGDN_NORMALDISPLAY flag and the
/// parsing (non-localized) name with IShellItem::GetDisplayName using the SIGDN_DESKTOPABSOLUTEPARSING flag.
/// </para>
/// <para>Calling SHRemoveLocalizedName makes the display name identical to the parsing name.</para>
/// </remarks>
// https://docs.microsoft.com/en-us/windows/desktop/api/shellapi/nf-shellapi-shsetlocalizedname SHSTDAPI SHSetLocalizedName( PCWSTR
// pszPath, PCWSTR pszResModule, int idsRes );
[DllImport(Lib.Shell32, SetLastError = false, ExactSpelling = true, CharSet = CharSet.Unicode)]
[PInvokeData("shellapi.h", MSDNShortId = "35b83fc8-3dad-4f08-a3fe-ce047b2ca3a2")]
public static extern HRESULT SHSetLocalizedName(string pszPath, string pszResModule, int idsRes);
/// <summary>
/// <para>Stores the current user's unread message count for a specified email account in the registry.</para>
/// </summary>
/// <param name="pszMailAddress">
/// <para>Type: <c>LPCTSTR</c></para>
/// <para>A pointer to a string in Unicode that contains the current user's full email address.</para>
/// </param>
/// <param name="dwCount">
/// <para>Type: <c>DWORD</c></para>
/// <para>The number of unread messages.</para>
/// </param>
/// <param name="pszShellExecuteCommand">
/// <para>Type: <c>LPCTSTR</c></para>
/// <para>
/// A pointer to a string in Unicode that contains the full text of a command that can be passed to ShellExecute. This command should
/// start the email application that owns the account referenced by .
/// </para>
/// </param>
/// <returns>
/// <para>Type: <c>HRESULT</c></para>
/// <para><c>HRESULT</c>, which includes the following possible values.</para>
/// <list type="table">
/// <listheader>
/// <term>Return code</term>
/// <term>Description</term>
/// </listheader>
/// <item>
/// <term>S_OK</term>
/// <term>The call completed successfully.</term>
/// </item>
/// <item>
/// <term>E_OUTOFMEMORY</term>
/// <term>Insufficient memory available.</term>
/// </item>
/// <item>
/// <term>E_INVALIDARG</term>
/// <term>Invalid string argument in either the or parameters.</term>
/// </item>
/// </list>
/// </returns>
/// <remarks>
/// <para>When this function updates the registry, the new registry entry is automatically stamped with the current time and date.</para>
/// <para>
/// If this function is called by different independent software vendors (ISVs) that specify the same email name, only the last call
/// is saved. That is, calls to this function overwrite any previously saved value for the same email address, even if the calls are
/// made by different ISVs.
/// </para>
/// <para>
/// It is recommended that the count of unread messages be set only for the main Inbox of the users account. Mail in sub-folders such
/// as Drafts or Deleted Items should be ignored.
/// </para>
/// <para>
/// It is important that email clients do not set the number of unread messages to 0 when the application exits, because this causes
/// the number of unread messages to be erroneously reported as 0.
/// </para>
/// <para>Because this function uses HKEY_CURRENT_USER, it should not be called by a system process impersonating a user.</para>
/// </remarks>
// https://docs.microsoft.com/en-us/windows/desktop/api/shellapi/nf-shellapi-shsetunreadmailcountw HRESULT SHSetUnreadMailCountW(
// LPCWSTR pszMailAddress, DWORD dwCount, LPCWSTR pszShellExecuteCommand );
[DllImport(Lib.Shell32, SetLastError = false, ExactSpelling = true, CharSet = CharSet.Unicode)]
[PInvokeData("shellapi.h", MSDNShortId = "4a0e1ade-8df1-41b5-b6ea-dad427b50f5a")]
public static extern HRESULT SHSetUnreadMailCountW(string pszMailAddress, uint dwCount, string pszShellExecuteCommand);
/// <summary>
/// <para>Uses CheckTokenMembership to test whether the given token is a member of the local group with the specified RID.</para>
/// </summary>
/// <param name="hToken">
/// <para>Type: <c>HANDLE</c></para>
/// <para>A handle to the token. This value can be <c>NULL</c>.</para>
/// </param>
/// <param name="ulRID">
/// <para>Type: <c>ULONG</c></para>
/// <para>The RID of the local group for which membership is tested.</para>
/// </param>
/// <returns>
/// <para>Type: <c>BOOL</c></para>
/// <para>Returns <c>TRUE</c> on success, <c>FALSE</c> on failure.</para>
/// </returns>
/// <remarks>
/// <para>This function wraps CheckTokenMembership and only checks local groups.</para>
/// </remarks>
// https://docs.microsoft.com/en-us/windows/desktop/api/shellapi/nf-shellapi-shtesttokenmembership BOOL SHTestTokenMembership( HANDLE
// hToken, ULONG ulRID );
[DllImport(Lib.Shell32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("shellapi.h", MSDNShortId = "ac2d591a-f431-4da7-aa9f-0476634ec9cf")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SHTestTokenMembership(SafeTokenHandle hToken, uint ulRID);
/// <summary>
/// <para>Contains information about a system appbar message.</para>
/// </summary>
@ -3504,6 +3759,25 @@ namespace Vanara.PInvoke
public string lpszProgressTitle;
}
/// <summary>
/// <para>Contains the size and item count information retrieved by the SHQueryRecycleBin function.</para>
/// </summary>
// https://docs.microsoft.com/en-us/windows/desktop/api/shellapi/ns-shellapi-_shqueryrbinfo typedef struct _SHQUERYRBINFO { DWORD
// cbSize; __int64 i64Size; __int64 i64NumItems; DWORDLONG i64Size; DWORDLONG i64NumItems; } SHQUERYRBINFO, *LPSHQUERYRBINFO;
[PInvokeData("shellapi.h", MSDNShortId = "7e9bc7e9-5712-45e7-a424-0afb62f26450")]
[StructLayout(LayoutKind.Sequential)]
public struct SHQUERYRBINFO
{
/// <summary>The size of the structure, in bytes. This member must be filled in prior to calling the function.</summary>
private uint cbSize;
/// <summary>The total size, in bytes, of all the items currently in the Recycle Bin.</summary>
private long i64Size;
/// <summary>The total number of items currently in the Recycle Bin.</summary>
private long i64NumItems;
}
/// <summary>
/// <para>Receives information used to retrieve a stock Shell icon. This structure is used in a call SHGetStockIconInfo.</para>
/// </summary>

File diff suppressed because it is too large Load Diff