using System;
using System.Runtime.InteropServices;
namespace Vanara.PInvoke
{
public static partial class Shell32
{
///
/// Exposes methods that get and set the parent and the parent's child ID. While IParentAndItem is typically implemented on
/// IShellItems, it is not specific to IShellItem.
///
///
/// The performance improvement using this interface can be noted in comparison with IPersistIDList, an interface that uses absolute
/// item identifier lists. Subsequent operations on objects that implement IPersistIDList may require
/// IShellFolder::BindToObject calls, and these calls may impact performance. In the case of IShellItems and participating
/// IShellFolders that implement IParentAndItem, the parent IShellFolder may already be cached. By implementing
/// IParentAndItem and then getting/setting the parent IShellFolder directly, the call to
/// IShellFolder::BindToObject on the item identifier list to retrieve the IShellFolder interface is eliminated.
///
// https://docs.microsoft.com/en-us/windows/desktop/api/shobjidl_core/nn-shobjidl_core-iparentanditem
[PInvokeData("shobjidl_core.h", MSDNShortId = "5cca426f-73fb-4b39-8eb0-16c01673c311")]
[ComImport, InterfaceType(ComInterfaceType.InterfaceIsIUnknown), Guid("b3a4b685-b685-4805-99d9-5dead2873236")]
public interface IParentAndItem
{
/// Sets the parent of an item and the parent's child ID.
///
/// Type: PCIDLIST_ABSOLUTE
/// A pointer of the parent.
///
///
/// Type: IShellFolder*
/// A pointer to the IShellFolder that is the parent.
///
///
/// Type: PCUITEMID_CHILD
/// A PIDL that is a child relative to psf.
///
///
/// Type: HRESULT
/// If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.
///
/// While IParentAndItem is typically implemented on IShellItems, it is not specific to IShellItem.
// https://docs.microsoft.com/en-us/windows/desktop/api/shobjidl_core/nf-shobjidl_core-iparentanditem-setparentanditem HRESULT
// SetParentAndItem( PCIDLIST_ABSOLUTE pidlParent, IShellFolder *psf, PCUITEMID_CHILD pidlChild );
[PreserveSig]
HRESULT SetParentAndItem([In] PIDL pidlParent, [In] IShellFolder psf, [In] PIDL pidlChild);
/// Gets the parent of an item and the parent's child ID.
///
/// Type: PIDLIST_ABSOLUTE*
/// When this method returns, contains the address of a PIDL that specifies the parent.
///
///
/// Type: IShellFolder**
/// When this method returns, contains the address of a pointer to the IShellFolder that is the parent.
///
///
/// Type: PITEMID_CHILD*
///
/// When this method returns, contains the address of a child PIDL that identifies the IParentAndItem object relative to that
/// specified by ppsf.
///
///
///
/// Type: HRESULT
/// If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.
///
/// While IParentAndItem is typically implemented on IShellItems, it is not specific to IShellItem.
// https://docs.microsoft.com/en-us/windows/desktop/api/shobjidl_core/nf-shobjidl_core-iparentanditem-getparentanditem HRESULT
// GetParentAndItem( PIDLIST_ABSOLUTE *ppidlParent, IShellFolder **ppsf, PITEMID_CHILD *ppidlChild );
[PreserveSig]
HRESULT GetParentAndItem(out PIDL ppidlParent, out IShellFolder ppsf, out PIDL ppidlChild);
}
}
}