using System;
using System.Runtime.InteropServices;
using System.Runtime.InteropServices.ComTypes;
using Vanara.Extensions;
using static Vanara.PInvoke.Kernel32;
namespace Vanara.PInvoke
{
public static partial class ComCtl32
{
/// Indicates a failure on the DSA_InsertItem when returned.
public const int DA_ERR = -1;
/// Used by DSA_InsertItem to indicate that the item should be inserted at the end of the array.
public const int DA_LAST = 0x7FFFFFFF;
/// Defines the prototype for the compare function used by DSA_Sort.
///
/// Type: void*
/// A pointer to the first item in the comparison.
///
///
/// Type: void*
/// A pointer to the second item in the comparison.
///
///
/// Type: LPARAM
/// Additional data passed to pfnCmp.
///
///
/// Type: int
///
/// The meaning of the return values depends on the function that uses this callback prototype. The return values for DSA_Sort
/// are the following.
///
///
///
///
/// less than 0
/// If p1 should be sorted ahead of p2.
///
/// -
/// equal to 0
/// If p1 and p2 should be sorted together.
///
/// -
/// greater than 0
/// If p1 should be sorted after p2.
///
///
///
///
// typedef int ( CALLBACK *PFNDACOMPARE)( _In_opt_ void *p1, _In_opt_ void *p2, _In_ LPARAM lParam); https://msdn.microsoft.com/en-us/library/windows/desktop/bb775707(v=vs.85).aspx
[PInvokeData("Commctrl.h", MSDNShortId = "bb775707")]
[UnmanagedFunctionPointer(CallingConvention.Winapi)]
public delegate int PFNDACOMPARE(IntPtr p1, IntPtr p2, IntPtr lParam);
///
/// Defines the prototype for the compare function used by DSA_Sort when the items being compared are constant objects.
///
///
/// Type: const void*
/// A pointer to the first item in the comparison.
///
///
/// Type: const void*
/// A pointer to the second item in the comparison.
///
///
/// Type: LPARAM
/// Additional data passed to pfnCmp.
///
///
/// Type: int
///
/// The meaning of the return values depends on the function that uses this callback prototype. The return values for DSA_Sort
/// are as follows:
///
///
///
///
/// less than 0
/// If p1 should be sorted ahead of p2.
///
/// -
/// equal to 0
/// If p1 and p2 should be sorted together.
///
/// -
/// greater than 0
/// If p1 should be sorted after p2.
///
///
///
///
// typedef int ( CALLBACK *PFNDACOMPARECONST)( _In_opt_ const void *p1, _In_opt_ const void *p2, _In_ LPARAM lParam); https://msdn.microsoft.com/en-us/library/windows/desktop/bb775709(v=vs.85).aspx
[PInvokeData("Commctrl.h", MSDNShortId = "bb775709")]
[UnmanagedFunctionPointer(CallingConvention.Winapi)]
public delegate int PFNDACOMPARECONST(IntPtr p1, IntPtr p2, IntPtr lParam);
///
/// Defines the prototype for the callback function used by dynamic structure array (DSA) and dynamic pointer array (DPA) functions.
///
///
/// Type: void*
/// A pointer to the structure to be enumerated.
///
///
/// Type: void*
/// The value that was passed in the pData parameter to function DSA_EnumCallback.
///
///
/// Type: int
///
/// The return value is used to determine whether to terminate or continue the iteration. A return value of zero indicates that the
/// iteration should stop; nonzero indicates that the iteration should continue.
///
///
// typedef int ( CALLBACK *PFNDAENUMCALLBACK)( _In_opt_ void *p, _In_opt_ void *pData); https://msdn.microsoft.com/en-us/library/windows/desktop/bb775711(v=vs.85).aspx
[PInvokeData("Commctrl.h", MSDNShortId = "bb775711")]
[UnmanagedFunctionPointer(CallingConvention.Winapi)]
public delegate int PFNDAENUMCALLBACK(IntPtr p, IntPtr pData);
///
/// Defines the prototype for the callback function used by dynamic structure array (DSA) and dynamic pointer array (DPA) functions
/// when the items involved are pointers to constant data.
///
///
/// Type: const void*
/// A pointer to the constant structure to be enumerated.
///
///
/// Type: void*
/// A value that was passed in the pData parameter to function DSA_EnumCallback or function DPA_EnumCallback.
///
///
/// Type: int
///
/// The return value is used to determine whether to terminate or continue the iteration. A return value of zero indicates that the
/// iteration should stop; nonzero indicates that the iteration should continue.
///
///
// typedef int ( CALLBACK *PFNDAENUMCALLBACKCONST)( _In_opt_ const void *p, _In_opt_ void *pData); https://msdn.microsoft.com/en-us/library/windows/desktop/bb775713(v=vs.85).aspx
[PInvokeData("Commctrl.h", MSDNShortId = "bb775713")]
[UnmanagedFunctionPointer(CallingConvention.Winapi)]
public delegate int PFNDAENUMCALLBACKCONST(IntPtr p, IntPtr pData);
/// Defines the prototype for the merge function used by DPA_Merge.
///
/// Type: UINT
/// A message that instructs this function how to handle the merge. One of the following values.
///
///
///
/// Value
/// Meaning
///
/// -
/// DPAMM_MERGE0x1
///
/// Perform any additional processing needed when merging pvSrc into pvDest. The function should return a pointer to an item that
/// contains the result of the merge. The value returned by the merge function is stored into the destination, which overwrites the
/// previous value. If the merge function returns NULL, then the merge operation is abandoned.
///
///
/// -
/// DPAMM_DELETE0x2
/// Perform any additional processing needed when a delete occurs as part of the merge. The function should return NULL.
///
/// -
/// DPAMM_INSERT0x3
///
/// Perform any user-defined processing when the merge results in an item being inserted as part of the merge. The return value of
/// this function should point to the item result that is inserted as part of the merge. If the merge function returns NULL, then the
/// merge operation is abandoned.
///
///
///
///
///
///
/// Type: void*
/// A pointer to the first item in the merge.
///
///
/// Type: void*
/// A pointer to the second item in the merge.
///
///
/// Type: LPARAM
/// Additional data that can be used by the merge callback.
///
///
/// A pointer to the item which results from the merge or NULL if there is a failure when DPAMM_MERGE or
/// DPAMM_INSERT is used.
///
// typedef void* ( CALLBACK *PFNDPAMERGE)( _In_ UINT uMsg, _In_ void *pvDest, _In_ void *pvSrc, _In_ LPARAM lParam); https://msdn.microsoft.com/en-us/library/windows/desktop/bb775721(v=vs.85).aspx
[PInvokeData("Commctrl.h", MSDNShortId = "bb775721")]
[UnmanagedFunctionPointer(CallingConvention.Winapi)]
public delegate IntPtr PFNDPAMERGE(DPAMM uMsg, IntPtr pvDest, IntPtr pvSrc, IntPtr lParam);
/// Defines the prototype for the merge function used by DPA_Merge, using constant values.
///
/// Type: UINT
/// A message that instructs this function how to handle the merge. One of the following values.
///
///
///
/// Value
/// Meaning
///
/// -
/// DPAMM_MERGE0x1
///
/// Perform any additional processing needed when merging p2 into p1. The function should return a pointer to an item that contains
/// the result of the merge.
///
///
/// -
/// DPAMM_DELETE0x2
/// Perform any additional processing needed when a delete occurs as part of the merge. The function should return NULL.
///
/// -
/// DPAMM_INSERT0x3
///
/// Perform any user-defined processing when the merge results in an item being inserted as part of the merge. The return value of
/// this function should point to the item result that is inserted as part of the merge.
///
///
///
///
///
///
/// Type: const void*
/// A pointer to the destination item in the merge.
///
///
/// Type: const void*
/// A pointer to the source item in the merge.
///
///
/// Type: LPARAM
/// Additional data that can be used by the merge callback.
///
///
/// Type: const void*
///
/// A pointer to constant data which results from the merge, or NULL if there is a failure when DPAMM_MERGE or DPAMM_INSERT is used.
///
///
// typedef const void* ( CALLBACK *PFNDPAMERGECONST)( _In_ UINT uMsg, _In_ const void *pvDest, _In_ const void *pvSrc, _In_ LPARAM
// lParam); https://msdn.microsoft.com/en-us/library/windows/desktop/bb775723(v=vs.85).aspx
[PInvokeData("Commctrl.h", MSDNShortId = "bb775723")]
[UnmanagedFunctionPointer(CallingConvention.Winapi)]
public delegate IntPtr PFNDPAMERGECONST(DPAMM uMsg, IntPtr pvDest, IntPtr pvSrc, IntPtr lParam);
/// Defines the prototype for the callback function used by DPA_LoadStream and DPA_SaveStream.
///
/// Type: DPASTREAMINFO*
/// A pointer to a DPASTREAMINFO structure.
///
///
/// Type: struct IStream*
/// An IStream object to read from or write to.
///
///
/// Type: void*
/// A void pointer to callback data that the client passed to DPA_LoadStream or DPA_SaveStream.
///
///
/// Type: HRESULT
/// If this function pointer succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.
///
// typedef HRESULT ( CALLBACK *PFNDPASTREAM)( _In_ DPASTREAMINFO *pinfo, _In_ struct IStream *pstream, _In_opt_ void *pvInstData); https://msdn.microsoft.com/en-us/library/windows/desktop/bb775725(v=vs.85).aspx
[PInvokeData("Commctrl.h", MSDNShortId = "bb775725")]
[UnmanagedFunctionPointer(CallingConvention.Winapi)]
public delegate HRESULT PFNDPASTREAM(ref DPASTREAMINFO pinfo, IStream pstream, IntPtr pvInstData);
///
/// Options determining the method used to merge the two arrays. DPAM_NORMAL, DPAM_UNION, and DPAM_UNION are mutually exclusive—only
/// one of those flags can be set, optionally in conjunction with DPAM_SORTED.
///
[Flags]
public enum DPAM
{
/// The arrays are presorted; skip sorting. If this flag is not set, the arrays are sorted before they are merged.
DPAM_SORTED = 0x00000001,
///
/// The final array consists of all of the elements originally present in hdpaDest. If any of those elements are also found in
/// hdpaSrc, those elements are merged in the final array. The PFNDPAMERGE callback function is called with the DPAMM_MERGE
/// message. When this flag is set, the final size of the array at hdpaDest is the same as its initial size.
///
DPAM_NORMAL = 0x00000002,
///
/// The final array is the union of all elements in both arrays. Elements found in both arrays are merged in the final array.
/// Elements found in only one array or the other are added as found. When this flag is set, the PFNDPAMERGE callback function
/// can be called with the DPAMM_MERGE or DPAMM_INSERT message. The final size of the array is at least the size of the larger of
/// hdpaDest and hdpaSrc, and at most the sum of the two.
///
DPAM_UNION = 0x00000004,
///
/// Only elements found in both hdpaSrc and hdpaDest are merged to form the final array. When this flag is set, the PFNDPAMERGE
/// callback function can be called with the DPAMM_MERGE or DPAMM_DELETE message. The final size of the array can range between 0
/// and the smaller of hdpaDest and hdpaSrc.
///
DPAM_INTERSECT = 0x00000008,
}
/// A message that instructs this function how to handle the merge.
public enum DPAMM
{
///
/// Perform any additional processing needed when merging pvSrc into pvDest. The function should return a pointer to an item that
/// contains the result of the merge. The value returned by the merge function is stored into the destination, which overwrites
/// the previous value. If the merge function returns NULL, then the merge operation is abandoned.
///
DPAMM_MERGE = 1,
///
/// Perform any additional processing needed when a delete occurs as part of the merge. The function should return NULL.
///
DPAMM_DELETE = 2,
///
/// Perform any user-defined processing when the merge results in an item being inserted as part of the merge. The return value
/// of this function should point to the item result that is inserted as part of the merge. If the merge function returns NULL,
/// then the merge operation is abandoned.
///
DPAMM_INSERT = 3
}
/// Options for DPA_Search.
[Flags]
public enum DPAS
{
/// Indicates that the DPA is sorted.
DPAS_SORTED = 0x0001,
///
/// This value is only valid in conjunction with DPAS_SORTED. If the item is not found, return the position where the item is
/// expected to be found in the sorted DPA.
///
DPAS_INSERTBEFORE = 0x0002,
///
/// This value is only valid in conjunction with DPAS_SORTED. If the item is not found, return the position where the item is
/// expected to be found in the sorted DPA.
///
DPAS_INSERTAFTER = 0x0004
}
/// Inserts a new item at the end of a dynamic pointer array (DPA).
/// A handle to a DPA.
/// A pointer to the item that is to be inserted.
/// Returns the index of the new item or , if the append action fails.
// int DPA_AppendPtr( HDPA pdpa, void *pitem); https://msdn.microsoft.com/en-us/library/windows/desktop/bb775585(v=vs.85).aspx
[PInvokeData("Dpa_dsa.h", MSDNShortId = "bb775585")]
public static int DPA_AppendPtr(HDPA pdpa, IntPtr pitem) => DPA_InsertPtr(pdpa, DA_LAST, pitem);
///
///
/// [ DPA_Clone is available through Windows XP with Service Pack 2 (SP2). It might be altered or unavailable in subsequent versions.]
///
/// Duplicates a dynamic pointer array (DPA).
///
///
/// Type: const HDPA
/// A handle to an existing DPA to copy.
///
///
/// Type: HDPA
/// When NULL, a new array is copied from hdpaSource.
///
/// This parameter can also contain an array created with DPA_Create or DPA_CreateEx. The data is overwritten but the
/// original delta size and heap handle retained.
///
///
///
/// Type: HDPA
/// The handle to the new or altered DPA (hdpaNew) if successful; otherwise, NULL.
///
// HDPA WINAPI DPA_Clone( _In_ const HDPA hdpaSource, _Inout_opt_ HDPA hdpaNew); https://msdn.microsoft.com/en-us/library/windows/desktop/bb775601(v=vs.85).aspx
[DllImport(Lib.ComCtl32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("Dpa_dsa.h", MSDNShortId = "bb775601")]
public static extern SafeHDPA DPA_Clone(HDPA hdpaSource, [Optional] HDPA hdpaNew);
///
///
/// [ DPA_Create is available for use in the operating systems specified in the Requirements section. It may be altered or
/// unavailable in subsequent versions.]
///
/// Creates a dynamic pointer array (DPA).
///
///
/// Type: int
/// The number of elements by which the array should be expanded, if the DPA needs to be enlarged.
///
///
/// Type: HDPA
/// Returns a handle to a DPA if successful, or NULL if the call fails.
///
// HDPA WINAPI DPA_Create( int cpGrow); https://msdn.microsoft.com/en-us/library/windows/desktop/bb775603(v=vs.85).aspx
[DllImport(Lib.ComCtl32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("Dpa_dsa.h", MSDNShortId = "bb775603")]
public static extern SafeHDPA DPA_Create(int cpGrow);
/// Creates a dynamic pointer array (DPA) using a given specified size and heap location.
///
/// Type: int
/// The number of elements by which the array should be expanded, if the DPA needs to be enlarged.
///
///
/// Type: HANDLE
/// A handle to the heap where the array is stored.
///
///
/// Type: HDPA
/// Returns a handle to a DPA if successful, or NULL if the call fails.
///
// HDPA WINAPI DPA_CreateEx( _In_ int cpGrow, _In_opt_ HANDLE hheap); https://msdn.microsoft.com/en-us/library/windows/desktop/bb775605(v=vs.85).aspx
[DllImport(Lib.ComCtl32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("Dpa_dsa.h", MSDNShortId = "bb775605")]
public static extern SafeHDPA DPA_CreateEx(int cpGrow, [Optional] HHEAP hheap);
///
///
/// [ DPA_DeleteAllPtrs is available for use in the operating systems specified in the Requirements section. It may be altered
/// or unavailable in subsequent versions.]
///
/// Removes all items from a dynamic pointer array (DPA) and shrinks the DPA accordingly.
///
///
/// Type: HDPA
/// Handle to a DPA.
///
///
/// Type: BOOL
/// Returns TRUE on success or FALSE on failure.
///
// BOOL WINAPI DPA_DeleteAllPtrs( HDPA pdpa); https://msdn.microsoft.com/en-us/library/windows/desktop/bb775607(v=vs.85).aspx
[DllImport(Lib.ComCtl32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("Dpa_dsa.h", MSDNShortId = "bb775607")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool DPA_DeleteAllPtrs(HDPA pdpa);
///
///
/// [ DPA_DeletePtr is available for use in the operating systems specified in the Requirements section. It may be altered or
/// unavailable in subsequent versions.]
///
/// Removes an item from a dynamic pointer array (DPA). The DPA shrinks if necessary to accommodate the removed item.
///
///
/// Type: HDPA
/// A handle to a DPA.
///
///
/// Type: int
/// An index of item to be removed from DPA.
///
/// Returns the removed item or NULL, if the call fails.
// void* WINAPI DPA_DeletePtr( HDPA pdpa, int index); https://msdn.microsoft.com/en-us/library/windows/desktop/bb775609(v=vs.85).aspx
[DllImport(Lib.ComCtl32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("Dpa_dsa.h", MSDNShortId = "bb775609")]
public static extern IntPtr DPA_DeletePtr(HDPA pdpa, int index);
///
///
/// [ DPA_Destroy is available for use in the operating systems specified in the Requirements section. It may be altered or
/// unavailable in subsequent versions.]
///
/// Frees a Dynamic Pointer Array (DPA).
///
///
/// Type: HDPA
/// A handle to a DPA.
///
///
/// Type: BOOL
/// Returns TRUE on success, FALSE on failure.
///
// BOOL WINAPI DPA_Destroy( HDPA pdpa); https://msdn.microsoft.com/en-us/library/windows/desktop/bb775611(v=vs.85).aspx
[DllImport(Lib.ComCtl32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("Dpa_dsa.h", MSDNShortId = "bb775611")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool DPA_Destroy(HDPA pdpa);
///
///
/// [ DPA_DestroyCallback is available for use in the operating systems specified in the Requirements section. It may be
/// altered or unavailable in subsequent versions.]
///
/// Calls pfnCB on each element of the dynamic pointer array (DPA), then frees the DPA.
///
///
/// Type: HDPA
/// A handle to a DPA.
///
///
/// Type: PFNDPAENUMCALLBACK
/// A callback function pointer. See PFNDPAENUMCALLBACK for the callback function prototype.
///
///
/// Type: void*
/// A callback data pointer. pData is passed as a parameter to pfnCB.
///
/// No return value.
// void WINAPI DPA_DestroyCallback( HDPA pdpa, PFNDPAENUMCALLBACK pfnCB, void *pData); https://msdn.microsoft.com/en-us/library/windows/desktop/bb775613(v=vs.85).aspx
[DllImport(Lib.ComCtl32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("Dpa_dsa.h", MSDNShortId = "bb775613")]
public static extern void DPA_DestroyCallback(HDPA pdpa, PFNDAENUMCALLBACK pfnCB, IntPtr pData);
///
///
/// [ DPA_EnumCallback is available for use in the operating systems specified in the Requirements section. It may be altered
/// or unavailable in subsequent versions.]
///
/// Iterates through the Dynamic Pointer Array (DPA) and calls pfnCB on each item.
///
///
/// Type: HDPA
/// A handle to a DPA.
///
///
/// Type: PFNDPAENUMCALLBACK
/// A callback function pointer. See PFNDPAENUMCALLBACK for the callback function prototype.
///
///
/// Type: void*
/// A callback data pointer. pData is passed as a parameter to pfnCB.
///
/// No return value.
// void WINAPI DPA_EnumCallback( HDPA pdpa, PFNDPAENUMCALLBACK pfnCB, void *pData); https://msdn.microsoft.com/en-us/library/windows/desktop/bb775615(v=vs.85).aspx
[DllImport(Lib.ComCtl32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("Dpa_dsa.h", MSDNShortId = "bb775615")]
public static extern void DPA_EnumCallback(HDPA pdpa, PFNDAENUMCALLBACK pfnCB, IntPtr pData);
/// Deletes the last pointer from a dynamic pointer array (DPA).
/// A handle to an existing DPA.
/// This macro does not return a value.
// void DPA_FastDeleteLastPtr( [in] HDPA hdpa); https://msdn.microsoft.com/en-us/library/windows/desktop/bb775586(v=vs.85).aspx
[PInvokeData("Dpa_dsa.h", MSDNShortId = "bb775586")]
public static void DPA_FastDeleteLastPtr(HDPA hdpa) => DPA_SetPtrCount(hdpa, DPA_GetPtrCount(hdpa) - 1);
/// Gets the value of the specified pointer in the dynamic pointer array (DPA).
/// A handle to an existing DPA.
/// The index of the DPA item.
/// No return value.
// void DPA_FastGetPtr( [in] HDPA hdpa, [in] int i); https://msdn.microsoft.com/en-us/library/windows/desktop/bb775587(v=vs.85).aspx
[PInvokeData("Dpa_dsa.h", MSDNShortId = "bb775587")]
public static IntPtr DPA_FastGetPtr(HDPA hdpa, int i) => Marshal.ReadIntPtr(DPA_GetPtrPtr(hdpa), IntPtr.Size * i);
///
///
/// [ DPA_GetPtr is available for use in the operating systems specified in the Requirements section. It may be altered or
/// unavailable in subsequent versions.]
///
/// Gets an item from a dynamic pointer array (DPA).
///
///
/// Type: HDPA
/// A handle to a DPA.
///
///
/// Type: int
/// The index of item to be retrieved.
///
/// Returns the specified item or NULL, if the call fails.
// void* WINAPI DPA_GetPtr( HDPA pdpa, int index); https://msdn.microsoft.com/en-us/library/windows/desktop/bb775617(v=vs.85).aspx
[DllImport(Lib.ComCtl32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("Dpa_dsa.h", MSDNShortId = "bb775617")]
public static extern IntPtr DPA_GetPtr(HDPA pdpa, int index);
/// Gets the number of pointers in a dynamic pointer array (DPA).
/// A handle to an existing DPA.
/// Returns the number of pointers (elements) the DPA contains.
// int DPA_GetPtrCount( [in] HDPA hdpa); https://msdn.microsoft.com/en-us/library/windows/desktop/bb775588(v=vs.85).aspx
[PInvokeData("Dpa_dsa.h", MSDNShortId = "bb775588")]
public static int DPA_GetPtrCount(HDPA hdpa) => Marshal.ReadInt32((IntPtr)hdpa);
///
///
/// [ DPA_GetPtrIndex is available through Windows XP with Service Pack 2 (SP2). It might be altered or unavailable in
/// subsequent versions.]
///
/// Gets the index of a matching item found in a dynamic pointer array (DPA).
///
///
/// Type: HDPA
/// A handle to an existing DPA.
///
///
/// Type: const void*
/// A pointer to an item to locate in hdpa.
///
///
/// Type: int
/// The index of the item pointed to by pvoid, if found; otherwise, -1.
///
// int WINAPI DPA_GetPtrIndex( _In_ HDPA hdpa, _In_ const void *pvoid); https://msdn.microsoft.com/en-us/library/windows/desktop/bb775619(v=vs.85).aspx
[DllImport(Lib.ComCtl32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("Dpa_dsa.h", MSDNShortId = "bb775619")]
public static extern int DPA_GetPtrIndex(HDPA pdpa, IntPtr pvoid);
/// Gets the pointer to the internal pointer array of a dynamic pointer array (DPA).
/// A handle to an existing DPA.
///
/// Returns a pointer to the array of pointers managed by the DPA. To retrieve the number of pointers in the array, call macro DPA_GetPtrCount.
///
// void DPA_GetPtrPtr( [in] HDPA hdpa); https://msdn.microsoft.com/en-us/library/windows/desktop/bb775589(v=vs.85).aspx
[PInvokeData("Dpa_dsa.h", MSDNShortId = "bb775589")]
public static IntPtr DPA_GetPtrPtr(HDPA hdpa) => ((IntPtr)hdpa).Offset(IntPtr.Size);
/// Gets the size of a dynamic pointer array (DPA).
///
/// Type: HDPA
/// A handle to an existing DPA.
///
///
/// Type: ULONGLONG
///
/// Returns the size of the DPA, including the internal bookkeeping information. If pdpa is NULL, the function returns zero.
///
///
// ULONGLONG DPA_GetSize( _In_ HDPA pdpa); https://msdn.microsoft.com/en-us/library/windows/desktop/bb775621(v=vs.85).aspx
[DllImport(Lib.ComCtl32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("Dpa_dsa.h", MSDNShortId = "bb775621")]
public static extern ulong DPA_GetSize(HDPA pdpa);
/// Changes the number of pointers in a dynamic pointer array (DPA).
///
/// Type: HDPA
/// A handle to an existing DPA.
///
///
/// Type: int
/// The number of pointers desired in the DPA.
///
///
/// Type: BOOL
/// Returns TRUE if successful, or FALSE otherwise.
///
// BOOL DPA_Grow( _In_ HDPA hdpa, _In_ int cp); https://msdn.microsoft.com/en-us/library/windows/desktop/bb775623(v=vs.85).aspx
[DllImport(Lib.ComCtl32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("Dpa_dsa.h", MSDNShortId = "bb775623")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool DPA_Grow(HDPA pdpa, int cp);
///
///
/// [ DPA_InsertPtr is available for use in the operating systems specified in the Requirements section. It may be altered or
/// unavailable in subsequent versions.]
///
///
/// Inserts a new item at a specified position in a dynamic pointer array (DPA). If neccessary, the DPA expands to accommodate the
/// new item.
///
///
///
/// Type: HDPA
/// A handle to a DPA.
///
///
/// Type: int
/// Tbe position where new item is to be inserted.
///
///
/// Type: void*
/// A pointer to the item that is to be inserted.
///
///
/// Type: int
/// Returns the index of the new item or , if the insertion fails.
///
// int WINAPI DPA_InsertPtr( HDPA pdpa, int index, void *p); https://msdn.microsoft.com/en-us/library/windows/desktop/bb775625(v=vs.85).aspx
[DllImport(Lib.ComCtl32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("Dpa_dsa.h", MSDNShortId = "bb775625")]
public static extern int DPA_InsertPtr(HDPA pdpa, int index, IntPtr p);
///
/// [ DPA_LoadStream is available in Windows Vista. It might be altered or unavailable in subsequent versions. ]
/// Loads the dynamic pointer array (DPA) from a stream by calling the specified callback function to read each element.
///
///
/// Type: HDPA*
/// A handle to a DPA.
///
///
/// Type: PFNDPASTREAM
/// The callback function. See PFNDPASTREAM for the callback function prototype.
///
///
/// Type: IStream*
/// An IStream object.
///
///
/// Type: void*
/// A pointer to callback data. pvInstData is passed as a parameter to pfn.
///
///
/// Type: HRESULT
/// Returns one of the following values.
///
///
///
/// Return code
/// Description
///
/// -
/// S_OK
/// Indicates that the callback function was successful and the element was loaded.
///
/// -
/// S_FALSE
/// Indicates that the callback function was unsuccessful in loading the element; however, the process should continue.
///
/// -
/// E_INVALIDARG
/// Indicates that one or more of the parameters is invalid.
///
/// -
/// E_FAIL
/// Indicates that the stream object could not be read.
///
/// -
/// E_OUTOFMEMORY
/// The buffer length is invalid or there was insufficient memory to complete the operation.
///
///
///
///
// HRESULT WINAPI DPA_LoadStream( _Out_ HDPA *ppdpa, _In_ PFNDPASTREAM pfn, _In_ IStream *pstm, _In_ void *pvInstData); https://msdn.microsoft.com/en-us/library/windows/desktop/bb775627(v=vs.85).aspx
[DllImport(Lib.ComCtl32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("Dpa_dsa.h", MSDNShortId = "bb775627")]
public static extern HRESULT DPA_LoadStream(out SafeHDPA ppdpa, PFNDPASTREAM pfn, IStream pstm, IntPtr pvInstData);
///
///
/// [ DPA_Merge is available through Windows XP with Service Pack 2 (SP2). It might be altered or unavailable in subsequent versions.]
///
/// Combines the contents of two dynamic pointer arrays (DPAs).
///
///
/// Type: HDPA
///
/// A handle to the first DPA. This array can be optionally presorted. When this function returns, contains the handle to the merged array.
///
///
///
/// Type: HDPA
/// A handle to the second DPA. This array can be optionally presorted.
///
///
/// Type: DWORD
///
/// Options determining the method used to merge the two arrays. DPAM_NORMAL, DPAM_UNION, and DPAM_UNION are mutually exclusive—only
/// one of those flags can be set, optionally in conjunction with DPAM_SORTED.
///
///
///
///
/// Value
/// Meaning
///
/// -
/// DPAM_SORTED0x00000001
/// The arrays are presorted; skip sorting. If this flag is not set, the arrays are sorted before they are merged.
///
/// -
/// DPAM_NORMAL0x00000002
///
/// The final array consists of all of the elements originally present in hdpaDest. If any of those elements are also found in
/// hdpaSrc, those elements are merged in the final array. The PFNDPAMERGE callback function is called with the DPAMM_MERGE message.
/// When this flag is set, the final size of the array at hdpaDest is the same as its initial size.
///
///
/// -
/// DPAM_UNION0x00000004
///
/// The final array is the union of all elements in both arrays. Elements found in both arrays are merged in the final array.
/// Elements found in only one array or the other are added as found. When this flag is set, the PFNDPAMERGE callback function can be
/// called with the DPAMM_MERGE or DPAMM_INSERT message. The final size of the array is at least the size of the larger of hdpaDest
/// and hdpaSrc, and at most the sum of the two.
///
///
/// -
/// DPAM_INTERSECT0x00000008
///
/// Only elements found in both hdpaSrc and hdpaDest are merged to form the final array. When this flag is set, the PFNDPAMERGE
/// callback function can be called with the DPAMM_MERGE or DPAMM_DELETE message. The final size of the array can range between 0 and
/// the smaller of hdpaDest and hdpaSrc.
///
///
///
///
///
///
/// Type: PFNDPACOMPARE
///
/// The PFNDPACOMPARE callback function that compares two elements, one from each DPA, to determine whether they are the same
/// item. If so, the callback function pointed to by pfnCompare is called.
///
///
///
/// Type: PFNDPAMERGE
///
/// The PFNDPAMERGE callback function that merges the contents when an element is found in both DPAs and is found to be the
/// same item by PFNDPACOMPARE.
///
///
///
/// Type: LPARAM
/// Additional parameter used to declare the basis of comparison upon which equality is determined.
///
///
/// Type: BOOL
/// TRUE if successful; otherwise, FALSE.
///
// BOOL WINAPI DPA_Merge( _Inout_ HDPA hdpaDest, _In_ HDPA hdpaSrc, _In_ DWORD dwFlags, _In_ PFNDPACOMPARE pfnCompare, _In_
// PFNDPAMERGE pfnMerge, _In_ LPARAM lParam); https://msdn.microsoft.com/en-us/library/windows/desktop/bb775629(v=vs.85).aspx
[DllImport(Lib.ComCtl32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("Dpa_dsa.h", MSDNShortId = "bb775629")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool DPA_Merge(HDPA hdpaDest, HDPA hdpaSrc, DPAM dwFlags, PFNDACOMPARE pfnCompare, PFNDPAMERGE pfnMerge, IntPtr lParam);
///
/// [ DPA_SaveStream is available in Windows Vista. It might be altered or unavailable in subsequent versions. ]
///
/// Saves the dynamic pointer array (DPA) to a stream by writing out a header, and then calling the specified callback function to
/// write each element.
///
///
///
/// Type: HDPA
/// Receives a handle to a DPA.
///
///
/// Type: PFNDPASTREAM
/// The callback function. See PFNDPASTREAM for the callback function prototype.
///
///
/// Type: IStream*
/// An IStream object.
///
///
/// Type: void*
/// A pointer to callback data. pvInstData is passed as a parameter to pfn.
///
///
/// Type: HRESULT
/// Returns one of the following values.
///
///
///
/// Return code
/// Description
///
/// -
/// S_OK
/// Indicates that the callback function was unsuccessful in saving the element; however, the process should continue.
///
/// -
/// S_FALSE
/// Indicates that even though the callback was unsuccessful, the process was uninterrupted.
///
/// -
/// E_INVALIDARG
/// Indicates that one or more of the parameters is invalid.
///
///
///
///
// HRESULT WINAPI DPA_SaveStream( _In_ HDPA pdpa, _In_ PFNDPASTREAM pfn, _In_ IStream *pstm, _In_ void *pvInstData); https://msdn.microsoft.com/en-us/library/windows/desktop/bb775631(v=vs.85).aspx
[DllImport(Lib.ComCtl32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("Dpa_dsa.h", MSDNShortId = "bb775631")]
public static extern HRESULT DPA_SaveStream(HDPA pdpa, PFNDPASTREAM pfn, IStream pstm, IntPtr pvInstData);
///
///
/// [ DPA_Search is available for use in the operating systems specified in the Requirements section. It may be altered or
/// unavailable in subsequent versions.]
///
/// Finds an item in a dynamic pointer array (DPA).
///
///
/// Type: HDPA
/// A handle to a DPA.
///
///
/// Type: void*
/// A pointer to search for.
///
///
/// Type: int
/// The index at which to start search.
///
///
/// Type: PFNDPACOMPARE
/// A comparison function pointer. See PFNDPACOMPARE for the comparison function prototype.
///
///
/// Type: LPARAM
/// An additional parameter to be passed to pfnCmp.
///
///
/// Type: UINT
/// This parameter may be one or more of the following.
///
///
///
/// Value
/// Meaning
///
/// -
/// DPAS_SORTED
/// Indicates that the DPA is sorted.
///
/// -
/// DPAS_INSERTBEFORE
///
/// This value is only valid in conjunction with DPAS_SORTED. If the item is not found, return the position where the item is
/// expected to be found in the sorted DPA.
///
///
/// -
/// DPAS_INSERTAFTER
///
/// This value is only valid in conjunction with DPAS_SORTED. If the item is not found, return the position where the item is
/// expected to be found in the sorted DPA.
///
///
///
///
///
///
/// Type: int
/// Returns the index where the item was found in the DPA or if the item was not found.
///
// int WINAPI DPA_Search( HDPA pdpa, void *pFind, int iStart, PFNDPACOMPARE pfnCmp, LPARAM lParam, UINT options); https://msdn.microsoft.com/en-us/library/windows/desktop/bb775633(v=vs.85).aspx
[DllImport(Lib.ComCtl32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("Dpa_dsa.h", MSDNShortId = "bb775633")]
public static extern int DPA_Search(HDPA pdpa, IntPtr pFind, int iStart, PFNDACOMPARE pfnCmp, IntPtr lParam, DPAS options);
///
///
/// [ DPA_SetPtr is available for use in the operating systems specified in the Requirements section. It may be altered or
/// unavailable in subsequent versions.]
///
/// Assigns a value to an item in a dynamic pointer array (DPA).
///
///
/// Type: HDPA
/// A handle to a DPA.
///
///
/// Type: int
/// The index of the item in the DPA.
///
///
/// Type: void*
/// A pointer to the value to assign to the specified DPA item.
///
///
/// Type: BOOL
/// Returns TRUE if successful, or FALSE otherwise.
///
// BOOL WINAPI DPA_SetPtr( HDPA pdpa, int index, void *p); https://msdn.microsoft.com/en-us/library/windows/desktop/bb775635(v=vs.85).aspx
[DllImport(Lib.ComCtl32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("Dpa_dsa.h", MSDNShortId = "bb775635")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool DPA_SetPtr(HDPA pdpa, int index, IntPtr p);
/// Sets the number of pointers in a dynamic pointer array (DPA).
/// A handle to an existing DPA.
/// The number of items in the DPA.
/// Returns the number of pointers (elements) the DPA contains.
// int DPA_SetPtrCount( [in] HDPA hdpa, [in] int cItems); https://msdn.microsoft.com/en-us/library/windows/desktop/dd375911(v=vs.85).aspx
[PInvokeData("Dpa_dsa.h", MSDNShortId = "dd375911")]
public static int DPA_SetPtrCount(HDPA hdpa, int cItems) { Marshal.WriteInt32((IntPtr)hdpa, cItems); return cItems; }
///
///
/// [ DPA_Sort is available for use in the operating systems specified in the Requirements section. It may be altered or
/// unavailable in subsequent versions.]
///
/// Sorts the items in a Dynamic Pointer Array (DPA).
///
///
/// Type: HDPA
/// A handle to a DPA.
///
///
/// Type: PFNDPACOMPARE
/// A comparison function pointer. See PFNDPACOMPARE for the comparison function prototype.
///
///
/// Type: LPARAM
/// An additional parameter to be passed to pfnCmp.
///
///
/// Type: BOOL
/// Returns TRUE on success or FALSE on failure.
///
// BOOL WINAPI DPA_Sort( HDPA pdpa, PFNDPACOMPARE pfnCmp, LPARAM lParam); https://msdn.microsoft.com/en-us/library/windows/desktop/bb775637(v=vs.85).aspx
[DllImport(Lib.ComCtl32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("Dpa_dsa.h", MSDNShortId = "bb775637")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool DPA_Sort(HDPA pdpa, PFNDACOMPARE pfnCmp, IntPtr lParam);
/// Inserts a new item before or after a specified existing item.
///
/// Type: HDPA
/// A handle to a DPA.
///
///
/// Type: void*
/// An item pointer which is used to determine the insertion point for the new item (see Remarks).
///
///
/// Type: int
/// The index in the DPA at which to begin searching for pFind.
///
///
/// Type: PFNDPACOMPARE
///
/// A pointer to the comparison function. See PFNDPACOMPARE or PFNDPACOMPARECONST for the comparison function prototype.
///
///
///
/// Type: LPARAM
/// An additional parameter used to pass information to the comparison function pointed to by pfnCmp.
///
///
/// Type: UINT
/// The insertion point. Must be one of the following values.
///
///
///
/// Value
/// Meaning
///
/// -
/// DPAS_INSERTBEFORE
/// Insert the new item before the pFind item.
///
/// -
/// DPAS_INSERTAFTER
/// Insert the new item after the pFind item.
///
///
///
///
///
/// Type: void*
/// A pointer to the item that is to be inserted.
///
/// Returns the index of the new item or , if the insert action fails.
// int DPA_SortedInsertPtr( HDPA pdpa, void *pFind, int iStart, PFNDPACOMPARE pfnCmp, LPARAM lParam, UINT options, void *pitem); https://msdn.microsoft.com/en-us/library/windows/desktop/bb775590(v=vs.85).aspx
[PInvokeData("Dpa_dsa.h", MSDNShortId = "bb775590")]
public static int DPA_SortedInsertPtr(HDPA hdpa, IntPtr pFind, int iStart, PFNDACOMPARE pfnCompare, IntPtr lParam, DPAS options, IntPtr pitem) =>
DPA_InsertPtr(hdpa, DPA_Search(hdpa, pFind, iStart, pfnCompare, lParam, DPAS.DPAS_SORTED | options), pitem);
/// Appends a new item to the end of a dynamic structure array (DSA).
/// A handle to the DSA in which to insert the item.
/// A pointer to the item that is to be inserted.
/// Returns the index of the new item if the append action succeeds, or if the append action fails.
// int DSA_AppendItem( [in] HDSA pdsa, [in] void *pItem); https://msdn.microsoft.com/en-us/library/windows/desktop/bb775591(v=vs.85).aspx
[PInvokeData("Dpa_dsa.h", MSDNShortId = "bb775591")]
public static int DSA_AppendItem(HDSA hdsa, IntPtr pitem) => DSA_InsertItem(hdsa, DA_LAST, pitem);
/// Duplicates a dynamic structure array (DSA).
///
/// Type: HDSA
/// A handle to an existing DSA.
///
///
/// Type: HDSA
/// Returns a handle to the clone, or NULL if the operation fails.
///
// HDSA DSA_Clone( _In_ HDSA hdsa); https://msdn.microsoft.com/en-us/library/windows/desktop/bb775645(v=vs.85).aspx
[DllImport(Lib.ComCtl32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("Dpa_dsa.h", MSDNShortId = "bb775645")]
public static extern SafeHDSA DSA_Clone(HDSA hdsa);
///
///
/// [ DSA_Create is available for use in the operating systems specified in the Requirements section. It may be altered or
/// unavailable in subsequent versions.]
///
/// Creates a dynamic structure array (DSA).
///
///
/// Type: int
/// The size, in bytes, of the item.
///
///
/// Type: int
/// The number of items by which the array should be incremented, if the DSA needs to be enlarged.
///
///
/// Type: HDSA
/// Returns a handle to a DSA if successful, or NULL if the creation fails.
///
// HDSA WINAPI DSA_Create( _In_ int cbItem, _In_ int cbItemGrow); https://msdn.microsoft.com/en-us/library/windows/desktop/bb775647(v=vs.85).aspx
[DllImport(Lib.ComCtl32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("Dpa_dsa.h", MSDNShortId = "bb775647")]
public static extern SafeHDSA DSA_Create(int cbItem, int cbItemGrow);
/// Deletes all items from a dynamic structure array (DSA).
///
/// Type: HDSA
/// A handle to an existing DSA.
///
///
/// Type: BOOL
/// TRUE if the items were successfully deleted; otherwise, FALSE.
///
// BOOL DSA_DeleteAllItems( _In_ HDSA hdsa); https://msdn.microsoft.com/en-us/library/windows/desktop/bb775649(v=vs.85).aspx
[DllImport(Lib.ComCtl32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("Dpa_dsa.h", MSDNShortId = "bb775649")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool DSA_DeleteAllItems(HDSA hdsa);
///
///
/// [ DSA_DeleteItem is available through Windows XP with Service Pack 2 (SP2). It might be altered or unavailable in
/// subsequent versions.]
///
/// Deletes an item from a dynamic structure array (DSA).
///
///
/// Type: HDSA
/// A handle to an existing DSA.
///
///
/// Type: int
/// The zero-based index of the item to delete.
///
///
/// Type: BOOL
/// TRUE if the item was successfully deleted; otherwise, FALSE.
///
// BOOL WINAPI DSA_DeleteItem( _In_ HDSA hdsa, _In_ int nPosition); https://msdn.microsoft.com/en-us/library/windows/desktop/bb775651(v=vs.85).aspx
[DllImport(Lib.ComCtl32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("Dpa_dsa.h", MSDNShortId = "bb775651")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool DSA_DeleteItem(HDSA hdsa, int nPosition);
///
///
/// [ DSA_Destroy is available for use in the operating systems specified in the Requirements section. It may be altered or
/// unavailable in subsequent versions.]
///
/// Frees a dynamic structure array (DSA).
///
///
/// Type: HDSA
/// A handle to a DSA to destroy.
///
///
/// Type: BOOL
/// Returns TRUE on success, FALSE on failure.
///
// BOOL WINAPI DSA_Destroy( _In_ HDSA pdsa); https://msdn.microsoft.com/en-us/library/windows/desktop/bb775653(v=vs.85).aspx
[DllImport(Lib.ComCtl32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("Dpa_dsa.h", MSDNShortId = "bb775653")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool DSA_Destroy(HDSA pdsa);
///
///
/// [ DSA_DestroyCallback is available for use in the operating systems specified in the Requirements section. It may be
/// altered or unavailable in subsequent versions.]
///
///
/// Iterates through a dynamic structure array (DSA), calling a specified callback function on each item. Upon reaching the end of
/// the array, the DSA is freed.
///
///
///
/// Type: HDSA
/// A handle to a DSA to walk and destroy.
///
///
/// Type: PFNDSAENUMCALLBACK
/// A callback function pointer. For the callback function prototype, see PFNDSAENUMCALLBACK.
///
///
/// Type: void*
/// A callback data pointer. This pointer is, in turn, passed as a parameter to pfnCB.
///
/// This function does not return a value.
// void WINAPI DSA_DestroyCallback( _In_ HDSA pdsa, _In_ PFNDSAENUMCALLBACK pfnCB, _In_ void *pData); https://msdn.microsoft.com/en-us/library/windows/desktop/bb775655(v=vs.85).aspx
[DllImport(Lib.ComCtl32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("Dpa_dsa.h", MSDNShortId = "bb775655")]
public static extern void DSA_DestroyCallback(HDSA pdsa, PFNDAENUMCALLBACK pfnCB, IntPtr pData);
/// Iterates through the dynamic structure array (DSA) and calls pfnCB on each item.
///
/// Type: HDSA
/// A handle to an existing DSA.
///
///
/// Type: PFNDAENUMCALLBACK*
/// A callback function pointer. See PFNDSAENUMCALLBACK for the callback function prototype.
///
///
/// Type: void*
/// A callback data pointer. pData is passed as a parameter to pfnCB.
///
/// This function does not return a value.
// void DSA_EnumCallback( _In_ HDSA hdsa, _In_ PFNDAENUMCALLBACK *pfnCB, _In_ void *pData); https://msdn.microsoft.com/en-us/library/windows/desktop/bb775657(v=vs.85).aspx
[DllImport(Lib.ComCtl32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("Dpa_dsa.h", MSDNShortId = "bb775657")]
public static extern void DSA_EnumCallback(HDSA hdsa, PFNDAENUMCALLBACK pfnCB, IntPtr pData);
/// Gets an element from a dynamic structure array (DSA).
///
/// Type: HDSA
/// A handle to the DSA containing the element.
///
///
/// Type: int
/// The index of the element to be retrieved (zero-based).
///
///
/// Type: void*
/// A pointer to a buffer which is filled with a copy of the specified element of the DSA.
///
///
/// Type: BOOL
/// Returns TRUE if successful or FALSE otherwise.
///
// BOOL WINAPI DSA_GetItem( _In_ HDSA pdsa, _In_ int index, _Out_ void *pitem); https://msdn.microsoft.com/en-us/library/windows/desktop/bb775659(v=vs.85).aspx
[DllImport(Lib.ComCtl32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("Dpa_dsa.h", MSDNShortId = "bb775659")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool DSA_GetItem(HDSA pdsa, int index, [Out] IntPtr pitem);
/// Gets the number of items in a dynamic structure array (DSA).
/// A handle to an existing DSA.
/// Returns the number of items in the DSA.
// int DSA_GetItemCount( [in] HDSA hdsa); https://msdn.microsoft.com/en-us/library/windows/desktop/bb775592(v=vs.85).aspx
[PInvokeData("Dpa_dsa.h", MSDNShortId = "bb775592")]
public static int DSA_GetItemCount(HDSA hdsa) => Marshal.ReadInt32((IntPtr)hdsa);
///
///
/// [ DSA_GetItemPtr is available for use in the operating systems specified in the Requirements section. It may be altered or
/// unavailable in subsequent versions.]
///
/// Gets a pointer to an element from a dynamic structure array (DSA).
///
///
/// Type: HDSA
/// A handle to the DSA containing the element.
///
///
/// Type: int
/// The index of the element to be retrieved (zero-based).
///
/// Returns a pointer to the specified element or NULL if the call fails.
// void* WINAPI DSA_GetItemPtr( _In_ HDSA pdsa, _In_ int index); https://msdn.microsoft.com/en-us/library/windows/desktop/bb775661(v=vs.85).aspx
[DllImport(Lib.ComCtl32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("Dpa_dsa.h", MSDNShortId = "bb775661")]
public static extern IntPtr DSA_GetItemPtr(HDSA pdsa, int index);
/// Gets the size of the dynamic structure array (DSA).
///
/// Type: HDSA
/// A handle to an existing DSA.
///
///
/// Type: ULONGLONG
///
/// Returns the size of the DSA, including the internal bookkeeping information, in bytes. If hdsa is NULL, the function
/// returns zero.
///
///
// ULONGLONG DSA_GetSize( _In_ HDSA hdsa); https://msdn.microsoft.com/en-us/library/windows/desktop/bb775663(v=vs.85).aspx
[DllImport(Lib.ComCtl32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("Dpa_dsa.h", MSDNShortId = "bb775663")]
public static extern ulong DSA_GetSize(HDSA pdsa);
///
///
/// [ DSA_InsertItem is available for use in the operating systems specified in the Requirements section. It may be altered or
/// unavailable in subsequent versions.]
///
/// Inserts a new item into a dynamic structure array (DSA). If necessary, the DSA expands to accommodate the new item.
///
///
/// Type: HDSA
/// A handle to the DSA in which to insert the item.
///
///
/// Type: int
/// The position in the DSA where new item is to be inserted, or DSA_APPEND to insert the item at the end of the array.
///
///
/// Type: void*
/// A pointer to the item that is to be inserted.
///
///
/// Type: int
/// Returns the index of the new item if the insertion succeeds, or DSA_ERR () if the insertion fails.
///
// int WINAPI DSA_InsertItem( _In_ HDSA pdsa, _In_ int index, _In_ void *pItem); https://msdn.microsoft.com/en-us/library/windows/desktop/bb775665(v=vs.85).aspx
[DllImport(Lib.ComCtl32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("Dpa_dsa.h", MSDNShortId = "bb775665")]
public static extern int DSA_InsertItem(HDSA pdsa, int index, IntPtr pItem);
///
///
/// [ DSA_SetItem is available for use in the operating systems specified in the Requirements section. It may be altered or
/// unavailable in subsequent versions.]
///
/// Inserts a new item into a dynamic structure array (DSA). If necessary, the DSA expands to accommodate the new item.
///
///
/// Type: HDSA
/// A handle to an existing DSA that contains the element.
///
///
/// Type: int
/// The zero-based index of the item to set.
///
///
/// Type: void*
/// A pointer to the item that will replace the specified item in the array.
///
///
/// Type: BOOL
/// Returns TRUE on success or FALSE on failure.
///
// BOOL WINAPI DSA_SetItem( _In_ HDSA hdsa, _In_ int index, _In_ void *pItem); https://msdn.microsoft.com/en-us/library/windows/desktop/bb775668(v=vs.85).aspx
[DllImport(Lib.ComCtl32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("Dpa_dsa.h", MSDNShortId = "bb775668")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool DSA_SetItem(HDSA hdsa, int index, IntPtr pItem);
/// Sorts the items in a dynamic structure array (DSA).
///
/// Type: HDSA
/// A handle to an existing DSA.
///
///
/// Type: PFNDACOMPARE
/// A comparison function pointer. See PFNDPACOMPARE for the comparison function prototype.
///
///
/// Type: LPARAM
/// An additional parameter to be passed to pfnCmp.
///
///
/// Type: BOOL
/// Returns TRUE on success or FALSE on failure.
///
// BOOL DSA_Sort( _In_ HDSA pdsa, _In_ PFNDACOMPARE pfnCompare, _In_ LPARAM lParam); https://msdn.microsoft.com/en-us/library/windows/desktop/bb775670(v=vs.85).aspx
[DllImport(Lib.ComCtl32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("Dpa_dsa.h", MSDNShortId = "bb775670")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool DSA_Sort(HDSA pdsa, PFNDACOMPARE pfnCompare, IntPtr lParam);
/// Sets ppszCurrent to a copy of pszNew and frees the previous value, if necessary.
///
/// Type: LPTSTR*
/// The address of a pointer to the current string. The current string is freed and the pointer is set to a copy of pszNew.
///
///
/// Type: LPCTSTR
/// A pointer to the string to copy into ppszCurrent.
///
///
/// Type: BOOL
/// Returns TRUE if successful; otherwise, FALSE.
///
// BOOL WINAPI Str_SetPtr( _Inout_ LPTSTR *ppszCurrent, LPCTSTR pszNew); https://msdn.microsoft.com/en-us/library/windows/desktop/bb775735(v=vs.85).aspx
[DllImport(Lib.ComCtl32, SetLastError = false, EntryPoint = "Str_SetPtrW", CharSet = CharSet.Unicode)]
[PInvokeData("Commctrl.h", MSDNShortId = "bb775735")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool Str_SetPtr(ref IntPtr ppszCurrent, string pszNew);
/// Contains a stream item used by the PFNDPASTREAM callback function.
// typedef struct _DPASTREAMINFO { int iPos; void *pvItem;} DPASTREAMINFO; https://msdn.microsoft.com/en-us/library/windows/desktop/bb775504(v=vs.85).aspx
[PInvokeData("Dpa_dsa.h", MSDNShortId = "bb775504")]
[StructLayout(LayoutKind.Sequential)]
public struct DPASTREAMINFO
{
///
/// Type: int
/// An index of the item in the DPA.
///
public int iPos;
///
/// Type: void*
/// A void pointer to the item data.
///
public IntPtr pvItem;
}
/// Provides a to a that releases a created HDPA instance at disposal using DPA_Destroy.
public class SafeHDPA : HANDLE
{
/// Initializes a new instance of the class and assigns an existing handle.
/// An object that represents the pre-existing handle to use.
///
/// to reliably release the handle during the finalization phase; otherwise, (not recommended).
///
public SafeHDPA(IntPtr preexistingHandle, bool ownsHandle = true) : base(preexistingHandle, ownsHandle) { }
private SafeHDPA() : base() { }
/// Performs an implicit conversion from to .
/// The safe handle instance.
/// The result of the conversion.
public static implicit operator HDPA(SafeHDPA h) => h.handle;
///
protected override bool InternalReleaseHandle() => DPA_Destroy(this);
}
/// Provides a to a that releases a created HDSA instance at disposal using DSA_Destroy.
public class SafeHDSA : HANDLE
{
/// Initializes a new instance of the class and assigns an existing handle.
/// An object that represents the pre-existing handle to use.
///
/// to reliably release the handle during the finalization phase; otherwise, (not recommended).
///
public SafeHDSA(IntPtr preexistingHandle, bool ownsHandle = true) : base(preexistingHandle, ownsHandle) { }
private SafeHDSA() : base() { }
/// Performs an implicit conversion from to .
/// The safe handle instance.
/// The result of the conversion.
public static implicit operator HDSA(SafeHDSA h) => h.handle;
///
protected override bool InternalReleaseHandle() => DSA_Destroy(this);
}
}
}