From cb01573d8cfa229d5227003f24a2d130d2b911aa Mon Sep 17 00:00:00 2001 From: David Hall Date: Sun, 20 Jan 2019 20:44:35 -0800 Subject: [PATCH] Added CIDA (HIDA) structure --- PInvoke/Shell32/Clipboard.cs | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/PInvoke/Shell32/Clipboard.cs b/PInvoke/Shell32/Clipboard.cs index 9f1105d1..338db5c9 100644 --- a/PInvoke/Shell32/Clipboard.cs +++ b/PInvoke/Shell32/Clipboard.cs @@ -4,6 +4,7 @@ using System.Collections.Generic; using System.Drawing; using System.Runtime.InteropServices; using Vanara.Extensions; +using Vanara.InteropServices; using static Vanara.PInvoke.Kernel32; using FILETIME = System.Runtime.InteropServices.ComTypes.FILETIME; @@ -80,6 +81,43 @@ namespace Vanara.PInvoke FD_UNICODE = 0x80000000, } + /// Used with the CFSTR_SHELLIDLIST clipboard format to transfer the pointer to an item identifier list (PIDL) of one or more Shell namespace objects.To use this structure to retrieve a particular PIDL, add the aoffset value of the PIDL to the address of the structure. The following two macros can be used to retrieve PIDLs from the structure. The first retrieves the PIDL of the parent folder. The second retrieves a PIDL, specified by its zero-based index.The value that is returned by these macros is a pointer to the ITEMIDLIST structure. Since these structures vary in length, you must determine the end of the structure by parsing it. See NameSpace for further discussion of PIDLs and the ITEMIDLIST structure. + // https://docs.microsoft.com/en-us/windows/desktop/api/shlobj_core/ns-shlobj_core-_ida + // typedef struct _IDA { UINT cidl; UINT aoffset[1]; } CIDA, *LPIDA; + [PInvokeData("shlobj_core.h", MSDNShortId = "30caf91d-8f3c-48ea-ad64-47f919f33f1d")] + [StructLayout(LayoutKind.Sequential)] + public struct CIDA + { + /// + /// Type: UINTThe number of PIDLs that are being transferred, not including the parent folder. + /// + public uint cidl; + + /// + /// Type: UINT[1]An array of offsets, relative to the beginning of this structure. The array contains cidl+1 elements. The first element of aoffset contains an offset to the fully qualified PIDL of a parent folder. If this PIDL is empty, the parent folder is the desktop. Each of the remaining elements of the array contains an offset to one of the PIDLs to be transferred. All of these PIDLs are relative to the PIDL of the parent folder. + /// + public IntPtr aoffset; + + /// + /// Type: UINT[]An array of offsets, relative to the beginning of this structure. The array contains cidl+1 elements. The first element of aoffset contains an offset to the fully qualified PIDL of a parent folder. If this PIDL is empty, the parent folder is the desktop. Each of the remaining elements of the array contains an offset to one of the PIDLs to be transferred. All of these PIDLs are relative to the PIDL of the parent folder. + /// + /// Returns a value. + public uint[] offsets => aoffset.ToArray((int)cidl + 1); + + public PIDL GetFolderPIDL() + { + using (var pinned = new PinnedObject(this)) + return new PIDL(((IntPtr)pinned).Offset(offsets[0]), true); + } + + public PIDL GetItemRelativePIDL(int childIndex) + { + if (childIndex >= cidl) throw new ArgumentOutOfRangeException(nameof(childIndex)); + using (var pinned = new PinnedObject(this)) + return new PIDL(((IntPtr)pinned).Offset(offsets[childIndex + 1]), true); + } + } + /// Describes the image and accompanying text for a drop object. /// /// Some UI coloring is applied to the text in szInsert if used by specifying %1 in szMessage. The characters %% and %1 are the