diff --git a/PInvoke/Shell32/Clipboard.cs b/PInvoke/Shell32/Clipboard.cs index eff79b2b..476f91e6 100644 --- a/PInvoke/Shell32/Clipboard.cs +++ b/PInvoke/Shell32/Clipboard.cs @@ -100,6 +100,7 @@ namespace Vanara.PInvoke // 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")] + [VanaraMarshaler(typeof(SafeAnysizeStructMarshaler), nameof(cidl))] [StructLayout(LayoutKind.Sequential)] public struct CIDA { @@ -118,29 +119,18 @@ namespace Vanara.PInvoke /// transferred. All of these PIDLs are relative to the PIDL of the parent folder. /// /// - public IntPtr aoffset; + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 1)] + public uint[] 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); - - /// Gets the folder PIDL from . + /// Gets the folder PIDL from . /// A PIDL. public PIDL GetFolderPIDL() { using var pinned = new PinnedObject(this); - return new PIDL(((IntPtr)pinned).Offset(offsets[0]), true); + return new PIDL(((IntPtr)pinned).Offset(aoffset[0]), true); } - /// Gets the item relative PIDL from at the specified index. + /// Gets the item relative PIDL from at the specified index. /// Index of the child PIDL. /// A PIDL. /// childIndex @@ -148,7 +138,7 @@ namespace Vanara.PInvoke { if (childIndex >= cidl) throw new ArgumentOutOfRangeException(nameof(childIndex)); using var pinned = new PinnedObject(this); - return new PIDL(((IntPtr)pinned).Offset(offsets[childIndex + 1]), true); + return new PIDL(((IntPtr)pinned).Offset(aoffset[childIndex + 1]), true); } }