using System; using System.Runtime.InteropServices; namespace Vanara.PInvoke { public static partial class Shell32 { /// Exposes methods that get or set selected items represented by a Shell item array. /// /// When to Implement /// /// This interface is implemented by verbs that implement IExecuteCommand. This allows objects to invoke the verb on the selection /// through IExecuteCommand::Execute. /// /// When to Use /// /// IObjectWithSelection is used by Windows Explorer to invoke a verb on the selected items. Do not call this interface directly. /// /// // https://docs.microsoft.com/en-us/windows/desktop/api/shobjidl_core/nn-shobjidl_core-iobjectwithselection [PInvokeData("shobjidl_core.h", MSDNShortId = "8fb248eb-73e7-4db0-8585-4accafe332d0")] [ComImport, Guid("1c9cd5bb-98e9-4491-a60f-31aacc72b83c"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] public interface IObjectWithSelection { /// Provides the Shell item array that specifies the items included in the selection. /// /// Type: IShellItemArray* /// A pointer to an IShellItemArray that represents the selected items. /// /// /// Type: HRESULT /// If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. /// // https://docs.microsoft.com/en-us/windows/desktop/api/shobjidl_core/nf-shobjidl_core-iobjectwithselection-setselection HRESULT // SetSelection( IShellItemArray *psia ); [PreserveSig] HRESULT SetSelection([In] IShellItemArray psia); /// Gets the Shell item array that contains the selected items. /// /// Type: REFIID /// A reference to the IID of the interface to retrieve through ppv, typically IID_IShellItemArray. /// /// /// Type: void** /// When this method returns successfully, contains the interface pointer requested in riid. This is typically an IShellItemArray. /// /// /// Type: HRESULT /// If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. /// /// /// We recommend that you use the IID_PPV_ARGS macro, defined in Objbase.h, to package the riid and ppv parameters. This /// macro provides the correct IID based on the interface pointed to by the value in ppv, which eliminates the possibility of a /// coding error in riid that could lead to unexpected results. /// // https://docs.microsoft.com/en-us/windows/desktop/api/shobjidl_core/nf-shobjidl_core-iobjectwithselection-getselection HRESULT // GetSelection( REFIID riid, void **ppv ); [PreserveSig] HRESULT GetSelection(in Guid riid, [MarshalAs(UnmanagedType.IUnknown, IidParameterIndex = 0)] out object ppv); } } }