2.0 Checkin - Buildable

pull/25/head
David Hall 2018-10-26 12:24:07 -06:00
parent 99e041749c
commit 627c6d2314
298 changed files with 43983 additions and 20038 deletions

View File

@ -241,7 +241,7 @@ namespace Vanara.Extensions
/// <param name="ptr">A pointer to an unmanaged block of memory.</param>
/// <returns>A managed object that contains the data that the <paramref name="ptr"/> parameter points to.</returns>
[SecurityPermission(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.UnmanagedCode)]
public static T ToStructure<T>(this IntPtr ptr) => (T)Marshal.PtrToStructure(ptr, typeof(T).IsEnum ? Enum.GetUnderlyingType(typeof(T)) : typeof(T));
public static T ToStructure<T>(this IntPtr ptr) => typeof(T) == typeof(IntPtr) ? (T)(object)ptr : ((T)Marshal.PtrToStructure(ptr, typeof(T).IsEnum ? Enum.GetUnderlyingType(typeof(T)) : typeof(T)));
/// <summary>Marshals data from an unmanaged block of memory to a managed object.</summary>
/// <typeparam name="T">The type of the object to which the data is to be copied. This must be a formatted class.</typeparam>
@ -276,7 +276,7 @@ namespace Vanara.Extensions
/// <returns>Enumeration of strings.</returns>
public static IEnumerable<string> ToStringEnum(this IntPtr ptr, int count, CharSet charSet = CharSet.Auto, int prefixBytes = 0)
{
if (ptr == IntPtr.Zero) yield break;
if (ptr == IntPtr.Zero || count == 0) yield break;
var lPtrVal = ptr.ToInt64();
for (var i = 0; i < count; i++)
{

View File

@ -39,18 +39,66 @@ namespace Vanara.Extensions
return Marshal.SecureStringToCoTaskMemAnsi(s);
}
/// <summary>Copies the contents of a managed <see cref="SecureString"/> object to a block of memory allocated from a supplied allocation method.</summary>
/// <param name="s">The managed object to copy.</param>
/// <param name="charSet">The character set.</param>
/// <param name="memAllocator">The method used to allocate the memory.</param>
/// <returns>The address, in unmanaged memory, where the <paramref name="s"/> parameter was copied to, or 0 if a null object was supplied.</returns>
public static IntPtr AllocSecureString(SecureString s, CharSet charSet, Func<int, IntPtr> memAllocator)
{
if (s == null) return IntPtr.Zero;
var chSz = StringHelper.GetCharSize(charSet);
var encoding = chSz == 2 ? System.Text.Encoding.Unicode : System.Text.Encoding.ASCII;
var hMem = AllocSecureString(s, charSet);
var str = chSz == 2 ? Marshal.PtrToStringUni(hMem) : Marshal.PtrToStringAnsi(hMem);
Marshal.FreeCoTaskMem(hMem);
if (str == null) return IntPtr.Zero;
var b = encoding.GetBytes(str);
var p = memAllocator(b.Length);
Marshal.Copy(b, 0, p, b.Length);
return p;
}
/// <summary>Copies the contents of a managed String to a block of memory allocated from the unmanaged COM task allocator.</summary>
/// <param name="s">A managed string to be copied.</param>
/// <param name="charSet">The character set.</param>
/// <returns>The allocated memory block, or 0 if <paramref name="s"/> is null.</returns>
public static IntPtr AllocString(string s, CharSet charSet = CharSet.Auto) => charSet == CharSet.Auto ? Marshal.StringToCoTaskMemAuto(s) : (charSet == CharSet.Unicode ? Marshal.StringToCoTaskMemUni(s) : Marshal.StringToCoTaskMemAnsi(s));
/// <summary>Copies the contents of a managed String to a block of memory allocated from a supplied allocation method.</summary>
/// <param name="s">A managed string to be copied.</param>
/// <param name="charSet">The character set.</param>
/// <param name="memAllocator">The method used to allocate the memory.</param>
/// <returns>The allocated memory block, or 0 if <paramref name="s"/> is null.</returns>
public static IntPtr AllocString(string s, CharSet charSet, Func<int, IntPtr> memAllocator)
{
if (s == null) return IntPtr.Zero;
var b = s.GetBytes(true, charSet);
var p = memAllocator(b.Length);
Marshal.Copy(b, 0, p, b.Length);
return p;
}
/// <summary>
/// Zeros out the allocated memory behind a secure string and then frees that memory.
/// </summary>
/// <param name="ptr">The address of the memory to be freed.</param>
/// <param name="sizeInBytes">The size in bytes of the memory pointed to by <paramref name="ptr"/>.</param>
/// <param name="memFreer">The memory freer.</param>
public static void FreeSecureString(IntPtr ptr, int sizeInBytes, Action<IntPtr> memFreer)
{
if (IsValue(ptr)) return;
var b = new byte[sizeInBytes];
Marshal.Copy(b, 0, ptr, b.Length);
memFreer(ptr);
}
/// <summary>Frees a block of memory allocated by the unmanaged COM task memory allocator for a string.</summary>
/// <param name="ptr">The address of the memory to be freed.</param>
/// <param name="charSet">The character set of the string.</param>
public static void FreeString(IntPtr ptr, CharSet charSet = CharSet.Auto)
{
if (ptr.ToInt64() >> 16 == 0) return;
if (IsValue(ptr)) return;
if (GetCharSize(charSet) == 2)
Marshal.ZeroFreeCoTaskMemUnicode(ptr);
else
@ -95,7 +143,20 @@ namespace Vanara.Extensions
/// <param name="ptr">The address of the first character.</param>
/// <param name="charSet">The character set of the string.</param>
/// <returns>A managed string that holds a copy of the unmanaged string if the value of the <paramref name="ptr"/> parameter is not null; otherwise, this method returns null.</returns>
public static string GetString(IntPtr ptr, CharSet charSet = CharSet.Auto) => charSet == CharSet.Auto ? Marshal.PtrToStringAuto(ptr) : (charSet == CharSet.Unicode ? Marshal.PtrToStringUni(ptr) : Marshal.PtrToStringAnsi(ptr));
public static string GetString(IntPtr ptr, CharSet charSet = CharSet.Auto) => IsValue(ptr) ? null : (charSet == CharSet.Auto ? Marshal.PtrToStringAuto(ptr) : (charSet == CharSet.Unicode ? Marshal.PtrToStringUni(ptr) : Marshal.PtrToStringAnsi(ptr)));
/// <summary>
/// Allocates a managed String and copies all characters up to the first null character or at most <paramref name="length"/> characters from a string stored in unmanaged memory into it.
/// </summary>
/// <param name="ptr">The address of the first character.</param>
/// <param name="length">The number of characters to copy.</param>
/// <param name="charSet">The character set of the string.</param>
/// <returns>
/// A managed string that holds a copy of the unmanaged string if the value of the <paramref name="ptr"/> parameter is not null;
/// otherwise, this method returns null.
/// </returns>
public static string GetString(IntPtr ptr, int length, CharSet charSet = CharSet.Auto) =>
IsValue(ptr) ? null : (charSet == CharSet.Auto ? Marshal.PtrToStringAuto(ptr, length) : (charSet == CharSet.Unicode ? Marshal.PtrToStringUni(ptr, length) : Marshal.PtrToStringAnsi(ptr, length)));
/// <summary>Refreshes the memory block from the unmanaged COM task allocator and copies the contents of a new managed String.</summary>
/// <param name="ptr">The address of the first character.</param>
@ -110,5 +171,7 @@ namespace Vanara.Extensions
charLen = s == null ? 0U : (uint)s.Length + 1;
return s != null;
}
private static bool IsValue(IntPtr ptr) => ptr.ToInt64() >> 16 == 0;
}
}

View File

@ -77,7 +77,7 @@ namespace Vanara.InteropServices
/// <typeparam name="T">Native type</typeparam>
/// <param name="value">The value.</param>
/// <returns><see cref="SafeCoTaskMemHandle"/> object to an native (unmanaged) memory block the size of T.</returns>
public static SafeCoTaskMemHandle CreateFromStructure<T>(T value = default(T)) => new SafeCoTaskMemHandle(InteropExtensions.StructureToPtr(value, mm.AllocMem, out int s), s);
public static SafeCoTaskMemHandle CreateFromStructure<T>(T value = default) => new SafeCoTaskMemHandle(InteropExtensions.StructureToPtr(value, new CoTaskMemoryMethods().AllocMem, out int s), s);
/// <summary>
/// Allocates from unmanaged memory to represent a structure with a variable length array at the end and marshal these structure elements. It is the
@ -89,7 +89,7 @@ namespace Vanara.InteropServices
/// <param name="count">Number of items in <paramref name="values"/>. Setting this value to -1 will cause the method to get the count by iterating through <paramref name="values"/>.</param>
/// <param name="prefixBytes">Number of bytes preceding the trailing array of structures</param>
/// <returns><see cref="SafeCoTaskMemHandle"/> object to an native (unmanaged) structure with a trail array of structures</returns>
public static SafeCoTaskMemHandle CreateFromList<T>(IEnumerable<T> values, int count = -1, int prefixBytes = 0) => new SafeCoTaskMemHandle(InteropExtensions.MarshalToPtr(values, mm.AllocMem, out int s, prefixBytes), s);
public static SafeCoTaskMemHandle CreateFromList<T>(IEnumerable<T> values, int count = -1, int prefixBytes = 0) => new SafeCoTaskMemHandle(InteropExtensions.MarshalToPtr(values, new CoTaskMemoryMethods().AllocMem, out int s, prefixBytes), s);
/// <summary>Allocates from unmanaged memory sufficient memory to hold an array of strings.</summary>
/// <param name="values">The list of strings.</param>
@ -97,6 +97,6 @@ namespace Vanara.InteropServices
/// <param name="charSet">The character set to use for the strings.</param>
/// <param name="prefixBytes">Number of bytes preceding the trailing strings.</param>
/// <returns><see cref="SafeCoTaskMemHandle"/> object to an native (unmanaged) array of strings stored using the <paramref name="packing"/> model and the character set defined by <paramref name="charSet"/>.</returns>
public static SafeCoTaskMemHandle CreateFromStringList(IEnumerable<string> values, StringListPackMethod packing = StringListPackMethod.Concatenated, CharSet charSet = CharSet.Auto, int prefixBytes = 0) => new SafeCoTaskMemHandle(InteropExtensions.MarshalToPtr(values, packing, mm.AllocMem, out int s, charSet, prefixBytes), s);
public static SafeCoTaskMemHandle CreateFromStringList(IEnumerable<string> values, StringListPackMethod packing = StringListPackMethod.Concatenated, CharSet charSet = CharSet.Auto, int prefixBytes = 0) => new SafeCoTaskMemHandle(InteropExtensions.MarshalToPtr(values, packing, new CoTaskMemoryMethods().AllocMem, out int s, charSet, prefixBytes), s);
}
}

View File

@ -77,7 +77,7 @@ namespace Vanara.InteropServices
/// <typeparam name="T">Native type</typeparam>
/// <param name="value">The value.</param>
/// <returns><see cref="SafeHGlobalHandle"/> object to an native (unmanaged) memory block the size of T.</returns>
public static SafeHGlobalHandle CreateFromStructure<T>(T value = default(T)) => new SafeHGlobalHandle(InteropExtensions.StructureToPtr(value, mm.AllocMem, out int s), s);
public static SafeHGlobalHandle CreateFromStructure<T>(T value = default(T)) => new SafeHGlobalHandle(InteropExtensions.StructureToPtr(value, new HGlobalMemoryMethods().AllocMem, out int s), s);
/// <summary>
/// Allocates from unmanaged memory to represent a structure with a variable length array at the end and marshal these structure elements. It is the
@ -89,7 +89,7 @@ namespace Vanara.InteropServices
/// <param name="count">Number of items in <paramref name="values"/>.</param>
/// <param name="prefixBytes">Number of bytes preceding the trailing array of structures</param>
/// <returns><see cref="SafeHGlobalHandle"/> object to an native (unmanaged) structure with a trail array of structures</returns>
public static SafeHGlobalHandle CreateFromList<T>(IEnumerable<T> values, int count = -1, int prefixBytes = 0) => new SafeHGlobalHandle(InteropExtensions.MarshalToPtr(values, mm.AllocMem, out int s, prefixBytes), s);
public static SafeHGlobalHandle CreateFromList<T>(IEnumerable<T> values, int count = -1, int prefixBytes = 0) => new SafeHGlobalHandle(InteropExtensions.MarshalToPtr(values, new HGlobalMemoryMethods().AllocMem, out int s, prefixBytes), s);
/// <summary>Allocates from unmanaged memory sufficient memory to hold an array of strings.</summary>
/// <param name="values">The list of strings.</param>
@ -97,6 +97,6 @@ namespace Vanara.InteropServices
/// <param name="charSet">The character set to use for the strings.</param>
/// <param name="prefixBytes">Number of bytes preceding the trailing strings.</param>
/// <returns><see cref="SafeHGlobalHandle"/> object to an native (unmanaged) array of strings stored using the <paramref name="packing"/> model and the character set defined by <paramref name="charSet"/>.</returns>
public static SafeHGlobalHandle CreateFromStringList(IEnumerable<string> values, StringListPackMethod packing = StringListPackMethod.Concatenated, CharSet charSet = CharSet.Auto, int prefixBytes = 0) => new SafeHGlobalHandle(InteropExtensions.MarshalToPtr(values, packing, mm.AllocMem, out int s, charSet, prefixBytes), s);
public static SafeHGlobalHandle CreateFromStringList(IEnumerable<string> values, StringListPackMethod packing = StringListPackMethod.Concatenated, CharSet charSet = CharSet.Auto, int prefixBytes = 0) => new SafeHGlobalHandle(InteropExtensions.MarshalToPtr(values, packing, new HGlobalMemoryMethods().AllocMem, out int s, charSet, prefixBytes), s);
}
}

View File

@ -2,15 +2,12 @@
using System.Collections.Generic;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Security;
using Vanara.Extensions;
// ReSharper disable InconsistentNaming
namespace Vanara.InteropServices
{
/// <summary>Method used to pack a list of strings into memory.</summary>
@ -129,7 +126,7 @@ namespace Vanara.InteropServices
/// <summary>Initializes a new instance of the <see cref="SafeAllocatedMemoryHandle"/> class.</summary>
/// <param name="handle">The handle.</param>
/// <param name="ownsHandle">if set to <c>true</c> if this class is responsible for freeing the memory on disposal.</param>
protected SafeAllocatedMemoryHandle(IntPtr handle, bool ownsHandle) : base(handle, ownsHandle) { }
protected SafeAllocatedMemoryHandle(IntPtr handle, bool ownsHandle) : base(IntPtr.Zero, ownsHandle) => SetHandle(handle);
/// <summary>Gets or sets the size in bytes of the allocated memory block.</summary>
/// <value>The size in bytes of the allocated memory block.</value>
@ -153,7 +150,7 @@ namespace Vanara.InteropServices
public abstract class SafeMemoryHandle<TMem> : SafeAllocatedMemoryHandle where TMem : IMemoryMethods, new()
{
/// <summary>The <see cref="IMemoryMethods"/> implementation instance.</summary>
protected static TMem mm = new TMem();
protected TMem mm = new TMem();
/// <summary>The number of bytes currently allocated.</summary>
protected int sz;
@ -165,30 +162,21 @@ namespace Vanara.InteropServices
{
if (size < 0)
throw new ArgumentOutOfRangeException(nameof(size), "The value of this argument must be non-negative");
sz = size;
if (size == 0) return;
RuntimeHelpers.PrepareConstrainedRegions();
SetHandle(mm.AllocMem(size));
SetHandle(mm.AllocMem(sz = size));
}
/// <summary>Initializes a new instance of the <see cref="SafeMemoryHandle{T}"/> class.</summary>
/// <param name="handle">The handle.</param>
/// <param name="size">The size of memory allocated to the handle, in bytes.</param>
/// <param name="ownsHandle">if set to <c>true</c> if this class is responsible for freeing the memory on disposal.</param>
protected SafeMemoryHandle(IntPtr handle, int size, bool ownsHandle) : base(IntPtr.Zero, ownsHandle)
{
if (handle != IntPtr.Zero)
SetHandle(handle);
sz = size;
}
protected SafeMemoryHandle(IntPtr handle, int size, bool ownsHandle) : base(handle, ownsHandle) => sz = size;
/// <summary>Allocates from unmanaged memory to represent an array of pointers and marshals the unmanaged pointers (IntPtr) to the native array equivalent.</summary>
/// <param name="bytes">Array of unmanaged pointers</param>
/// <returns>SafeHGlobalHandle object to an native (unmanaged) array of pointers</returns>
protected SafeMemoryHandle(byte[] bytes) : this(bytes.Length)
{
Marshal.Copy(bytes, 0, handle, bytes.Length);
}
protected SafeMemoryHandle(byte[] bytes) : this(bytes.Length) => Marshal.Copy(bytes, 0, handle, bytes.Length);
/// <summary>When overridden in a derived class, gets a value indicating whether the handle value is invalid.</summary>
public override bool IsInvalid => handle == IntPtr.Zero;
@ -273,10 +261,7 @@ namespace Vanara.InteropServices
/// <summary>Allocates from unmanaged memory to represent an array of pointers and marshals the unmanaged pointers (IntPtr) to the native array equivalent.</summary>
/// <param name="values">Array of unmanaged pointers</param>
/// <returns>SafeMemoryHandleExt object to an native (unmanaged) array of pointers</returns>
protected SafeMemoryHandleExt(IntPtr[] values) : this(IntPtr.Size * values.Length)
{
Marshal.Copy(values, 0, handle, values.Length);
}
protected SafeMemoryHandleExt(IntPtr[] values) : this(IntPtr.Size * values.Length) => Marshal.Copy(values, 0, handle, values.Length);
/// <summary>Allocates from unmanaged memory to represent a Unicode string (WSTR) and marshal this to a native PWSTR.</summary>
/// <param name="s">The string value.</param>
@ -361,7 +346,7 @@ namespace Vanara.InteropServices
/// <returns>A managed object that contains the data that this <see cref="SafeMemoryHandleExt{T}"/> holds.</returns>
public T ToStructure<T>()
{
if (IsInvalid) return default(T);
if (IsInvalid) return default;
//if (Size < Marshal.SizeOf(typeof(T)))
// throw new InsufficientMemoryException("Requested structure is larger than the memory allocated.");
return handle.ToStructure<T>();

View File

@ -12,25 +12,23 @@ namespace Vanara.InteropServices
/// <summary>Initializes a new instance of the <see cref="StrPtrAuto"/> struct.</summary>
/// <param name="s">The string value.</param>
public StrPtrAuto(string s)
{
ptr = StringHelper.AllocString(s);
}
public StrPtrAuto(string s) => ptr = StringHelper.AllocString(s);
/// <summary>Initializes a new instance of the <see cref="StrPtrAuto"/> struct.</summary>
/// <param name="charLen">Number of characters to reserve in memory.</param>
public StrPtrAuto(uint charLen)
{
ptr = StringHelper.AllocChars(charLen);
}
public StrPtrAuto(uint charLen) => ptr = StringHelper.AllocChars(charLen);
/// <summary>Gets a value indicating whether this instance is equivalent to null pointer or void*.</summary>
/// <value><c>true</c> if this instance is null; otherwise, <c>false</c>.</value>
public bool IsNull => ptr == IntPtr.Zero;
/// <summary>Assigns a string pointer value to the pointer.</summary>
/// <param name="stringPtr">The string pointer value.</param>
public void Assign(IntPtr stringPtr) { Free(); ptr = stringPtr; }
/// <summary>Assigns a new string value to the pointer.</summary>
/// <param name="s">The string value.</param>
public void Assign(string s) { StringHelper.RefreshString(ref ptr, out uint _, s); }
public void Assign(string s) => StringHelper.RefreshString(ref ptr, out var _, s);
/// <summary>Assigns a new string value to the pointer.</summary>
/// <param name="s">The string value.</param>
@ -68,17 +66,11 @@ namespace Vanara.InteropServices
/// <summary>Initializes a new instance of the <see cref="StrPtrUni"/> struct.</summary>
/// <param name="s">The string value.</param>
public StrPtrUni(string s)
{
ptr = StringHelper.AllocString(s, CharSet.Unicode);
}
public StrPtrUni(string s) => ptr = StringHelper.AllocString(s, CharSet.Unicode);
/// <summary>Initializes a new instance of the <see cref="StrPtrUni"/> struct.</summary>
/// <param name="charLen">Number of characters to reserve in memory.</param>
public StrPtrUni(uint charLen)
{
ptr = StringHelper.AllocChars(charLen, CharSet.Unicode);
}
public StrPtrUni(uint charLen) => ptr = StringHelper.AllocChars(charLen, CharSet.Unicode);
/// <summary>Gets a value indicating whether this instance is equivalent to null pointer or void*.</summary>
/// <value><c>true</c> if this instance is null; otherwise, <c>false</c>.</value>
@ -86,7 +78,7 @@ namespace Vanara.InteropServices
/// <summary>Assigns a new string value to the pointer.</summary>
/// <param name="s">The string value.</param>
public void Assign(string s) { StringHelper.RefreshString(ref ptr, out uint _, s, CharSet.Unicode); }
public void Assign(string s) => StringHelper.RefreshString(ref ptr, out var _, s, CharSet.Unicode);
/// <summary>Assigns a new string value to the pointer.</summary>
/// <param name="s">The string value.</param>
@ -124,17 +116,11 @@ namespace Vanara.InteropServices
/// <summary>Initializes a new instance of the <see cref="StrPtrAnsi"/> struct.</summary>
/// <param name="s">The string value.</param>
public StrPtrAnsi(string s)
{
ptr = StringHelper.AllocString(s, CharSet.Ansi);
}
public StrPtrAnsi(string s) => ptr = StringHelper.AllocString(s, CharSet.Ansi);
/// <summary>Initializes a new instance of the <see cref="StrPtrAnsi"/> struct.</summary>
/// <param name="charLen">Number of characters to reserve in memory.</param>
public StrPtrAnsi(uint charLen)
{
ptr = StringHelper.AllocChars(charLen, CharSet.Ansi);
}
public StrPtrAnsi(uint charLen) => ptr = StringHelper.AllocChars(charLen, CharSet.Ansi);
/// <summary>Gets a value indicating whether this instance is equivalent to null pointer or void*.</summary>
/// <value><c>true</c> if this instance is null; otherwise, <c>false</c>.</value>
@ -142,7 +128,7 @@ namespace Vanara.InteropServices
/// <summary>Assigns a new string value to the pointer.</summary>
/// <param name="s">The string value.</param>
public void Assign(string s) { StringHelper.RefreshString(ref ptr, out uint _, s, CharSet.Ansi); }
public void Assign(string s) => StringHelper.RefreshString(ref ptr, out var _, s, CharSet.Ansi);
/// <summary>Assigns a new string value to the pointer.</summary>
/// <param name="s">The string value.</param>

View File

@ -3,8 +3,6 @@ using System.Runtime.InteropServices;
using static Vanara.PInvoke.AdvApi32;
using static Vanara.PInvoke.Authz;
// ReSharper disable InconsistentNaming ReSharper disable FieldCanBeMadeReadOnly.Global
namespace Vanara.PInvoke
{
/// <summary>Platform invokable enumerated types, constants and functions from aclui.h</summary>
@ -358,7 +356,7 @@ namespace Vanara.PInvoke
/// <param name="pcGrantedAccessListLength">
/// A pointer to a ULONG variable that receives the count of granted access masks pointed to by the ppGrantedAccessList parameter.
/// </param>
void GetEffectivePermission([In, MarshalAs(UnmanagedType.LPStruct)] Guid pguidObjectType, [In] PSID pUserSid,
void GetEffectivePermission(in Guid pguidObjectType, [In] PSID pUserSid,
[In, MarshalAs(UnmanagedType.LPWStr)] string pszServerName, [In] IntPtr pSD,
[MarshalAs(UnmanagedType.LPArray)] out OBJECT_TYPE_LIST[] ppObjectTypeList,
out uint pcObjectTypeListLength,
@ -446,19 +444,19 @@ namespace Vanara.PInvoke
/// </param>
[PreserveSig]
uint ComputeEffectivePermissionWithSecondarySecurity(
PSID pSid,
PSID pDeviceSid,
[MarshalAs(UnmanagedType.LPWStr)] string pszServerName,
[MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 4)] SECURITY_OBJECT[] pSecurityObjects,
[In] PSID pSid,
[In, Optional] PSID pDeviceSid,
[In, Optional, MarshalAs(UnmanagedType.LPWStr)] string pszServerName,
[In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 4)] SECURITY_OBJECT[] pSecurityObjects,
uint dwSecurityObjectCount,
ref TOKEN_GROUPS pUserGroups,
AUTHZ_SID_OPERATION[] pAuthzUserGroupsOperations,
ref TOKEN_GROUPS pDeviceGroups,
AUTHZ_SID_OPERATION[] pAuthzDeviceGroupsOperations,
ref AUTHZ_SECURITY_ATTRIBUTES_INFORMATION pAuthzUserClaims,
AUTHZ_SECURITY_ATTRIBUTE_OPERATION[] pAuthzUserClaimsOperations,
ref AUTHZ_SECURITY_ATTRIBUTES_INFORMATION pAuthzDeviceClaims,
AUTHZ_SECURITY_ATTRIBUTE_OPERATION[] pAuthzDeviceClaimsOperations,
in TOKEN_GROUPS pUserGroups,
[In, Optional] AUTHZ_SID_OPERATION[] pAuthzUserGroupsOperations,
in TOKEN_GROUPS pDeviceGroups,
[In, Optional] AUTHZ_SID_OPERATION[] pAuthzDeviceGroupsOperations,
in AUTHZ_SECURITY_ATTRIBUTES_INFORMATION pAuthzUserClaims,
[In, Optional] AUTHZ_SECURITY_ATTRIBUTE_OPERATION[] pAuthzUserClaimsOperations,
in AUTHZ_SECURITY_ATTRIBUTES_INFORMATION pAuthzDeviceClaims,
[In, Optional] AUTHZ_SECURITY_ATTRIBUTE_OPERATION[] pAuthzDeviceClaimsOperations,
[MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 4)] EFFPERM_RESULT_LIST[] pEffpermResultLists);
}
@ -538,7 +536,7 @@ namespace Vanara.PInvoke
/// A pointer to ULONG that indicates the zero-based index of the array entry that contains the default access rights. The access control editor uses
/// this entry as the initial access rights in a new ACE.
/// </param>
void GetAccessRights([In, MarshalAs(UnmanagedType.LPStruct)] Guid guidObject, [In] int dwFlags, [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 3)] out SI_ACCESS[] access, ref uint access_count, out uint DefaultAccess);
void GetAccessRights(in Guid guidObject, [In] int dwFlags, [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 3)] out SI_ACCESS[] access, ref uint access_count, out uint DefaultAccess);
/// <summary>
/// The MapGeneric method requests that the generic access rights in an access mask be mapped to their corresponding standard and specific access
@ -553,7 +551,7 @@ namespace Vanara.PInvoke
/// A pointer to an access mask that contains the generic access rights to map. Your implementation must map the generic access rights to the
/// corresponding standard and specific access rights for the specified object type.
/// </param>
void MapGeneric([In, MarshalAs(UnmanagedType.LPStruct)] Guid guidObjectType, [In] ref sbyte AceFlags, [In] ref uint Mask);
void MapGeneric(in Guid guidObjectType, ref sbyte AceFlags, ref uint Mask);
/// <summary>
/// The GetInheritTypes method requests information about how ACEs can be inherited by child objects. For more information, see ACE Inheritance.
@ -563,7 +561,7 @@ namespace Vanara.PInvoke
/// combination of inheritance flags and child object type that you support.
/// </param>
/// <param name="InheritTypesCount">A pointer to a variable that you should set to indicate the number of entries in the ppInheritTypes array.</param>
void GetInheritTypes([MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)]out SI_INHERIT_TYPE[] InheritType, out uint InheritTypesCount);
void GetInheritTypes([MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)] out SI_INHERIT_TYPE[] InheritType, out uint InheritTypesCount);
/// <summary>
/// The PropertySheetPageCallback method notifies an EditSecurity or CreateSecurityPage caller that an access control editor property page is being
@ -936,7 +934,7 @@ namespace Vanara.PInvoke
/// Identifies a module that contains string resources to be used in the property sheet. The ISecurityInformation::GetAccessRights and
/// ISecurityInformation::GetInheritTypes methods can specify string resource identifiers for display names.
/// </summary>
public IntPtr hInstance;
public HINSTANCE hInstance;
/// <summary>
/// A pointer to a null-terminated, Unicode string that names the computer on which to look up account names and SIDs. This value can be NULL to
/// specify the local computer. The access control editor does not free this pointer.

View File

@ -12,7 +12,6 @@ Native Structure | Header | Managed Structure
[SECURITY_OBJECT](http://msdn2.microsoft.com/en-us/library/hh448532) | aclui.h | Vanara.PInvoke.AclUI+SECURITY_OBJECT
[SI_ACCESS](http://msdn2.microsoft.com/en-us/library/aa379603) | aclui.h | Vanara.PInvoke.AclUI+SI_ACCESS
[SI_INHERIT_TYPE](http://msdn2.microsoft.com/en-us/library/aa379604) | aclui.h | Vanara.PInvoke.AclUI+SI_INHERIT_TYPE
[SI_OBJECT_INFO](http://msdn2.microsoft.com/en-us/library/aa379605) | aclui.h | Vanara.PInvoke.AclUI+SI_OBJECT_INFO
[SID_INFO](http://msdn2.microsoft.com/en-us/library/aa379599) | aclui.h | Vanara.PInvoke.AclUI+SID_INFO
### Interfaces
Native Interface | Native DLL | Header | Managed Interface

View File

@ -28,13 +28,13 @@ Functions
CreateSecurityPage, EditSecurity, EditSecurityAdvanced
Structures
EFFPERM_RESULT_LIST, SECURITY_OBJECT, SI_ACCESS, SI_INHERIT_TYPE, SI_OBJECT_INFO, SID_INFO
EFFPERM_RESULT_LIST, SECURITY_OBJECT, SI_ACCESS, SI_INHERIT_TYPE, SID_INFO
Interfaces
IEffectivePermission, IEffectivePermission2, ISecurityInformation, ISecurityInformation2, ISecurityInformation3, ISecurityInformation4, ISecurityObjectTypeInfo
</PackageReleaseNotes>
<LangVersion>latest</LangVersion>
<LangVersion>latest</LangVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)'=='Release'">
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>

View File

@ -31,7 +31,7 @@ Interfaces
IBackgroundCopyCallback, IBackgroundCopyCallback2, IBackgroundCopyCallback3, IBackgroundCopyError, IBackgroundCopyFile, IBackgroundCopyFile2, IBackgroundCopyFile3, IBackgroundCopyFile4, IBackgroundCopyFile5, IBackgroundCopyFile6, IBackgroundCopyJob, IBackgroundCopyJob2, IBackgroundCopyJob3, IBackgroundCopyJob4, IBackgroundCopyJob5, IBackgroundCopyJobHttpOptions, IBackgroundCopyManager, IBitsPeer, IBitsPeerCacheAdministration, IBitsPeerCacheRecord, IBitsTokenOptions, IEnumBackgroundCopyFiles, IEnumBackgroundCopyJobs, IEnumBitsPeerCacheRecords, IEnumBitsPeers
</PackageReleaseNotes>
<LangVersion>latest</LangVersion>
<LangVersion>latest</LangVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)'=='Release'">
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>

File diff suppressed because it is too large Load Diff

View File

@ -13,8 +13,8 @@ namespace Vanara.Windows.Forms
/// <code lang="cs">
/// using (new ComCtl32v6Context())
/// {
/// // Code that needs the right lib
/// TaskDialog.Show(...)
/// // Code that needs the right lib
/// TaskDialog.Show(...)
/// }
/// </code>
/// </remarks>
@ -22,12 +22,10 @@ namespace Vanara.Windows.Forms
[SuppressUnmanagedCodeSecurity]
public class ComCtl32v6Context : IDisposable
{
private ActCtxSafeHandle hActCtx;
private SafeHACTCTX hActCtx;
private IntPtr localCookie;
/// <summary>
/// Initializes a new instance of the <see cref="ComCtl32v6Context"/> class.
/// </summary>
/// <summary>Initializes a new instance of the <see cref="ComCtl32v6Context"/> class.</summary>
public ComCtl32v6Context()
{
if (Environment.OSVersion.Version.Major < 6) return;
@ -36,7 +34,7 @@ namespace Vanara.Windows.Forms
dwFlags = ActCtxFlags.ACTCTX_FLAG_RESOURCE_NAME_VALID,
lpResourceName = "#2"
};
Create(ref actctx);
Create(actctx);
Activate();
}
@ -57,6 +55,6 @@ namespace Vanara.Windows.Forms
localCookie = IntPtr.Zero;
}
private void Create(ref ACTCTX context) { hActCtx = CreateActCtx(ref context); }
private void Create(in ACTCTX context) => hActCtx = CreateActCtx(context);
}
}
}

View File

@ -81,7 +81,8 @@ namespace Vanara.PInvoke
/// <param name="wParam">Additional message-specific information.</param>
/// <param name="splitInfo">Additional message-specific information.</param>
/// <returns>The return value specifies the result of the message processing; it depends on the message sent.</returns>
public static IntPtr SendMessage(HWND hWnd, ButtonMessage Msg, int wParam, ref BUTTON_SPLITINFO splitInfo) => User32_Gdi.SendMessage(hWnd, Msg, wParam, ref splitInfo);
[DllImport(Lib.User32, SetLastError = false, CharSet = CharSet.Auto)]
public static extern IntPtr SendMessage(HWND hWnd, ButtonMessage Msg, int wParam, ref BUTTON_SPLITINFO splitInfo);
/// <summary>
/// Sends the specified message to a window or windows. The SendMessage function calls the window procedure for the specified window
@ -96,7 +97,8 @@ namespace Vanara.PInvoke
/// <param name="wParam">Additional message-specific information.</param>
/// <param name="imageList">Additional message-specific information.</param>
/// <returns>The return value specifies the result of the message processing; it depends on the message sent.</returns>
public static IntPtr SendMessage(HWND hWnd, ButtonMessage Msg, int wParam, ref BUTTON_IMAGELIST imageList) => User32_Gdi.SendMessage(hWnd, Msg, wParam, ref imageList);
[DllImport(Lib.User32, SetLastError = false, CharSet = CharSet.Auto)]
public static extern IntPtr SendMessage(HWND hWnd, ButtonMessage Msg, int wParam, ref BUTTON_IMAGELIST imageList);
/// <summary>Contains information about an image list that is used with a button control.</summary>
[PInvokeData("Commctrl.h", MSDNShortId = "bb775953")]
@ -107,7 +109,7 @@ namespace Vanara.PInvoke
/// A handle to the image list. The provider retains ownership of the image list and is ultimately responsible for its disposal.
/// Under Windows Vista, you can pass BCCL_NOGLYPH in this parameter to indicate that no glyph should be displayed.
/// </summary>
public IntPtr himl;
public HIMAGELIST himl;
/// <summary>A RECT that specifies the margin around the icon.</summary>
public RECT margin;
@ -132,7 +134,7 @@ namespace Vanara.PInvoke
/// <summary>
/// A handle to the image list. The provider retains ownership of the image list and is ultimately responsible for its disposal.
/// </summary>
public IntPtr himlGlyph;
public HIMAGELIST himlGlyph;
/// <summary>The split button style.</summary>
public SplitButtonInfoStyle uSplitButtonInfoStyle;

View File

@ -107,7 +107,8 @@ namespace Vanara.PInvoke
/// <param name="wParam">Additional message-specific information.</param>
/// <param name="item">Additional message-specific information.</param>
/// <returns>The return value specifies the result of the message processing; it depends on the message sent.</returns>
public static IntPtr SendMessage(HWND hWnd, ComboBoxMessage Msg, int wParam, ref COMBOBOXINFO item) => User32_Gdi.SendMessage(hWnd, Msg, wParam, ref item);
[DllImport(Lib.User32, SetLastError = false, CharSet = CharSet.Auto)]
public static extern IntPtr SendMessage(HWND hWnd, ComboBoxMessage Msg, int wParam, ref COMBOBOXINFO item);
/// <summary>Contains combo box status information.</summary>
[PInvokeData("Winuser.h", MSDNShortId = "bb775798")]
@ -127,13 +128,13 @@ namespace Vanara.PInvoke
public ComboBoxInfoState buttonState;
/// <summary>A handle to the combo box.</summary>
public IntPtr hwndCombo;
public HWND hwndCombo;
/// <summary>A handle to the edit box.</summary>
public IntPtr hwndEdit;
public HWND hwndEdit;
/// <summary>A handle to the drop-down list.</summary>
public IntPtr hwndList;
public HWND hwndList;
/// <summary>Creates an instance of the <see cref="COMBOBOXINFO"/> structure from a handle and retrieves its values.</summary>
/// <param name="hComboBox">The handle to a ComboBox.</param>

View File

@ -52,6 +52,7 @@ namespace Vanara.PInvoke
/// <param name="wParam">Additional message-specific information.</param>
/// <param name="balloonTip">Additional message-specific information.</param>
/// <returns>The return value specifies the result of the message processing; it depends on the message sent.</returns>
public static IntPtr SendMessage(HWND hWnd, User32_Gdi.EditMessage Msg, int wParam, ref EDITBALLOONTIP balloonTip) => User32_Gdi.SendMessage(hWnd, Msg, wParam, ref balloonTip);
[DllImport(Lib.User32, SetLastError = false, CharSet = CharSet.Auto)]
public static extern IntPtr SendMessage(HWND hWnd, User32_Gdi.EditMessage Msg, int wParam, ref EDITBALLOONTIP balloonTip);
}
}

View File

@ -5,8 +5,6 @@ using Vanara.Extensions;
using Vanara.InteropServices;
using static Vanara.PInvoke.User32_Gdi;
// ReSharper disable InconsistentNaming
namespace Vanara.PInvoke
{
public static partial class ComCtl32
@ -23,31 +21,47 @@ namespace Vanara.PInvoke
{
/// <summary>The point is above the header control's bounding rectangle.</summary>
HHT_ABOVE = 0x0100,
/// <summary>The point is below the header control's bounding rectangle.</summary>
HHT_BELOW = 0x0200,
/// <summary>The point is inside the header control's bounding rectangle but is not over a header item.</summary>
HHT_NOWHERE = 0x0001,
/// <summary>The point is on the divider between two header items.</summary>
HHT_ONDIVIDER = 0x0004,
/// <summary>
/// The point is on the divider of an item that has a width of zero. Dragging the divider reveals the item instead of resizing the item to the left
/// of the divider.
/// The point is on the divider of an item that has a width of zero. Dragging the divider reveals the item instead of resizing
/// the item to the left of the divider.
/// </summary>
HHT_ONDIVOPEN = 0x0008,
/// <summary>The point is within the split button of the item. The style HDF_SPLITBUTTON must be set on the item.</summary>
HHT_ONDROPDOWN = 0x2000,
/// <summary>The point is over the filter area.</summary>
HHT_ONFILTER = 0x0010,
/// <summary>The point is on the filter button.</summary>
HHT_ONFILTERBUTTON = 0x0020,
/// <summary>The point is to the left of the header control's bounding rectangle.</summary>
HHT_ONHEADER = 0x0002,
/// <summary>The point is within the state icon of the item. If style HDS_CHECKBOXES is specified, the point is within the checkbox of the item.</summary>
/// <summary>
/// The point is within the state icon of the item. If style HDS_CHECKBOXES is specified, the point is within the checkbox of the item.
/// </summary>
HHT_ONITEMSTATEICON = 0x1000,
/// <summary>The point is within the overflow button of the header control. The style HDS_OVERFLOW must be set on the header control.</summary>
/// <summary>
/// The point is within the overflow button of the header control. The style HDS_OVERFLOW must be set on the header control.
/// </summary>
HHT_ONOVERFLOW = 0x4000,
/// <summary>The point is to the left of the header control's bounding rectangle.</summary>
HHT_TOLEFT = 0x0800,
/// <summary>The point is to the right of the header control's bounding rectangle.</summary>
HHT_TORIGHT = 0x0400,
}
@ -57,10 +71,13 @@ namespace Vanara.PInvoke
{
/// <summary>String data.</summary>
HDFT_ISSTRING = 0,
/// <summary>Numerical data.</summary>
HDFT_ISNUMBER = 1,
/// <summary>Date data. The pvFilter member is a pointer to a SYSTEMTIME structure.</summary>
HDFT_ISDATE = 2,
/// <summary>Ignore pvFilter.</summary>
HDFT_HASNOVALUE = 0x8000
}
@ -71,47 +88,64 @@ namespace Vanara.PInvoke
{
/// <summary>The item's contents are left-aligned.</summary>
HDF_LEFT = 0x0000,
/// <summary>The item's contents are right-aligned.</summary>
HDF_RIGHT = 0x0001,
/// <summary>The item's contents are centered.</summary>
HDF_CENTER = 0x0002,
/// <summary>Isolate the bits corresponding to the three justification flags listed in the preceding table.</summary>
HDF_JUSTIFYMASK = 0x0003,
/// <summary>
/// Typically, windows displays text left-to-right (LTR). Windows can be mirrored to display languages such as Hebrew or Arabic that read
/// right-to-left (RTL). Usually, header text is read in the same direction as the text in its parent window. If HDF_RTLREADING is set, header text
/// will read in the opposite direction from the text in the parent window.
/// Typically, windows displays text left-to-right (LTR). Windows can be mirrored to display languages such as Hebrew or Arabic
/// that read right-to-left (RTL). Usually, header text is read in the same direction as the text in its parent window. If
/// HDF_RTLREADING is set, header text will read in the opposite direction from the text in the parent window.
/// </summary>
HDF_RTLREADING = 0x0004,
/// <summary>The item displays a checkbox. The flag is only valid when the HDS_CHECKBOXES style is first set on the header control.</summary>
/// <summary>
/// The item displays a checkbox. The flag is only valid when the HDS_CHECKBOXES style is first set on the header control.
/// </summary>
HDF_CHECKBOX = 0x0040,
/// <summary>The item displays a checked checkbox. The flag is only valid when HDF_CHECKBOX is also set.</summary>
HDF_CHECKED = 0x0080,
/// <summary>The width of the item cannot be modified by a user action to resize it.</summary>
HDF_FIXEDWIDTH = 0x0100,
/// <summary>The header control's owner draws the item.</summary>
HDF_OWNERDRAW = 0x8000,
/// <summary>The item displays a string.</summary>
HDF_STRING = 0x4000,
/// <summary>The item displays a bitmap.</summary>
HDF_BITMAP = 0x2000,
/// <summary>The bitmap appears to the right of text.</summary>
HDF_BITMAP_ON_RIGHT = 0x1000,
/// <summary>
/// Display an image from an image list. Specify the image list by sending an HDM_SETIMAGELIST message. Specify the index of the image in the iImage
/// member of this structure.
/// Display an image from an image list. Specify the image list by sending an HDM_SETIMAGELIST message. Specify the index of the
/// image in the iImage member of this structure.
/// </summary>
HDF_IMAGE = 0x0800,
/// <summary>
/// Draws an up-arrow on this item. This is typically used to indicate that information in the current window is sorted on this column in ascending
/// order. This flag cannot be combined with HDF_IMAGE or HDF_BITMAP.
/// Draws an up-arrow on this item. This is typically used to indicate that information in the current window is sorted on this
/// column in ascending order. This flag cannot be combined with HDF_IMAGE or HDF_BITMAP.
/// </summary>
HDF_SORTUP = 0x0400,
/// <summary>
/// Draws a down-arrow on this item. This is typically used to indicate that information in the current window is sorted on this column in descending
/// order. This flag cannot be combined with HDF_IMAGE or HDF_BITMAP.
/// Draws a down-arrow on this item. This is typically used to indicate that information in the current window is sorted on this
/// column in descending order. This flag cannot be combined with HDF_IMAGE or HDF_BITMAP.
/// </summary>
HDF_SORTDOWN = 0x0200,
/// <summary>The item displays a split button. The HDN_DROPDOWN notification is sent when the split button is clicked.</summary>
HDF_SPLITBUTTON = 0x1000000
}
@ -132,32 +166,45 @@ namespace Vanara.PInvoke
{
/// <summary>The <see cref="HDITEM.hbm"/> member is valid.</summary>
HDI_BITMAP = 0x0010,
/// <summary>
/// While handling the message HDM_GETITEM, the header control may not have all the values needed to complete the request. In this case, the control
/// must call the application back for the values via the HDN_GETDISPINFO notification. If HDI_DI_SETITEM has been passed in the HDM_GETITEM message,
/// the control will cache any values returned from HDN_GETDISPINFO (otherwise the values remain unset.)
/// While handling the message HDM_GETITEM, the header control may not have all the values needed to complete the request. In
/// this case, the control must call the application back for the values via the HDN_GETDISPINFO notification. If HDI_DI_SETITEM
/// has been passed in the HDM_GETITEM message, the control will cache any values returned from HDN_GETDISPINFO (otherwise the
/// values remain unset.)
/// </summary>
HDI_DI_SETITEM = 0x0040,
/// <summary>
/// The <see cref="HDITEM.type"/> and <see cref="HDITEM.pvFilter"/> members are valid. This is used to filter out the values specified in the type member.
/// The <see cref="HDITEM.type"/> and <see cref="HDITEM.pvFilter"/> members are valid. This is used to filter out the values
/// specified in the type member.
/// </summary>
HDI_FILTER = 0x0100,
/// <summary>The <see cref="HDITEM.fmt"/> member is valid.</summary>
HDI_FORMAT = 0x0004,
/// <summary>The same as HDI_WIDTH.</summary>
HDI_HEIGHT = HDI_WIDTH,
/// <summary>The <see cref="HDITEM.iImage"/> member is valid and specifies the image to be displayed with the item.</summary>
HDI_IMAGE = 0x0020,
/// <summary>The <see cref="HDITEM.lParam"/> member is valid.</summary>
HDI_LPARAM = 0x0008,
/// <summary>The <see cref="HDITEM.iOrder"/> member is valid and specifies the item's order value.</summary>
HDI_ORDER = 0x0080,
/// <summary>The <see cref="HDITEM.state"/> member is valid.</summary>
HDI_STATE = 0x0200,
/// <summary>The <see cref="HDITEM.pszText"/> and <see cref="HDITEM.cchTextMax"/> members are valid.</summary>
HDI_TEXT = 0x0002,
/// <summary>The <see cref="HDITEM.cxy"/> member is valid and specifies the item's width.</summary>
HDI_WIDTH = 0x0001,
/// <summary>All <see cref="HDITEM"/> members are valid.</summary>
HDI_ALL = 0x03FF,
}
@ -167,6 +214,7 @@ namespace Vanara.PInvoke
{
/// <summary>No state value.</summary>
None = 0,
/// <summary>The item has keyboard focus.</summary>
HDIS_FOCUSED = 1
}
@ -206,214 +254,289 @@ namespace Vanara.PInvoke
public enum HeaderNotification
{
/// <summary>
/// Sent by a header control when a drag operation has begun on one of its items. This notification code is sent only by header controls that are set
/// to the <c>HDS_DRAGDROP</c> style. This notification code is sent in the form of a <c>WM_NOTIFY</c> message.
/// </summary>
/// <param name="lParam">A pointer to an <c>NMHEADER</c> structure containing information about the header item that is being dragged.</param>
/// <returns>
/// To allow the header control to automatically manage drag-and-drop operations, return <c>FALSE</c>. If the owner of the control is manually
/// performing drag-and-drop reordering, return <c>TRUE</c>.
/// </returns>
HDN_BEGINDRAG = HDN_FIRST - 10,
/// <summary>
/// Notifies a header control's parent window that a filter edit has begun. This notification code is sent in the form of a <c>WM_NOTIFY</c> message.
/// </summary>
/// <param name="lParam">A pointer to an <c>NMHEADER</c> structure that contains additional information about the filter that is being edited.</param>
/// <returns>No return value.</returns>
HDN_BEGINFILTEREDIT = HDN_FIRST - 14,
/// <summary>
/// Notifies a header control's parent window that the user has begun dragging a divider in the control (that is, the user has pressed the left mouse
/// button while the mouse cursor is on a divider in the header control). This notification code is sent in the form of a <c>WM_NOTIFY</c> message.
/// Sent by a header control when a drag operation has begun on one of its items. This notification code is sent only by header
/// controls that are set to the <c>HDS_DRAGDROP</c> style. This notification code is sent in the form of a <c>WM_NOTIFY</c> message.
/// </summary>
/// <param name="lParam">
/// A pointer to an <c>NMHEADER</c> structure that contains information about the header control and the item whose divider is to be dragged.
/// A pointer to an <c>NMHEADER</c> structure containing information about the header item that is being dragged.
/// </param>
/// <returns>
/// To allow the header control to automatically manage drag-and-drop operations, return <c>FALSE</c>. If the owner of the
/// control is manually performing drag-and-drop reordering, return <c>TRUE</c>.
/// </returns>
HDN_BEGINDRAG = HDN_FIRST - 10,
/// <summary>
/// Notifies a header control's parent window that a filter edit has begun. This notification code is sent in the form of a
/// <c>WM_NOTIFY</c> message.
/// </summary>
/// <param name="lParam">
/// A pointer to an <c>NMHEADER</c> structure that contains additional information about the filter that is being edited.
/// </param>
/// <returns>No return value.</returns>
HDN_BEGINFILTEREDIT = HDN_FIRST - 14,
/// <summary>
/// Notifies a header control's parent window that the user has begun dragging a divider in the control (that is, the user has
/// pressed the left mouse button while the mouse cursor is on a divider in the header control). This notification code is sent
/// in the form of a <c>WM_NOTIFY</c> message.
/// </summary>
/// <param name="lParam">
/// A pointer to an <c>NMHEADER</c> structure that contains information about the header control and the item whose divider is to
/// be dragged.
/// </param>
/// <returns>Returns <c>FALSE</c> to allow tracking of the divider, or <c>TRUE</c> to prevent tracking.</returns>
HDN_BEGINTRACK = HDN_FIRST - 26,
/// <summary>
/// Notifies a header control's parent window that the user double-clicked the divider area of the control. This notification code is sent in the
/// form of a <c>WM_NOTIFY</c> message.
/// Notifies a header control's parent window that the user double-clicked the divider area of the control. This notification
/// code is sent in the form of a <c>WM_NOTIFY</c> message.
/// </summary>
/// <param name="lParam">
/// A pointer to an <c>NMHEADER</c> structure that contains information about the header control and the item whose divider was double-clicked.
/// </param>
/// <returns>No return value.</returns>
HDN_DIVIDERDBLCLICK = HDN_FIRST - 25,
/// <summary>
/// Sent by a header control to its parent when the drop-down arrow on the header control is clicked. This notification code is sent in the form of a
/// <c>WM_NOTIFY</c> message.
/// Sent by a header control to its parent when the drop-down arrow on the header control is clicked. This notification code is
/// sent in the form of a <c>WM_NOTIFY</c> message.
/// </summary>
/// <param name="lParam">A pointer to an <c>NMHEADER</c> structure that contains information on the header control.</param>
/// <returns>No return value.</returns>
HDN_DROPDOWN = HDN_FIRST - 18,
/// <summary>
/// Sent by a header control when a drag operation has ended on one of its items. This notification code is sent as a <c>WM_NOTIFY</c> message. Only
/// header controls that are set to the <c>HDS_DRAGDROP</c> style send this notification code.
/// Sent by a header control when a drag operation has ended on one of its items. This notification code is sent as a
/// <c>WM_NOTIFY</c> message. Only header controls that are set to the <c>HDS_DRAGDROP</c> style send this notification code.
/// </summary>
/// <param name="lParam">A pointer to an <c>NMHEADER</c> structure containing information about the header item that was being dragged.</param>
/// <param name="lParam">
/// A pointer to an <c>NMHEADER</c> structure containing information about the header item that was being dragged.
/// </param>
/// <returns>
/// To allow the control to automatically place and reorder the item, return <c>FALSE</c>. To prevent the item from being placed, return <c>TRUE</c>.
/// To allow the control to automatically place and reorder the item, return <c>FALSE</c>. To prevent the item from being placed,
/// return <c>TRUE</c>.
/// </returns>
HDN_ENDDRAG = HDN_FIRST - 11,
/// <summary>
/// Notifies a header control's parent window that a filter edit has ended. This notification code is sent in the form of a <c>WM_NOTIFY</c> message.
/// Notifies a header control's parent window that a filter edit has ended. This notification code is sent in the form of a
/// <c>WM_NOTIFY</c> message.
/// </summary>
/// <param name="lParam">A pointer to an <c>NMHEADER</c> structure that contains additional information about the filter that is being edited.</param>
/// <param name="lParam">
/// A pointer to an <c>NMHEADER</c> structure that contains additional information about the filter that is being edited.
/// </param>
/// <returns>No return value.</returns>
HDN_ENDFILTEREDIT = HDN_FIRST - 15,
/// <summary>
/// Notifies a header control's parent window that the user has finished dragging a divider. This notification code sent in the form of a
/// <c>WM_NOTIFY</c> message.
/// Notifies a header control's parent window that the user has finished dragging a divider. This notification code sent in the
/// form of a <c>WM_NOTIFY</c> message.
/// </summary>
/// <param name="lParam">
/// A pointer to an <c>NMHEADER</c> structure that contains information about the header control and the item whose divider was dragged.
/// </param>
/// <returns>No return value.</returns>
HDN_ENDTRACK = HDN_FIRST - 27,
/// <summary>
/// Notifies the header control's parent window when the filter button is clicked or in response to an <c>HDM_SETITEM</c> message. This notification
/// code sent in the form of a <c>WM_NOTIFY</c> message.
/// Notifies the header control's parent window when the filter button is clicked or in response to an <c>HDM_SETITEM</c>
/// message. This notification code sent in the form of a <c>WM_NOTIFY</c> message.
/// </summary>
/// <param name="lParam">
/// A pointer to an <c>NMHDFILTERBTNCLICK</c> structure that contains information about the header control and the header filter button.
/// </param>
/// <returns>
/// If you return <c>TRUE</c>, an HDN_FILTERCHANGE notification code will be sent to the header control's parent window. This notification code gives
/// the parent window an opportunity to synchronize its user interface elements. Return <c>FALSE</c> if you do not want the notification sent.
/// If you return <c>TRUE</c>, an HDN_FILTERCHANGE notification code will be sent to the header control's parent window. This
/// notification code gives the parent window an opportunity to synchronize its user interface elements. Return <c>FALSE</c> if
/// you do not want the notification sent.
/// </returns>
HDN_FILTERBTNCLICK = HDN_FIRST - 13,
/// <summary>
/// Notifies the header control's parent window that the attributes of a header control filter are being changed or edited. This notification code
/// sent in the form of a <c>WM_NOTIFY</c> message.
/// Notifies the header control's parent window that the attributes of a header control filter are being changed or edited. This
/// notification code sent in the form of a <c>WM_NOTIFY</c> message.
/// </summary>
/// <param name="lParam">
/// A pointer to an <c>NMHEADER</c> structure that contains information about the header control and the header item, including the attributes that
/// are about to change.
/// A pointer to an <c>NMHEADER</c> structure that contains information about the header control and the header item, including
/// the attributes that are about to change.
/// </param>
/// <returns>No return value.</returns>
HDN_FILTERCHANGE = HDN_FIRST - 12,
/// <summary>
/// Sent to the owner of a header control when the control needs information about a callback header item. This notification code is sent as a
/// <c>WM_NOTIFY</c> message.
/// Sent to the owner of a header control when the control needs information about a callback header item. This notification code
/// is sent as a <c>WM_NOTIFY</c> message.
/// </summary>
/// <param name="lParam">
/// A pointer to an <c>NMHDDISPINFO</c> structure. On input, the fields of the structure specify what information is required and the item of interest.
/// A pointer to an <c>NMHDDISPINFO</c> structure. On input, the fields of the structure specify what information is required and
/// the item of interest.
/// </param>
/// <returns>Returns an LRESULT.</returns>
HDN_GETDISPINFO = HDN_FIRST - 29,
/// <summary>
/// Notifies a header control's parent window that the attributes of a header item have changed. This notification code is sent in the form of a
/// <c>WM_NOTIFY</c> message.
/// Notifies a header control's parent window that the attributes of a header item have changed. This notification code is sent
/// in the form of a <c>WM_NOTIFY</c> message.
/// </summary>
/// <param name="lParam">
/// A pointer to an <c>NMHEADER</c> structure that contains information about the header control, including the attributes that have changed.
/// A pointer to an <c>NMHEADER</c> structure that contains information about the header control, including the attributes that
/// have changed.
/// </param>
/// <returns>No return value.</returns>
HDN_ITEMCHANGED = HDN_FIRST - 21,
/// <summary>
/// Notifies a header control's parent window that the attributes of a header item are about to change. This notification code is sent in the form of
/// a <c>WM_NOTIFY</c> message.
/// Notifies a header control's parent window that the attributes of a header item are about to change. This notification code is
/// sent in the form of a <c>WM_NOTIFY</c> message.
/// </summary>
/// <param name="lParam">
/// A pointer to an <c>NMHEADER</c> structure that contains information about the header control and the header item, including the attributes that
/// are about to change.
/// A pointer to an <c>NMHEADER</c> structure that contains information about the header control and the header item, including
/// the attributes that are about to change.
/// </param>
/// <returns>Returns <c>FALSE</c> to allow the changes, or <c>TRUE</c> to prevent them.</returns>
HDN_ITEMCHANGING = HDN_FIRST - 20,
/// <summary>
/// Notifies a header control's parent window that the user clicked the control. This notification code is sent in the form of a <c>WM_NOTIFY</c> message.
/// Notifies a header control's parent window that the user clicked the control. This notification code is sent in the form of a
/// <c>WM_NOTIFY</c> message.
/// </summary>
/// <param name="lParam">
/// A pointer to an <c>NMHEADER</c> structure that identifies the header control and specifies the index of the header item that was clicked and the
/// mouse button used to click the item. The <c>pItem</c> member is set to <c>NULL</c>.
/// A pointer to an <c>NMHEADER</c> structure that identifies the header control and specifies the index of the header item that
/// was clicked and the mouse button used to click the item. The <c>pItem</c> member is set to <c>NULL</c>.
/// </param>
/// <returns>No return value.</returns>
HDN_ITEMCLICK = HDN_FIRST - 22,
/// <summary>
/// Notifies a header control's parent window that the user double-clicked the control. This notification code is sent in the form of a
/// <c>WM_NOTIFY</c> message. Only header controls that are set to the <c>HDS_BUTTONS</c> style send this notification code.
/// Notifies a header control's parent window that the user double-clicked the control. This notification code is sent in the
/// form of a <c>WM_NOTIFY</c> message. Only header controls that are set to the <c>HDS_BUTTONS</c> style send this notification code.
/// </summary>
/// <param name="lParam">A pointer to an <c>NMHEADER</c> structure that contains information about this notification code.</param>
/// <returns>No return value.</returns>
HDN_ITEMDBLCLICK = HDN_FIRST - 23,
/// <summary>
/// Notifies a header control's parent window that a key has been pressed with an item selected. This notification code is sent in the form of a
/// <c>WM_NOTIFY</c> message.
/// Notifies a header control's parent window that a key has been pressed with an item selected. This notification code is sent
/// in the form of a <c>WM_NOTIFY</c> message.
/// </summary>
/// <param name="lParam">A pointer to an <c>NMHEADER</c> structure that contains additional information about the key that is being pressed.</param>
/// <param name="lParam">
/// A pointer to an <c>NMHEADER</c> structure that contains additional information about the key that is being pressed.
/// </param>
/// <returns>No return value.</returns>
HDN_ITEMKEYDOWN = HDN_FIRST - 17,
/// <summary>
/// Notifies a header control's parent window that the user clicked an item's state icon. This notification code is sent in the form of a
/// <c>WM_NOTIFY</c> message.
/// Notifies a header control's parent window that the user clicked an item's state icon. This notification code is sent in the
/// form of a <c>WM_NOTIFY</c> message.
/// </summary>
/// <param name="lParam">A pointer to an <c>NMHEADER</c> structure that contains additional information about the state icon that was clicked on.</param>
/// <param name="lParam">
/// A pointer to an <c>NMHEADER</c> structure that contains additional information about the state icon that was clicked on.
/// </param>
/// <returns>No return value.</returns>
HDN_ITEMSTATEICONCLICK = HDN_FIRST - 16,
/// <summary>
/// Sent by a header control to its parent when the header's overflow button is clicked. This notification code is sent in the form of an
/// <c>WM_NOTIFY</c> message.
/// Sent by a header control to its parent when the header's overflow button is clicked. This notification code is sent in the
/// form of an <c>WM_NOTIFY</c> message.
/// </summary>
/// <param name="lParam">
/// <para>
/// A pointer to a <c>NMHEADER</c> structure that describes the notification code. The calling process is responsible for allocating this structure,
/// including the contained <c>NMHDR</c> structure. Set the members of the <c>NMHDR</c> structure, including the code member that must be set to HDN_OVERFLOWCLICK.
/// A pointer to a <c>NMHEADER</c> structure that describes the notification code. The calling process is responsible for
/// allocating this structure, including the contained <c>NMHDR</c> structure. Set the members of the <c>NMHDR</c> structure,
/// including the code member that must be set to HDN_OVERFLOWCLICK.
/// </para>
/// <para>
/// Set the <c>iItem</c> member of the <c>NMHEADER</c> structure to the index of the first header item that is not visible and thus should be
/// displayed on an overflow.
/// Set the <c>iItem</c> member of the <c>NMHEADER</c> structure to the index of the first header item that is not visible and
/// thus should be displayed on an overflow.
/// </para>
/// </param>
/// <returns>No return value.</returns>
HDN_OVERFLOWCLICK = HDN_FIRST - 19,
/// <summary>
/// Notifies a header control's parent window that the user is dragging a divider in the header control. This notification code is sent in the form
/// of a <c>WM_NOTIFY</c> message.
/// Notifies a header control's parent window that the user is dragging a divider in the header control. This notification code
/// is sent in the form of a <c>WM_NOTIFY</c> message.
/// </summary>
/// <param name="lParam">
/// A pointer to an <c>NMHEADER</c> structure that contains information about the header control and the item whose divider is being dragged.
/// A pointer to an <c>NMHEADER</c> structure that contains information about the header control and the item whose divider is
/// being dragged.
/// </param>
/// <returns>Returns <c>FALSE</c> to continue tracking the divider, or <c>TRUE</c> to end tracking.</returns>
HDN_TRACK = HDN_FIRST - 28,
}
/// <summary>
/// Header controls have a number of styles, described in this section, that determine the control's appearance and behavior. You set the initial styles when you create the header control.
/// Header controls have a number of styles, described in this section, that determine the control's appearance and behavior. You set
/// the initial styles when you create the header control.
/// </summary>
[PInvokeData("Commctrl.h", MSDNShortId = "bb775241")]
[Flags]
public enum HeaderStyle
{
/// <summary>Each item in the control looks and behaves like a push button. This style is useful if an application carries out a task when the user clicks an item in the header control. For example, an application could sort information in the columns differently depending on which item the user clicks.</summary>
/// <summary>
/// Each item in the control looks and behaves like a push button. This style is useful if an application carries out a task when
/// the user clicks an item in the header control. For example, an application could sort information in the columns differently
/// depending on which item the user clicks.
/// </summary>
HDS_BUTTONS = 0x0002,
/// <summary>Allows drag-and-drop reordering of header items.</summary>
HDS_DRAGDROP = 0x0040,
/// <summary>Include a filter bar as part of the standard header control. This bar allows users to conveniently apply a filter to the display. Calls to HDM_LAYOUT will yield a new size for the control and cause the list view to update.</summary>
/// <summary>
/// Include a filter bar as part of the standard header control. This bar allows users to conveniently apply a filter to the
/// display. Calls to HDM_LAYOUT will yield a new size for the control and cause the list view to update.
/// </summary>
HDS_FILTERBAR = 0x0100,
/// <summary>Version 6.0 and later. Causes the header control to be drawn flat when the operating system is running in classic mode.
/// <note>Comctl32.dll version 6 is not redistributable but it is included in Windows. To use Comctl32.dll version 6, specify it in a manifest. For more information on manifests, see Enabling Visual Styles.</note></summary>
/// <summary>
/// Version 6.0 and later. Causes the header control to be drawn flat when the operating system is running in classic mode.
/// <note>Comctl32.dll version 6 is not redistributable but it is included in Windows. To use Comctl32.dll version 6, specify it
/// in a manifest. For more information on manifests, see Enabling Visual Styles.</note>
/// </summary>
HDS_FLAT = 0x0200,
/// <summary>Causes the header control to display column contents even while the user resizes a column.</summary>
HDS_FULLDRAG = 0x0080,
/// <summary>Indicates a header control that is intended to be hidden. This style does not hide the control. Instead, when you send the HDM_LAYOUT message to a header control with the HDS_HIDDEN style, the control returns zero in the cy member of the WINDOWPOS structure. You would then hide the control by setting its height to zero. This can be useful when you want to use the control as an information container instead of a visual control.</summary>
/// <summary>
/// Indicates a header control that is intended to be hidden. This style does not hide the control. Instead, when you send the
/// HDM_LAYOUT message to a header control with the HDS_HIDDEN style, the control returns zero in the cy member of the WINDOWPOS
/// structure. You would then hide the control by setting its height to zero. This can be useful when you want to use the control
/// as an information container instead of a visual control.
/// </summary>
HDS_HIDDEN = 0x0008,
/// <summary>Creates a header control with a horizontal orientation.</summary>
HDS_HORZ = 0x0000,
/// <summary>Enables hot tracking.</summary>
HDS_HOTTRACK = 0x0004,
/// <summary>Version 6.00 and later. Allows the placing of checkboxes on header items. For more information, see the fmt member of HDITEM.</summary>
/// <summary>
/// Version 6.00 and later. Allows the placing of checkboxes on header items. For more information, see the fmt member of HDITEM.
/// </summary>
HDS_CHECKBOXES = 0x0400,
/// <summary>Version 6.00 and later. The user cannot drag the divider on the header control.</summary>
HDS_NOSIZING = 0x0800,
/// <summary>Version 6.00 and later. A button is displayed when not all items can be displayed within the header control's rectangle. When clicked, this button sends an HDN_OVERFLOWCLICK notification.</summary>
/// <summary>
/// Version 6.00 and later. A button is displayed when not all items can be displayed within the header control's rectangle. When
/// clicked, this button sends an HDN_OVERFLOWCLICK notification.
/// </summary>
HDS_OVERFLOW = 0x1000,
}
public static IntPtr SendMessage(HWND hWnd, HeaderMessage message, int wParam, [In, Out] HDITEM item) => User32_Gdi.SendMessage(hWnd, message, wParam, item);
[DllImport(Lib.User32, SetLastError = false, CharSet = CharSet.Auto)]
public static extern IntPtr SendMessage(HWND hWnd, HeaderMessage message, int wParam, [In, Out] HDITEM item);
public static IntPtr SendMessage(HWND hWnd, HeaderMessage message, int wParam, [In, Out] HDLAYOUT layout) => User32_Gdi.SendMessage(hWnd, message, wParam, layout);
[DllImport(Lib.User32, SetLastError = false, CharSet = CharSet.Auto)]
public static extern IntPtr SendMessage(HWND hWnd, HeaderMessage message, int wParam, [In, Out] HDLAYOUT layout);
public static IntPtr SendMessage(HWND hWnd, HeaderMessage message, int wParam, [In, Out] HDHITTESTINFO hittest) => User32_Gdi.SendMessage(hWnd, message, wParam, hittest);
[DllImport(Lib.User32, SetLastError = false, CharSet = CharSet.Auto)]
public static extern IntPtr SendMessage(HWND hWnd, HeaderMessage message, int wParam, [In, Out] HDHITTESTINFO hittest);
/// <summary>Contains information about header control text filters.</summary>
[PInvokeData("Commctrl.h", MSDNShortId = "bb775251")]
@ -422,6 +545,7 @@ namespace Vanara.PInvoke
{
/// <summary>A pointer to the buffer containing the filter.</summary>
public string pszText;
/// <summary>A value specifying the maximum size, in characters, for an edit control buffer.</summary>
public int cchTextMax;
@ -444,18 +568,22 @@ namespace Vanara.PInvoke
public override string ToString() => pszText;
}
/// <summary>Contains information about a hit test. This structure is used with the HDM_HITTEST message and it supersedes the HD_HITTESTINFO structure.</summary>
/// <summary>
/// Contains information about a hit test. This structure is used with the HDM_HITTEST message and it supersedes the HD_HITTESTINFO structure.
/// </summary>
[PInvokeData("Commctrl.h", MSDNShortId = "bb775245")]
[StructLayout(LayoutKind.Sequential)]
public sealed class HDHITTESTINFO
{
/// <summary>A POINT structure that contains the point to be hit test, in client coordinates.</summary>
public Point pt;
/// <summary>
/// The variable that receives information about the results of a hit test. Two of these values can be combined, such as when the position is above
/// and to the left of the client area.
/// The variable that receives information about the results of a hit test. Two of these values can be combined, such as when the
/// position is above and to the left of the client area.
/// </summary>
public HeaderHitTestFlag flags;
/// <summary>If the hit test is successful, contains the index of the item at the hit test point.</summary>
public int iItem;
}
@ -468,44 +596,56 @@ namespace Vanara.PInvoke
{
/// <summary>Flags indicating which other structure members contain valid data or must be filled in.</summary>
public HeaderItemMask mask = 0;
/// <summary>The width or height of the item.</summary>
public int cxy;
/// <summary>
/// A pointer to an item string. If the text is being retrieved from the control, this member must be initialized to point to a character buffer. If
/// this member is set to LPSTR_TEXTCALLBACK, the control will request text information for this item by sending an HDN_GETDISPINFO notification
/// code. Note that although the header control allows a string of any length to be stored as item text, only the first 260 TCHARs are displayed.
/// A pointer to an item string. If the text is being retrieved from the control, this member must be initialized to point to a
/// character buffer. If this member is set to LPSTR_TEXTCALLBACK, the control will request text information for this item by
/// sending an HDN_GETDISPINFO notification code. Note that although the header control allows a string of any length to be
/// stored as item text, only the first 260 TCHARs are displayed.
/// </summary>
public StrPtrAuto pszText;
/// <summary>A handle to the item bitmap.</summary>
public IntPtr hbm = IntPtr.Zero;
public HBITMAP hbm = IntPtr.Zero;
/// <summary>
/// The length of the item string, in TCHARs. If the text is being retrieved from the control, this member must contain the number of TCHARs at the
/// address specified by pszText.
/// The length of the item string, in TCHARs. If the text is being retrieved from the control, this member must contain the
/// number of TCHARs at the address specified by pszText.
/// </summary>
public uint cchTextMax;
/// <summary>Flags that specify the item's format.</summary>
public HeaderItemFormat fmt = 0;
/// <summary>Application-defined item data.</summary>
public IntPtr lParam = IntPtr.Zero;
/// <summary>
/// The zero-based index of an image within the image list. The specified image will be displayed in the header item in addition to any image
/// specified in the hbm field. If iImage is set to I_IMAGECALLBACK, the control requests text information for this item by using an HDN_GETDISPINFO
/// notification code. To clear the image, set this value to I_IMAGENONE.
/// The zero-based index of an image within the image list. The specified image will be displayed in the header item in addition
/// to any image specified in the hbm field. If iImage is set to I_IMAGECALLBACK, the control requests text information for this
/// item by using an HDN_GETDISPINFO notification code. To clear the image, set this value to I_IMAGENONE.
/// </summary>
public int iImage;
/// <summary>
/// The order in which the item appears within the header control, from left to right. That is, the value for the far left item is 0. The value for
/// the next item to the right is 1, and so on.
/// The order in which the item appears within the header control, from left to right. That is, the value for the far left item
/// is 0. The value for the next item to the right is 1, and so on.
/// </summary>
public int iOrder;
/// <summary>The type of filter specified by pvFilter.</summary>
public HeaderItemFilterType type;
/// <summary>
/// The address of an application-defined data item. The data filter type is determined by setting the flag value of the member. Use the
/// HDFT_ISSTRING flag to indicate a string and HDFT_ISNUMBER to indicate an integer. When the HDFT_ISSTRING flag is used pvFilter is a pointer to a
/// HDTEXTFILTER structure.
/// The address of an application-defined data item. The data filter type is determined by setting the flag value of the member.
/// Use the HDFT_ISSTRING flag to indicate a string and HDFT_ISNUMBER to indicate an integer. When the HDFT_ISSTRING flag is used
/// pvFilter is a pointer to a HDTEXTFILTER structure.
/// </summary>
public IntPtr pvFilter = IntPtr.Zero;
/// <summary>The state.</summary>
public HeaderItemState state;
@ -520,15 +660,12 @@ namespace Vanara.PInvoke
/// <summary>Initializes a new instance of the <see cref="HDITEM"/> class.</summary>
/// <param name="text">The text.</param>
public HDITEM(string text = null)
{
Text = text;
}
public HDITEM(string text = null) => Text = text;
/// <summary>Gets or sets the bitmap. Aligned to the <see cref="hbm"/> field.</summary>
public Bitmap Bitmap
{
get => hbm == IntPtr.Zero ? null : Image.FromHbitmap(hbm);
get => hbm.IsNull ? null : Image.FromHbitmap((IntPtr)hbm);
set { hbm = value?.GetHbitmap() ?? IntPtr.Zero; EnumExtensions.SetFlags(ref mask, HeaderItemMask.HDI_BITMAP); }
}
@ -577,12 +714,12 @@ namespace Vanara.PInvoke
break;
case DateTime dt:
pvFilter = new SYSTEMTIME(dt).StructureToPtr(Marshal.AllocCoTaskMem, out int _);
pvFilter = new SYSTEMTIME(dt).StructureToPtr(Marshal.AllocCoTaskMem, out var _);
type = HeaderItemFilterType.HDFT_ISDATE;
break;
case string str:
pvFilter = new HDTEXTFILTER(str).StructureToPtr(Marshal.AllocCoTaskMem, out int _);
pvFilter = new HDTEXTFILTER(str).StructureToPtr(Marshal.AllocCoTaskMem, out var _);
type = HeaderItemFilterType.HDFT_ISSTRING;
break;
@ -592,7 +729,7 @@ namespace Vanara.PInvoke
break;
case SYSTEMTIME st:
pvFilter = st.StructureToPtr(Marshal.AllocCoTaskMem, out int _);
pvFilter = st.StructureToPtr(Marshal.AllocCoTaskMem, out var _);
type = HeaderItemFilterType.HDFT_ISDATE;
break;
@ -752,8 +889,9 @@ namespace Vanara.PInvoke
}
/// <summary>
/// Gets or sets a value indicating whether this header requests a callback message to retrieve the text. <note>Setting this value to either true or
/// false will remove any previously set value for the <see cref="Text"/> property or <see cref="pszText"/> field.</note>
/// Gets or sets a value indicating whether this header requests a callback message to retrieve the text. <note>Setting this
/// value to either true or false will remove any previously set value for the <see cref="Text"/> property or <see
/// cref="pszText"/> field.</note>
/// </summary>
/// <value><c>true</c> if using text callback; otherwise, <c>false</c>.</value>
public bool UseTextCallback
@ -780,8 +918,8 @@ namespace Vanara.PInvoke
}
/// <summary>
/// Contains information used to set the size and position of a header control. HDLAYOUT is used with the HDM_LAYOUT message. This structure supersedes
/// the HD_LAYOUT structure.
/// Contains information used to set the size and position of a header control. HDLAYOUT is used with the HDM_LAYOUT message. This
/// structure supersedes the HD_LAYOUT structure.
/// </summary>
/// <seealso cref="System.IDisposable"/>
[PInvokeData("Commctrl.h", MSDNShortId = "bb775249")]
@ -790,14 +928,17 @@ namespace Vanara.PInvoke
{
/// <summary>Structure that contains the coordinates of a rectangle that the header control will occupy.</summary>
public IntPtr prc;
/// <summary>Structure that receives information about the appropriate size and position of the header control.</summary>
public IntPtr pwpos;
/// <summary>Initializes a new instance of the <see cref="HDLAYOUT"/> class setting the prc member and allocating memory for the pwpos member.</summary>
/// <summary>
/// Initializes a new instance of the <see cref="HDLAYOUT"/> class setting the prc member and allocating memory for the pwpos member.
/// </summary>
/// <param name="rc">The coordinates of the header.</param>
public HDLAYOUT(RECT rc)
{
prc = rc.StructureToPtr(Marshal.AllocHGlobal, out int _);
prc = rc.StructureToPtr(Marshal.AllocHGlobal, out var _);
pwpos = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(WINDOWPOS)));
}
@ -809,7 +950,7 @@ namespace Vanara.PInvoke
set
{
Marshal.FreeHGlobal(prc);
prc = value.StructureToPtr(Marshal.AllocHGlobal, out int _);
prc = value.StructureToPtr(Marshal.AllocHGlobal, out var _);
}
}
@ -832,20 +973,26 @@ namespace Vanara.PInvoke
{
/// <summary>NMHDR structure containing information about this notification code</summary>
public NMHDR hdr;
/// <summary>The zero-based index of the item in the header control.</summary>
public int iItem;
/// <summary>A set of bit flags specifying which members of the structure must be filled in by the owner of the header control.</summary>
public uint mask;
/// <summary>A pointer to a null-terminated string containing the text that will be displayed for the header item.</summary>
public IntPtr pszText = IntPtr.Zero;
public StrPtrAuto pszText;
/// <summary>The size of the buffer that pszText points to.</summary>
public int cchTextMax;
/// <summary>
/// The zero-based index of an image within the image list. The specified image will be displayed with the header item, but it does not take the
/// place of the item's bitmap. If iImage is set to I_IMAGECALLBACK, the control requests image information for this item by using an HDN_GETDISPINFO
/// notification code.
/// The zero-based index of an image within the image list. The specified image will be displayed with the header item, but it
/// does not take the place of the item's bitmap. If iImage is set to I_IMAGECALLBACK, the control requests image information for
/// this item by using an HDN_GETDISPINFO notification code.
/// </summary>
public int iImage;
/// <summary>An application-defined value to associate with the item.</summary>
public IntPtr lParam = IntPtr.Zero;
}
@ -857,8 +1004,10 @@ namespace Vanara.PInvoke
{
/// <summary>A handle of an NMHDR structure that contains additional information.</summary>
public NMHDR hdr;
/// <summary>The zero-based index of the control to which this structure refers.</summary>
public int iItem;
/// <summary>A pointer to a RECT structure that contains the client rectangle for the filter button.</summary>
public RECT rc;
}
@ -870,10 +1019,13 @@ namespace Vanara.PInvoke
{
/// <summary>A NMHDR structure that contains information about the notification message.</summary>
public NMHDR nmhdr;
/// <summary>The zero-based index of the header item that is the focus of the notification message.</summary>
public int iItem;
/// <summary>
/// A value specifying the index of the mouse button used to generate the notification message. This member can be one of the following values:
/// A value specifying the index of the mouse button used to generate the notification message. This member can be one of the
/// following values:
/// <list type="table">
/// <listheader>
/// <term>Value</term>
@ -894,9 +1046,10 @@ namespace Vanara.PInvoke
/// </list>
/// </summary>
public int iButton;
/// <summary>
/// An optional pointer to an HDITEM structure containing information about the item specified by iItem. The mask member of the HDITEM structure
/// indicates which of its members are valid.
/// An optional pointer to an HDITEM structure containing information about the item specified by iItem. The mask member of the
/// HDITEM structure indicates which of its members are valid.
/// </summary>
public IntPtr pItem = IntPtr.Zero;
}

View File

@ -2,19 +2,20 @@ using System;
using System.Runtime.InteropServices;
using static Vanara.PInvoke.User32_Gdi;
// ReSharper disable InconsistentNaming
// ReSharper disable FieldCanBeMadeReadOnly.Global ReSharper disable InconsistentNaming
namespace Vanara.PInvoke
{
public static partial class ComCtl32
{
/// <summary>Creates IP address controls. These controls are similar to an edit control, but they enable you to enter a numeric address in Internet protocol (IP) format.</summary>
/// <summary>
/// Creates IP address controls. These controls are similar to an edit control, but they enable you to enter a numeric address in
/// Internet protocol (IP) format.
/// </summary>
public const string WC_IPADDRESS = "SysIPAddress32";
private const int IPN_FIRST = -860;
#pragma warning disable 1584, 1711, 1572, 1581, 1580
/// <summary>IP Address Messages</summary>
public enum IPAddressMessage
{
@ -26,25 +27,46 @@ namespace Vanara.PInvoke
/// <summary>Sets the address values for all four fields in the IP address control.</summary>
/// <param name="wParam">Must be zero.</param>
/// <param name="lParam">A DWORD value that contains the new address. The field 3 value is contained in bits 0 through 7. The field 2 value is contained in bits 8 through 15. The field 1 value is contained in bits 16 through 23. The field 0 value is contained in bits 24 through 31. The MAKEIPADDRESS macro can also be used to create the address information.</param>
/// <param name="lParam">
/// A DWORD value that contains the new address. The field 3 value is contained in bits 0 through 7. The field 2 value is
/// contained in bits 8 through 15. The field 1 value is contained in bits 16 through 23. The field 0 value is contained in bits
/// 24 through 31. The MAKEIPADDRESS macro can also be used to create the address information.
/// </param>
/// <returns>The return value is not used.</returns>
IPM_SETADDRESS = WindowMessage.WM_USER + 101,
/// <summary>Gets the address values for all four fields in the IP address control.</summary>
/// <param name="wParam">Must be zero.</param>
/// <param name="lParam">A pointer to a DWORD value that receives the address. The field 3 value will be contained in bits 0 through 7. The field 2 value will be contained in bits 8 through 15. The field 1 value will be contained in bits 16 through 23. The field 0 value will be contained in bits 24 through 31. The FIRST_IPADDRESS, SECOND_IPADDRESS, THIRD_IPADDRESS, and FOURTH_IPADDRESS macros can also be used to extract the address information. Zero will be returned as the address for any blank fields.</param>
/// <param name="lParam">
/// A pointer to a DWORD value that receives the address. The field 3 value will be contained in bits 0 through 7. The field 2
/// value will be contained in bits 8 through 15. The field 1 value will be contained in bits 16 through 23. The field 0 value
/// will be contained in bits 24 through 31. The FIRST_IPADDRESS, SECOND_IPADDRESS, THIRD_IPADDRESS, and FOURTH_IPADDRESS macros
/// can also be used to extract the address information. Zero will be returned as the address for any blank fields.
/// </param>
/// <returns>Returns the number of nonblank fields.</returns>
IPM_GETADDRESS = WindowMessage.WM_USER + 102,
/// <summary>ets the valid range for the specified field in the IP address control.</summary>
/// <remarks>If the user enters a value in the field that is outside of this range, the control will send the IPN_FIELDCHANGED notification with the entered value. If the value is still outside of the range after sending the notification, the control will attempt to change the entered value to the closest range limit.</remarks>
/// <remarks>
/// If the user enters a value in the field that is outside of this range, the control will send the IPN_FIELDCHANGED
/// notification with the entered value. If the value is still outside of the range after sending the notification, the control
/// will attempt to change the entered value to the closest range limit.
/// </remarks>
/// <param name="wParam">A zero-based field index to which the range will be applied.</param>
/// <param name="lParam">A WORD value that contains the lower limit of the range in the low-order byte and the upper limit in the high-order byte. Both of these values are inclusive. The MAKEIPRANGE macro can also be used to create the range.</param>
/// <param name="lParam">
/// A WORD value that contains the lower limit of the range in the low-order byte and the upper limit in the high-order byte.
/// Both of these values are inclusive. The MAKEIPRANGE macro can also be used to create the range.
/// </param>
/// <returns>Returns nonzero if successful, or zero otherwise.</returns>
IPM_SETRANGE = WindowMessage.WM_USER + 103,
/// <summary>Sets the keyboard focus to the specified field in the IP address control. All of the text in that field will be selected.</summary>
/// <param name="wParam">A zero-based field index to which the focus should be set. If this value is greater than the number of fields, focus is set to the first blank field. If all fields are nonblank, focus is set to the first field.</param>
/// <summary>
/// Sets the keyboard focus to the specified field in the IP address control. All of the text in that field will be selected.
/// </summary>
/// <param name="wParam">
/// A zero-based field index to which the focus should be set. If this value is greater than the number of fields, focus is set
/// to the first blank field. If all fields are nonblank, focus is set to the first field.
/// </param>
/// <param name="lParam">Must be zero.</param>
/// <returns>The return value is not used.</returns>
IPM_SETFOCUS = WindowMessage.WM_USER + 104,
@ -59,20 +81,25 @@ namespace Vanara.PInvoke
/// <summary>IP Address Notifications</summary>
public enum IPAddressNotification
{
/// <summary>Sent when the user changes a field in the control or moves from one field to another. This notification code is sent in the form of a WM_NOTIFY message.</summary>
/// <param name="lParam">A pointer to an NMIPADDRESS structure that contains information about the changed address. The iValue member of this structure will contain the entered value, even if it is out of the range of the field. You can modify this member to any value that is within the range for the field in response to this notification code.</param>
/// <summary>
/// Sent when the user changes a field in the control or moves from one field to another. This notification code is sent in the
/// form of a WM_NOTIFY message.
/// </summary>
/// <param name="lParam">
/// A pointer to an NMIPADDRESS structure that contains information about the changed address. The iValue member of this
/// structure will contain the entered value, even if it is out of the range of the field. You can modify this member to any
/// value that is within the range for the field in response to this notification code.
/// </param>
/// <returns>The return value is ignored.</returns>
IPN_FIELDCHANGED = IPN_FIRST - 0
}
#pragma warning restore 1584, 1711, 1572, 1581, 1580
/// <summary>Gets the IP address represented as a byte array from an unsigned pointer.</summary>
/// <param name="ipAddress">The IP address.</param>
/// <returns>The IP address represented as a byte array.</returns>
public static byte[] GET_IPADDRESS(uint ipAddress)
{
return new[] { (byte)((ipAddress >> 24) & 0xff), (byte)((ipAddress >> 16) & 0xff), (byte)((ipAddress >> 8) & 0xff), (byte)(ipAddress & 0xff) };
}
public static byte[] GET_IPADDRESS(uint ipAddress) => new[] { (byte)((ipAddress >> 24) & 0xff), (byte)((ipAddress >> 16) & 0xff), (byte)((ipAddress >> 8) & 0xff), (byte)(ipAddress & 0xff) };
/// <summary>Packs four byte-values into a single LPARAM suitable for use with the IPM_SETADDRESS message.</summary>
/// <param name="b0">The field 0 address.</param>
@ -112,7 +139,10 @@ namespace Vanara.PInvoke
/// <summary>The zero-based number of the field that was changed.</summary>
public int iField;
/// <summary>The new value of the field specified in the iField member. While processing the IPN_FIELDCHANGED notification, this member can be set to any value that is within the range of the field and the control will place this new value in the field.</summary>
/// <summary>
/// The new value of the field specified in the iField member. While processing the IPN_FIELDCHANGED notification, this member
/// can be set to any value that is within the range of the field and the control will place this new value in the field.
/// </summary>
public int iValue;
}
}

File diff suppressed because one or more lines are too long

View File

@ -1,11 +1,6 @@
using System;
using System.Drawing;
using System.Runtime.InteropServices;
// ReSharper disable InconsistentNaming
// ReSharper disable FieldCanBeMadeReadOnly.Global
// ReSharper disable InconsistentNaming
namespace Vanara.PInvoke
{
public static partial class ComCtl32
@ -41,8 +36,8 @@ namespace Vanara.PInvoke
/// <param name="bAutoScroll">
/// <para>Type: <c><c>BOOL</c></c></para>
/// <para>
/// A scroll flag. If this parameter is <c>TRUE</c> and the point is directly above or below the list box, the function scrolls the list box by one line
/// and returns -1. Otherwise, the function does not scroll the list box.
/// A scroll flag. If this parameter is <c>TRUE</c> and the point is directly above or below the list box, the function scrolls the
/// list box by one line and returns -1. Otherwise, the function does not scroll the list box.
/// </para>
/// </param>
/// <returns>

File diff suppressed because it is too large Load Diff

View File

@ -1,11 +1,8 @@
// ReSharper disable FieldCanBeMadeReadOnly.Global
// ReSharper disable InconsistentNaming
namespace Vanara.PInvoke
namespace Vanara.PInvoke
{
public static partial class ComCtl32
{
public const int CCM_FIRST = 0x2000;
internal const int CCM_FIRST = 0x2000;
public enum CommonControlMessage
{

View File

@ -2,30 +2,28 @@ using System;
using System.Runtime.InteropServices;
using static Vanara.PInvoke.User32_Gdi;
// ReSharper disable InconsistentNaming
namespace Vanara.PInvoke
{
public static partial class ComCtl32
{
public enum ProgressMessage
{
PBM_SETRANGE = WindowMessage.WM_USER+1,
PBM_SETPOS = WindowMessage.WM_USER+2,
PBM_DELTAPOS = WindowMessage.WM_USER+3,
PBM_SETSTEP = WindowMessage.WM_USER+4,
PBM_STEPIT = WindowMessage.WM_USER+5,
PBM_SETRANGE32 = WindowMessage.WM_USER+6, // lParam = high, wParam = low
PBM_GETRANGE = WindowMessage.WM_USER+7, // wParam = return (TRUE ? low : high). lParam = PPBRANGE or NULL
PBM_GETPOS = WindowMessage.WM_USER+8,
PBM_SETBARCOLOR = WindowMessage.WM_USER+9, // lParam = bar color
PBM_SETBKCOLOR = CommonControlMessage.CCM_SETBKCOLOR, // lParam = bkColor
PBM_SETMARQUEE = WindowMessage.WM_USER+10,
PBM_GETSTEP = WindowMessage.WM_USER+13,
PBM_GETBKCOLOR = WindowMessage.WM_USER+14,
PBM_GETBARCOLOR = WindowMessage.WM_USER+15,
PBM_SETSTATE = WindowMessage.WM_USER+16, // wParam = PBST_[State] (NORMAL, ERROR, PAUSED)
PBM_GETSTATE = WindowMessage.WM_USER+17,
PBM_SETRANGE = WindowMessage.WM_USER + 1,
PBM_SETPOS = WindowMessage.WM_USER + 2,
PBM_DELTAPOS = WindowMessage.WM_USER + 3,
PBM_SETSTEP = WindowMessage.WM_USER + 4,
PBM_STEPIT = WindowMessage.WM_USER + 5,
PBM_SETRANGE32 = WindowMessage.WM_USER + 6, // lParam = high, wParam = low
PBM_GETRANGE = WindowMessage.WM_USER + 7, // wParam = return (TRUE ? low : high). lParam = PPBRANGE or NULL
PBM_GETPOS = WindowMessage.WM_USER + 8,
PBM_SETBARCOLOR = WindowMessage.WM_USER + 9, // lParam = bar color
PBM_SETBKCOLOR = CommonControlMessage.CCM_SETBKCOLOR, // lParam = bkColor
PBM_SETMARQUEE = WindowMessage.WM_USER + 10,
PBM_GETSTEP = WindowMessage.WM_USER + 13,
PBM_GETBKCOLOR = WindowMessage.WM_USER + 14,
PBM_GETBARCOLOR = WindowMessage.WM_USER + 15,
PBM_SETSTATE = WindowMessage.WM_USER + 16, // wParam = PBST_[State] (NORMAL, ERROR, PAUSED)
PBM_GETSTATE = WindowMessage.WM_USER + 17,
}
/// <summary>State of the progress bar used in PBM_SETSTATE and PBM_GETSTATE messages.</summary>
@ -34,8 +32,10 @@ namespace Vanara.PInvoke
{
/// <summary>In progress</summary>
PBST_NORMAL = 0x0001,
/// <summary>Error.</summary>
PBST_ERROR = 0x0002,
/// <summary>Paused.</summary>
PBST_PAUSED = 0x0003,
}
@ -45,37 +45,59 @@ namespace Vanara.PInvoke
[Flags]
public enum ProgressStyle
{
/// <summary>Version 4.70 or later. The progress bar displays progress status in a smooth scrolling bar instead of the default segmented bar.
/// <note type="note">This style is supported only in the Windows Classic theme. All other themes override this style.</note></summary>
/// <summary>
/// Version 4.70 or later. The progress bar displays progress status in a smooth scrolling bar instead of the default segmented
/// bar. <note type="note">This style is supported only in the Windows Classic theme. All other themes override this style.</note>
/// </summary>
PBS_SMOOTH = 0x01,
/// <summary>Version 4.70 or later. The progress bar displays progress status vertically, from bottom to top.</summary>
PBS_VERTICAL = 0x04,
/// <summary>Version 6.0 or later. The progress indicator does not grow in size but instead moves repeatedly along the length of the bar, indicating activity without specifying what proportion of the progress is complete.
/// <note type="note">Comctl32.dll version 6 is not redistributable but it is included in Windows or later. To use Comctl32.dll version 6, specify it in a manifest. For more information on manifests, see Enabling Visual Styles.</note></summary>
/// <summary>
/// Version 6.0 or later. The progress indicator does not grow in size but instead moves repeatedly along the length of the bar,
/// indicating activity without specifying what proportion of the progress is complete. <note type="note">Comctl32.dll version 6
/// is not redistributable but it is included in Windows or later. To use Comctl32.dll version 6, specify it in a manifest. For
/// more information on manifests, see Enabling Visual Styles.</note>
/// </summary>
PBS_MARQUEE = 0x08,
/// <summary>Version 6.0 or later and Windows Vista. Determines the animation behavior that the progress bar should use when moving backward (from a higher value to a lower value). If this is set, then a "smooth" transition will occur, otherwise the control will "jump" to the lower value.</summary>
/// <summary>
/// Version 6.0 or later and Windows Vista. Determines the animation behavior that the progress bar should use when moving
/// backward (from a higher value to a lower value). If this is set, then a "smooth" transition will occur, otherwise the control
/// will "jump" to the lower value.
/// </summary>
PBS_SMOOTHREVERSE = 0x10,
}
/// <summary>Contains information about the high and low limits of a progress bar control. This structure is used with the PBM_GETRANGE message.</summary>
/// <summary>
/// Sends the specified message to a window or windows. The SendMessage function calls the window procedure for the specified window
/// and does not return until the window procedure has processed the message.
/// </summary>
/// <param name="hWnd">
/// A handle to the window whose window procedure will receive the message. If this parameter is HWND_BROADCAST ((HWND)0xffff), the
/// message is sent to all top-level windows in the system, including disabled or invisible unowned windows, overlapped windows, and
/// pop-up windows; but the message is not sent to child windows.
/// </param>
/// <param name="Msg">The message to be sent.</param>
/// <param name="wParam">Additional message-specific information.</param>
/// <param name="splitInfo">Additional message-specific information.</param>
/// <returns>The return value specifies the result of the message processing; it depends on the message sent.</returns>
[DllImport(Lib.User32, SetLastError = false, CharSet = CharSet.Auto)]
public static extern IntPtr SendMessage(HWND hWnd, ProgressMessage Msg, bool wParam, ref PBRANGE progressRange);
/// <summary>
/// Contains information about the high and low limits of a progress bar control. This structure is used with the PBM_GETRANGE message.
/// </summary>
[PInvokeData("Commctrl.h", MSDNShortId = "bb760822")]
[StructLayout(LayoutKind.Sequential)]
public struct PBRANGE
{
/// <summary>Low limit for the progress bar control. This is a signed integer.</summary>
public int iLow;
/// <summary>High limit for the progress bar control. This is a signed integer.</summary>
public int iHigh;
}
/// <summary>
/// Sends the specified message to a window or windows. The SendMessage function calls the window procedure for the specified window and does not return until the window procedure has processed the message.
/// </summary>
/// <param name="hWnd">A handle to the window whose window procedure will receive the message. If this parameter is HWND_BROADCAST ((HWND)0xffff), the message is sent to all top-level windows in the system, including disabled or invisible unowned windows, overlapped windows, and pop-up windows; but the message is not sent to child windows.</param>
/// <param name="Msg">The message to be sent.</param>
/// <param name="wParam">Additional message-specific information.</param>
/// <param name="progressRange">Additional message-specific information.</param>
/// <returns>The return value specifies the result of the message processing; it depends on the message sent.</returns>
public static IntPtr SendMessage(HWND hWnd, ProgressMessage Msg, bool wParam, ref PBRANGE progressRange) => User32_Gdi.SendMessage(hWnd, Msg, wParam, ref progressRange);
}
}

View File

@ -1,18 +1,17 @@
using System;
using System.Runtime.InteropServices;
using Vanara.Extensions;
using Vanara.InteropServices;
using static Vanara.PInvoke.Kernel32;
using static Vanara.PInvoke.Macros;
using static Vanara.PInvoke.User32_Gdi;
// ReSharper disable FieldCanBeMadeReadOnly.Global
// ReSharper disable InconsistentNaming
namespace Vanara.PInvoke
{
public static partial class ComCtl32
{
/// <summary>Specifies an application-defined callback function that a property sheet extension uses to add a page to a property sheet.</summary>
/// <summary>
/// Specifies an application-defined callback function that a property sheet extension uses to add a page to a property sheet.
/// </summary>
/// <param name="hpage">
/// <para>Type: <c>HPROPSHEETPAGE</c></para>
/// <para>Handle to a property sheet page.</para>
@ -25,73 +24,136 @@ namespace Vanara.PInvoke
/// <para>Type: <c><c>BOOL</c></c></para>
/// <para>Returns <c>TRUE</c> if successful, or <c>FALSE</c> otherwise.</para>
/// </returns>
// BOOL CALLBACK AddPropSheetPageProc( HPROPSHEETPAGE hpage, LPARAM lParam);
// https://msdn.microsoft.com/en-us/library/windows/desktop/bb760805(v=vs.85).aspx
// BOOL CALLBACK AddPropSheetPageProc( HPROPSHEETPAGE hpage, LPARAM lParam); https://msdn.microsoft.com/en-us/library/windows/desktop/bb760805(v=vs.85).aspx
[PInvokeData("Prsht.h", MSDNShortId = "bb760805")]
[UnmanagedFunctionPointer(CallingConvention.Winapi, CharSet = CharSet.Unicode)]
[return: MarshalAs(UnmanagedType.Bool)]
public delegate bool AddPropSheetPageProc(IntPtr hpage, IntPtr lParam);
/// <summary>
/// Specifies an application-defined callback function that a property sheet calls when a page is created and when it is about to be destroyed. An application can use this function to perform initialization and cleanup operations for the page.
/// Specifies an application-defined callback function that a property sheet calls when a page is created and when it is about to be
/// destroyed. An application can use this function to perform initialization and cleanup operations for the page.
/// </summary>
/// <param name="hwnd">Reserved; must be NULL.</param>
/// <param name="uMsg">Action flag.</param>
/// <param name="ppsp">Pointer to a PROPSHEETPAGE structure that defines the page being created or destroyed. See the Remarks section for further discussion.</param>
/// <param name="ppsp">
/// Pointer to a PROPSHEETPAGE structure that defines the page being created or destroyed. See the Remarks section for further discussion.
/// </param>
/// <returns>The return value depends on the value of the uMsg parameter.</returns>
[PInvokeData("Commctrl.h", MSDNShortId = "bb760813")]
[UnmanagedFunctionPointer(CallingConvention.Winapi, CharSet = CharSet.Unicode)]
public delegate uint PropSheetPageProc(IntPtr hwnd, PropSheetPageCallbackAction uMsg, PROPSHEETPAGE ppsp);
public delegate uint PropSheetPageProc(HWND hwnd, PropSheetPageCallbackAction uMsg, PROPSHEETPAGE ppsp);
/// <summary>
/// An application-defined callback function that the system calls when the property sheet is being created and initialized.
/// </summary>
/// <summary>An application-defined callback function that the system calls when the property sheet is being created and initialized.</summary>
/// <param name="hwndDlg">Handle to the property sheet dialog box.</param>
/// <param name="uMsg">
/// Message being received.This parameter is one of the following values.
/// <list type="table">
/// <listheader><term>Value</term><term>Meaning</term></listheader>
/// <item><term>PSCB_BUTTONPRESSED</term><term>Version 6.0 and later.Indicates the user pressed a button in the property sheet dialog box.To enable this, specify PSH_USECALLBACK in PROPSHEETHEADER.dwFlags and specify the name of this callback function in PROPSHEETHEADER.pfnCallback. The lParam value is one of the following. Note that only PSBTN_CANCEL is valid when you are using the Aero wizard style(PSH_AEROWIZARD).
/// <listheader>
/// <term>Value</term>
/// <term>Meaning</term>
/// </listheader>
/// <item>
/// <term>PSCB_BUTTONPRESSED</term>
/// <term>
/// Version 6.0 and later.Indicates the user pressed a button in the property sheet dialog box.To enable this, specify
/// PSH_USECALLBACK in PROPSHEETHEADER.dwFlags and specify the name of this callback function in PROPSHEETHEADER.pfnCallback. The
/// lParam value is one of the following. Note that only PSBTN_CANCEL is valid when you are using the Aero wizard style(PSH_AEROWIZARD).
/// <list type="table">
/// <listheader><term>Button pressed</term><term>lParam value</term></listheader>
/// <item><term>OK</term><term>PSBTN_OK</term></item>
/// <item><term>Cancel</term><term>PSBTN_CANCEL</term></item>
/// <item><term>Apply</term><term>PSBTN_APPLYNOW</term></item>
/// <item><term>Close</term><term>PSBTN_FINISH</term></item>
/// <listheader>
/// <term>Button pressed</term>
/// <term>lParam value</term>
/// </listheader>
/// <item>
/// <term>OK</term>
/// <term>PSBTN_OK</term>
/// </item>
/// <item>
/// <term>Cancel</term>
/// <term>PSBTN_CANCEL</term>
/// </item>
/// <item>
/// <term>Apply</term>
/// <term>PSBTN_APPLYNOW</term>
/// </item>
/// <item>
/// <term>Close</term>
/// <term>PSBTN_FINISH</term>
/// </item>
/// </list>
/// <para>Note that Comctl32.dll versions 6 and later are not redistributable.To use these versions of Comctl32.dll, specify the particular version in a manifest. For more information on manifests, see Enabling Visual Styles.</para>
/// </term></item>
/// <item><term>PSCB_INITIALIZED</term><term>Indicates that the property sheet is being initialized. The lParam value is zero for this message.</term></item>
/// <item><term>PSCB_PRECREATE</term><term>Indicates that the property sheet is about to be created. The hwndDlg parameter is NULL, and the lParam parameter is the address of a dialog template in memory.This template is in the form of a DLGTEMPLATE or DLGTEMPLATEEX structure followed by one or more DLGITEMTEMPLATE structures.This message is not applicable if you are using the Aero wizard style(PSH_AEROWIZARD).</term></item>
/// <para>
/// Note that Comctl32.dll versions 6 and later are not redistributable.To use these versions of Comctl32.dll, specify the particular
/// version in a manifest. For more information on manifests, see Enabling Visual Styles.
/// </para>
/// </term>
/// </item>
/// <item>
/// <term>PSCB_INITIALIZED</term>
/// <term>Indicates that the property sheet is being initialized. The lParam value is zero for this message.</term>
/// </item>
/// <item>
/// <term>PSCB_PRECREATE</term>
/// <term>
/// Indicates that the property sheet is about to be created. The hwndDlg parameter is NULL, and the lParam parameter is the address
/// of a dialog template in memory.This template is in the form of a DLGTEMPLATE or DLGTEMPLATEEX structure followed by one or more
/// DLGITEMTEMPLATE structures.This message is not applicable if you are using the Aero wizard style(PSH_AEROWIZARD).
/// </term>
/// </item>
/// </list>
/// </param>
/// <param name="lParam">Additional information about the message. The meaning of this value depends on the uMsg parameter.
/// <param name="lParam">
/// Additional information about the message. The meaning of this value depends on the uMsg parameter.
/// <para>If uMsg is PSCB_INITIALIZED or PSCB_BUTTONPRESSED, the value of lParam is zero.</para>
/// <para>If uMsg is PSCB_PRECREATE, then lParam will be a pointer to either a DLGTEMPLATE or DLGTEMPLATEEX structure describing the property sheet dialog box. Test the signature of the structure to determine the type. If signature is equal to 0xFFFF then the structure is an extended dialog template, otherwise the structure is a standard dialog template.</para></param>
/// <para>
/// If uMsg is PSCB_PRECREATE, then lParam will be a pointer to either a DLGTEMPLATE or DLGTEMPLATEEX structure describing the
/// property sheet dialog box. Test the signature of the structure to determine the type. If signature is equal to 0xFFFF then the
/// structure is an extended dialog template, otherwise the structure is a standard dialog template.
/// </para>
/// </param>
/// <returns>Returns zero.</returns>
[PInvokeData("Commctrl.h", MSDNShortId = "bb760815")]
[UnmanagedFunctionPointer(CallingConvention.Winapi, CharSet = CharSet.Unicode)]
public delegate int PropSheetProc(IntPtr hwndDlg, PropSheetCallbackMessage uMsg, IntPtr lParam);
public delegate int PropSheetProc(HWND hwndDlg, PropSheetCallbackMessage uMsg, IntPtr lParam);
[PInvokeData("Commctrl.h", MSDNShortId = "bb760815")]
public enum PropSheetCallbackMessage
{
/// <summary>Version 6.0 and later.Indicates the user pressed a button in the property sheet dialog box.To enable this, specify PSH_USECALLBACK in PROPSHEETHEADER.dwFlags and specify the name of this callback function in PROPSHEETHEADER.pfnCallback. The lParam value is one of the following. Note that only PSBTN_CANCEL is valid when you are using the Aero wizard style(PSH_AEROWIZARD).
/// <summary>
/// Version 6.0 and later.Indicates the user pressed a button in the property sheet dialog box.To enable this, specify
/// PSH_USECALLBACK in PROPSHEETHEADER.dwFlags and specify the name of this callback function in PROPSHEETHEADER.pfnCallback. The
/// lParam value is one of the following. Note that only PSBTN_CANCEL is valid when you are using the Aero wizard style(PSH_AEROWIZARD).
/// <list type="table">
/// <listheader><term>Button pressed</term><term>lParam value</term></listheader>
/// <item><term>OK</term><term>PSBTN_OK</term></item>
/// <item><term>Cancel</term><term>PSBTN_CANCEL</term></item>
/// <item><term>Apply</term><term>PSBTN_APPLYNOW</term></item>
/// <item><term>Close</term><term>PSBTN_FINISH</term></item>
/// <listheader>
/// <term>Button pressed</term>
/// <term>lParam value</term>
/// </listheader>
/// <item>
/// <term>OK</term>
/// <term>PSBTN_OK</term>
/// </item>
/// <item>
/// <term>Cancel</term>
/// <term>PSBTN_CANCEL</term>
/// </item>
/// <item>
/// <term>Apply</term>
/// <term>PSBTN_APPLYNOW</term>
/// </item>
/// <item>
/// <term>Close</term>
/// <term>PSBTN_FINISH</term>
/// </item>
/// </list>
/// </summary>
PSCB_BUTTONPRESSED = 3,
/// <summary>
/// Indicates that the property sheet is being initialized. The lParam value is zero for this message.
/// </summary>
/// <summary>Indicates that the property sheet is being initialized. The lParam value is zero for this message.</summary>
PSCB_INITIALIZED = 1,
/// <summary>
/// Indicates that the property sheet is about to be created. The hwndDlg parameter is NULL, and the lParam parameter is the address of a dialog template in memory. This template is in the form of a DLGTEMPLATE or DLGTEMPLATEEX structure followed by one or more DLGITEMTEMPLATE structures. This message is not applicable if you are using the Aero wizard style (PSH_AEROWIZARD).
/// Indicates that the property sheet is about to be created. The hwndDlg parameter is NULL, and the lParam parameter is the
/// address of a dialog template in memory. This template is in the form of a DLGTEMPLATE or DLGTEMPLATEEX structure followed by
/// one or more DLGITEMTEMPLATE structures. This message is not applicable if you are using the Aero wizard style (PSH_AEROWIZARD).
/// </summary>
PSCB_PRECREATE = 2
}
@ -101,33 +163,91 @@ namespace Vanara.PInvoke
[Flags]
public enum PropSheetFlags : uint
{
/// <summary>Uses the default meaning for all structure members. This flag is not supported when using the Aero-style wizard (PSH_AEROWIZARD).</summary>
/// <summary>
/// Uses the default meaning for all structure members. This flag is not supported when using the Aero-style wizard (PSH_AEROWIZARD).
/// </summary>
PSP_DEFAULT = 0x0,
/// <summary>Creates the page from the dialog box template in memory pointed to by the pResource member. The PropertySheet function assumes that the template that is in memory is not write-protected. A read-only template will cause an exception in some versions of Windows.</summary>
/// <summary>
/// Creates the page from the dialog box template in memory pointed to by the pResource member. The PropertySheet function
/// assumes that the template that is in memory is not write-protected. A read-only template will cause an exception in some
/// versions of Windows.
/// </summary>
PSP_DLGINDIRECT = 0x1,
/// <summary>Enables the property sheet Help button when the page is active. This flag is not supported when using the Aero-style wizard (PSH_AEROWIZARD).</summary>
/// <summary>
/// Enables the property sheet Help button when the page is active. This flag is not supported when using the Aero-style wizard (PSH_AEROWIZARD).
/// </summary>
PSP_HASHELP = 0x20,
/// <summary>Version 5.80 and later. Causes the wizard property sheet to hide the header area when the page is selected. If a watermark has been provided, it will be painted on the left side of the page. This flag should be set for welcome and completion pages, and omitted for interior pages. This flag is not supported when using the Aero-style wizard (PSH_AEROWIZARD).</summary>
/// <summary>
/// Version 5.80 and later. Causes the wizard property sheet to hide the header area when the page is selected. If a watermark
/// has been provided, it will be painted on the left side of the page. This flag should be set for welcome and completion pages,
/// and omitted for interior pages. This flag is not supported when using the Aero-style wizard (PSH_AEROWIZARD).
/// </summary>
PSP_HIDEHEADER = 0x800,
/// <summary>Version 4.71 or later. Causes the page to be created when the property sheet is created. If this flag is not specified, the page will not be created until it is selected the first time. This flag is not supported when using the Aero-style wizard (PSH_AEROWIZARD).</summary>
/// <summary>
/// Version 4.71 or later. Causes the page to be created when the property sheet is created. If this flag is not specified, the
/// page will not be created until it is selected the first time. This flag is not supported when using the Aero-style wizard (PSH_AEROWIZARD).
/// </summary>
PSP_PREMATURE = 0x400,
/// <summary>Reverses the direction in which pszTitle is displayed. Normal windows display all text, including pszTitle, left-to-right (LTR). For languages such as Hebrew or Arabic that read right-to-left (RTL), a window can be mirrored and all text will be displayed RTL. If PSP_RTLREADING is set, pszTitle will instead read RTL in a normal parent window, and LTR in a mirrored parent window.</summary>
/// <summary>
/// Reverses the direction in which pszTitle is displayed. Normal windows display all text, including pszTitle, left-to-right
/// (LTR). For languages such as Hebrew or Arabic that read right-to-left (RTL), a window can be mirrored and all text will be
/// displayed RTL. If PSP_RTLREADING is set, pszTitle will instead read RTL in a normal parent window, and LTR in a mirrored
/// parent window.
/// </summary>
PSP_RTLREADING = 0x10,
/// <summary>Calls the function specified by the pfnCallback member when creating or destroying the property sheet page defined by this structure.</summary>
/// <summary>
/// Calls the function specified by the pfnCallback member when creating or destroying the property sheet page defined by this structure.
/// </summary>
PSP_USECALLBACK = 0x80,
/// <summary>Version 6.0 and later. Use an activation context. To use an activation context, you must set this flag and assign the activation context handle to hActCtx. See the Remarks.</summary>
/// <summary>
/// Version 6.0 and later. Use an activation context. To use an activation context, you must set this flag and assign the
/// activation context handle to hActCtx. See the Remarks.
/// </summary>
PSP_USEFUSIONCONTEXT = 0x4000,
/// <summary>Version 5.80 or later. Displays the string pointed to by the pszHeaderSubTitle member as the subtitle of the header area of a Wizard97 page. To use this flag, you must also set the PSH_WIZARD97 flag in the dwFlags member of the associated PROPSHEETHEADER structure. The PSP_USEHEADERSUBTITLE flag is ignored if PSP_HIDEHEADER is set. In Aero-style wizards, the title appears near the top of the client area.</summary>
/// <summary>
/// Version 5.80 or later. Displays the string pointed to by the pszHeaderSubTitle member as the subtitle of the header area of a
/// Wizard97 page. To use this flag, you must also set the PSH_WIZARD97 flag in the dwFlags member of the associated
/// PROPSHEETHEADER structure. The PSP_USEHEADERSUBTITLE flag is ignored if PSP_HIDEHEADER is set. In Aero-style wizards, the
/// title appears near the top of the client area.
/// </summary>
PSP_USEHEADERSUBTITLE = 0x2000,
/// <summary>Version 5.80 or later. Displays the string pointed to by the pszHeaderTitle member as the title in the header of a Wizard97 interior page. You must also set the PSH_WIZARD97 flag in the dwFlags member of the associated PROPSHEETHEADER structure. The PSP_USEHEADERTITLE flag is ignored if PSP_HIDEHEADER is set. This flag is not supported when using the Aero-style wizard (PSH_AEROWIZARD).</summary>
/// <summary>
/// Version 5.80 or later. Displays the string pointed to by the pszHeaderTitle member as the title in the header of a Wizard97
/// interior page. You must also set the PSH_WIZARD97 flag in the dwFlags member of the associated PROPSHEETHEADER structure. The
/// PSP_USEHEADERTITLE flag is ignored if PSP_HIDEHEADER is set. This flag is not supported when using the Aero-style wizard (PSH_AEROWIZARD).
/// </summary>
PSP_USEHEADERTITLE = 0x1000,
/// <summary>Uses hIcon as the small icon on the tab for the page. This flag is not supported when using the Aero-style wizard (PSH_AEROWIZARD).</summary>
/// <summary>
/// Uses hIcon as the small icon on the tab for the page. This flag is not supported when using the Aero-style wizard (PSH_AEROWIZARD).
/// </summary>
PSP_USEHICON = 0x2,
/// <summary>Uses pszIcon as the name of the icon resource to load and use as the small icon on the tab for the page. This flag is not supported when using the Aero-style wizard (PSH_AEROWIZARD).</summary>
/// <summary>
/// Uses pszIcon as the name of the icon resource to load and use as the small icon on the tab for the page. This flag is not
/// supported when using the Aero-style wizard (PSH_AEROWIZARD).
/// </summary>
PSP_USEICONID = 0x4,
/// <summary>Maintains the reference count specified by the pcRefParent member for the lifetime of the property sheet page created from this structure.</summary>
/// <summary>
/// Maintains the reference count specified by the pcRefParent member for the lifetime of the property sheet page created from
/// this structure.
/// </summary>
PSP_USEREFPARENT = 0x40,
/// <summary>Uses the pszTitle member as the title of the property sheet dialog box instead of the title stored in the dialog box template. This flag is not supported when using the Aero-style wizard (PSH_AEROWIZARD).</summary>
/// <summary>
/// Uses the pszTitle member as the title of the property sheet dialog box instead of the title stored in the dialog box
/// template. This flag is not supported when using the Aero-style wizard (PSH_AEROWIZARD).
/// </summary>
PSP_USETITLE = 0x8,
}
@ -136,61 +256,168 @@ namespace Vanara.PInvoke
[Flags]
public enum PropSheetHeaderFlags : uint
{
/// <summary>Uses the default meaning for all structure members, and creates a normal property sheet. This flag has a value of zero and is not combined with other flags.</summary>
/// <summary>
/// Uses the default meaning for all structure members, and creates a normal property sheet. This flag has a value of zero and is
/// not combined with other flags.
/// </summary>
PSH_DEFAULT = 0x00000000,
/// <summary>Version 6.00 and Windows Vista.. Creates a wizard property sheet that uses the newer Aero style. The PSH_WIZARD flag must also be set. The single-threaded apartment (STA) model must be used.</summary>
/// <summary>
/// Version 6.00 and Windows Vista.. Creates a wizard property sheet that uses the newer Aero style. The PSH_WIZARD flag must
/// also be set. The single-threaded apartment (STA) model must be used.
/// </summary>
PSH_AEROWIZARD = 0x00004000,
/// <summary>Permits property sheet pages to display a Help button. You must also set the PSP_HASHELP flag in the page's PROPSHEETPAGE structure when the page is created. If any of the initial property sheet pages enable a Help button, PSH_HASHELP will be set automatically. If none of the initial pages enable a Help button, you must explicitly set PSH_HASHELP if you want to have Help buttons on any pages that might be added later. This flag is not supported in conjunction with PSH_AEROWIZARD.</summary>
/// <summary>
/// Permits property sheet pages to display a Help button. You must also set the PSP_HASHELP flag in the page's PROPSHEETPAGE
/// structure when the page is created. If any of the initial property sheet pages enable a Help button, PSH_HASHELP will be set
/// automatically. If none of the initial pages enable a Help button, you must explicitly set PSH_HASHELP if you want to have
/// Help buttons on any pages that might be added later. This flag is not supported in conjunction with PSH_AEROWIZARD.
/// </summary>
PSH_HASHELP = 0x00000200,
/// <summary>Version 5.80 and later. Indicates that a header bitmap will be used with a Wizard97 wizard. You must also set the PSH_WIZARD97 flag. The header bitmap is obtained from the pszbmHeader member, unless the PSH_USEHBMHEADER flag is also set. In that case, the header bitmap is obtained from the hbmHeader member. This flag is not supported in conjunction with PSH_AEROWIZARD.</summary>
/// <summary>
/// Version 5.80 and later. Indicates that a header bitmap will be used with a Wizard97 wizard. You must also set the
/// PSH_WIZARD97 flag. The header bitmap is obtained from the pszbmHeader member, unless the PSH_USEHBMHEADER flag is also set.
/// In that case, the header bitmap is obtained from the hbmHeader member. This flag is not supported in conjunction with PSH_AEROWIZARD.
/// </summary>
PSH_HEADER = 0x00080000,
/// <summary>Version 6.00 and Windows Vista..The pszbmHeader member specifies a bitmap that is displayed in the header area. Must be used in combination with PSH_AEROWIZARD.</summary>
/// <summary>
/// Version 6.00 and Windows Vista..The pszbmHeader member specifies a bitmap that is displayed in the header area. Must be used
/// in combination with PSH_AEROWIZARD.
/// </summary>
PSH_HEADERBITMAP = 0x08000000,
/// <summary>Causes the PropertySheet function to create the property sheet as a modeless dialog box instead of as a modal dialog box. When this flag is set, PropertySheet returns immediately after the dialog box is created, and the return value from PropertySheet is the window handle to the property sheet dialog box. This flag is not supported in conjunction with PSH_AEROWIZARD.</summary>
/// <summary>
/// Causes the PropertySheet function to create the property sheet as a modeless dialog box instead of as a modal dialog box.
/// When this flag is set, PropertySheet returns immediately after the dialog box is created, and the return value from
/// PropertySheet is the window handle to the property sheet dialog box. This flag is not supported in conjunction with PSH_AEROWIZARD.
/// </summary>
PSH_MODELESS = 0x00000400,
/// <summary>Removes the Apply button. This flag is not supported in conjunction with PSH_AEROWIZARD.</summary>
PSH_NOAPPLYNOW = 0x00000080,
/// <summary>Version 5.80 and later. Removes the context-sensitive Help button ("?"), which is usually present on the caption bar of property sheets. This flag is not valid for wizards. See About Property Sheets for a discussion of how to remove the caption bar Help button for earlier versions of the common controls. This flag is not supported in conjunction with PSH_AEROWIZARD.</summary>
/// <summary>
/// Version 5.80 and later. Removes the context-sensitive Help button ("?"), which is usually present on the caption bar of
/// property sheets. This flag is not valid for wizards. See About Property Sheets for a discussion of how to remove the caption
/// bar Help button for earlier versions of the common controls. This flag is not supported in conjunction with PSH_AEROWIZARD.
/// </summary>
PSH_NOCONTEXTHELP = 0x02000000,
/// <summary>Version 6.00 and Windows Vista.. Specifies that no margin is inserted between the page and the frame. Must be used in combination with PSH_AEROWIZARD.</summary>
/// <summary>
/// Version 6.00 and Windows Vista.. Specifies that no margin is inserted between the page and the frame. Must be used in
/// combination with PSH_AEROWIZARD.
/// </summary>
PSH_NOMARGIN = 0x10000000,
/// <summary>Uses the ppsp member and ignores the phpage member when creating the pages for the property sheet.</summary>
PSH_PROPSHEETPAGE = 0x00000008,
/// <summary>Displays a title in the title bar of the property sheet. The title takes the appropriate form for the Windows version. In more recent versions of Windows, the title is the string specified by the pszCaption followed by the string "Properties". In older versions of Windows, the title is the string "Properties for", followed by the string specified by the pszCaption member. This flag is not supported for wizards.</summary>
/// <summary>
/// Displays a title in the title bar of the property sheet. The title takes the appropriate form for the Windows version. In
/// more recent versions of Windows, the title is the string specified by the pszCaption followed by the string "Properties". In
/// older versions of Windows, the title is the string "Properties for", followed by the string specified by the pszCaption
/// member. This flag is not supported for wizards.
/// </summary>
PSH_PROPTITLE = 0x00000001,
/// <summary>Allows the wizard to be resized by the user. Maximize and minimize buttons appear in the wizard's frame and the frame is sizable. To use this flag, you must also set PSH_AEROWIZARD.</summary>
/// <summary>
/// Allows the wizard to be resized by the user. Maximize and minimize buttons appear in the wizard's frame and the frame is
/// sizable. To use this flag, you must also set PSH_AEROWIZARD.
/// </summary>
PSH_RESIZABLE = 0x04000000,
/// <summary>Displays the title of the property sheet (pszCaption) using right-to-left (RTL) reading order for Hebrew or Arabic languages. If this flag is not specified, the title is displayed in left-to-right (LTR) reading order.</summary>
/// <summary>
/// Displays the title of the property sheet (pszCaption) using right-to-left (RTL) reading order for Hebrew or Arabic languages.
/// If this flag is not specified, the title is displayed in left-to-right (LTR) reading order.
/// </summary>
PSH_RTLREADING = 0x00000800,
/// <summary>Stretches the watermark in Internet Explorer 4.0-compatible Wizard97-style wizards. This flag is not supported in conjunction with PSH_AEROWIZARD. <note>This style flag is only included to provide backward compatibility for certain applications. Its use is not recommended, and it is only supported by common controls versions 4.0 and 4.01. With common controls version 5.80 and later, this flag is ignored.</note></summary>
/// <summary>
/// Stretches the watermark in Internet Explorer 4.0-compatible Wizard97-style wizards. This flag is not supported in conjunction
/// with PSH_AEROWIZARD. <note>This style flag is only included to provide backward compatibility for certain applications. Its
/// use is not recommended, and it is only supported by common controls versions 4.0 and 4.01. With common controls version 5.80
/// and later, this flag is ignored.</note>
/// </summary>
PSH_STRETCHWATERMARK = 0x00040000,
/// <summary>Calls the function specified by the pfnCallback member when initializing the property sheet defined by this structure.</summary>
/// <summary>
/// Calls the function specified by the pfnCallback member when initializing the property sheet defined by this structure.
/// </summary>
PSH_USECALLBACK = 0x00000100,
/// <summary>Version 5.80 or later. Obtains the header bitmap from the hbmHeader member instead of the pszbmHeader member. You must also set either the PSH_AEROWIZARD flag or the PSH_WIZARD97 flag together with the PSH_HEADER flag.</summary>
/// <summary>
/// Version 5.80 or later. Obtains the header bitmap from the hbmHeader member instead of the pszbmHeader member. You must also
/// set either the PSH_AEROWIZARD flag or the PSH_WIZARD97 flag together with the PSH_HEADER flag.
/// </summary>
PSH_USEHBMHEADER = 0x00100000,
/// <summary>Version 5.80 or later. Obtains the watermark bitmap from the hbmWatermark member instead of the pszbmWatermark member. You must also set PSH_WIZARD97 and PSH_WATERMARK. This flag is not supported in conjunction with PSH_AEROWIZARD.</summary>
/// <summary>
/// Version 5.80 or later. Obtains the watermark bitmap from the hbmWatermark member instead of the pszbmWatermark member. You
/// must also set PSH_WIZARD97 and PSH_WATERMARK. This flag is not supported in conjunction with PSH_AEROWIZARD.
/// </summary>
PSH_USEHBMWATERMARK = 0x00010000,
/// <summary>Uses hIcon as the small icon in the title bar of the property sheet dialog box.</summary>
PSH_USEHICON = 0x00000002,
/// <summary>Version 5.80 or later. Uses the HPALETTE structure pointed to by the hplWatermark member instead of the default palette to draw the watermark bitmap and/or header bitmap for a Wizard97 wizard. You must also set PSH_WIZARD97, and PSH_WATERMARK or PSH_HEADER. This flag is not supported in conjunction with PSH_AEROWIZARD.</summary>
/// <summary>
/// Version 5.80 or later. Uses the HPALETTE structure pointed to by the hplWatermark member instead of the default palette to
/// draw the watermark bitmap and/or header bitmap for a Wizard97 wizard. You must also set PSH_WIZARD97, and PSH_WATERMARK or
/// PSH_HEADER. This flag is not supported in conjunction with PSH_AEROWIZARD.
/// </summary>
PSH_USEHPLWATERMARK = 0x00020000,
/// <summary>Uses pszIcon as the name of the icon resource to load and use as the small icon in the title bar of the property sheet dialog box.</summary>
/// <summary>
/// Uses pszIcon as the name of the icon resource to load and use as the small icon in the title bar of the property sheet dialog box.
/// </summary>
PSH_USEICONID = 0x00000004,
/// <summary>Version 5.80 or later. Specifies that the language for the property sheet will be taken from the first page's resource. That page must be specified by resource identifier.</summary>
/// <summary>
/// Version 5.80 or later. Specifies that the language for the property sheet will be taken from the first page's resource. That
/// page must be specified by resource identifier.
/// </summary>
PSH_USEPAGELANG = 0x00200000,
/// <summary>Uses the pStartPage member instead of the nStartPage member when displaying the initial page of the property sheet.</summary>
/// <summary>
/// Uses the pStartPage member instead of the nStartPage member when displaying the initial page of the property sheet.
/// </summary>
PSH_USEPSTARTPAGE = 0x00000040,
/// <summary>Version 5.80 or later. Specifies that a watermark bitmap will be used with a Wizard97 wizard on pages that have the PSP_HIDEHEADER style. You must also set the PSH_WIZARD97 flag. The watermark bitmap is obtained from the pszbmWatermark member, unless PSH_USEHBMWATERMARK is set. In that case, the header bitmap is obtained from the hbmWatermark member. This flag is not supported in conjunction with PSH_AEROWIZARD.</summary>
/// <summary>
/// Version 5.80 or later. Specifies that a watermark bitmap will be used with a Wizard97 wizard on pages that have the
/// PSP_HIDEHEADER style. You must also set the PSH_WIZARD97 flag. The watermark bitmap is obtained from the pszbmWatermark
/// member, unless PSH_USEHBMWATERMARK is set. In that case, the header bitmap is obtained from the hbmWatermark member. This
/// flag is not supported in conjunction with PSH_AEROWIZARD.
/// </summary>
PSH_WATERMARK = 0x00008000,
/// <summary>Creates a wizard property sheet. When using PSH_AEROWIZARD, you must also set this flag.</summary>
PSH_WIZARD = 0x00000020,
/// <summary>Version 5.80 or later. Creates a Wizard97-style property sheet, which supports bitmaps in the header of interior pages and on the left side of exterior pages. This flag is not supported in conjunction with PSH_AEROWIZARD.</summary>
/// <summary>
/// Version 5.80 or later. Creates a Wizard97-style property sheet, which supports bitmaps in the header of interior pages and on
/// the left side of exterior pages. This flag is not supported in conjunction with PSH_AEROWIZARD.
/// </summary>
PSH_WIZARD97 = 0x00002000,
/// <summary>Adds a context-sensitive Help button ("?"), which is usually absent from the caption bar of a wizard. This flag is not valid for regular property sheets. This flag is not supported in conjunction with PSH_AEROWIZARD.</summary>
/// <summary>
/// Adds a context-sensitive Help button ("?"), which is usually absent from the caption bar of a wizard. This flag is not valid
/// for regular property sheets. This flag is not supported in conjunction with PSH_AEROWIZARD.
/// </summary>
PSH_WIZARDCONTEXTHELP = 0x00001000,
/// <summary>Always displays the Finish button on the wizard. You must also set either PSH_WIZARD, PSH_WIZARD97, or PSH_AEROWIZARD.</summary>
PSH_WIZARDHASFINISH = 0x00000010,
/// <summary>Version 5.80 or later. Uses the Wizard-lite style. This style is similar in appearance to PSH_WIZARD97, but it is implemented much like PSH_WIZARD. There are few restrictions on how the pages are formatted. For instance, there are no enforced borders, and the PSH_WIZARD_LITE style does not paint the watermark and header bitmaps for you the way Wizard97 does. This flag is not supported in conjunction with PSH_AEROWIZARD.</summary>
/// <summary>
/// Version 5.80 or later. Uses the Wizard-lite style. This style is similar in appearance to PSH_WIZARD97, but it is implemented
/// much like PSH_WIZARD. There are few restrictions on how the pages are formatted. For instance, there are no enforced borders,
/// and the PSH_WIZARD_LITE style does not paint the watermark and header bitmaps for you the way Wizard97 does. This flag is not
/// supported in conjunction with PSH_AEROWIZARD.
/// </summary>
PSH_WIZARD_LITE = 0x00400000,
}
@ -199,8 +426,10 @@ namespace Vanara.PInvoke
{
/// <summary>Version 5.80 or later. A page is being created. The return value is not used.</summary>
PSPCB_ADDREF = 0x0,
/// <summary>A page is being destroyed. The return value is ignored.</summary>
PSPCB_RELEASE = 0x1,
/// <summary>A dialog box for a page is being created. Return nonzero to allow it to be created, or zero to prevent it.</summary>
PSPCB_CREATE = 0x2,
}
@ -214,27 +443,83 @@ namespace Vanara.PInvoke
/// <para>Type: <c>HPROPSHEETPAGE</c></para>
/// <para>Returns the handle to the new property page if successful, or <c>NULL</c> otherwise.</para>
/// </returns>
// HPROPSHEETPAGE CreatePropertySheetPage( LPCPROPSHEETPAGE lppsp);
// https://msdn.microsoft.com/en-us/library/windows/desktop/bb760807(v=vs.85).aspx
// HPROPSHEETPAGE CreatePropertySheetPage( LPCPROPSHEETPAGE lppsp); https://msdn.microsoft.com/en-us/library/windows/desktop/bb760807(v=vs.85).aspx
[DllImport(Lib.ComCtl32, SetLastError = false, CharSet = CharSet.Auto)]
[PInvokeData("Prsht.h", MSDNShortId = "bb760807")]
public static extern SafeHPROPSHEETPAGE CreatePropertySheetPage(PROPSHEETPAGE lppsp);
/// <summary>Destroys a property sheet page. An application must call this function for pages that have not been passed to the <c>PropertySheet</c> function.</summary><param name="hPSPage"><para>Type: <c>HPROPSHEETPAGE</c></para><para>Handle to the property sheet page to delete.</para></param><returns><para>Type: <c><c>BOOL</c></c></para><para>Returns nonzero if successful, or zero otherwise.</para></returns>
// BOOL DestroyPropertySheetPage( HPROPSHEETPAGE hPSPage);
// https://msdn.microsoft.com/en-us/library/windows/desktop/bb760809(v=vs.85).aspx
/// <summary>
/// Destroys a property sheet page. An application must call this function for pages that have not been passed to the
/// <c>PropertySheet</c> function.
/// </summary>
/// <param name="hPSPage">
/// <para>Type: <c>HPROPSHEETPAGE</c></para>
/// <para>Handle to the property sheet page to delete.</para>
/// </param>
/// <returns>
/// <para>Type: <c><c>BOOL</c></c></para>
/// <para>Returns nonzero if successful, or zero otherwise.</para>
/// </returns>
// BOOL DestroyPropertySheetPage( HPROPSHEETPAGE hPSPage); https://msdn.microsoft.com/en-us/library/windows/desktop/bb760809(v=vs.85).aspx
[DllImport(Lib.ComCtl32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("Prsht.h", MSDNShortId = "bb760809")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool DestroyPropertySheetPage(HPROPSHEETPAGE hPSPage);
/// <summary>Creates a property sheet and adds the pages defined in the specified property sheet header structure.</summary><param name="lppsph"><para>Type: <c>LPCPROPSHEETHEADER</c></para><para>Pointer to a <c>PROPSHEETHEADER</c> structure that defines the frame and pages of a property sheet.</para></param><returns><para>Type: <c><c>INT_PTR</c></c></para><para>For modal property sheets, the return value is as follows:</para><para><list type="table"><listheader><term>&amp;gt;=1</term><term>Changes were saved by the user.</term></listheader><item><term>0</term><term>No changes were saved by the user.</term></item><item><term>-1</term><term>An error occurred.</term></item></list></para><para>For modeless property sheets, the return value is the property sheet&#39;s window handle.</para><para>The following return values have a special meaning.</para><para><list type="table"><listheader><term>Return code</term><term>Description</term></listheader><item><term>ID_PSREBOOTSYSTEM</term><term>A page sent the PSM_REBOOTSYSTEM message to the property sheet. The computer must be restarted for the user&amp;#39;s changes to take effect.</term></item><item><term>ID_PSRESTARTWINDOWS</term><term>A page sent the PSM_RESTARTWINDOWS message to the property sheet. Windows must be restarted for the user&amp;#39;s changes to take effect.</term></item></list></para></returns>
// INT_PTR PropertySheet( LPCPROPSHEETHEADER lppsph);
// https://msdn.microsoft.com/en-us/library/windows/desktop/bb760811(v=vs.85).aspx
/// <summary>Creates a property sheet and adds the pages defined in the specified property sheet header structure.</summary>
/// <param name="lppsph">
/// <para>Type: <c>LPCPROPSHEETHEADER</c></para>
/// <para>Pointer to a <c>PROPSHEETHEADER</c> structure that defines the frame and pages of a property sheet.</para>
/// </param>
/// <returns>
/// <para>Type: <c><c>INT_PTR</c></c></para>
/// <para>For modal property sheets, the return value is as follows:</para>
/// <para>
/// <list type="table">
/// <listheader>
/// <term>&amp;gt;=1</term>
/// <term>Changes were saved by the user.</term>
/// </listheader>
/// <item>
/// <term>0</term>
/// <term>No changes were saved by the user.</term>
/// </item>
/// <item>
/// <term>-1</term>
/// <term>An error occurred.</term>
/// </item>
/// </list>
/// </para>
/// <para>For modeless property sheets, the return value is the property sheet's window handle.</para>
/// <para>The following return values have a special meaning.</para>
/// <para>
/// <list type="table">
/// <listheader>
/// <term>Return code</term>
/// <term>Description</term>
/// </listheader>
/// <item>
/// <term>ID_PSREBOOTSYSTEM</term>
/// <term>
/// A page sent the PSM_REBOOTSYSTEM message to the property sheet. The computer must be restarted for the user's changes to
/// take effect.
/// </term>
/// </item>
/// <item>
/// <term>ID_PSRESTARTWINDOWS</term>
/// <term>
/// A page sent the PSM_RESTARTWINDOWS message to the property sheet. Windows must be restarted for the user's changes to
/// take effect.
/// </term>
/// </item>
/// </list>
/// </para>
/// </returns>
// INT_PTR PropertySheet( LPCPROPSHEETHEADER lppsph); https://msdn.microsoft.com/en-us/library/windows/desktop/bb760811(v=vs.85).aspx
[DllImport(Lib.ComCtl32, SetLastError = false, CharSet = CharSet.Auto)]
[PInvokeData("Prsht.h", MSDNShortId = "bb760811")]
[return: MarshalAs(UnmanagedType.SysInt)]
public static extern int PropertySheet(ref PROPSHEETHEADER psh);
public static extern IntPtr PropertySheet(ref PROPSHEETHEADER psh);
// TODO: Convert resource id fields to managed properties.
/// <summary>Defines the frame and pages of a property sheet.</summary>
@ -243,88 +528,106 @@ namespace Vanara.PInvoke
public struct PROPSHEETHEADER
{
/// <summary>
/// Size, in bytes, of this structure. The property sheet manager uses this member to determine which version of the PROPSHEETHEADER structure you
/// are using. For more information, see the Remarks.
/// Size, in bytes, of this structure. The property sheet manager uses this member to determine which version of the
/// PROPSHEETHEADER structure you are using. For more information, see the Remarks.
/// </summary>
public uint dwSize;
/// <summary>Flags that indicate which options to use when creating the property sheet page.</summary>
public PropSheetHeaderFlags dwFlags;
/// <summary>Handle to the property sheet's owner window.</summary>
public IntPtr hwndParent;
public HWND hwndParent;
/// <summary>
/// Handle to the instance from which to load the icon or title string resource. If the pszIcon or pszCaption member identifies a resource to load,
/// this member must be specified.
/// Handle to the instance from which to load the icon or title string resource. If the pszIcon or pszCaption member identifies a
/// resource to load, this member must be specified.
/// </summary>
public IntPtr hInstance;
public HINSTANCE hInstance;
/// <summary>
/// Handle to the icon to use as the small icon in the title bar of the property sheet dialog box. If the dwFlags member does not include
/// PSH_USEHICON, this member is ignored. This member is declared as a union with pszIcon.
/// Handle to the icon to use as the small icon in the title bar of the property sheet dialog box. If the dwFlags member does not
/// include PSH_USEHICON, this member is ignored. This member is declared as a union with pszIcon.
/// <para><c>OR</c></para>
/// <para>
/// String icon resource to use as the small icon in the title bar of the property sheet dialog box. This member can specify either the identifier of
/// the icon resource or the address of the string that specifies the name of the icon resource. If the dwFlags member does not include
/// PSH_USEICONID, this member is ignored. This member is declared as a union with hIcon.
/// String icon resource to use as the small icon in the title bar of the property sheet dialog box. This member can specify
/// either the identifier of the icon resource or the address of the string that specifies the name of the icon resource. If the
/// dwFlags member does not include PSH_USEICONID, this member is ignored. This member is declared as a union with hIcon.
/// </para>
/// </summary>
public IntPtr pIcon;
public HICON pIcon;
/// <summary>
/// Title of the property sheet dialog box. This member can specify either the identifier of a string resource or the address of a string that
/// specifies the title. If the dwFlags member includes PSH_PROPTITLE, the string "Properties for" is inserted at the beginning of the title. This
/// field is ignored for Wizard97 wizards. For Aero wizards, the string alone is used for the caption, regardless of whether the PSH_PROPTITLE flag
/// is set.
/// Title of the property sheet dialog box. This member can specify either the identifier of a string resource or the address of
/// a string that specifies the title. If the dwFlags member includes PSH_PROPTITLE, the string "Properties for" is inserted at
/// the beginning of the title. This field is ignored for Wizard97 wizards. For Aero wizards, the string alone is used for the
/// caption, regardless of whether the PSH_PROPTITLE flag is set.
/// </summary>
public IntPtr pszCaption;
/// <summary>Number of elements in the phpage array.</summary>
public uint nPages;
/// <summary>
/// Zero-based index of the initial page that appears when the property sheet dialog box is created. This member is declared as a union with pStartPage.
/// Zero-based index of the initial page that appears when the property sheet dialog box is created. This member is declared as a
/// union with pStartPage.
/// <para><c>OR</c></para>
/// <para>
/// Name of the initial page that appears when the property sheet dialog box is created. This member can specify either the identifier of a string
/// resource or the address of a string that specifies the name. This member is declared as a union with nStartPage.
/// Name of the initial page that appears when the property sheet dialog box is created. This member can specify either the
/// identifier of a string resource or the address of a string that specifies the name. This member is declared as a union with nStartPage.
/// </para>
/// </summary>
public IntPtr pStartPage;
/// <summary>
/// Pointer to an array of PROPSHEETPAGE structures that define the pages in the property sheet. If the dwFlags member does not include
/// PSH_PROPSHEETPAGE, this member is ignored. Note that the PROPSHEETPAGE structure is variable in size. Applications that parse the array pointed
/// to by ppsp must take the size of each page into account. This member is declared as a union with phpage.
/// Pointer to an array of PROPSHEETPAGE structures that define the pages in the property sheet. If the dwFlags member does not
/// include PSH_PROPSHEETPAGE, this member is ignored. Note that the PROPSHEETPAGE structure is variable in size. Applications
/// that parse the array pointed to by ppsp must take the size of each page into account. This member is declared as a union with phpage.
/// <para><c>OR</c></para>
/// <para>
/// Pointer to an array of handles to the property sheet pages. Each handle must have been created by a previous call to the CreatePropertySheetPage
/// function. If the dwFlags member includes PSH_PROPSHEETPAGE, phpage is ignored and should be set to NULL. When the PropertySheet function returns,
/// any HPROPSHEETPAGE handles in the phpage array will have been destroyed. This member is declared as a union with ppsp.
/// Pointer to an array of handles to the property sheet pages. Each handle must have been created by a previous call to the
/// CreatePropertySheetPage function. If the dwFlags member includes PSH_PROPSHEETPAGE, phpage is ignored and should be set to
/// NULL. When the PropertySheet function returns, any HPROPSHEETPAGE handles in the phpage array will have been destroyed. This
/// member is declared as a union with ppsp.
/// </para>
/// </summary>
public IntPtr phpage;
/// <summary>
/// Pointer to an application-defined callback function that is called when the property sheet is initialized. For more information about the
/// callback function, see the description of the PropSheetProc function. If the dwFlags member does not include PSH_USECALLBACK, this member is ignored.
/// Pointer to an application-defined callback function that is called when the property sheet is initialized. For more
/// information about the callback function, see the description of the PropSheetProc function. If the dwFlags member does not
/// include PSH_USECALLBACK, this member is ignored.
/// </summary>
public PropSheetProc pfnCallback;
/// <summary>
/// Version 5.80 or later. Handle to the watermark bitmap. If the dwFlags member does not include PSH_USEHBMWATERMARK, this member is ignored.
/// Version 5.80 or later. Handle to the watermark bitmap. If the dwFlags member does not include PSH_USEHBMWATERMARK, this
/// member is ignored.
/// <para><c>OR</c></para>
/// <para>
/// Version 5.80 or later. Bitmap resource to use as the watermark. This member can specify either the identifier of the bitmap resource or the
/// address of the string that specifies the name of the bitmap resource. If the dwFlags member includes PSH_USEHBMWATERMARK, this member is ignored.
/// Version 5.80 or later. Bitmap resource to use as the watermark. This member can specify either the identifier of the bitmap
/// resource or the address of the string that specifies the name of the bitmap resource. If the dwFlags member includes
/// PSH_USEHBMWATERMARK, this member is ignored.
/// </para>
/// </summary>
public IntPtr hbmWatermark;
public HBITMAP hbmWatermark;
/// <summary>
/// Version 5.80 or later. HPALETTE structure used for drawing the watermark bitmap and/or header bitmap. If the dwFlags member does not include
/// PSH_USEHPLWATERMARK, this member is ignored.
/// Version 5.80 or later. HPALETTE structure used for drawing the watermark bitmap and/or header bitmap. If the dwFlags member
/// does not include PSH_USEHPLWATERMARK, this member is ignored.
/// </summary>
public IntPtr hplWatermark;
public HPALETTE hplWatermark;
/// <summary>
/// Version 5.80 or later. Handle to the header bitmap. If the dwFlags member does not include PSH_USEHBMHEADER, this member is ignored.
/// <para><c>OR</c></para>
/// <para>
/// Version 5.80 or later. Bitmap resource to use as the header. This member can specify either the identifier of the bitmap resource or the address
/// of the string that specifies the name of the bitmap resource. If the dwFlags member includes PSH_USEHBMHEADER, this member is ignored.
/// Version 5.80 or later. Bitmap resource to use as the header. This member can specify either the identifier of the bitmap
/// resource or the address of the string that specifies the name of the bitmap resource. If the dwFlags member includes
/// PSH_USEHBMHEADER, this member is ignored.
/// </para>
/// </summary>
public IntPtr hbmHeader;
public HBITMAP hbmHeader;
}
/// <summary>Defines a page in a property sheet.</summary>
@ -334,54 +637,67 @@ namespace Vanara.PInvoke
{
/// <summary>Size, in bytes, of this structure.</summary>
public uint dwSize;
/// <summary>Flags that indicate which options to use when creating the property sheet page.</summary>
public PropSheetFlags dwFlags;
/// <summary>
/// Handle to the instance from which to load an icon or string resource. If the pszIcon, pszTitle, pszHeaderTitle, or pszHeaderSubTitle member
/// identifies a resource to load, hInstance must be specified.
/// Handle to the instance from which to load an icon or string resource. If the pszIcon, pszTitle, pszHeaderTitle, or
/// pszHeaderSubTitle member identifies a resource to load, hInstance must be specified.
/// </summary>
public IntPtr hInstance;
public HINSTANCE hInstance;
/// <summary>
/// Dialog box template to use to create the page. This member can specify either the resource identifier of the template or the address of a string
/// that specifies the name of the template. If the PSP_DLGINDIRECT flag in the dwFlags member is set, pszTemplate is ignored. This member is
/// declared as a union with pResource.
/// Dialog box template to use to create the page. This member can specify either the resource identifier of the template or the
/// address of a string that specifies the name of the template. If the PSP_DLGINDIRECT flag in the dwFlags member is set,
/// pszTemplate is ignored. This member is declared as a union with pResource.
/// </summary>
private IntPtr _pszTemplate;
/// <summary>
/// Handle to the icon to use as the icon in the tab of the page. If the dwFlags member does not include PSP_USEHICON, this member is ignored. This
/// member is declared as a union with pszIcon.
/// Handle to the icon to use as the icon in the tab of the page. If the dwFlags member does not include PSP_USEHICON, this
/// member is ignored. This member is declared as a union with pszIcon.
/// <para><c>OR</c></para>
/// <para>
/// Icon resource to use as the icon in the tab of the page. This member can specify either the identifier of the icon resource or the address of the
/// string that specifies the name of the icon resource. To use this member, you must set the PSP_USEICONID flag in the dwFlags member. This member
/// is declared as a union with hIcon.
/// Icon resource to use as the icon in the tab of the page. This member can specify either the identifier of the icon resource
/// or the address of the string that specifies the name of the icon resource. To use this member, you must set the PSP_USEICONID
/// flag in the dwFlags member. This member is declared as a union with hIcon.
/// </para>
/// </summary>
private IntPtr _hIcon;
/// <summary>
/// Title of the property sheet dialog box. This title overrides the title specified in the dialog box template. This member can specify either the
/// identifier of a string resource or the address of a string that specifies the title. To use this member, you must set the PSP_USETITLE flag in
/// the dwFlags member.
/// Title of the property sheet dialog box. This title overrides the title specified in the dialog box template. This member can
/// specify either the identifier of a string resource or the address of a string that specifies the title. To use this member,
/// you must set the PSP_USETITLE flag in the dwFlags member.
/// </summary>
private IntPtr _pszTitle;
/// <summary>
/// Pointer to the dialog box procedure for the page. Because the pages are created as modeless dialog boxes, the dialog box procedure must not call
/// the EndDialog function.
/// Pointer to the dialog box procedure for the page. Because the pages are created as modeless dialog boxes, the dialog box
/// procedure must not call the EndDialog function.
/// </summary>
public DialogProc pfnDlgProc;
/// <summary>
/// When the page is created, a copy of the page's PROPSHEETPAGE structure is passed to the dialog box procedure with a WM_INITDIALOG message. The
/// lParam member is provided to allow you to pass application-specific information to the dialog box procedure. It has no effect on the page itself.
/// For more information, see Property Sheet Creation.
/// When the page is created, a copy of the page's PROPSHEETPAGE structure is passed to the dialog box procedure with a
/// WM_INITDIALOG message. The lParam member is provided to allow you to pass application-specific information to the dialog box
/// procedure. It has no effect on the page itself. For more information, see Property Sheet Creation.
/// </summary>
public IntPtr lParam;
/// <summary>
/// Pointer to an application-defined callback function that is called when the page is created and when it is about to be destroyed. For more
/// information about the callback function, see PropSheetPageProc. To use this member, you must set the PSP_USECALLBACK flag in the dwFlags member.
/// Pointer to an application-defined callback function that is called when the page is created and when it is about to be
/// destroyed. For more information about the callback function, see PropSheetPageProc. To use this member, you must set the
/// PSP_USECALLBACK flag in the dwFlags member.
/// </summary>
private PropSheetPageProc _pfnCallback;
/// <summary>Pointer to the reference count value. To use this member, you must set the PSP_USEREFPARENT flag in the dwFlags member.</summary>
/// <summary>
/// Pointer to the reference count value. To use this member, you must set the PSP_USEREFPARENT flag in the dwFlags member.
/// </summary>
private IntPtr _pcRefParent;
/// <summary>
/// Version 5.80 or later. Title of the header area. To use this member under the Wizard97-style wizard, you must also do the following:
/// <list type="bullet">
@ -397,6 +713,7 @@ namespace Vanara.PInvoke
/// </list>
/// </summary>
private IntPtr _pszHeaderTitle;
/// <summary>
/// Version 5.80 or later. Subtitle of the header area. To use this member, you must do the following:
/// <list type="bullet">
@ -413,21 +730,21 @@ namespace Vanara.PInvoke
/// <note>This member is ignored when using the Aero-style wizard (PSH_AEROWIZARD).</note>
/// </summary>
private IntPtr _pszHeaderSubTitle;
/// <summary>
/// Version 6.0 or later. An activation context handle. Set this member to the handle that is returned when you create the activation context with
/// CreateActCtx. The system will activate this context before creating the dialog box. You do not need to use this member if you use a global manifest.
/// Version 6.0 or later. An activation context handle. Set this member to the handle that is returned when you create the
/// activation context with CreateActCtx. The system will activate this context before creating the dialog box. You do not need
/// to use this member if you use a global manifest.
/// </summary>
public IntPtr hActCtx;
public HACTCTX hActCtx;
/// <summary>Initializes a new instance of the <see cref="PROPSHEETPAGE"/> class and sets the value of <see cref="dwSize"/>.</summary>
public PROPSHEETPAGE()
{
dwSize = (uint)Marshal.SizeOf(this);
}
public PROPSHEETPAGE() => dwSize = (uint)Marshal.SizeOf(this);
/// <summary>
/// Dialog box template to use to create the page. This member can specify either the resource identifier of the template or the address of a string
/// that specifies the name of the template. If the PSP_DLGINDIRECT flag in the dwFlags member is set, pszTemplate is ignored.
/// Dialog box template to use to create the page. This member can specify either the resource identifier of the template or the
/// address of a string that specifies the name of the template. If the PSP_DLGINDIRECT flag in the dwFlags member is set,
/// pszTemplate is ignored.
/// </summary>
public SafeResourceId pszTemplate
{
@ -457,7 +774,8 @@ namespace Vanara.PInvoke
}
/// <summary>
/// A handle to the icon to use as the small icon in the tab for the page. If dwFlags does not include the PSP_USEHICON value, this member is ignored.
/// A handle to the icon to use as the small icon in the tab for the page. If dwFlags does not include the PSP_USEHICON value,
/// this member is ignored.
/// </summary>
public IntPtr hIcon
{
@ -554,8 +872,9 @@ namespace Vanara.PInvoke
}
/// <summary>
/// Pointer to an application-defined callback function that is called when the page is created and when it is about to be destroyed. For more
/// information about the callback function, see PropSheetPageProc. To use this member, you must set the PSP_USECALLBACK flag in the dwFlags member.
/// Pointer to an application-defined callback function that is called when the page is created and when it is about to be
/// destroyed. For more information about the callback function, see PropSheetPageProc. To use this member, you must set the
/// PSP_USECALLBACK flag in the dwFlags member.
/// </summary>
public PropSheetPageProc pfnCallback
{
@ -567,7 +886,9 @@ namespace Vanara.PInvoke
}
}
/// <summary>Pointer to the reference count value. To use this member, you must set the PSP_USEREFPARENT flag in the dwFlags member.</summary>
/// <summary>
/// Pointer to the reference count value. To use this member, you must set the PSP_USEREFPARENT flag in the dwFlags member.
/// </summary>
public IntPtr pcRefParent
{
get => _pcRefParent;
@ -596,14 +917,23 @@ namespace Vanara.PInvoke
}
}
/// <summary>Provides a <see cref="SafeHandle"/> to a that releases a created HPROPSHEETPAGE instance at disposal using DestroyPropertySheetPage.</summary>
public class SafeHPROPSHEETPAGE : HPROPSHEETPAGE
/// <summary>Provides a <see cref="SafeHandle"/> to a that releases a created HPROPSHEETPAGE instance at disposal using DestroyPropertySheetPage.</summary>
public class SafeHPROPSHEETPAGE : HANDLE
{
/// <summary>Initializes a new instance of the <see cref="HPROPSHEETPAGE"/> class and assigns an existing handle.</summary>
/// <param name="preexistingHandle">An <see cref="IntPtr"/> object that represents the pre-existing handle to use.</param>
/// <param name="ownsHandle"><see langword="true"/> to reliably release the handle during the finalization phase; otherwise, <see langword="false"/> (not recommended).</param>
/// <param name="ownsHandle">
/// <see langword="true"/> to reliably release the handle during the finalization phase; otherwise, <see langword="false"/> (not recommended).
/// </param>
public SafeHPROPSHEETPAGE(IntPtr preexistingHandle, bool ownsHandle = true) : base(preexistingHandle, ownsHandle) { }
private SafeHPROPSHEETPAGE() : base() { }
/// <summary>Performs an implicit conversion from <see cref="SafeHPROPSHEETPAGE"/> to <see cref="HPROPSHEETPAGE"/>.</summary>
/// <param name="h">The safe handle instance.</param>
/// <returns>The result of the conversion.</returns>
public static implicit operator HPROPSHEETPAGE(SafeHPROPSHEETPAGE h) => h.handle;
/// <inheritdoc/>
protected override bool InternalReleaseHandle() => DestroyPropertySheetPage(this);
}

View File

@ -1,11 +1,5 @@
using System;
using System.Runtime.InteropServices;
using static Vanara.PInvoke.Gdi32;
using static Vanara.PInvoke.Kernel32;
// ReSharper disable InconsistentNaming
// ReSharper disable FieldCanBeMadeReadOnly.Global
// ReSharper disable InconsistentNaming
namespace Vanara.PInvoke
{
@ -17,39 +11,46 @@ namespace Vanara.PInvoke
{
/// <summary>Prevents borders from being drawn around the specified text.</summary>
SBT_NOBORDERS = 0x0100,
/// <summary>Draws highlighted borders that make the text stand out.</summary>
SBT_POPOUT = 0x0200,
/// <summary>Indicates that the string pointed to by pszText will be displayed in the opposite direction to the text in the parent window.</summary>
/// <summary>
/// Indicates that the string pointed to by pszText will be displayed in the opposite direction to the text in the parent window.
/// </summary>
SBT_RTLREADING = 0x0400,
/// <summary>Tab characters are ignored.</summary>
SBT_NOTABPARSING = 0x0800,
/// <summary>The text is drawn by the parent window.</summary>
SBT_OWNERDRAW = 0x1000,
}
/// <summary>The <c>DrawStatusText</c> function draws the specified text in the style of a status window with borders.</summary>
/// <param name="hdc">
/// <para>Type: <c><c>HDC</c></c></para>
/// <summary>
/// <para>The <c>DrawStatusText</c> function draws the specified text in the style of a status window with borders.</para>
/// </summary>
/// <param name="hDC">
/// <para>Type: <c>HDC</c></para>
/// <para>Handle to the display context for the window.</para>
/// </param>
/// <param name="lprc">
/// <para>Type: <c>LPCRECT</c></para>
/// <para>
/// Pointer to a <c>RECT</c> structure that contains the position, in client coordinates, of the rectangle in which the text is drawn. The function draws
/// the borders just inside the edges of the specified rectangle.
/// Pointer to a RECT structure that contains the position, in client coordinates, of the rectangle in which the text is drawn. The
/// function draws the borders just inside the edges of the specified rectangle.
/// </para>
/// </param>
/// <param name="pszText">
/// <para>Type: <c><c>LPCTSTR</c></c></para>
/// <para>Type: <c>LPCTSTR</c></para>
/// <para>
/// Pointer to a null-terminated string that specifies the text to display. Tab characters in the string determine whether the string is left-aligned,
/// right-aligned, or centered.
/// Pointer to a null-terminated string that specifies the text to display. Tab characters in the string determine whether the string
/// is left-aligned, right-aligned, or centered.
/// </para>
/// </param>
/// <param name="uFlags">
/// <para>Type: <c><c>UINT</c></c></para>
/// <para>Type: <c>UINT</c></para>
/// <para>Text drawing flags. This parameter can be a combination of these values:</para>
/// <para>
/// <list type="table">
/// <listheader>
/// <term>Value</term>
@ -65,20 +66,31 @@ namespace Vanara.PInvoke
/// </item>
/// <item>
/// <term>SBT_RTLREADING</term>
/// <term>Indicates that the string pointed to by pszText will be displayed in the opposite direction to the text in the parent window.</term>
/// <term>
/// Indicates that the string pointed to by pszText will be displayed in the opposite direction to the text in the parent window.
/// </term>
/// </item>
/// </list>
/// </para>
/// </param>
/// <returns>This function does not return a value.</returns>
// void DrawStatusText( HDC hdc, LPCRECT lprc, LPCTSTR pszText, UINT uFlags);
// https://msdn.microsoft.com/en-us/library/windows/desktop/bb760763(v=vs.85).aspx
/// <returns>
/// <para>This function does not return a value.</para>
/// </returns>
/// <remarks>
/// <para>
/// Normal windows display text left-to-right (LTR). Windows can be mirrored to display languages such as Hebrew or Arabic that read
/// right-to-left (RTL). Normally, the pszText string will be displayed in the same direction as the text in its parent window. If
/// SBT_RTLREADING is set, the pszText string will read in the opposite direction from the text in the parent window.
/// </para>
/// </remarks>
// https://docs.microsoft.com/en-us/windows/desktop/api/commctrl/nf-commctrl-drawstatustexta
// void DrawStatusTextA( HDC hDC, LPCRECT lprc, LPCSTR pszText, UINT uFlags );
[DllImport(Lib.ComCtl32, SetLastError = false, CharSet = CharSet.Auto)]
[PInvokeData("Commctrl.h", MSDNShortId = "bb760763")]
public static extern void DrawStatusText(HDC hdc, ref RECT lprc, string pszText, SBT uFlags);
public static extern void DrawStatusText(HDC hdc, in RECT lprc, string pszText, SBT uFlags);
/// <summary>
/// Processes <c>WM_MENUSELECT</c> and <c>WM_COMMAND</c> messages and displays Help text about the current menu in the specified status window.
/// Processes <c>WM_MENUSELECT</c> and <c>WM_COMMAND</c> messages and displays Help text about the current menu in the specified
/// status window.
/// </summary>
/// <param name="uMsg">
/// <para>Type: <c><c>UINT</c></c></para>
@ -107,13 +119,12 @@ namespace Vanara.PInvoke
/// <param name="lpwIDs">
/// <para>Type: <c>LPUINT</c></para>
/// <para>
/// Pointer to an array of values that contains pairs of string resource identifiers and menu handles. The function searches the array for the handle to
/// the selected menu and, if found, uses the corresponding resource identifier to load the appropriate Help string.
/// Pointer to an array of values that contains pairs of string resource identifiers and menu handles. The function searches the
/// array for the handle to the selected menu and, if found, uses the corresponding resource identifier to load the appropriate Help string.
/// </para>
/// </param>
/// <returns>No return value.</returns>
// void MenuHelp( UINT uMsg, WPARAM wParam, LPARAM lParam, HMENU hMainMenu, HINSTANCE hInst, HWND hwndStatus, LPUINT lpwIDs);
// https://msdn.microsoft.com/en-us/library/windows/desktop/bb760765(v=vs.85).aspx
// void MenuHelp( UINT uMsg, WPARAM wParam, LPARAM lParam, HMENU hMainMenu, HINSTANCE hInst, HWND hwndStatus, LPUINT lpwIDs); https://msdn.microsoft.com/en-us/library/windows/desktop/bb760765(v=vs.85).aspx
[DllImport(Lib.ComCtl32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("Commctrl.h", MSDNShortId = "bb760765")]
public static extern void MenuHelp(uint uMsg, IntPtr wParam, IntPtr lParam, HMENU hMainMenu, HINSTANCE hInst, HWND hwndStatus, IntPtr lpwIDs);

View File

@ -2,8 +2,7 @@ using System;
using System.Drawing;
using System.Runtime.InteropServices;
using Vanara.Extensions;
// ReSharper disable FieldCanBeMadeReadOnly.Global
// ReSharper disable InconsistentNaming
using Vanara.InteropServices;
namespace Vanara.PInvoke
{
@ -19,11 +18,17 @@ namespace Vanara.PInvoke
{
/// <summary>The position is not over a tab.</summary>
TCHT_NOWHERE = 0x0001,
/// <summary>The position is over a tab's icon.</summary>
TCHT_ONITEMICON = 0x0002,
/// <summary>The position is over a tab's text.</summary>
TCHT_ONITEMLABEL = 0x0004,
/// <summary>The position is over a tab but not over its icon or its text. For owner-drawn tab controls, this value is specified if the position is anywhere over a tab.</summary>
/// <summary>
/// The position is over a tab but not over its icon or its text. For owner-drawn tab controls, this value is specified if the
/// position is anywhere over a tab.
/// </summary>
TCHT_ONITEM = TCHT_ONITEMICON | TCHT_ONITEMLABEL,
}
@ -34,29 +39,42 @@ namespace Vanara.PInvoke
{
/// <summary>The pszText member is valid.</summary>
TCIF_TEXT = 0x0001,
/// <summary>The iImage member is valid.</summary>
TCIF_IMAGE = 0x0002,
/// <summary>The string pointed to by pszText will be displayed in the direction opposite to the text in the parent window.</summary>
TCIF_RTLREADING = 0x0004,
/// <summary>The lParam member is valid.</summary>
TCIF_PARAM = 0x0008,
/// <summary>Version 4.70. The dwState member is valid.</summary>
TCIF_STATE = 0x0010,
/// <summary>All members are valid.</summary>
TCIF_ALL = 0x001B,
}
/// <summary>
/// Tab control items now support an item state to support the TCM_DESELECTALL message. Additionally, the TCITEM structure supports item state values.
/// Tab control items now support an item state to support the TCM_DESELECTALL message. Additionally, the TCITEM structure supports
/// item state values.
/// </summary>
[PInvokeData("Commctrl.h", MSDNShortId = "bb760547")]
[Flags]
public enum TabControlItemStates
{
/// <summary>Version 4.70. The tab control item is selected. This state is only meaningful if the TCS_BUTTONS style flag has been set.</summary>
/// <summary>
/// Version 4.70. The tab control item is selected. This state is only meaningful if the TCS_BUTTONS style flag has been set.
/// </summary>
TCIS_BUTTONPRESSED = 0x0001,
/// <summary>Version 4.71. The tab control item is highlighted, and the tab and text are drawn using the current highlight color. When using high-color, this will be a true interpolation, not a dithered color.</summary>
/// <summary>
/// Version 4.71. The tab control item is highlighted, and the tab and text are drawn using the current highlight color. When
/// using high-color, this will be a true interpolation, not a dithered color.
/// </summary>
TCIS_HIGHLIGHTED = 0x0002,
/// <summary>Look at all states.</summary>
TCIS_ALL
}
@ -112,75 +130,161 @@ namespace Vanara.PInvoke
{
/// <summary>Version 4.70. Unneeded tabs scroll to the opposite side of the control when a tab is selected.</summary>
TCS_SCROLLOPPOSITE = 0x0001,
/// <summary>Version 4.70. Tabs appear at the bottom of the control. This value equals TCS_RIGHT. This style is not supported if you use ComCtl32.dll version 6.</summary>
/// <summary>
/// Version 4.70. Tabs appear at the bottom of the control. This value equals TCS_RIGHT. This style is not supported if you use
/// ComCtl32.dll version 6.
/// </summary>
TCS_BOTTOM = 0x0002,
/// <summary>Version 4.70. Tabs appear vertically on the right side of controls that use the TCS_VERTICAL style. This value equals TCS_BOTTOM. This style is not supported if you use visual styles.</summary>
/// <summary>
/// Version 4.70. Tabs appear vertically on the right side of controls that use the TCS_VERTICAL style. This value equals
/// TCS_BOTTOM. This style is not supported if you use visual styles.
/// </summary>
TCS_RIGHT = 0x0002,
/// <summary>Version 4.70. Multiple tabs can be selected by holding down the CTRL key when clicking. This style must be used with the TCS_BUTTONS style.</summary>
/// <summary>
/// Version 4.70. Multiple tabs can be selected by holding down the CTRL key when clicking. This style must be used with the
/// TCS_BUTTONS style.
/// </summary>
TCS_MULTISELECT = 0x0004,
/// <summary>Version 4.71. Selected tabs appear as being indented into the background while other tabs appear as being on the same plane as the background. This style only affects tab controls with the TCS_BUTTONS style.</summary>
/// <summary>
/// Version 4.71. Selected tabs appear as being indented into the background while other tabs appear as being on the same plane
/// as the background. This style only affects tab controls with the TCS_BUTTONS style.
/// </summary>
TCS_FLATBUTTONS = 0x0008,
/// <summary>Icons are aligned with the left edge of each fixed-width tab. This style can only be used with the TCS_FIXEDWIDTH style.</summary>
/// <summary>
/// Icons are aligned with the left edge of each fixed-width tab. This style can only be used with the TCS_FIXEDWIDTH style.
/// </summary>
TCS_FORCEICONLEFT = 0x0010,
/// <summary>Labels are aligned with the left edge of each fixed-width tab; that is, the label is displayed immediately to the right of the icon instead of being centered. This style can only be used with the TCS_FIXEDWIDTH style, and it implies the TCS_FORCEICONLEFT style.</summary>
/// <summary>
/// Labels are aligned with the left edge of each fixed-width tab; that is, the label is displayed immediately to the right of
/// the icon instead of being centered. This style can only be used with the TCS_FIXEDWIDTH style, and it implies the
/// TCS_FORCEICONLEFT style.
/// </summary>
TCS_FORCELABELLEFT = 0x0020,
/// <summary>Version 4.70. Items under the pointer are automatically highlighted. You can check whether hot tracking is enabled by calling SystemParametersInfo.</summary>
/// <summary>
/// Version 4.70. Items under the pointer are automatically highlighted. You can check whether hot tracking is enabled by calling SystemParametersInfo.
/// </summary>
TCS_HOTTRACK = 0x0040,
/// <summary>Version 4.70. Tabs appear at the left side of the control, with tab text displayed vertically. This style is valid only when used with the TCS_MULTILINE style. To make tabs appear on the right side of the control, also use the TCS_RIGHT style. This style is not supported if you use ComCtl32.dll version 6.</summary>
/// <summary>
/// Version 4.70. Tabs appear at the left side of the control, with tab text displayed vertically. This style is valid only when
/// used with the TCS_MULTILINE style. To make tabs appear on the right side of the control, also use the TCS_RIGHT style. This
/// style is not supported if you use ComCtl32.dll version 6.
/// </summary>
TCS_VERTICAL = 0x0080,
/// <summary>Tabs appear as tabs, and a border is drawn around the display area. This style is the default.</summary>
TCS_TABS = 0x0000,
/// <summary>Tabs appear as buttons, and no border is drawn around the display area.</summary>
TCS_BUTTONS = 0x0100,
/// <summary>Only one row of tabs is displayed. The user can scroll to see more tabs, if necessary. This style is the default.</summary>
TCS_SINGLELINE = 0x0000,
/// <summary>Multiple rows of tabs are displayed, if necessary, so all tabs are visible at once.</summary>
TCS_MULTILINE = 0x0200,
/// <summary>The width of each tab is increased, if necessary, so that each row of tabs fills the entire width of the tab control. This window style is ignored unless the TCS_MULTILINE style is also specified.</summary>
/// <summary>
/// The width of each tab is increased, if necessary, so that each row of tabs fills the entire width of the tab control. This
/// window style is ignored unless the TCS_MULTILINE style is also specified.
/// </summary>
TCS_RIGHTJUSTIFY = 0x0000,
/// <summary>All tabs are the same width. This style cannot be combined with the TCS_RIGHTJUSTIFY style.</summary>
TCS_FIXEDWIDTH = 0x0400,
/// <summary>Rows of tabs will not be stretched to fill the entire width of the control. This style is the default.</summary>
TCS_RAGGEDRIGHT = 0x0800,
/// <summary>The tab control receives the input focus when clicked.</summary>
TCS_FOCUSONBUTTONDOWN = 0x1000,
/// <summary>The parent window is responsible for drawing tabs.</summary>
TCS_OWNERDRAWFIXED = 0x2000,
/// <summary>The tab control has a tooltip control associated with it.</summary>
TCS_TOOLTIPS = 0x4000,
/// <summary>The tab control does not receive the input focus when clicked.</summary>
TCS_FOCUSNEVER = 0x8000,
}
/// <summary>
/// The tab control now supports extended styles. These styles are manipulated using the TCM_GETEXTENDEDSTYLE and TCM_SETEXTENDEDSTYLE messages and should not be confused with extended window styles that are passed to CreateWindowEx.
/// The tab control now supports extended styles. These styles are manipulated using the TCM_GETEXTENDEDSTYLE and
/// TCM_SETEXTENDEDSTYLE messages and should not be confused with extended window styles that are passed to CreateWindowEx.
/// </summary>
[PInvokeData("Commctrl.h", MSDNShortId = "bb760546")]
[Flags]
public enum TabControlStylesEx
{
/// <summary>Version 4.71. The tab control will draw separators between the tab items. This extended style only affects tab controls that have the TCS_BUTTONS and TCS_FLATBUTTONS styles. By default, creating the tab control with the TCS_FLATBUTTONS style sets this extended style. If you do not require separators, you should remove this extended style after creating the control.</summary>
/// <summary>
/// Version 4.71. The tab control will draw separators between the tab items. This extended style only affects tab controls that
/// have the TCS_BUTTONS and TCS_FLATBUTTONS styles. By default, creating the tab control with the TCS_FLATBUTTONS style sets
/// this extended style. If you do not require separators, you should remove this extended style after creating the control.
/// </summary>
TCS_EX_FLATSEPARATORS = 0x00000001,
/// <summary>Version 4.71. The tab control generates TCN_GETOBJECT notification codes to request a drop target object when an object is dragged over the tab items in the control. The application must call CoInitialize or OleInitialize before setting this style.</summary>
/// <summary>
/// Version 4.71. The tab control generates TCN_GETOBJECT notification codes to request a drop target object when an object is
/// dragged over the tab items in the control. The application must call CoInitialize or OleInitialize before setting this style.
/// </summary>
TCS_EX_REGISTERDROP = 0x00000002
}
/// <summary>
/// Contains information about a hit test. This structure supersedes the TC_HITTESTINFO structure.
/// Sends the specified message to a window or windows. The SendMessage function calls the window procedure for the specified window
/// and does not return until the window procedure has processed the message.
/// </summary>
/// <param name="hWnd">
/// A handle to the window whose window procedure will receive the message. If this parameter is HWND_BROADCAST ((HWND)0xffff), the
/// message is sent to all top-level windows in the system, including disabled or invisible unowned windows, overlapped windows, and
/// pop-up windows; but the message is not sent to child windows.
/// </param>
/// <param name="Msg">The message to be sent.</param>
/// <param name="wParam">Additional message-specific information.</param>
/// <param name="splitInfo">Additional message-specific information.</param>
/// <returns>The return value specifies the result of the message processing; it depends on the message sent.</returns>
[DllImport(Lib.User32, SetLastError = false, CharSet = CharSet.Auto)]
public static extern IntPtr SendMessage(HWND hWnd, TabControlMessage Msg, int wParam, ref TCHITTESTINFO item);
/// <summary>
/// Sends the specified message to a window or windows. The SendMessage function calls the window procedure for the specified window
/// and does not return until the window procedure has processed the message.
/// </summary>
/// <param name="hWnd">
/// A handle to the window whose window procedure will receive the message. If this parameter is HWND_BROADCAST ((HWND)0xffff), the
/// message is sent to all top-level windows in the system, including disabled or invisible unowned windows, overlapped windows, and
/// pop-up windows; but the message is not sent to child windows.
/// </param>
/// <param name="Msg">The message to be sent.</param>
/// <param name="wParam">Additional message-specific information.</param>
/// <param name="splitInfo">Additional message-specific information.</param>
/// <returns>The return value specifies the result of the message processing; it depends on the message sent.</returns>
[DllImport(Lib.User32, SetLastError = false, CharSet = CharSet.Auto)]
public static extern IntPtr SendMessage(HWND hWnd, TabControlMessage Msg, int wParam, TCITEM item);
/// <summary>Contains information about a hit test. This structure supersedes the TC_HITTESTINFO structure.</summary>
[PInvokeData("Commctrl.h", MSDNShortId = "bb760553")]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct TCHITTESTINFO
{
/// <summary>Position to hit test, in client coordinates.</summary>
public Point pt;
/// <summary>Variable that receives the results of a hit test. The tab control sets this member to one of the following values:</summary>
public TabControlHitTestFlags flags;
}
/// <summary>
/// Specifies or receives the attributes of a tab item. It is used with the TCM_INSERTITEM, TCM_GETITEM, and TCM_SETITEM messages. This structure
/// supersedes the TC_ITEM structure.
/// Specifies or receives the attributes of a tab item. It is used with the TCM_INSERTITEM, TCM_GETITEM, and TCM_SETITEM messages.
/// This structure supersedes the TC_ITEM structure.
/// </summary>
/// <seealso cref="System.IDisposable"/>
[PInvokeData("Commctrl.h", MSDNShortId = "bb760554")]
@ -189,37 +293,59 @@ namespace Vanara.PInvoke
{
/// <summary>Value that specifies which members to retrieve or set.</summary>
public TabControlItemMask mask;
/// <summary>Version 4.70. Specifies the item's current state if information is being retrieved. If item information is being set, this member contains the state value to be set for the item. For a list of valid tab control item states, see Tab Control Item States. This member is ignored in the TCM_INSERTITEM message.</summary>
/// <summary>
/// Version 4.70. Specifies the item's current state if information is being retrieved. If item information is being set, this
/// member contains the state value to be set for the item. For a list of valid tab control item states, see Tab Control Item
/// States. This member is ignored in the TCM_INSERTITEM message.
/// </summary>
public TabControlItemStates dwState;
/// <summary>Version 4.70. Specifies which bits of the dwState member contain valid information. This member is ignored in the TCM_INSERTITEM message.</summary>
/// <summary>
/// Version 4.70. Specifies which bits of the dwState member contain valid information. This member is ignored in the
/// TCM_INSERTITEM message.
/// </summary>
public TabControlItemStates dwStateMask;
/// <summary>Pointer to a null-terminated string that contains the tab text when item information is being set. If item information is being retrieved, this member specifies the address of the buffer that receives the tab text.</summary>
public IntPtr pszText;
/// <summary>Size in TCHARs of the buffer pointed to by the pszText member. If the structure is not receiving information, this member is ignored.</summary>
/// <summary>
/// Pointer to a null-terminated string that contains the tab text when item information is being set. If item information is
/// being retrieved, this member specifies the address of the buffer that receives the tab text.
/// </summary>
public StrPtrAuto pszText;
/// <summary>
/// Size in TCHARs of the buffer pointed to by the pszText member. If the structure is not receiving information, this member is ignored.
/// </summary>
public uint cchTextMax;
/// <summary>Index in the tab control's image list, or -1 if there is no image for the tab.</summary>
public int iImage;
/// <summary>Application-defined data associated with the tab control item. If more or less than 4 bytes of application-defined data exist per tab, an application must define a structure and use it instead of the TCITEM structure. The first member of the application-defined structure must be a TCITEMHEADER structure.</summary>
/// <summary>
/// Application-defined data associated with the tab control item. If more or less than 4 bytes of application-defined data exist
/// per tab, an application must define a structure and use it instead of the TCITEM structure. The first member of the
/// application-defined structure must be a TCITEMHEADER structure.
/// </summary>
public IntPtr lParam;
/// <summary>Initializes a new instance of the <see cref="TCITEM"/> class.</summary>
public TCITEM(TabControlItemMask itemsToGet = TabControlItemMask.TCIF_ALL, TabControlItemStates statesToGet = TabControlItemStates.TCIS_ALL)
{
if ((itemsToGet & TabControlItemMask.TCIF_TEXT) != 0) pszText = StringHelper.AllocChars(cchTextMax = 1024);
if ((itemsToGet & TabControlItemMask.TCIF_TEXT) != 0) pszText = new StrPtrAuto(cchTextMax = 1024);
}
/// <summary>Initializes a new instance of the <see cref="TCITEM"/> class.</summary>
/// <param name="text">The text.</param>
public TCITEM(string text) { Text = text; }
public TCITEM(string text) => Text = text;
/// <summary>Gets or sets the text.</summary>
/// <value>The text.</value>
public string Text
{
get => Marshal.PtrToStringAuto(pszText);
get => pszText.ToString();
set
{
StringHelper.RefreshString(ref pszText, out cchTextMax, value);
pszText.Assign(value, out cchTextMax);
mask |= TabControlItemMask.TCIF_TEXT;
}
}
@ -227,14 +353,14 @@ namespace Vanara.PInvoke
/// <summary>Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.</summary>
void IDisposable.Dispose()
{
StringHelper.FreeString(pszText);
pszText.Free();
cchTextMax = 0;
}
}
/// <summary>
/// Specifies or receives the attributes of a tab. It is used with the TCM_INSERTITEM, TCM_GETITEM, and TCM_SETITEM messages. This structure supersedes
/// the TC_ITEMHEADER structure.
/// Specifies or receives the attributes of a tab. It is used with the TCM_INSERTITEM, TCM_GETITEM, and TCM_SETITEM messages. This
/// structure supersedes the TC_ITEMHEADER structure.
/// </summary>
/// <seealso cref="System.IDisposable"/>
[PInvokeData("Commctrl.h", MSDNShortId = "bb760813")]
@ -243,35 +369,52 @@ namespace Vanara.PInvoke
{
/// <summary>Value that specifies which members to retrieve or set.</summary>
public TabControlItemMask mask;
/// <summary>Version 4.70. Specifies the item's current state if information is being retrieved. If item information is being set, this member contains the state value to be set for the item. For a list of valid tab control item states, see Tab Control Item States. This member is ignored in the TCM_INSERTITEM message.</summary>
/// <summary>
/// Version 4.70. Specifies the item's current state if information is being retrieved. If item information is being set, this
/// member contains the state value to be set for the item. For a list of valid tab control item states, see Tab Control Item
/// States. This member is ignored in the TCM_INSERTITEM message.
/// </summary>
public TabControlItemStates dwState;
/// <summary>Version 4.70. Specifies which bits of the dwState member contain valid information. This member is ignored in the TCM_INSERTITEM message.</summary>
/// <summary>
/// Version 4.70. Specifies which bits of the dwState member contain valid information. This member is ignored in the
/// TCM_INSERTITEM message.
/// </summary>
public TabControlItemStates dwStateMask;
/// <summary>Pointer to a null-terminated string that contains the tab text when item information is being set. If item information is being retrieved, this member specifies the address of the buffer that receives the tab text.</summary>
public IntPtr pszText;
/// <summary>Size in TCHARs of the buffer pointed to by the pszText member. If the structure is not receiving information, this member is ignored.</summary>
/// <summary>
/// Pointer to a null-terminated string that contains the tab text when item information is being set. If item information is
/// being retrieved, this member specifies the address of the buffer that receives the tab text.
/// </summary>
public StrPtrAuto pszText;
/// <summary>
/// Size in TCHARs of the buffer pointed to by the pszText member. If the structure is not receiving information, this member is ignored.
/// </summary>
public uint cchTextMax;
/// <summary>Index in the tab control's image list, or -1 if there is no image for the tab.</summary>
public int iImage;
/// <summary>Initializes a new instance of the <see cref="TCITEM"/> class.</summary>
public TCITEMHEADER(TabControlItemMask itemsToGet = TabControlItemMask.TCIF_ALL, TabControlItemStates statesToGet = TabControlItemStates.TCIS_ALL)
{
if ((itemsToGet & TabControlItemMask.TCIF_TEXT) != 0) pszText = StringHelper.AllocChars(cchTextMax = 1024);
if ((itemsToGet & TabControlItemMask.TCIF_TEXT) != 0) pszText = new StrPtrAuto(cchTextMax = 1024);
}
/// <summary>Initializes a new instance of the <see cref="TCITEM"/> class.</summary>
/// <param name="text">The text.</param>
public TCITEMHEADER(string text) { Text = text; }
public TCITEMHEADER(string text) => Text = text;
/// <summary>Gets or sets the text.</summary>
/// <value>The text.</value>
public string Text
{
get => Marshal.PtrToStringAuto(pszText);
get =>pszText.ToString();
set
{
StringHelper.RefreshString(ref pszText, out cchTextMax, value);
pszText.Assign(value, out cchTextMax);
mask |= TabControlItemMask.TCIF_TEXT;
}
}
@ -279,29 +422,9 @@ namespace Vanara.PInvoke
/// <summary>Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.</summary>
void IDisposable.Dispose()
{
StringHelper.FreeString(pszText);
pszText.Free();
cchTextMax = 0;
}
}
/// <summary>
/// Sends the specified message to a window or windows. The SendMessage function calls the window procedure for the specified window and does not return until the window procedure has processed the message.
/// </summary>
/// <param name="hWnd">A handle to the window whose window procedure will receive the message. If this parameter is HWND_BROADCAST ((HWND)0xffff), the message is sent to all top-level windows in the system, including disabled or invisible unowned windows, overlapped windows, and pop-up windows; but the message is not sent to child windows.</param>
/// <param name="Msg">The message to be sent.</param>
/// <param name="wParam">Additional message-specific information.</param>
/// <param name="item">Additional message-specific information.</param>
/// <returns>The return value specifies the result of the message processing; it depends on the message sent.</returns>
public static IntPtr SendMessage(HWND hWnd, TabControlMessage Msg, int wParam, ref TCHITTESTINFO item) => User32_Gdi.SendMessage(hWnd, Msg, wParam, ref item);
/// <summary>
/// Sends the specified message to a window or windows. The SendMessage function calls the window procedure for the specified window and does not return until the window procedure has processed the message.
/// </summary>
/// <param name="hWnd">A handle to the window whose window procedure will receive the message. If this parameter is HWND_BROADCAST ((HWND)0xffff), the message is sent to all top-level windows in the system, including disabled or invisible unowned windows, overlapped windows, and pop-up windows; but the message is not sent to child windows.</param>
/// <param name="Msg">The message to be sent.</param>
/// <param name="wParam">Additional message-specific information.</param>
/// <param name="item">Additional message-specific information.</param>
/// <returns>The return value specifies the result of the message processing; it depends on the message sent.</returns>
public static IntPtr SendMessage(HWND hWnd, TabControlMessage Msg, int wParam, TCITEM item) => User32_Gdi.SendMessage(hWnd, Msg, wParam, item);
}
}

View File

@ -2,13 +2,8 @@ using System;
using System.Diagnostics.CodeAnalysis;
using System.Runtime.InteropServices;
using Vanara.Extensions;
using static Vanara.PInvoke.Kernel32;
using static Vanara.PInvoke.Macros;
using static Vanara.PInvoke.User32_Gdi;
// ReSharper disable InconsistentNaming
// ReSharper disable FieldCanBeMadeReadOnly.Global
namespace Vanara.PInvoke
{
public static partial class ComCtl32
@ -22,9 +17,13 @@ namespace Vanara.PInvoke
/// <returns>A HRESULT value. The return value is specific to the message being processed.</returns>
[PInvokeData("Commctrl.h", MSDNShortId = "bb760542")]
[UnmanagedFunctionPointer(CallingConvention.Winapi)]
public delegate HRESULT TaskDialogCallbackProc([In] IntPtr hwnd, [In] TaskDialogNotification msg, [In] IntPtr wParam, [In] IntPtr lParam, [In] IntPtr refData);
public delegate HRESULT TaskDialogCallbackProc([In] HWND hwnd, [In] TaskDialogNotification msg, [In] IntPtr wParam, [In] IntPtr lParam, [In] IntPtr refData);
/// <summary>Specifies the push buttons displayed in the task dialog. If no common buttons are specified and no custom buttons are specified using the cButtons and pButtons members, the task dialog will contain the OK button by default. This parameter may be a combination of flags</summary>
/// <summary>
/// Specifies the push buttons displayed in the task dialog. If no common buttons are specified and no custom buttons are specified
/// using the cButtons and pButtons members, the task dialog will contain the OK button by default. This parameter may be a
/// combination of flags
/// </summary>
[PInvokeData("Commctrl.h", MSDNShortId = "bb760540")]
[Flags]
public enum TASKDIALOG_COMMON_BUTTON_FLAGS
@ -39,7 +38,8 @@ namespace Vanara.PInvoke
TDCBF_NO_BUTTON = 0x0004,
/// <summary>
/// The task dialog contains the push button: Cancel. If this button is specified, the task dialog will respond to typical cancel actions (Alt-F4 and Escape).
/// The task dialog contains the push button: Cancel. If this button is specified, the task dialog will respond to typical cancel
/// actions (Alt-F4 and Escape).
/// </summary>
TDCBF_CANCEL_BUTTON = 0x0008,
@ -72,34 +72,68 @@ namespace Vanara.PInvoke
[Flags]
public enum TASKDIALOG_FLAGS
{
/// <summary>Enables hyperlink processing for the strings specified in the pszContent, pszExpandedInformation and pszFooter members. When enabled, these members may point to strings that contain hyperlinks in the following form:
/// <code><![CDATA[<A HREF = "executablestring" > Hyperlink Text</A>]]></code>
/// <note type="warning">Enabling hyperlinks when using content from an unsafe source may cause security vulnerabilities.</note>
/// <note>Task Dialogs will not actually execute any hyperlinks.Hyperlink execution must be handled in the callback function specified by pfCallback.For more details, see TaskDialogCallbackProc.</note></summary>
/// <summary>
/// Enables hyperlink processing for the strings specified in the pszContent, pszExpandedInformation and pszFooter members. When
/// enabled, these members may point to strings that contain hyperlinks in the following form:
/// <code>
/// <![CDATA[<A HREF = "executablestring" > Hyperlink Text</A>]]>
/// </code>
/// <note type="warning">Enabling hyperlinks when using content from an unsafe source may cause security
/// vulnerabilities.</note><note>Task Dialogs will not actually execute any hyperlinks.Hyperlink execution must be handled in the
/// callback function specified by pfCallback.For more details, see TaskDialogCallbackProc.</note>
/// </summary>
TDF_ENABLE_HYPERLINKS = 0x0001,
/// <summary>Indicates that the dialog should use the icon referenced by the handle in the hMainIcon member as the primary icon in the task dialog. If this flag is specified, the pszMainIcon member is ignored.</summary>
/// <summary>
/// Indicates that the dialog should use the icon referenced by the handle in the hMainIcon member as the primary icon in the
/// task dialog. If this flag is specified, the pszMainIcon member is ignored.
/// </summary>
TDF_USE_HICON_MAIN = 0x0002,
/// <summary>Indicates that the dialog should use the icon referenced by the handle in the hFooterIcon member as the footer icon in the task dialog. If this flag is specified, the pszFooterIcon member is ignored.</summary>
/// <summary>
/// Indicates that the dialog should use the icon referenced by the handle in the hFooterIcon member as the footer icon in the
/// task dialog. If this flag is specified, the pszFooterIcon member is ignored.
/// </summary>
TDF_USE_HICON_FOOTER = 0x0004,
/// <summary>Indicates that the dialog should be able to be closed using Alt-F4, Escape, and the title bar's close button even if no cancel button is specified in either the dwCommonButtons or pButtons members.</summary>
/// <summary>
/// Indicates that the dialog should be able to be closed using Alt-F4, Escape, and the title bar's close button even if no
/// cancel button is specified in either the dwCommonButtons or pButtons members.
/// </summary>
TDF_ALLOW_DIALOG_CANCELLATION = 0x0008,
/// <summary>Indicates that the buttons specified in the pButtons member are to be displayed as command links (using a standard task dialog glyph) instead of push buttons. When using command links, all characters up to the first new line character in the pszButtonText member will be treated as the command link's main text, and the remainder will be treated as the command link's note. This flag is ignored if the cButtons member is zero.</summary>
/// <summary>
/// Indicates that the buttons specified in the pButtons member are to be displayed as command links (using a standard task
/// dialog glyph) instead of push buttons. When using command links, all characters up to the first new line character in the
/// pszButtonText member will be treated as the command link's main text, and the remainder will be treated as the command link's
/// note. This flag is ignored if the cButtons member is zero.
/// </summary>
TDF_USE_COMMAND_LINKS = 0x0010,
/// <summary>Indicates that the buttons specified in the pButtons member are to be displayed as command links (without a glyph) instead of push buttons. When using command links, all characters up to the first new line character in the pszButtonText member will be treated as the command link's main text, and the remainder will be treated as the command link's note. This flag is ignored if the cButtons member is zero.</summary>
/// <summary>
/// Indicates that the buttons specified in the pButtons member are to be displayed as command links (without a glyph) instead of
/// push buttons. When using command links, all characters up to the first new line character in the pszButtonText member will be
/// treated as the command link's main text, and the remainder will be treated as the command link's note. This flag is ignored
/// if the cButtons member is zero.
/// </summary>
TDF_USE_COMMAND_LINKS_NO_ICON = 0x0020,
/// <summary>Indicates that the string specified by the pszExpandedInformation member is displayed at the bottom of the dialog's footer area instead of immediately after the dialog's content. This flag is ignored if the pszExpandedInformation member is NULL.</summary>
/// <summary>
/// Indicates that the string specified by the pszExpandedInformation member is displayed at the bottom of the dialog's footer
/// area instead of immediately after the dialog's content. This flag is ignored if the pszExpandedInformation member is NULL.
/// </summary>
TDF_EXPAND_FOOTER_AREA = 0x0040,
/// <summary>Indicates that the string specified by the pszExpandedInformation member is displayed when the dialog is initially displayed. This flag is ignored if the pszExpandedInformation member is NULL.</summary>
/// <summary>
/// Indicates that the string specified by the pszExpandedInformation member is displayed when the dialog is initially displayed.
/// This flag is ignored if the pszExpandedInformation member is NULL.
/// </summary>
TDF_EXPANDED_BY_DEFAULT = 0x0080,
/// <summary>Indicates that the verification checkbox in the dialog is checked when the dialog is initially displayed. This flag is ignored if the pszVerificationText parameter is NULL.</summary>
/// <summary>
/// Indicates that the verification checkbox in the dialog is checked when the dialog is initially displayed. This flag is
/// ignored if the pszVerificationText parameter is NULL.
/// </summary>
TDF_VERIFICATION_FLAG_CHECKED = 0x0100,
/// <summary>Indicates that a Progress Bar is to be displayed.</summary>
@ -111,7 +145,10 @@ namespace Vanara.PInvoke
/// <summary>Indicates that the task dialog's callback is to be called approximately every 200 milliseconds.</summary>
TDF_CALLBACK_TIMER = 0x0800,
/// <summary>Indicates that the task dialog is positioned (centered) relative to the window specified by hwndParent. If the flag is not supplied (or no hwndParent member is specified), the task dialog is positioned (centered) relative to the monitor.</summary>
/// <summary>
/// Indicates that the task dialog is positioned (centered) relative to the window specified by hwndParent. If the flag is not
/// supplied (or no hwndParent member is specified), the task dialog is positioned (centered) relative to the monitor.
/// </summary>
TDF_POSITION_RELATIVE_TO_WINDOW = 0x1000,
/// <summary>Indicates that text is displayed reading right to left.</summary>
@ -127,7 +164,8 @@ namespace Vanara.PInvoke
TDF_NO_SET_FOREGROUND = 0x00010000,
/// <summary>
/// Indicates that the width of the task dialog is determined by the width of its content area. This flag is ignored if cxWidth is not set to 0.
/// Indicates that the width of the task dialog is determined by the width of its content area. This flag is ignored if cxWidth
/// is not set to 0.
/// </summary>
TDF_SIZE_TO_CONTENT = 0x01000000
}
@ -143,6 +181,39 @@ namespace Vanara.PInvoke
TDIE_ICON_FOOTER
}
/// <summary>The System icons the TaskDialog supports for <see cref="TASKDIALOGCONFIG.footerIcon"/> and <see cref="TASKDIALOGCONFIG.mainIcon"/>.</summary>
[PInvokeData("Commctrl.h", MSDNShortId = "bb787473")]
[SuppressMessage("Microsoft.Design", "CA1028:EnumStorageShouldBeInt32")] // Type comes from CommCtrl.h
public enum TaskDialogIcon : uint
{
/// <summary>An exclamation-point icon appears in the task dialog.</summary>
TD_WARNING_ICON = 0xFFFF, // MAKEINTRESOURCEW(-1)
/// <summary>A stop-sign icon appears in the task dialog.</summary>
TD_ERROR_ICON = 0xFFFE, // MAKEINTRESOURCEW(-2)
/// <summary>An icon consisting of a lowercase letter i in a circle appears in the task dialog.</summary>
TD_INFORMATION_ICON = 0xFFFD, // MAKEINTRESOURCEW(-3)
/// <summary>A shield icon appears in the task dialog.</summary>
TD_SHIELD_ICON = 0xFFFC, // MAKEINTRESOURCEW(-4)
/// <summary>Shield icon on a blue background. Only available on Windows 8 and later.</summary>
TD_SHIELDBLUE_ICON = 0xFFFB, // MAKEINTRESOURCEW(-5)
/// <summary>Warning Shield icon on a yellow background. Only available on Windows 8 and later.</summary>
TD_SECURITYWARNING_ICON = 0xFFFA, // MAKEINTRESOURCEW(-6)
/// <summary>Error Shield icon on a red background. Only available on Windows 8 and later.</summary>
TD_SECURITYERROR_ICON = 0xFFF9, // MAKEINTRESOURCEW(-7)
/// <summary>Success Shield icon on a green background. Only available on Windows 8 and later.</summary>
TD_SECURITYSUCCESS_ICON = 0xFFF8, // MAKEINTRESOURCEW(-8)
/// <summary>Shield icon on a gray background. Only available on Windows 8 and later.</summary>
TD_SHIELDGRAY_ICON = 0xFFF7, // MAKEINTRESOURCEW(-9)
}
/// <summary>TaskDialogMessage taken from CommCtrl.h.</summary>
[PInvokeData("Commctrl.h", MSDNShortId = "bb787473")]
public enum TaskDialogMessage : uint
@ -186,136 +257,198 @@ namespace Vanara.PInvoke
/// <summary>Update the text of an element (no effect if originally set as null).</summary>
TDM_UPDATE_ELEMENT_TEXT = WindowMessage.WM_USER + 114, // wParam = element (TASKDIALOG_ELEMENTS), lParam = new element text (LPCWSTR)
/// <summary>Designate whether a given Task Dialog button or command link should have a User Account Control (UAC) shield icon.</summary>
/// <summary>
/// Designate whether a given Task Dialog button or command link should have a User Account Control (UAC) shield icon.
/// </summary>
TDM_SET_BUTTON_ELEVATION_REQUIRED_STATE = WindowMessage.WM_USER + 115, // wParam = Button ID, lParam = 0 (elevation not required), lParam != 0 (elevation required)
/// <summary>Refreshes the icon of the task dialog.</summary>
TDM_UPDATE_ICON = WindowMessage.WM_USER + 116 // wParam = icon element (TASKDIALOG_ICON_ELEMENTS), lParam = new icon (hIcon if TDF_USE_HICON_* was set, PCWSTR otherwise)
}
/// <summary>The System icons the TaskDialog supports for <see cref="TASKDIALOGCONFIG.footerIcon"/> and <see cref="TASKDIALOGCONFIG.mainIcon"/>.</summary>
[PInvokeData("Commctrl.h", MSDNShortId = "bb787473")]
[SuppressMessage("Microsoft.Design", "CA1028:EnumStorageShouldBeInt32")] // Type comes from CommCtrl.h
public enum TaskDialogIcon : uint
{
/// <summary>An exclamation-point icon appears in the task dialog.</summary>
TD_WARNING_ICON = 0xFFFF, // MAKEINTRESOURCEW(-1)
/// <summary>A stop-sign icon appears in the task dialog.</summary>
TD_ERROR_ICON = 0xFFFE, // MAKEINTRESOURCEW(-2)
/// <summary>An icon consisting of a lowercase letter i in a circle appears in the task dialog.</summary>
TD_INFORMATION_ICON = 0xFFFD, // MAKEINTRESOURCEW(-3)
/// <summary>A shield icon appears in the task dialog.</summary>
TD_SHIELD_ICON = 0xFFFC, // MAKEINTRESOURCEW(-4)
/// <summary>Shield icon on a blue background. Only available on Windows 8 and later.</summary>
TD_SHIELDBLUE_ICON = 0xFFFB, // MAKEINTRESOURCEW(-5)
/// <summary>Warning Shield icon on a yellow background. Only available on Windows 8 and later.</summary>
TD_SECURITYWARNING_ICON = 0xFFFA, // MAKEINTRESOURCEW(-6)
/// <summary>Error Shield icon on a red background. Only available on Windows 8 and later.</summary>
TD_SECURITYERROR_ICON = 0xFFF9, // MAKEINTRESOURCEW(-7)
/// <summary>Success Shield icon on a green background. Only available on Windows 8 and later.</summary>
TD_SECURITYSUCCESS_ICON = 0xFFF8, // MAKEINTRESOURCEW(-8)
/// <summary>Shield icon on a gray background. Only available on Windows 8 and later.</summary>
TD_SHIELDGRAY_ICON = 0xFFF7, // MAKEINTRESOURCEW(-9)
}
/// <summary>Task Dialog callback notifications.</summary>
[PInvokeData("Commctrl.h", MSDNShortId = "bb787473")]
public enum TaskDialogNotification : uint
{
/// <summary>Sent by the task dialog after the dialog has been created and before it is displayed. This notification code is received only through the task dialog callback function, which can be registered using the TaskDialogIndirect method.</summary>
/// <summary>
/// Sent by the task dialog after the dialog has been created and before it is displayed. This notification code is received only
/// through the task dialog callback function, which can be registered using the TaskDialogIndirect method.
/// </summary>
TDN_CREATED = 0,
/// <summary>
/// Sent by a task dialog when navigation has occurred. This notification code is received only through the task dialog callback function, which can be registered using the TaskDialogIndirect method.
/// Sent by a task dialog when navigation has occurred. This notification code is received only through the task dialog callback
/// function, which can be registered using the TaskDialogIndirect method.
/// </summary>
TDN_NAVIGATED = 1,
/// <summary>
/// Sent by a task dialog when the user selects a button or command link in the task dialog. This notification code is received only through the task dialog callback function, which can be registered using the TaskDialogIndirect method. To prevent the task dialog from closing, the application must return S_FALSE, otherwise the task dialog is closed and the button ID is returned via the original application call.
/// Sent by a task dialog when the user selects a button or command link in the task dialog. This notification code is received
/// only through the task dialog callback function, which can be registered using the TaskDialogIndirect method. To prevent the
/// task dialog from closing, the application must return S_FALSE, otherwise the task dialog is closed and the button ID is
/// returned via the original application call.
/// </summary>
TDN_BUTTON_CLICKED = 2,
/// <summary>
/// Sent by a task dialog when the user clicks a hyperlink in the task dialog content. This notification code is received only through the task dialog callback function, which can be registered using the TaskDialogIndirect method.
/// Sent by a task dialog when the user clicks a hyperlink in the task dialog content. This notification code is received only
/// through the task dialog callback function, which can be registered using the TaskDialogIndirect method.
/// </summary>
TDN_HYPERLINK_CLICKED = 3,
/// <summary>
/// Sent by a task dialog approximately every 200 milliseconds. This notification code is sent when the TDF_CALLBACK_TIMER flag has been set in the dwFlags member of the TASKDIALOGCONFIG structure that was passed to the TaskDialogIndirect function. This notification code is received only through the task dialog callback function, which can be registered using the TaskDialogIndirect method.
/// Sent by a task dialog approximately every 200 milliseconds. This notification code is sent when the TDF_CALLBACK_TIMER flag
/// has been set in the dwFlags member of the TASKDIALOGCONFIG structure that was passed to the TaskDialogIndirect function. This
/// notification code is received only through the task dialog callback function, which can be registered using the
/// TaskDialogIndirect method.
/// </summary>
TDN_TIMER = 4,
/// <summary>Sent by a task dialog when it is destroyed and its window handle is no longer valid. This notification code is received only through the task dialog callback function, which can be registered using the TaskDialogIndirect method.</summary>
/// <summary>
/// Sent by a task dialog when it is destroyed and its window handle is no longer valid. This notification code is received only
/// through the task dialog callback function, which can be registered using the TaskDialogIndirect method.
/// </summary>
TDN_DESTROYED = 5,
/// <summary>
/// Sent by a task dialog when the user selects a radio button or command link in the task dialog. This notification code is received only through the task dialog callback function, which can be registered using the TaskDialogIndirect method.
/// Sent by a task dialog when the user selects a radio button or command link in the task dialog. This notification code is
/// received only through the task dialog callback function, which can be registered using the TaskDialogIndirect method.
/// </summary>
TDN_RADIO_BUTTON_CLICKED = 6,
/// <summary>Sent by a task dialog after the dialog has been created and before it is displayed. This notification code is received only through the task dialog callback function, which can be registered using the TaskDialogIndirect method.</summary>
/// <summary>
/// Sent by a task dialog after the dialog has been created and before it is displayed. This notification code is received only
/// through the task dialog callback function, which can be registered using the TaskDialogIndirect method.
/// </summary>
TDN_DIALOG_CONSTRUCTED = 7,
/// <summary>
/// Sent by a task dialog when the user clicks the task dialog verification check box. This notification code is received only through the task dialog callback function, which can be registered using the TaskDialogIndirect method.
/// Sent by a task dialog when the user clicks the task dialog verification check box. This notification code is received only
/// through the task dialog callback function, which can be registered using the TaskDialogIndirect method.
/// </summary>
TDN_VERIFICATION_CLICKED = 8,
/// <summary>
/// Sent by a task dialog when the user presses F1 on the keyboard while the dialog has focus. This notification code is received only through the task dialog callback function, which can be registered using the TaskDialogIndirect method.
/// Sent by a task dialog when the user presses F1 on the keyboard while the dialog has focus. This notification code is received
/// only through the task dialog callback function, which can be registered using the TaskDialogIndirect method.
/// </summary>
TDN_HELP = 9,
/// <summary>
/// Sent by the task dialog when the user clicks on the dialog's expando button. This notification is received only through the task dialog callback function, which can be registered using the TaskDialogIndirect method.
/// Sent by the task dialog when the user clicks on the dialog's expando button. This notification is received only through the
/// task dialog callback function, which can be registered using the TaskDialogIndirect method.
/// </summary>
TDN_EXPANDO_BUTTON_CLICKED = 10
}
/// <summary>
/// The TaskDialog function creates, displays, and operates a task dialog. The task dialog contains application-defined message text and title, icons, and any combination of predefined push buttons. This function does not support the registration of a callback function to receive notifications.
/// The TaskDialog function creates, displays, and operates a task dialog. The task dialog contains application-defined message text
/// and title, icons, and any combination of predefined push buttons. This function does not support the registration of a callback
/// function to receive notifications.
/// </summary>
/// <param name="hwndParent">Handle to the owner window of the task dialog to be created. If this parameter is NULL, the task dialog has no owner window.</param>
/// <param name="hInstance">Handle to the module that contains the icon resource identified by the pszIcon member, and the string resources identified by the pszWindowTitle and pszMainInstruction members. If this parameter is NULL, pszIcon must be NULL or a pointer to a null-terminated, Unicode string that contains a system resource identifier, for example, TD_ERROR_ICON.</param>
/// <param name="pszWindowTitle">Pointer to the string to be used for the task dialog title. This parameter is a null-terminated, Unicode string that contains either text, or an integer resource identifier passed through the MAKEINTRESOURCE macro. If this parameter is NULL, the filename of the executable program is used.</param>
/// <param name="pszMainInstruction">Pointer to the string to be used for the main instruction. This parameter is a null-terminated, Unicode string that contains either text, or an integer resource identifier passed through the MAKEINTRESOURCE macro. This parameter can be NULL if no main instruction is wanted.</param>
/// <param name="pszContent">Pointer to a string used for additional text that appears below the main instruction, in a smaller font. This parameter is a null-terminated, Unicode string that contains either text, or an integer resource identifier passed through the MAKEINTRESOURCE macro. Can be NULL if no additional text is wanted.</param>
/// <param name="dwCommonButtons">Specifies the push buttons displayed in the dialog box. This parameter may be a combination of flags from the following group.</param>
/// <param name="pszIcon">Pointer to a string that identifies the icon to display in the task dialog. This parameter must be an integer resource identifier passed to the MAKEINTRESOURCE macro or one of the following predefined values. If this parameter is NULL, no icon will be displayed. If the hInstance parameter is NULL and one of the predefined values is not used, the TaskDialog function fails.</param>
/// <param name="pnButton">When this function returns, contains a pointer to an integer location that receives one of the standard button result values.</param>
/// <returns>This function can return one of these values.
/// <param name="hwndParent">
/// Handle to the owner window of the task dialog to be created. If this parameter is NULL, the task dialog has no owner window.
/// </param>
/// <param name="hInstance">
/// Handle to the module that contains the icon resource identified by the pszIcon member, and the string resources identified by the
/// pszWindowTitle and pszMainInstruction members. If this parameter is NULL, pszIcon must be NULL or a pointer to a null-terminated,
/// Unicode string that contains a system resource identifier, for example, TD_ERROR_ICON.
/// </param>
/// <param name="pszWindowTitle">
/// Pointer to the string to be used for the task dialog title. This parameter is a null-terminated, Unicode string that contains
/// either text, or an integer resource identifier passed through the MAKEINTRESOURCE macro. If this parameter is NULL, the filename
/// of the executable program is used.
/// </param>
/// <param name="pszMainInstruction">
/// Pointer to the string to be used for the main instruction. This parameter is a null-terminated, Unicode string that contains
/// either text, or an integer resource identifier passed through the MAKEINTRESOURCE macro. This parameter can be NULL if no main
/// instruction is wanted.
/// </param>
/// <param name="pszContent">
/// Pointer to a string used for additional text that appears below the main instruction, in a smaller font. This parameter is a
/// null-terminated, Unicode string that contains either text, or an integer resource identifier passed through the MAKEINTRESOURCE
/// macro. Can be NULL if no additional text is wanted.
/// </param>
/// <param name="dwCommonButtons">
/// Specifies the push buttons displayed in the dialog box. This parameter may be a combination of flags from the following group.
/// </param>
/// <param name="pszIcon">
/// Pointer to a string that identifies the icon to display in the task dialog. This parameter must be an integer resource identifier
/// passed to the MAKEINTRESOURCE macro or one of the following predefined values. If this parameter is NULL, no icon will be
/// displayed. If the hInstance parameter is NULL and one of the predefined values is not used, the TaskDialog function fails.
/// </param>
/// <param name="pnButton">
/// When this function returns, contains a pointer to an integer location that receives one of the standard button result values.
/// </param>
/// <returns>
/// This function can return one of these values.
/// <list type="table">
/// <listheader><term>Return code</term><term>Description</term></listheader>
/// <item><term>S_OK</term><term>The operation completed successfully.</term></item>
/// <item><term>E_OUTOFMEMORY</term><term>There is insufficient memory to complete the operation.</term></item>
/// <item><term>E_INVALIDARG</term><term>One or more arguments are not valid.</term></item>
/// <item><term>E_FAIL</term><term>The operation failed.</term></item>
/// <listheader>
/// <term>Return code</term>
/// <term>Description</term>
/// </listheader>
/// <item>
/// <term>S_OK</term>
/// <term>The operation completed successfully.</term>
/// </item>
/// <item>
/// <term>E_OUTOFMEMORY</term>
/// <term>There is insufficient memory to complete the operation.</term>
/// </item>
/// <item>
/// <term>E_INVALIDARG</term>
/// <term>One or more arguments are not valid.</term>
/// </item>
/// <item>
/// <term>E_FAIL</term>
/// <term>The operation failed.</term>
/// </item>
/// </list>
/// </returns>
[PInvokeData("Commctrl.h", MSDNShortId = "bb760540")]
[DllImport(Lib.ComCtl32, CharSet = CharSet.Unicode, ExactSpelling = true)]
public static extern HRESULT TaskDialog(HWND hwndParent, HINSTANCE hInstance, string pszWindowTitle, string pszMainInstruction, string pszContent, TASKDIALOG_COMMON_BUTTON_FLAGS dwCommonButtons, IntPtr pszIcon, out int pnButton);
public static extern HRESULT TaskDialog(HWND hwndParent, HINSTANCE hInstance, string pszWindowTitle, string pszMainInstruction, string pszContent, TASKDIALOG_COMMON_BUTTON_FLAGS dwCommonButtons, SafeResourceId pszIcon, out int pnButton);
/// <summary>The TaskDialogIndirect function creates, displays, and operates a task dialog. The task dialog contains application-defined icons, messages, title, verification check box, command links, push buttons, and radio buttons. This function can register a callback function to receive notification messages.</summary>
/// <summary>
/// The TaskDialogIndirect function creates, displays, and operates a task dialog. The task dialog contains application-defined
/// icons, messages, title, verification check box, command links, push buttons, and radio buttons. This function can register a
/// callback function to receive notification messages.
/// </summary>
/// <param name="pTaskConfig">Pointer to a TASKDIALOGCONFIG structure that contains information used to display the task dialog.</param>
/// <param name="pnButton">Address of a variable that receives one of the button IDs specified in the pButtons member of the pTaskConfig parameter or a standard button ID value.</param>
/// <param name="pnRadioButton">Address of a variable that receives one of the button IDs specified in the pRadioButtons member of the pTaskConfig parameter. If this parameter is NULL, no value is returned.</param>
/// <param name="pfVerificationFlagChecked">Address of a variable that receives a value indicating if the verification checkbox was checked when the dialog was dismissed.</param>
/// <returns>This function can return one of these values.
/// <param name="pnButton">
/// Address of a variable that receives one of the button IDs specified in the pButtons member of the pTaskConfig parameter or a
/// standard button ID value.
/// </param>
/// <param name="pnRadioButton">
/// Address of a variable that receives one of the button IDs specified in the pRadioButtons member of the pTaskConfig parameter. If
/// this parameter is NULL, no value is returned.
/// </param>
/// <param name="pfVerificationFlagChecked">
/// Address of a variable that receives a value indicating if the verification checkbox was checked when the dialog was dismissed.
/// </param>
/// <returns>
/// This function can return one of these values.
/// <list type="table">
/// <listheader><term>Return code</term><term>Description</term></listheader>
/// <item><term>S_OK</term><term>The operation completed successfully.</term></item>
/// <item><term>E_OUTOFMEMORY</term><term>There is insufficient memory to complete the operation.</term></item>
/// <item><term>E_INVALIDARG</term><term>One or more arguments are not valid.</term></item>
/// <item><term>E_FAIL</term><term>The operation failed.</term></item>
/// <listheader>
/// <term>Return code</term>
/// <term>Description</term>
/// </listheader>
/// <item>
/// <term>S_OK</term>
/// <term>The operation completed successfully.</term>
/// </item>
/// <item>
/// <term>E_OUTOFMEMORY</term>
/// <term>There is insufficient memory to complete the operation.</term>
/// </item>
/// <item>
/// <term>E_INVALIDARG</term>
/// <term>One or more arguments are not valid.</term>
/// </item>
/// <item>
/// <term>E_FAIL</term>
/// <term>The operation failed.</term>
/// </item>
/// </list>
/// </returns>
[PInvokeData("Commctrl.h", MSDNShortId = "bb760544")]
@ -323,7 +456,8 @@ namespace Vanara.PInvoke
public static extern HRESULT TaskDialogIndirect(TASKDIALOGCONFIG pTaskConfig, out int pnButton, out int pnRadioButton, [MarshalAs(UnmanagedType.Bool)] out bool pfVerificationFlagChecked);
/// <summary>
/// The TASKDIALOG_BUTTON structure contains information used to display a button in a task dialog. The TASKDIALOGCONFIG structure uses this structure.
/// The TASKDIALOG_BUTTON structure contains information used to display a button in a task dialog. The TASKDIALOGCONFIG structure
/// uses this structure.
/// </summary>
[PInvokeData("Commctrl.h", MSDNShortId = "bb787475")]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
@ -331,7 +465,12 @@ namespace Vanara.PInvoke
{
/// <summary>Indicates the value to be returned when this button is selected.</summary>
public int nButtonID;
/// <summary>Pointer that references the string to be used to label the button. This parameter can be either a null-terminated string or an integer resource identifier passed to the MAKEINTRESOURCE macro. When using Command Links, you delineate the command from the note by placing a new line character in the string.</summary>
/// <summary>
/// Pointer that references the string to be used to label the button. This parameter can be either a null-terminated string or
/// an integer resource identifier passed to the MAKEINTRESOURCE macro. When using Command Links, you delineate the command from
/// the note by placing a new line character in the string.
/// </summary>
public IntPtr pszButtonText;
}
@ -348,14 +487,14 @@ namespace Vanara.PInvoke
public uint cbSize;
/// <summary>Handle to the parent window. This member can be NULL.</summary>
public IntPtr hwndParent;
public HWND hwndParent;
/// <summary>
/// Handle to the module that contains the icon resource identified by the pszMainIcon or pszFooterIcon members, and the string
/// resources identified by the pszWindowTitle, pszMainInstruction, pszContent, pszVerificationText, pszExpandedInformation,
/// pszExpandedControlText, pszCollapsedControlText or pszFooter members.
/// </summary>
public IntPtr hInstance;
public HINSTANCE hInstance;
/// <summary>Specifies the behavior of the task dialog. This parameter can be a combination of flags.</summary>
public TASKDIALOG_FLAGS dwFlags;

View File

@ -4,8 +4,6 @@ using System.Runtime.InteropServices;
using Vanara.InteropServices;
using static Vanara.PInvoke.User32_Gdi;
// ReSharper disable InconsistentNaming
namespace Vanara.PInvoke
{
public static partial class ComCtl32
@ -18,16 +16,22 @@ namespace Vanara.PInvoke
{
/// <summary>No icon.</summary>
TTI_NONE = 0,
/// <summary>Info icon.</summary>
TTI_INFO = 1,
/// <summary>Warning icon</summary>
TTI_WARNING = 2,
/// <summary>Error Icon</summary>
TTI_ERROR = 3,
/// <summary>Large error Icon</summary>
TTI_INFO_LARGE = 4,
/// <summary>Large error Icon</summary>
TTI_WARNING_LARGE = 5,
/// <summary>Large error Icon</summary>
TTI_ERROR_LARGE = 6,
}
@ -39,21 +43,46 @@ namespace Vanara.PInvoke
{
/// <summary>Indicates that the uId member is the window handle to the tool. If this flag is not set, uId is the tool's identifier.</summary>
TTF_IDISHWND = 0x0001,
/// <summary>Centers the tooltip window below the tool specified by the uId member.</summary>
TTF_CENTERTIP = 0x0002,
/// <summary>Indicates that the tooltip text will be displayed in the opposite direction to the text in the parent window.</summary>
TTF_RTLREADING = 0x0004,
/// <summary>Indicates that the tooltip control should subclass the tool's window to intercept messages, such as WM_MOUSEMOVE. If this flag is not set, you must use the TTM_RELAYEVENT message to forward messages to the tooltip control. For a list of messages that a tooltip control processes, see TTM_RELAYEVENT.</summary>
/// <summary>
/// Indicates that the tooltip control should subclass the tool's window to intercept messages, such as WM_MOUSEMOVE. If this
/// flag is not set, you must use the TTM_RELAYEVENT message to forward messages to the tooltip control. For a list of messages
/// that a tooltip control processes, see TTM_RELAYEVENT.
/// </summary>
TTF_SUBCLASS = 0x0010,
/// <summary>Positions the tooltip window next to the tool to which it corresponds and moves the window according to coordinates supplied by the TTM_TRACKPOSITION messages. You must activate this type of tool using the TTM_TRACKACTIVATE message.</summary>
/// <summary>
/// Positions the tooltip window next to the tool to which it corresponds and moves the window according to coordinates supplied
/// by the TTM_TRACKPOSITION messages. You must activate this type of tool using the TTM_TRACKACTIVATE message.
/// </summary>
TTF_TRACK = 0x0020,
/// <summary>Positions the tooltip window at the same coordinates provided by TTM_TRACKPOSITION. This flag must be used with the TTF_TRACK flag.</summary>
/// <summary>
/// Positions the tooltip window at the same coordinates provided by TTM_TRACKPOSITION. This flag must be used with the TTF_TRACK flag.
/// </summary>
TTF_ABSOLUTE = 0x0080,
/// <summary>Causes the tooltip control to forward mouse event messages to the parent window. This is limited to mouse events that occur within the bounds of the tooltip window.</summary>
/// <summary>
/// Causes the tooltip control to forward mouse event messages to the parent window. This is limited to mouse events that occur
/// within the bounds of the tooltip window.
/// </summary>
TTF_TRANSPARENT = 0x0100,
/// <summary>Version 6.0 and later. Indicates that links in the tooltip text should be parsed.
/// <para>Note that Comctl32.dll version 6 is not redistributable but it is included in Windows or later. To use Comctl32.dll version 6, specify it in a manifest. For more information on manifests, see Enabling Visual Styles.</para></summary>
/// <summary>
/// Version 6.0 and later. Indicates that links in the tooltip text should be parsed.
/// <para>
/// Note that Comctl32.dll version 6 is not redistributable but it is included in Windows or later. To use Comctl32.dll version
/// 6, specify it in a manifest. For more information on manifests, see Enabling Visual Styles.
/// </para>
/// </summary>
TTF_PARSELINKS = 0x1000,
/// <summary>The TTF di setitem</summary>
TTF_DI_SETITEM = 0x8000, // valid only on the TTN_NEEDTEXT callback
}
@ -100,75 +129,146 @@ namespace Vanara.PInvoke
[PInvokeData("Commctrl.h", MSDNShortId = "ff486070")]
public enum ToolTipNotification
{
/// <summary>Sent by a tooltip control to retrieve information needed to display a tooltip window. This notification code is sent in the form of a WM_NOTIFY message.</summary>
/// <summary>
/// Sent by a tooltip control to retrieve information needed to display a tooltip window. This notification code is sent in the
/// form of a WM_NOTIFY message.
/// </summary>
TTN_GETDISPINFO = TTN_FIRST - 10,
/// <summary>Notifies the owner window that a tooltip control is about to be displayed. This notification code is sent in the form of a WM_NOTIFY message.</summary>
/// <summary>
/// Notifies the owner window that a tooltip control is about to be displayed. This notification code is sent in the form of a
/// WM_NOTIFY message.
/// </summary>
TTN_SHOW = TTN_FIRST - 1,
/// <summary>Notifies the owner window that a tooltip is about to be hidden. This notification code is sent in the form of a WM_NOTIFY message.</summary>
/// <summary>
/// Notifies the owner window that a tooltip is about to be hidden. This notification code is sent in the form of a WM_NOTIFY message.
/// </summary>
TTN_POP = TTN_FIRST - 2,
/// <summary>Sent when a text link inside a balloon tooltip is clicked. This notification code is sent in the form of a WM_NOTIFY message.</summary>
/// <summary>
/// Sent when a text link inside a balloon tooltip is clicked. This notification code is sent in the form of a WM_NOTIFY message.
/// </summary>
TTN_LINKCLICK = TTN_FIRST - 3,
/// <summary>Sent by a tooltip control to retrieve information needed to display a tooltip window. This notification code is identical to TTN_GETDISPINFO. This notification code is sent in the form of a WM_NOTIFY message.</summary>
/// <summary>
/// Sent by a tooltip control to retrieve information needed to display a tooltip window. This notification code is identical to
/// TTN_GETDISPINFO. This notification code is sent in the form of a WM_NOTIFY message.
/// </summary>
TTN_NEEDTEXT = TTN_GETDISPINFO,
}
/// <summary>Contains information used in handling the TTN_GETDISPINFO notification code. This structure supersedes the TOOLTIPTEXT structure.</summary>
/// <summary>
/// Sends the specified message to a window or windows. The SendMessage function calls the window procedure for the specified window
/// and does not return until the window procedure has processed the message.
/// </summary>
/// <param name="hWnd">
/// A handle to the window whose window procedure will receive the message. If this parameter is HWND_BROADCAST ((HWND)0xffff), the
/// message is sent to all top-level windows in the system, including disabled or invisible unowned windows, overlapped windows, and
/// pop-up windows; but the message is not sent to child windows.
/// </param>
/// <param name="Msg">The message to be sent.</param>
/// <param name="wParam">Additional message-specific information.</param>
/// <param name="title">Additional message-specific information.</param>
/// <returns>The return value specifies the result of the message processing; it depends on the message sent.</returns>
[DllImport(Lib.User32, SetLastError = false, CharSet = CharSet.Auto)]
public static extern IntPtr SendMessage(HWND hWnd, EditMessage Msg, int wParam, ref TTGETTITLE title);
/// <summary>
/// Sends the specified message to a window or windows. The SendMessage function calls the window procedure for the specified window
/// and does not return until the window procedure has processed the message.
/// </summary>
/// <param name="hWnd">
/// A handle to the window whose window procedure will receive the message. If this parameter is HWND_BROADCAST ((HWND)0xffff), the
/// message is sent to all top-level windows in the system, including disabled or invisible unowned windows, overlapped windows, and
/// pop-up windows; but the message is not sent to child windows.
/// </param>
/// <param name="Msg">The message to be sent.</param>
/// <param name="wParam">Additional message-specific information.</param>
/// <param name="toolInfo">Additional message-specific information.</param>
/// <returns>The return value specifies the result of the message processing; it depends on the message sent.</returns>
[DllImport(Lib.User32, SetLastError = false, CharSet = CharSet.Auto)]
public static extern IntPtr SendMessage(HWND hWnd, EditMessage Msg, int wParam, ref TOOLINFO toolInfo);
/// <summary>
/// Sends the specified message to a window or windows. The SendMessage function calls the window procedure for the specified window
/// and does not return until the window procedure has processed the message.
/// </summary>
/// <param name="hWnd">
/// A handle to the window whose window procedure will receive the message. If this parameter is HWND_BROADCAST ((HWND)0xffff), the
/// message is sent to all top-level windows in the system, including disabled or invisible unowned windows, overlapped windows, and
/// pop-up windows; but the message is not sent to child windows.
/// </param>
/// <param name="Msg">The message to be sent.</param>
/// <param name="wParam">Additional message-specific information.</param>
/// <param name="hitTestInfo">Additional message-specific information.</param>
/// <returns>The return value specifies the result of the message processing; it depends on the message sent.</returns>
[DllImport(Lib.User32, SetLastError = false, CharSet = CharSet.Auto)]
public static extern IntPtr SendMessage(HWND hWnd, EditMessage Msg, int wParam, ref TTHITTESTINFO hitTestInfo);
/// <summary>
/// Contains information used in handling the TTN_GETDISPINFO notification code. This structure supersedes the TOOLTIPTEXT structure.
/// </summary>
[PInvokeData("Commctrl.h", MSDNShortId = "bb760258")]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
public struct NMTTDISPINFO
{
/// <summary>NMHDR structure that contains additional information about the notification.</summary>
public NMHDR hdr;
/// <summary>Pointer to a null-terminated string that will be displayed as the tooltip text. If hinst specifies an instance handle, this member must be the identifier of a string resource.</summary>
/// <summary>
/// Pointer to a null-terminated string that will be displayed as the tooltip text. If hinst specifies an instance handle, this
/// member must be the identifier of a string resource.
/// </summary>
public string lpszText;
/// <summary>Buffer that receives the tooltip text. An application can copy the text to this buffer instead of specifying a string address or string resource. For tooltip text that exceeds 80 TCHARs, see comments in the remarks section of this document.</summary>
/// <summary>
/// Buffer that receives the tooltip text. An application can copy the text to this buffer instead of specifying a string address
/// or string resource. For tooltip text that exceeds 80 TCHARs, see comments in the remarks section of this document.
/// </summary>
[MarshalAs(UnmanagedType.LPTStr, SizeConst = 80)]
public string szText;
/// <summary>Handle to the instance that contains a string resource to be used as the tooltip text. If lpszText is the address of the tooltip text string, this member must be NULL.</summary>
public IntPtr hinst;
/// <summary>Flags that indicates how to interpret the idFrom member of the included NMHDR structure.
/// <summary>
/// Handle to the instance that contains a string resource to be used as the tooltip text. If lpszText is the address of the
/// tooltip text string, this member must be NULL.
/// </summary>
public HINSTANCE hinst;
/// <summary>
/// Flags that indicates how to interpret the idFrom member of the included NMHDR structure.
/// <list type="table">
/// <listheader><term>Value</term><term>Meaning</term></listheader>
/// <item><term>TTF_IDISHWND</term><description>If this flag is set, idFrom is the tool's handle. Otherwise, it is the tool's identifier.</description></item>
/// <item><term>TTF_RTLREADING</term><description>Windows can be mirrored to display languages such as Hebrew or Arabic that read right-to-left (RTL). Normally, tooltip text is read in same direction as the text in its parent window. To have a tooltip read in the opposite direction from its parent window, add the TTF_RTLREADING flag to the uFlags member when processing the notification.</description></item>
/// <item><term>TTF_DI_SETITEM</term><description>Version 4.70. If you add this flag to uFlags while processing the notification, the tooltip control will retain the supplied information and not request it again.</description></item>
/// <listheader>
/// <term>Value</term>
/// <term>Meaning</term>
/// </listheader>
/// <item>
/// <term>TTF_IDISHWND</term>
/// <description>If this flag is set, idFrom is the tool's handle. Otherwise, it is the tool's identifier.</description>
/// </item>
/// <item>
/// <term>TTF_RTLREADING</term>
/// <description>
/// Windows can be mirrored to display languages such as Hebrew or Arabic that read right-to-left (RTL). Normally, tooltip text
/// is read in same direction as the text in its parent window. To have a tooltip read in the opposite direction from its parent
/// window, add the TTF_RTLREADING flag to the uFlags member when processing the notification.
/// </description>
/// </item>
/// <item>
/// <term>TTF_DI_SETITEM</term>
/// <description>
/// Version 4.70. If you add this flag to uFlags while processing the notification, the tooltip control will retain the supplied
/// information and not request it again.
/// </description>
/// </item>
/// </list>
/// </summary>
public ToolTipInfoFlags uFlags;
/// <summary>Version 4.70. Application-defined data associated with the tool.</summary>
public IntPtr lParam;
}
/// <summary>
/// Contains information that a tooltip control uses to determine whether a point is in the bounding rectangle of the specified tool. If the point is in the rectangle, the structure receives information about the tool.
/// </summary>
[PInvokeData("Commctrl.h", MSDNShortId = "bb760262")]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
public struct TTHITTESTINFO
{
/// <summary>Handle to the tool or window with the specified tool.</summary>
public IntPtr hwnd;
/// <summary>Client coordinates of the point to test.</summary>
public Point pt;
/// <summary>TOOLINFO structure. If the point specified by pt is in the tool specified by hwnd, this structure receives information about the tool. The cbSize member of this structure must be filled in before sending this message.</summary>
public TOOLINFO ti;
}
/// <summary>Provides information about the title of a tooltip control.</summary>
[PInvokeData("Commctrl.h", MSDNShortId = "bb760260")]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct TTGETTITLE
{
/// <summary>DWORD that specifies size of structure. Set to sizeof(TTGETTITLE).</summary>
public uint dwSize;
/// <summary>UINT that specifies the tooltip icon.</summary>
public ToolTipIcon uTitleBitmap;
/// <summary>UINT that specifies the number of characters in the title.</summary>
public uint cch;
/// <summary>Pointer to a wide character string that contains the title.</summary>
public StrPtrUni pszTitle;
}
/// <summary>The TOOLINFO structure contains information about a tool in a tooltip control.</summary>
[PInvokeData("Commctrl.h", MSDNShortId = "bb760256")]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
@ -176,52 +276,86 @@ namespace Vanara.PInvoke
{
/// <summary>Size of this structure, in bytes. This member must be specified.</summary>
public uint cbSize;
/// <summary>Flags that control the tooltip display. This member can be a combination of the following values:</summary>
public ToolTipInfoFlags uFlags;
/// <summary>Handle to the window that contains the tool. If lpszText includes the LPSTR_TEXTCALLBACK value, this member identifies the window that receives the TTN_GETDISPINFO notification codes.</summary>
public IntPtr hwnd;
/// <summary>Application-defined identifier of the tool. If uFlags includes the TTF_IDISHWND flag, uId must specify the window handle to the tool.</summary>
/// <summary>
/// Handle to the window that contains the tool. If lpszText includes the LPSTR_TEXTCALLBACK value, this member identifies the
/// window that receives the TTN_GETDISPINFO notification codes.
/// </summary>
public HWND hwnd;
/// <summary>
/// Application-defined identifier of the tool. If uFlags includes the TTF_IDISHWND flag, uId must specify the window handle to
/// the tool.
/// </summary>
public IntPtr uId;
/// <summary>The bounding rectangle coordinates of the tool. The coordinates are relative to the upper-left corner of the client area of the window identified by hwnd. If uFlags includes the TTF_IDISHWND flag, this member is ignored.</summary>
/// <summary>
/// The bounding rectangle coordinates of the tool. The coordinates are relative to the upper-left corner of the client area of
/// the window identified by hwnd. If uFlags includes the TTF_IDISHWND flag, this member is ignored.
/// </summary>
public RECT rect;
/// <summary>Handle to the instance that contains the string resource for the tool. If lpszText specifies the identifier of a string resource, this member is used.</summary>
public IntPtr hinst;
/// <summary>Pointer to the buffer that contains the text for the tool, or identifier of the string resource that contains the text. This member is sometimes used to return values. If you need to examine the returned value, must point to a valid buffer of sufficient size. Otherwise, it can be set to NULL. If lpszText is set to LPSTR_TEXTCALLBACK, the control sends the TTN_GETDISPINFO notification code to the owner window to retrieve the text.</summary>
/// <summary>
/// Handle to the instance that contains the string resource for the tool. If lpszText specifies the identifier of a string
/// resource, this member is used.
/// </summary>
public HINSTANCE hinst;
/// <summary>
/// Pointer to the buffer that contains the text for the tool, or identifier of the string resource that contains the text. This
/// member is sometimes used to return values. If you need to examine the returned value, must point to a valid buffer of
/// sufficient size. Otherwise, it can be set to NULL. If lpszText is set to LPSTR_TEXTCALLBACK, the control sends the
/// TTN_GETDISPINFO notification code to the owner window to retrieve the text.
/// </summary>
public StrPtrAuto lpszText;
/// <summary>Version 4.70 and later. A 32-bit application-defined value that is associated with the tool.</summary>
public IntPtr lParam;
/// <summary>Reserved. Must be set to NULL.</summary>
public IntPtr lpReserved;
}
/// <summary>
/// Sends the specified message to a window or windows. The SendMessage function calls the window procedure for the specified window and does not return until the window procedure has processed the message.
/// </summary>
/// <param name="hWnd">A handle to the window whose window procedure will receive the message. If this parameter is HWND_BROADCAST ((HWND)0xffff), the message is sent to all top-level windows in the system, including disabled or invisible unowned windows, overlapped windows, and pop-up windows; but the message is not sent to child windows.</param>
/// <param name="Msg">The message to be sent.</param>
/// <param name="wParam">Additional message-specific information.</param>
/// <param name="title">Additional message-specific information.</param>
/// <returns>The return value specifies the result of the message processing; it depends on the message sent.</returns>
public static IntPtr SendMessage(HWND hWnd, EditMessage Msg, int wParam, ref TTGETTITLE title) => User32_Gdi.SendMessage(hWnd, Msg, wParam, ref title);
/// <summary>Provides information about the title of a tooltip control.</summary>
[PInvokeData("Commctrl.h", MSDNShortId = "bb760260")]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct TTGETTITLE
{
/// <summary>DWORD that specifies size of structure. Set to sizeof(TTGETTITLE).</summary>
public uint dwSize;
/// <summary>UINT that specifies the tooltip icon.</summary>
public ToolTipIcon uTitleBitmap;
/// <summary>UINT that specifies the number of characters in the title.</summary>
public uint cch;
/// <summary>Pointer to a wide character string that contains the title.</summary>
public StrPtrUni pszTitle;
}
/// <summary>
/// Sends the specified message to a window or windows. The SendMessage function calls the window procedure for the specified window and does not return until the window procedure has processed the message.
/// Contains information that a tooltip control uses to determine whether a point is in the bounding rectangle of the specified tool.
/// If the point is in the rectangle, the structure receives information about the tool.
/// </summary>
/// <param name="hWnd">A handle to the window whose window procedure will receive the message. If this parameter is HWND_BROADCAST ((HWND)0xffff), the message is sent to all top-level windows in the system, including disabled or invisible unowned windows, overlapped windows, and pop-up windows; but the message is not sent to child windows.</param>
/// <param name="Msg">The message to be sent.</param>
/// <param name="wParam">Additional message-specific information.</param>
/// <param name="toolInfo">Additional message-specific information.</param>
/// <returns>The return value specifies the result of the message processing; it depends on the message sent.</returns>
public static IntPtr SendMessage(HWND hWnd, EditMessage Msg, int wParam, ref TOOLINFO toolInfo) => User32_Gdi.SendMessage(hWnd, Msg, wParam, ref toolInfo);
[PInvokeData("Commctrl.h", MSDNShortId = "bb760262")]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
public struct TTHITTESTINFO
{
/// <summary>Handle to the tool or window with the specified tool.</summary>
public HWND hwnd;
/// <summary>
/// Sends the specified message to a window or windows. The SendMessage function calls the window procedure for the specified window and does not return until the window procedure has processed the message.
/// </summary>
/// <param name="hWnd">A handle to the window whose window procedure will receive the message. If this parameter is HWND_BROADCAST ((HWND)0xffff), the message is sent to all top-level windows in the system, including disabled or invisible unowned windows, overlapped windows, and pop-up windows; but the message is not sent to child windows.</param>
/// <param name="Msg">The message to be sent.</param>
/// <param name="wParam">Additional message-specific information.</param>
/// <param name="hitTestInfo">Additional message-specific information.</param>
/// <returns>The return value specifies the result of the message processing; it depends on the message sent.</returns>
public static IntPtr SendMessage(HWND hWnd, EditMessage Msg, int wParam, ref TTHITTESTINFO hitTestInfo) => User32_Gdi.SendMessage(hWnd, Msg, wParam, ref hitTestInfo);
/// <summary>Client coordinates of the point to test.</summary>
public Point pt;
/// <summary>
/// TOOLINFO structure. If the point specified by pt is in the tool specified by hwnd, this structure receives information about
/// the tool. The cbSize member of this structure must be filled in before sending this message.
/// </summary>
public TOOLINFO ti;
}
}
}

View File

@ -1,11 +1,7 @@
using System;
using System.Runtime.InteropServices;
using static Vanara.PInvoke.Gdi32;
using static Vanara.PInvoke.Kernel32;
using static Vanara.PInvoke.User32_Gdi;
// ReSharper disable InconsistentNaming ReSharper disable FieldCanBeMadeReadOnly.Global ReSharper disable InconsistentNaming
namespace Vanara.PInvoke
{
public static partial class ComCtl32
@ -20,34 +16,42 @@ namespace Vanara.PInvoke
{
/// <summary>No flags</summary>
CMB_NONE = 0,
/// <summary>Uses a bitmap as a mask.</summary>
CMB_MASKED = 2
}
/// <summary>
/// The value your application can return depends on the current drawing stage. The <c>dwDrawStage</c> member of the associated <c>NMCUSTOMDRAW</c>
/// structure holds a value that specifies the drawing stage. You must return one of the following values.
/// The value your application can return depends on the current drawing stage. The <c>dwDrawStage</c> member of the associated
/// <c>NMCUSTOMDRAW</c> structure holds a value that specifies the drawing stage. You must return one of the following values.
/// </summary>
[PInvokeData("Commctrl.h", MSDNShortId = "bb760492")]
public enum TBCDRF
{
/// <summary>Version 4.71. Do not draw button edges. This occurs when dwDrawStage equals CDDS_ITEMPREPAINT.</summary>
TBCDRF_NOEDGES = 0x00010000,
/// <summary>
/// Version 4.71. Use the clrHighlightHotTrack member of the NMTBCUSTOMDRAW structure to draw the background of hot-tracked items. This occurs when
/// dwDrawStage equals CDDS_ITEMPREPAINT.
/// Version 4.71. Use the clrHighlightHotTrack member of the NMTBCUSTOMDRAW structure to draw the background of hot-tracked
/// items. This occurs when dwDrawStage equals CDDS_ITEMPREPAINT.
/// </summary>
TBCDRF_HILITEHOTTRACK = 0x00020000,
/// <summary>Version 4.71. Do not offset the button when pressed. This occurs when dwDrawStage equals CDDS_ITEMPREPAINT.</summary>
TBCDRF_NOOFFSET = 0x00040000,
/// <summary>Do not draw default highlight of items that have the TBSTATE_MARKED. This occurs when dwDrawStage equals CDDS_ITEMPREPAINT.</summary>
TBCDRF_NOMARK = 0x00080000,
/// <summary>Version 4.71. Do not draw etched effect for disabled items. This occurs when dwDrawStage equals CDDS_ITEMPREPAINT.</summary>
TBCDRF_NOETCHEDEFFECT = 0x00100000,
/// <summary>Version 5.00. Blend the button 50 percent with the background. This occurs when dwDrawStage equals CDDS_ITEMPREPAINT.</summary>
TBCDRF_BLENDICON = 0x00200000,
/// <summary>Version 5.00. Do not draw button background. This occurs when dwDrawStage equals CDDS_ITEMPREPAINT.</summary>
TBCDRF_NOBACKGROUND = 0x00400000,
/// <summary>Version 6.00, Windows Vista only. Use custom draw colors to render text regardless of visual style.</summary>
TBCDRF_USECDCOLORS = 0x00800000,
}
@ -57,18 +61,25 @@ namespace Vanara.PInvoke
{
/// <summary>The button has the TBSTYLE_CHECK style and is being clicked.</summary>
TBSTATE_CHECKED = 0x01,
/// <summary>Version 4.70. The button's text is cut off and an ellipsis is displayed.</summary>
TBSTATE_ELLIPSES = 0x40,
/// <summary>The button accepts user input. A button that does not have this state is grayed.</summary>
TBSTATE_ENABLED = 0x04,
/// <summary>The button is not visible and cannot receive user input.</summary>
TBSTATE_HIDDEN = 0x08,
/// <summary>The button is grayed.</summary>
TBSTATE_INDETERMINATE = 0x10,
/// <summary>Version 4.71. The button is marked. The interpretation of a marked item is dependent upon the application.</summary>
TBSTATE_MARKED = 0x80,
/// <summary>The button is being clicked.</summary>
TBSTATE_PRESSED = 0x02,
/// <summary>The button is followed by a line break. The button must also have the TBSTATE_ENABLED state.</summary>
TBSTATE_WRAP = 0x20,
}
@ -210,52 +221,72 @@ namespace Vanara.PInvoke
public enum ToolbarStyle : ushort
{
/// <summary>
/// Allows users to change a toolbar button's position by dragging it while holding down the ALT key. If this style is not specified, the user must
/// hold down the SHIFT key while dragging a button. Note that the CCS_ADJUSTABLE style must be specified to enable toolbar buttons to be dragged.
/// Allows users to change a toolbar button's position by dragging it while holding down the ALT key. If this style is not
/// specified, the user must hold down the SHIFT key while dragging a button. Note that the CCS_ADJUSTABLE style must be
/// specified to enable toolbar buttons to be dragged.
/// </summary>
TBSTYLE_ALTDRAG = 0x0400,
/// <summary>Equivalent to BTNS_AUTOSIZE. Use TBSTYLE_AUTOSIZE for version 4.72 and earlier.</summary>
TBSTYLE_AUTOSIZE = 0x0010,
/// <summary>Equivalent to BTNS_BUTTON. Use TBSTYLE_BUTTON for version 4.72 and earlier.</summary>
TBSTYLE_BUTTON = 0x0000,
/// <summary>Equivalent to BTNS_CHECK. Use TBSTYLE_CHECK for version 4.72 and earlier.</summary>
TBSTYLE_CHECK = 0x0002,
/// <summary>Equivalent to BTNS_CHECKGROUP. Use TBSTYLE_CHECKGROUP for version 4.72 and earlier.</summary>
TBSTYLE_CHECKGROUP = (TBSTYLE_GROUP | TBSTYLE_CHECK),
/// <summary>Version 4.70. Generates NM_CUSTOMDRAW notification codes when the toolbar processes WM_ERASEBKGND messages.</summary>
TBSTYLE_CUSTOMERASE = 0x2000,
/// <summary>Equivalent to BTNS_DROPDOWN. Use TBSTYLE_DROPDOWN for version 4.72 and earlier.</summary>
TBSTYLE_DROPDOWN = 0x0008,
/// <summary>
/// Version 4.70. Creates a flat toolbar. In a flat toolbar, both the toolbar and the buttons are transparent and hot-tracking is enabled. Button
/// text appears under button bitmaps. To prevent repainting problems, this style should be set before the toolbar control becomes visible.
/// Version 4.70. Creates a flat toolbar. In a flat toolbar, both the toolbar and the buttons are transparent and hot-tracking is
/// enabled. Button text appears under button bitmaps. To prevent repainting problems, this style should be set before the
/// toolbar control becomes visible.
/// </summary>
TBSTYLE_FLAT = 0x0800,
/// <summary>Equivalent to BTNS_GROUP. Use TBSTYLE_GROUP for version 4.72 and earlier.</summary>
TBSTYLE_GROUP = 0x0004,
/// <summary>
/// Version 4.70. Creates a flat toolbar with button text to the right of the bitmap. Otherwise, this style is identical to TBSTYLE_FLAT. To prevent
/// repainting problems, this style should be set before the toolbar control becomes visible.
/// Version 4.70. Creates a flat toolbar with button text to the right of the bitmap. Otherwise, this style is identical to
/// TBSTYLE_FLAT. To prevent repainting problems, this style should be set before the toolbar control becomes visible.
/// </summary>
TBSTYLE_LIST = 0x1000,
/// <summary>Equivalent to BTNS_NOPREFIX. Use TBSTYLE_NOPREFIX for version 4.72 and earlier.</summary>
TBSTYLE_NOPREFIX = 0x0020,
/// <summary>Version 4.71. Generates TBN_GETOBJECT notification codes to request drop target objects when the cursor passes over toolbar buttons.</summary>
/// <summary>
/// Version 4.71. Generates TBN_GETOBJECT notification codes to request drop target objects when the cursor passes over toolbar buttons.
/// </summary>
TBSTYLE_REGISTERDROP = 0x4000,
/// <summary>Equivalent to BTNS_SEP. Use TBSTYLE_SEP for version 4.72 and earlier.</summary>
TBSTYLE_SEP = 0x0001,
/// <summary>Creates a tooltip control that an application can use to display descriptive text for the buttons in the toolbar.</summary>
TBSTYLE_TOOLTIPS = 0x0100,
/// <summary>
/// Version 4.71. Creates a transparent toolbar. In a transparent toolbar, the toolbar is transparent but the buttons are not. Button text appears
/// under button bitmaps. To prevent repainting problems, this style should be set before the toolbar control becomes visible.
/// Version 4.71. Creates a transparent toolbar. In a transparent toolbar, the toolbar is transparent but the buttons are not.
/// Button text appears under button bitmaps. To prevent repainting problems, this style should be set before the toolbar control
/// becomes visible.
/// </summary>
TBSTYLE_TRANSPARENT = 0x8000,
/// <summary>
/// Creates a toolbar that can have multiple lines of buttons. Toolbar buttons can "wrap" to the next line when the toolbar becomes too narrow to
/// include all buttons on the same line. When the toolbar is wrapped, the break will occur on either the rightmost separator or the rightmost button
/// if there are no separators on the bar. This style must be set to display a vertical toolbar control when the toolbar is part of a vertical rebar
/// control. This style cannot be combined with CCS_VERT.
/// Creates a toolbar that can have multiple lines of buttons. Toolbar buttons can "wrap" to the next line when the toolbar
/// becomes too narrow to include all buttons on the same line. When the toolbar is wrapped, the break will occur on either the
/// rightmost separator or the rightmost button if there are no separators on the bar. This style must be set to display a
/// vertical toolbar control when the toolbar is part of a vertical rebar control. This style cannot be combined with CCS_VERT.
/// </summary>
TBSTYLE_WRAPABLE = 0x0200,
}
@ -267,45 +298,52 @@ namespace Vanara.PInvoke
public enum ToolbarStyleEx
{
/// <summary>
/// Version 4.71. This style allows buttons to have a separate dropdown arrow. Buttons that have the BTNS_DROPDOWN style will be drawn with a
/// dropdown arrow in a separate section, to the right of the button. If the arrow is clicked, only the arrow portion of the button will depress, and
/// the toolbar control will send a TBN_DROPDOWN notification code to prompt the application to display the dropdown menu. If the main part of the
/// button is clicked, the toolbar control sends a WM_COMMAND message with the button's ID. The application normally responds by launching the first
/// command on the menu. There are many situations where you may want to have only some of the dropdown buttons on a toolbar with separated arrows.
/// To do so, set the TBSTYLE_EX_DRAWDDARROWS extended style. Give those buttons that will not have separated arrows the BTNS_WHOLEDROPDOWN style.
/// Buttons with this style will have an arrow displayed next to the image. However, the arrow will not be separate and when any part of the button
/// is clicked, the toolbar control will send a TBN_DROPDOWN notification code. To prevent repainting problems, this style should be set before the
/// toolbar control becomes visible.
/// Version 4.71. This style allows buttons to have a separate dropdown arrow. Buttons that have the BTNS_DROPDOWN style will be
/// drawn with a dropdown arrow in a separate section, to the right of the button. If the arrow is clicked, only the arrow
/// portion of the button will depress, and the toolbar control will send a TBN_DROPDOWN notification code to prompt the
/// application to display the dropdown menu. If the main part of the button is clicked, the toolbar control sends a WM_COMMAND
/// message with the button's ID. The application normally responds by launching the first command on the menu. There are many
/// situations where you may want to have only some of the dropdown buttons on a toolbar with separated arrows. To do so, set the
/// TBSTYLE_EX_DRAWDDARROWS extended style. Give those buttons that will not have separated arrows the BTNS_WHOLEDROPDOWN style.
/// Buttons with this style will have an arrow displayed next to the image. However, the arrow will not be separate and when any
/// part of the button is clicked, the toolbar control will send a TBN_DROPDOWN notification code. To prevent repainting
/// problems, this style should be set before the toolbar control becomes visible.
/// </summary>
TBSTYLE_EX_DRAWDDARROWS = 0x00000001,
/// <summary>
/// Version 5.81. This style allows you to set text for all buttons, but only display it for those buttons with the BTNS_SHOWTEXT button style. The
/// TBSTYLE_LIST style must also be set. Normally, when a button does not display text, your application must handle TBN_GETINFOTIP or
/// TTN_GETDISPINFO to display a tooltip. With the TBSTYLE_EX_MIXEDBUTTONS extended style, text that is set but not displayed on a button will
/// automatically be used as the button's tooltip text. Your application only needs to handle TBN_GETINFOTIP or or TTN_GETDISPINFO if it needs more
/// flexibility in specifying the tooltip text.
/// Version 5.81. This style allows you to set text for all buttons, but only display it for those buttons with the BTNS_SHOWTEXT
/// button style. The TBSTYLE_LIST style must also be set. Normally, when a button does not display text, your application must
/// handle TBN_GETINFOTIP or TTN_GETDISPINFO to display a tooltip. With the TBSTYLE_EX_MIXEDBUTTONS extended style, text that is
/// set but not displayed on a button will automatically be used as the button's tooltip text. Your application only needs to
/// handle TBN_GETINFOTIP or or TTN_GETDISPINFO if it needs more flexibility in specifying the tooltip text.
/// </summary>
TBSTYLE_EX_MIXEDBUTTONS = 0x00000008,
/// <summary>
/// Version 5.81. This style hides partially clipped buttons. The most common use of this style is for toolbars that are part of a rebar control. If
/// an adjacent band covers part of a button, the button will not be displayed. However, if the rebar band has the RBBS_USECHEVRON style, the button
/// will be displayed on the chevron's dropdown menu.
/// Version 5.81. This style hides partially clipped buttons. The most common use of this style is for toolbars that are part of
/// a rebar control. If an adjacent band covers part of a button, the button will not be displayed. However, if the rebar band
/// has the RBBS_USECHEVRON style, the button will be displayed on the chevron's dropdown menu.
/// </summary>
TBSTYLE_EX_HIDECLIPPEDBUTTONS = 0x00000010,
/// <summary>
/// Version 5.82. Intended for internal use; not recommended for use in applications. This style gives the toolbar a vertical orientation and
/// organizes the toolbar buttons into columns. The buttons flow down vertically until a button has exceeded the bounding height of the toolbar (see
/// TB_SETBOUNDINGSIZE), and then a new column is created. The toolbar flows the buttons in this manner until all buttons are positioned. To use this
/// style, the TBSTYLE_EX_VERTICAL style must also be set.
/// Version 5.82. Intended for internal use; not recommended for use in applications. This style gives the toolbar a vertical
/// orientation and organizes the toolbar buttons into columns. The buttons flow down vertically until a button has exceeded the
/// bounding height of the toolbar (see TB_SETBOUNDINGSIZE), and then a new column is created. The toolbar flows the buttons in
/// this manner until all buttons are positioned. To use this style, the TBSTYLE_EX_VERTICAL style must also be set.
/// </summary>
TBSTYLE_EX_MULTICOLUMN = 0x00000002,
/// <summary>
/// Version 5.82. Intended for internal use; not recommended for use in applications. This style gives the toolbar a vertical orientation. Toolbar
/// buttons flow from top to bottom instead of horizontally.
/// Version 5.82. Intended for internal use; not recommended for use in applications. This style gives the toolbar a vertical
/// orientation. Toolbar buttons flow from top to bottom instead of horizontally.
/// </summary>
TBSTYLE_EX_VERTICAL = 0x00000004,
/// <summary>
/// Version 6. This style requires the toolbar to be double buffered. Double buffering is a mechanism that detects when the toolbar has changed.
/// Version 6. This style requires the toolbar to be double buffered. Double buffering is a mechanism that detects when the
/// toolbar has changed.
/// </summary>
TBSTYLE_EX_DOUBLEBUFFER = 0x00000080,
}
@ -338,8 +376,8 @@ namespace Vanara.PInvoke
/// <param name="lpColorMap">
/// <para>Type: <c>LPCOLORMAP</c></para>
/// <para>
/// Pointer to a <c>COLORMAP</c> structure that contains the color information needed to map the bitmaps. If this parameter is <c>NULL</c>, the function
/// uses the default color map.
/// Pointer to a <c>COLORMAP</c> structure that contains the color information needed to map the bitmaps. If this parameter is
/// <c>NULL</c>, the function uses the default color map.
/// </para>
/// </param>
/// <param name="iNumMaps">
@ -348,12 +386,14 @@ namespace Vanara.PInvoke
/// </param>
/// <returns>
/// <para>Type: <c><c>HBITMAP</c></c></para>
/// <para>Returns the handle to the bitmap if successful, or <c>NULL</c> otherwise. To retrieve extended error information, call <c>GetLastError</c>.</para>
/// <para>
/// Returns the handle to the bitmap if successful, or <c>NULL</c> otherwise. To retrieve extended error information, call <c>GetLastError</c>.
/// </para>
/// </returns>
// HBITMAP CreateMappedBitmap( HINSTANCE hInstance, INT_PTR idBitmap, UINT wFlags, _In_ LPCOLORMAP lpColorMap, int iNumMaps); https://msdn.microsoft.com/en-us/library/windows/desktop/bb787467(v=vs.85).aspx
[DllImport(Lib.ComCtl32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("Commctrl.h", MSDNShortId = "bb787467")]
public static extern IntPtr CreateMappedBitmap(HINSTANCE hInstance, SafeResourceId idBitmap, CMB wFlags, ref COLORMAP lpColorMap, int iNumMaps);
public static extern IntPtr CreateMappedBitmap(HINSTANCE hInstance, SafeResourceId idBitmap, CMB wFlags, in COLORMAP lpColorMap, int iNumMaps);
/// <summary>Contains information used by the <c>CreateMappedBitmap</c> function to map the colors of the bitmap.</summary>
// typedef struct _COLORMAP { COLORREF from; COLORREF to;} COLORMAP, *LPCOLORMAP; https://msdn.microsoft.com/en-us/library/windows/desktop/bb760448(v=vs.85).aspx
@ -365,6 +405,7 @@ namespace Vanara.PInvoke
/// <para>Color to map from.</para>
/// </summary>
public COLORREF from;
/// <summary>
/// <para>Type: <c><c>COLORREF</c></c></para>
/// <para>Color to map to.</para>
@ -372,8 +413,11 @@ namespace Vanara.PInvoke
public COLORREF to;
}
/// <summary>Contains and receives display information for a toolbar item. This structure is used with the TBN_GETDISPINFO notification code.</summary>
// typedef struct { NMHDR hdr; DWORD dwMask; int idCommand; DWORD_PTR lParam; int iImage; LPTSTR pszText; int cchText;} NMTBDISPINFO, *LPNMTBDISPINFO; https://msdn.microsoft.com/en-us/library/windows/desktop/bb760452(v=vs.85).aspx
/// <summary>
/// Contains and receives display information for a toolbar item. This structure is used with the TBN_GETDISPINFO notification code.
/// </summary>
// typedef struct { NMHDR hdr; DWORD dwMask; int idCommand; DWORD_PTR lParam; int iImage; LPTSTR pszText; int cchText;} NMTBDISPINFO,
// *LPNMTBDISPINFO; https://msdn.microsoft.com/en-us/library/windows/desktop/bb760452(v=vs.85).aspx
[PInvokeData("Commctrl.h", MSDNShortId = "bb760452")]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
public struct NMTBDISPINFO
@ -383,9 +427,12 @@ namespace Vanara.PInvoke
/// <para><c>NMHDR</c> structure that contains additional information about the notification.</para>
/// </summary>
public NMHDR hdr;
/// <summary>
/// <para>Type: <c><c>DWORD</c></c></para>
/// <para>Set of flags that indicate which members of this structure are being requested. This can be one or more of the following values.</para>
/// <para>
/// Set of flags that indicate which members of this structure are being requested. This can be one or more of the following values.
/// </para>
/// <para>
/// <list type="table">
/// <listheader>
@ -394,7 +441,7 @@ namespace Vanara.PInvoke
/// </listheader>
/// <item>
/// <term>TBNF_IMAGE</term>
/// <term>The item&amp;#39;s image index is being requested. The image index must be placed in the iImage member.</term>
/// <term>The item's image index is being requested. The image index must be placed in the iImage member.</term>
/// </item>
/// <item>
/// <term>TBNF_TEXT</term>
@ -402,38 +449,45 @@ namespace Vanara.PInvoke
/// </item>
/// <item>
/// <term>TBNF_DI_SETITEM</term>
/// <term>Set this flag when processing TBN_GETDISPINFO; the toolbar control will retain the supplied information and not request it again.</term>
/// <term>
/// Set this flag when processing TBN_GETDISPINFO; the toolbar control will retain the supplied information and not request it again.
/// </term>
/// </item>
/// </list>
/// </para>
/// </summary>
public uint dwMask;
/// <summary>
/// <para>Type: <c>int</c></para>
/// <para>
/// Command identifier of the item for which display information is being requested. This member is filled in by the control before it sends the
/// notification code.
/// Command identifier of the item for which display information is being requested. This member is filled in by the control
/// before it sends the notification code.
/// </para>
/// </summary>
public int idCommand;
/// <summary>
/// <para>Type: <c><c>DWORD_PTR</c></c></para>
/// <para>
/// Application-defined value associated with the item for which display information is being requested. This member is filled in by the control
/// before sending the notification code.
/// Application-defined value associated with the item for which display information is being requested. This member is filled in
/// by the control before sending the notification code.
/// </para>
/// </summary>
public IntPtr lParam;
/// <summary>
/// <para>Type: <c>int</c></para>
/// <para>Image index for the item.</para>
/// </summary>
public int iImage;
/// <summary>
/// <para>Type: <c><c>LPTSTR</c></c></para>
/// <para>Pointer to a character buffer that receives the item's text.</para>
/// </summary>
public string pszText;
/// <summary>
/// <para>Type: <c>int</c></para>
/// <para>Size of the <c>pszText</c> buffer, in characters.</para>
@ -441,8 +495,11 @@ namespace Vanara.PInvoke
public int cchText;
}
/// <summary>Contains and receives infotip information for a toolbar item. This structure is used with the TBN_GETINFOTIP notification code.</summary>
// typedef struct tagNMTBGETINFOTIP { NMHDR hdr; LPTSTR pszText; int cchTextMax; int iItem; LPARAM lParam;} NMTBGETINFOTIP, *LPNMTBGETINFOTIP; https://msdn.microsoft.com/en-us/library/windows/desktop/bb760454(v=vs.85).aspx
/// <summary>
/// Contains and receives infotip information for a toolbar item. This structure is used with the TBN_GETINFOTIP notification code.
/// </summary>
// typedef struct tagNMTBGETINFOTIP { NMHDR hdr; LPTSTR pszText; int cchTextMax; int iItem; LPARAM lParam;} NMTBGETINFOTIP,
// *LPNMTBGETINFOTIP; https://msdn.microsoft.com/en-us/library/windows/desktop/bb760454(v=vs.85).aspx
[PInvokeData("Commctrl.h", MSDNShortId = "bb760454")]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
public struct NMTBGETINFOTIP
@ -452,32 +509,36 @@ namespace Vanara.PInvoke
/// <para><c>NMHDR</c> structure that contains additional information about the notification.</para>
/// </summary>
public NMHDR hdr;
/// <summary>
/// <para>Type: <c><c>LPTSTR</c></c></para>
/// <para>Address of a character buffer that receives the infotip text.</para>
/// </summary>
public string pszText;
/// <summary>
/// <para>Type: <c>int</c></para>
/// <para>
/// Size of the buffer, in characters, at <c>pszText</c>. In most cases, the buffer will be INFOTIPSIZE characters in size, but you should always
/// make sure that your application does not copy more than <c>cchTextMax</c> characters to the buffer at <c>pszText</c>.
/// Size of the buffer, in characters, at <c>pszText</c>. In most cases, the buffer will be INFOTIPSIZE characters in size, but
/// you should always make sure that your application does not copy more than <c>cchTextMax</c> characters to the buffer at <c>pszText</c>.
/// </para>
/// </summary>
public int cchTextMax;
/// <summary>
/// <para>Type: <c>int</c></para>
/// <para>
/// The command identifier of the item for which infotip information is being requested. This member is filled in by the control before sending the
/// notification code.
/// The command identifier of the item for which infotip information is being requested. This member is filled in by the control
/// before sending the notification code.
/// </para>
/// </summary>
public int iItem;
/// <summary>
/// <para>Type: <c><c>LPARAM</c></c></para>
/// <para>
/// The application-defined value associated with the item for which infotip information is being requested. This member is filled in by the control
/// before sending the notification code.
/// The application-defined value associated with the item for which infotip information is being requested. This member is
/// filled in by the control before sending the notification code.
/// </para>
/// </summary>
public IntPtr lParam;
@ -494,16 +555,19 @@ namespace Vanara.PInvoke
/// <para><c>NMHDR</c> structure that contains additional information about the notification.</para>
/// </summary>
public NMHDR hdr;
/// <summary>
/// <para>Type: <c>int</c></para>
/// <para>Command identifier of the previously highlighted item.</para>
/// </summary>
public int idOld;
/// <summary>
/// <para>Type: <c>int</c></para>
/// <para>Command identifier of the item about to be highlighted.</para>
/// </summary>
public int idNew;
/// <summary>
/// <para>Type: <c><c>DWORD</c></c></para>
/// <para>Flags that indicate why the hot item has changed. This can be one or more of the following values:</para>
@ -527,7 +591,9 @@ namespace Vanara.PInvoke
/// </item>
/// <item>
/// <term>HICF_ENTERING</term>
/// <term>Modifies the other reason flags. If this flag is set, there is no previous hot item and idOld does not contain valid information.</term>
/// <term>
/// Modifies the other reason flags. If this flag is set, there is no previous hot item and idOld does not contain valid information.
/// </term>
/// </item>
/// <item>
/// <term>HICF_LEAVING</term>
@ -544,8 +610,8 @@ namespace Vanara.PInvoke
/// <item>
/// <term>HICF_OTHER</term>
/// <term>
/// The change in the hot item resulted from an event that could not be determined. This will most often be due to a change in focus or the
/// TB_SETHOTITEM message.
/// The change in the hot item resulted from an event that could not be determined. This will most often be due to a change in
/// focus or the TB_SETHOTITEM message.
/// </term>
/// </item>
/// <item>
@ -563,11 +629,11 @@ namespace Vanara.PInvoke
}
/// <summary>
/// Allows applications to extract the information that was placed in <c>NMTBSAVE</c> when the toolbar state was saved. This structure is passed to
/// applications when they receive a TBN_RESTORE notification code.
/// Allows applications to extract the information that was placed in <c>NMTBSAVE</c> when the toolbar state was saved. This
/// structure is passed to applications when they receive a TBN_RESTORE notification code.
/// </summary>
// typedef struct tagNMTBRESTORE { NMHDR nmhdr; DWORD *pData; DWORD *pCurrent; UINT cbData; int iItem; int cButtons; int cbBytesPerRecord; TBBUTTON
// tbButton;} NMTBRESTORE, *LPNMTBRESTORE; https://msdn.microsoft.com/en-us/library/windows/desktop/bb760458(v=vs.85).aspx
// typedef struct tagNMTBRESTORE { NMHDR nmhdr; DWORD *pData; DWORD *pCurrent; UINT cbData; int iItem; int cButtons; int
// cbBytesPerRecord; TBBUTTON tbButton;} NMTBRESTORE, *LPNMTBRESTORE; https://msdn.microsoft.com/en-us/library/windows/desktop/bb760458(v=vs.85).aspx
[PInvokeData("Commctrl.h", MSDNShortId = "bb760458")]
[StructLayout(LayoutKind.Sequential)]
public struct NMTBRESTORE
@ -577,65 +643,73 @@ namespace Vanara.PInvoke
/// <para><c>NMHDR</c> structure that contains additional information about the notification.</para>
/// </summary>
public NMHDR hdr;
/// <summary>
/// <para>Type: <c><c>DWORD</c>*</c></para>
/// <para>
/// Pointer to the data stream with the stored save information. It contains Shell-defined blocks of information for each button, alternating with
/// application-defined blocks. Applications may also place a block of global data at the start of <c>pData</c>. The format and length of the
/// application-defined blocks are determined by the application.
/// Pointer to the data stream with the stored save information. It contains Shell-defined blocks of information for each button,
/// alternating with application-defined blocks. Applications may also place a block of global data at the start of <c>pData</c>.
/// The format and length of the application-defined blocks are determined by the application.
/// </para>
/// </summary>
public IntPtr pData;
/// <summary>
/// <para>Type: <c><c>DWORD</c>*</c></para>
/// <para>
/// Pointer to the current block of application-defined data. After extracting the data, the application must advance <c>pCurrent</c> to the end of
/// the block, so it is pointing to the next block of Shell-defined data.
/// Pointer to the current block of application-defined data. After extracting the data, the application must advance
/// <c>pCurrent</c> to the end of the block, so it is pointing to the next block of Shell-defined data.
/// </para>
/// </summary>
public IntPtr pCurrent;
/// <summary>
/// <para>Type: <c><c>UINT</c></c></para>
/// <para>Size of <c>pData</c>.</para>
/// </summary>
public uint cbData;
/// <summary>
/// <para>Type: <c>int</c></para>
/// <para>
/// Value of -1 indicates that the restore is starting, and <c>pCurrent</c> will point to the start of the data stream. Otherwise, it is the
/// zero-based button index, and <c>pCurrent</c> will point to the current button's data.
/// Value of -1 indicates that the restore is starting, and <c>pCurrent</c> will point to the start of the data stream.
/// Otherwise, it is the zero-based button index, and <c>pCurrent</c> will point to the current button's data.
/// </para>
/// </summary>
public int iItem;
/// <summary>
/// <para>Type: <c>int</c></para>
/// <para>
/// Estimate of the number of buttons. Because the estimate is based on the size of the data stream, it might be incorrect. The client should update
/// it as appropriate.
/// Estimate of the number of buttons. Because the estimate is based on the size of the data stream, it might be incorrect. The
/// client should update it as appropriate.
/// </para>
/// </summary>
public int cButtons;
/// <summary>
/// <para>Type: <c>int</c></para>
/// <para>
/// Number of bytes needed to hold the data for each button. When the restore starts, <c>cbBytesPerRecord</c> will be set to the size of the
/// Shell-defined data structure. You need to increment it by the size of the structure that holds the application-defined data.
/// Number of bytes needed to hold the data for each button. When the restore starts, <c>cbBytesPerRecord</c> will be set to the
/// size of the Shell-defined data structure. You need to increment it by the size of the structure that holds the
/// application-defined data.
/// </para>
/// </summary>
public int cbBytesPerRecord;
/// <summary>
/// <para>Type: <c><c>TBBUTTON</c></c></para>
/// <para>
/// <c>TBBUTTON</c> structure that contains information about the button currently being restored. Applications must modify this structure as
/// necessary before returning.
/// <c>TBBUTTON</c> structure that contains information about the button currently being restored. Applications must modify this
/// structure as necessary before returning.
/// </para>
/// </summary>
public TBBUTTON tbButton;
}
/// <summary>
/// This structure is passed to applications when they receive a TBN_SAVE notification code. It contains information about the button currently being
/// saved. Applications can modify the values of the members to save additional information.
/// This structure is passed to applications when they receive a TBN_SAVE notification code. It contains information about the button
/// currently being saved. Applications can modify the values of the members to save additional information.
/// </summary>
// typedef struct tagNMTBSAVE { NMHDR hdr; DWORD *pData; DWORD *pCurrent; UINT cbData; int iItem; int cButtons; TBBUTTON tbButton;} NMTBSAVE,
// *LPNMTBSAVE; https://msdn.microsoft.com/en-us/library/windows/desktop/bb760471(v=vs.85).aspx
@ -648,45 +722,56 @@ namespace Vanara.PInvoke
/// <para>An <c>NMHDR</c> structure that contains additional information about the notification.</para>
/// </summary>
public NMHDR hdr;
/// <summary>
/// <para>Type: <c><c>DWORD</c>*</c></para>
/// <para>
/// A pointer to the data stream used to store the save information. When complete, it will contain blocks of Shell-defined information for each
/// button, alternating with blocks defined by the application. Applications may also choose to place a block of global data at the start of
/// <c>pData</c>. The format and length of the application-defined blocks are determined by the application. When the save starts, the Shell will
/// pass the amount of memory it needs in <c>cbData</c>, but no memory will be allocated. You must allocate enough memory for <c>pData</c> to hold
/// your data, plus the Shell's.
/// A pointer to the data stream used to store the save information. When complete, it will contain blocks of Shell-defined
/// information for each button, alternating with blocks defined by the application. Applications may also choose to place a
/// block of global data at the start of <c>pData</c>. The format and length of the application-defined blocks are determined by
/// the application. When the save starts, the Shell will pass the amount of memory it needs in <c>cbData</c>, but no memory will
/// be allocated. You must allocate enough memory for <c>pData</c> to hold your data, plus the Shell's.
/// </para>
/// </summary>
public IntPtr pData;
/// <summary>
/// <para>Type: <c><c>DWORD</c>*</c></para>
/// <para>
/// A pointer to the start of the unused portion of the data stream. You should load your data here, and then advance <c>pCurrent</c> to the start of
/// the remaining unused portion. The Shell will then load the information for the next button, advance <c>pCurrent</c>, and so on.
/// A pointer to the start of the unused portion of the data stream. You should load your data here, and then advance
/// <c>pCurrent</c> to the start of the remaining unused portion. The Shell will then load the information for the next button,
/// advance <c>pCurrent</c>, and so on.
/// </para>
/// </summary>
public IntPtr pCurrent;
/// <summary>
/// <para>Type: <c><c>UINT</c></c></para>
/// <para>
/// The size of the data stream. When the save starts, <c>cbData</c> will be set to the amount of data needed by the Shell. You should change it to
/// the total amount allocated.
/// The size of the data stream. When the save starts, <c>cbData</c> will be set to the amount of data needed by the Shell. You
/// should change it to the total amount allocated.
/// </para>
/// </summary>
public uint cbData;
/// <summary>
/// <para>Type: <c>int</c></para>
/// <para>This parameter is usually the zero-based index of the button currently being saved. It is set to -1 to indicate that a save is starting.</para>
/// </summary>
public int iItem;
/// <summary>
/// <para>Type: <c>int</c></para>
/// <para>
/// An estimate of the number of buttons. Because it is based on the size of the data stream, it may be incorrect. The client should update it as appropriate.
/// This parameter is usually the zero-based index of the button currently being saved. It is set to -1 to indicate that a save
/// is starting.
/// </para>
/// </summary>
public int iItem;
/// <summary>
/// <para>Type: <c>int</c></para>
/// <para>
/// An estimate of the number of buttons. Because it is based on the size of the data stream, it may be incorrect. The client
/// should update it as appropriate.
/// </para>
/// </summary>
public int cButtons;
/// <summary>
/// <para>Type: <c><c>TBBUTTON</c></c></para>
/// <para>A <c>TBBUTTON</c> structure that contains information about the button currently being saved.</para>
@ -695,7 +780,8 @@ namespace Vanara.PInvoke
}
/// <summary>Contains information used to process toolbar notification codes. This structure supersedes the <c>TBNOTIFY</c> structure.</summary>
// typedef struct tagNMTOOLBAR { NMHDR hdr; int iItem; TBBUTTON tbButton; int cchText; LPTSTR pszText; RECT rcButton;} NMTOOLBAR, *LPNMTOOLBAR; https://msdn.microsoft.com/en-us/library/windows/desktop/bb760473(v=vs.85).aspx
// typedef struct tagNMTOOLBAR { NMHDR hdr; int iItem; TBBUTTON tbButton; int cchText; LPTSTR pszText; RECT rcButton;} NMTOOLBAR,
// *LPNMTOOLBAR; https://msdn.microsoft.com/en-us/library/windows/desktop/bb760473(v=vs.85).aspx
[PInvokeData("Commctrl.h", MSDNShortId = "bb760473")]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
public struct NMTOOLBAR
@ -705,29 +791,34 @@ namespace Vanara.PInvoke
/// <para><c>NMHDR</c> structure that contains additional information about the notification.</para>
/// </summary>
public NMHDR hdr;
/// <summary>
/// <para>Type: <c>int</c></para>
/// <para>Command identifier of the button associated with the notification code.</para>
/// </summary>
public int iItem;
/// <summary>
/// <para>Type: <c><c>TBBUTTON</c></c></para>
/// <para>
/// <c>TBBUTTON</c> structure that contains information about the toolbar button associated with the notification code. This member only contains
/// valid information with the TBN_QUERYINSERT and TBN_QUERYDELETE notification codes.
/// <c>TBBUTTON</c> structure that contains information about the toolbar button associated with the notification code. This
/// member only contains valid information with the TBN_QUERYINSERT and TBN_QUERYDELETE notification codes.
/// </para>
/// </summary>
public TBBUTTON tbButton;
/// <summary>
/// <para>Type: <c>int</c></para>
/// <para>Count of characters in the button text.</para>
/// </summary>
public int cchText;
/// <summary>
/// <para>Type: <c><c>LPTSTR</c></c></para>
/// <para>Address of a character buffer that contains the button text.</para>
/// </summary>
public string pszText;
/// <summary>
/// <para>Type: <c><c>RECT</c></c></para>
/// <para>Version 5.80. A <c>RECT</c> structure that defines the area covered by the button.</para>
@ -744,12 +835,12 @@ namespace Vanara.PInvoke
/// <summary>
/// <para>Type: <c><c>HINSTANCE</c></c></para>
/// <para>
/// Handle to the module instance with the executable file that contains a bitmap resource. To use bitmap handles instead of resource IDs, set this
/// member to <c>NULL</c>.
/// Handle to the module instance with the executable file that contains a bitmap resource. To use bitmap handles instead of
/// resource IDs, set this member to <c>NULL</c>.
/// </para>
/// <para>
/// You can add the system-defined button bitmaps to the list by specifying HINST_COMMCTRL as the <c>hInst</c> member and one of the following values
/// as the <c>nID</c> member.
/// You can add the system-defined button bitmaps to the list by specifying HINST_COMMCTRL as the <c>hInst</c> member and one of
/// the following values as the <c>nID</c> member.
/// </para>
/// <para>
/// <list type="table">
@ -792,39 +883,44 @@ namespace Vanara.PInvoke
/// </list>
/// </para>
/// </summary>
public IntPtr hInst;
public HINSTANCE hInst;
/// <summary>
/// <para>Type: <c><c>UINT_PTR</c></c></para>
/// <para>
/// If <c>hInst</c> is <c>NULL</c>, set this member to the bitmap handle of the bitmap with the button images. Otherwise, set it to the resource
/// identifier of the bitmap with the button images.
/// If <c>hInst</c> is <c>NULL</c>, set this member to the bitmap handle of the bitmap with the button images. Otherwise, set it
/// to the resource identifier of the bitmap with the button images.
/// </para>
/// </summary>
public IntPtr nID;
}
/// <summary>Contains information about a button in a toolbar.</summary>
// typedef struct { int iBitmap; int idCommand; BYTE fsState; BYTE fsStyle;#ifdef _WIN64 BYTE bReserved[6];#else #if defined(_WIN32) BYTE bReserved[2];#endif #endif DWORD_PTR dwData; INT_PTR iString;} TBBUTTON, *PTBBUTTON, *LPTBBUTTON;
// https://msdn.microsoft.com/en-us/library/windows/desktop/bb760476(v=vs.85).aspx
// typedef struct { int iBitmap; int idCommand; BYTE fsState; BYTE fsStyle;#ifdef _WIN64 BYTE bReserved[6];#else #if defined(_WIN32)
// BYTE bReserved[2];#endif #endif DWORD_PTR dwData; INT_PTR iString;} TBBUTTON, *PTBBUTTON, *LPTBBUTTON; https://msdn.microsoft.com/en-us/library/windows/desktop/bb760476(v=vs.85).aspx
[PInvokeData("Commctrl.h", MSDNShortId = "bb760476")]
[StructLayout(LayoutKind.Sequential)]
public struct TBBUTTON
{
/// <summary>
/// Zero-based index of the button image. Set this member to I_IMAGECALLBACK, and the toolbar will send the TBN_GETDISPINFO notification code to
/// retrieve the image index when it is needed.
/// Zero-based index of the button image. Set this member to I_IMAGECALLBACK, and the toolbar will send the TBN_GETDISPINFO
/// notification code to retrieve the image index when it is needed.
/// <para>
/// Version 5.81. Set this member to I_IMAGENONE to indicate that the button does not have an image.The button layout will not include any space for
/// a bitmap, only text.
/// Version 5.81. Set this member to I_IMAGENONE to indicate that the button does not have an image.The button layout will not
/// include any space for a bitmap, only text.
/// </para>
/// <para>
/// If the button is a separator, that is, if fsStyle is set to BTNS_SEP, iBitmap determines the width of the separator, in pixels.For information on
/// selecting button images from image lists, see TB_SETIMAGELIST message.
/// If the button is a separator, that is, if fsStyle is set to BTNS_SEP, iBitmap determines the width of the separator, in
/// pixels.For information on selecting button images from image lists, see TB_SETIMAGELIST message.
/// </para>
/// </summary>
public int iBitmap;
/// <summary>Command identifier associated with the button. This identifier is used in a WM_COMMAND message when the button is chosen.</summary>
/// <summary>
/// Command identifier associated with the button. This identifier is used in a WM_COMMAND message when the button is chosen.
/// </summary>
public int idCommand;
// Funky holder to make preprocessor directives work
private TBBUTTON_U union;
@ -836,21 +932,22 @@ namespace Vanara.PInvoke
/// <summary>Application-defined value.</summary>
public IntPtr dwData;
/// <summary>Zero-based index of the button string, or a pointer to a string buffer that contains text for the button.</summary>
public IntPtr iString;
[StructLayout(LayoutKind.Explicit, Pack = 1)]
private struct TBBUTTON_U
{
[FieldOffset(0)] private IntPtr bReserved;
[FieldOffset(0)] private readonly IntPtr bReserved;
[FieldOffset(0)] public TBSTATE fsState;
[FieldOffset(1)] public ToolbarStyle fsStyle;
}
}
/// <summary>Contains or receives information for a specific button in a toolbar.</summary>
// typedef struct { UINT cbSize; DWORD dwMask; int idCommand; int iImage; BYTE fsState; BYTE fsStyle; WORD cx; DWORD_PTR lParam; LPTSTR pszText; int
// cchText;} TBBUTTONINFO, *LPTBBUTTONINFO; https://msdn.microsoft.com/en-us/library/windows/desktop/bb760478(v=vs.85).aspx
// typedef struct { UINT cbSize; DWORD dwMask; int idCommand; int iImage; BYTE fsState; BYTE fsStyle; WORD cx; DWORD_PTR lParam;
// LPTSTR pszText; int cchText;} TBBUTTONINFO, *LPTBBUTTONINFO; https://msdn.microsoft.com/en-us/library/windows/desktop/bb760478(v=vs.85).aspx
[PInvokeData("Commctrl.h", MSDNShortId = "bb760478")]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto, Pack = 1)]
public struct TBBUTTONINFO
@ -860,11 +957,12 @@ namespace Vanara.PInvoke
/// <para>Size of the structure, in bytes. This member must be filled in prior to sending the associated message.</para>
/// </summary>
public uint cbSize;
/// <summary>
/// <para>Type: <c><c>DWORD</c></c></para>
/// <para>
/// Set of flags that indicate which members contain valid information. This member must be filled in prior to sending the associated message. This
/// can be one or more of the following values.
/// Set of flags that indicate which members contain valid information. This member must be filled in prior to sending the
/// associated message. This can be one or more of the following values.
/// </para>
/// <para>
/// <list type="table">
@ -908,48 +1006,56 @@ namespace Vanara.PInvoke
/// </para>
/// </summary>
public uint dwMask;
/// <summary>
/// <para>Type: <c>int</c></para>
/// <para>Command identifier of the button.</para>
/// </summary>
public int idCommand;
/// <summary>
/// <para>Type: <c>int</c></para>
/// <para>
/// Image index of the button. Set this member to I_IMAGECALLBACK, and the toolbar will send the TBN_GETDISPINFO notification code to retrieve the
/// image index when it is needed.
/// Image index of the button. Set this member to I_IMAGECALLBACK, and the toolbar will send the TBN_GETDISPINFO notification
/// code to retrieve the image index when it is needed.
/// </para>
/// <para>
/// Version 5.81. Set this member to I_IMAGENONE to indicate that the button does not have an image. The button layout will not include any space for
/// a bitmap, only text.
/// Version 5.81. Set this member to I_IMAGENONE to indicate that the button does not have an image. The button layout will not
/// include any space for a bitmap, only text.
/// </para>
/// </summary>
public int iImage;
/// <summary>
/// <para>Type: <c><c>BYTE</c></c></para>
/// <para>State flags of the button. This can be one or more of the values listed in Toolbar Button States.</para>
/// </summary>
public byte fsState;
/// <summary>
/// <para>Type: <c><c>BYTE</c></c></para>
/// <para>Style flags of the button. This can be one or more of the values listed in Toolbar Control and Button Styles.</para>
/// </summary>
public byte fsStyle;
/// <summary>
/// <para>Type: <c><c>WORD</c></c></para>
/// <para>Width of the button, in pixels.</para>
/// </summary>
public ushort cx;
/// <summary>
/// <para>Type: <c><c>DWORD_PTR</c></c></para>
/// <para>Application-defined value associated with the button.</para>
/// </summary>
public IntPtr lParam;
/// <summary>
/// <para>Type: <c><c>LPTSTR</c></c></para>
/// <para>Address of a character buffer that contains or receives the button text.</para>
/// </summary>
public string pszText;
/// <summary>
/// <para>Type: <c>int</c></para>
/// <para>Size of the buffer at <c>pszText</c>. If the button information is being set, this member is ignored.</para>
@ -968,6 +1074,7 @@ namespace Vanara.PInvoke
/// <para>Zero-based index of the insertion mark. If this member is -1, there is no insertion mark.</para>
/// </summary>
public int iButton;
/// <summary>
/// <para>Type: <c><c>DWORD</c></c></para>
/// <para>Defines where the insertion mark is in relation to <c>iButton</c>. This can be one of the following values:</para>
@ -996,7 +1103,8 @@ namespace Vanara.PInvoke
}
/// <summary>Defines the metrics of a toolbar that are used to shrink or expand toolbar items.</summary>
// typedef struct { UINT cbSize; DWORD dwMask; int cxPad; int cyPad; int cxBarPad; int cyBarPad; int cxButtonSpacing; int cyButtonSpacing;} TBMETRICS,
// typedef struct { UINT cbSize; DWORD dwMask; int cxPad; int cyPad; int cxBarPad; int cyBarPad; int cxButtonSpacing; int
// cyButtonSpacing;} TBMETRICS,
// *LPTBMETRICS; https://msdn.microsoft.com/en-us/library/windows/desktop/bb760482(v=vs.85).aspx
[PInvokeData("Commctrl.h", MSDNShortId = "bb760482")]
[StructLayout(LayoutKind.Sequential)]
@ -1007,6 +1115,7 @@ namespace Vanara.PInvoke
/// <para>Size of the <c>TBMETRICS</c> structure.</para>
/// </summary>
public uint cbSize;
/// <summary>
/// <para>Type: <c><c>DWORD</c></c></para>
/// <para>Mask that determines the metric to retrieve. It can be any combination of the following:</para>
@ -1032,31 +1141,37 @@ namespace Vanara.PInvoke
/// </para>
/// </summary>
public uint dwMask;
/// <summary>
/// <para>Type: <c>int</c></para>
/// <para>Width of the padding inside the toolbar buttons, between the content and the edge of the button.</para>
/// </summary>
public int cxPad;
/// <summary>
/// <para>Type: <c>int</c></para>
/// <para>Height of the padding inside the toolbar buttons, between the content and the edge of the button.</para>
/// </summary>
public int cyPad;
/// <summary>
/// <para>Type: <c>int</c></para>
/// <para>Width of the toolbar. Not used.</para>
/// </summary>
public int cxBarPad;
/// <summary>
/// <para>Type: <c>int</c></para>
/// <para>Height of the toolbar. Not used.</para>
/// </summary>
public int cyBarPad;
/// <summary>
/// <para>Type: <c>int</c></para>
/// <para>Width of the space between toolbar buttons.</para>
/// </summary>
public int cxButtonSpacing;
/// <summary>
/// <para>Type: <c>int</c></para>
/// <para>Height of the space between toolbar buttons.</para>
@ -1065,46 +1180,58 @@ namespace Vanara.PInvoke
}
/// <summary>Used with the <c>TB_REPLACEBITMAP</c> message to replace one toolbar bitmap with another.</summary>
// typedef struct { HINSTANCE hInstOld; UINT_PTR nIDOld; HINSTANCE hInstNew; UINT_PTR nIDNew; int nButtons;} TBREPLACEBITMAP, *LPTBREPLACEBITMAP; https://msdn.microsoft.com/en-us/library/windows/desktop/bb760484(v=vs.85).aspx
// typedef struct { HINSTANCE hInstOld; UINT_PTR nIDOld; HINSTANCE hInstNew; UINT_PTR nIDNew; int nButtons;} TBREPLACEBITMAP,
// *LPTBREPLACEBITMAP; https://msdn.microsoft.com/en-us/library/windows/desktop/bb760484(v=vs.85).aspx
[PInvokeData("Commctrl.h", MSDNShortId = "bb760484")]
[StructLayout(LayoutKind.Sequential)]
public struct TBREPLACEBITMAP
{
/// <summary>
/// <para>Type: <c><c>HINSTANCE</c></c></para>
/// <para>Module instance handle to the bitmap resource being replaced. Set this member to <c>NULL</c> to instead use a bitmap handle.</para>
/// <para>
/// Module instance handle to the bitmap resource being replaced. Set this member to <c>NULL</c> to instead use a bitmap handle.
/// </para>
/// </summary>
public IntPtr hInstOld;
public HINSTANCE hInstOld;
/// <summary>
/// <para>Type: <c><c>UINT_PTR</c></c></para>
/// <para>
/// If <c>hInstOld</c> is <c>NULL</c>, set this member to the bitmap handle of the bitmap that is being replaced. Otherwise, set it to the resource
/// identifier of the bitmap being replaced.
/// If <c>hInstOld</c> is <c>NULL</c>, set this member to the bitmap handle of the bitmap that is being replaced. Otherwise, set
/// it to the resource identifier of the bitmap being replaced.
/// </para>
/// </summary>
public IntPtr nIDOld;
/// <summary>
/// <para>Type: <c><c>HINSTANCE</c></c></para>
/// <para>Module instance handle that contains the new bitmap resource. Set this member to <c>NULL</c> to instead use a bitmap handle.</para>
/// <para>
/// Module instance handle that contains the new bitmap resource. Set this member to <c>NULL</c> to instead use a bitmap handle.
/// </para>
/// </summary>
public IntPtr hInstNew;
public HINSTANCE hInstNew;
/// <summary>
/// <para>Type: <c><c>UINT_PTR</c></c></para>
/// <para>
/// If <c>hInstNew</c> is <c>NULL</c>, set this member to the bitmap handle of the bitmap with the new button images. Otherwise, set it to the
/// resource identifier of the bitmap with the new button images.
/// If <c>hInstNew</c> is <c>NULL</c>, set this member to the bitmap handle of the bitmap with the new button images. Otherwise,
/// set it to the resource identifier of the bitmap with the new button images.
/// </para>
/// </summary>
public IntPtr nIDNew;
/// <summary>
/// <para>Type: <c>int</c></para>
/// <para>Number of button images contained in the new bitmap. The number of new images should be the same as the number of replaced images.</para>
/// <para>
/// Number of button images contained in the new bitmap. The number of new images should be the same as the number of replaced images.
/// </para>
/// </summary>
public int nButtons;
}
/// <summary>
/// Specifies the location in the registry where the <c>TB_SAVERESTORE</c> message stores and retrieves information about the state of a toolbar.
/// Specifies the location in the registry where the <c>TB_SAVERESTORE</c> message stores and retrieves information about the state
/// of a toolbar.
/// </summary>
// typedef struct { HKEY hkr; LPCTSTR pszSubKey; LPCTSTR pszValueName;} TBSAVEPARAMS; https://msdn.microsoft.com/en-us/library/windows/desktop/bb760486(v=vs.85).aspx
[PInvokeData("Commctrl.h", MSDNShortId = "bb760486")]
@ -1115,12 +1242,14 @@ namespace Vanara.PInvoke
/// <para>Type: <c><c>HKEY</c></c></para>
/// <para>Handle to the registry key.</para>
/// </summary>
public IntPtr hkr;
public HKEY hkr;
/// <summary>
/// <para>Type: <c><c>LPCTSTR</c></c></para>
/// <para>Subkey name.</para>
/// </summary>
public string pszSubKey;
/// <summary>
/// <para>Type: <c><c>LPCTSTR</c></c></para>
/// <para>Value name.</para>

View File

@ -1,6 +1,3 @@
// ReSharper disable InconsistentNaming
using System;
using System.Runtime.InteropServices;
using static Vanara.PInvoke.User32_Gdi;
@ -28,8 +25,8 @@ namespace Vanara.PInvoke
public enum TrackBarMessage
{
/// <summary>
/// Retrieves the current logical position of the slider in a trackbar. The logical positions are the integer values in the trackbar's range of
/// minimum to maximum slider positions.
/// Retrieves the current logical position of the slider in a trackbar. The logical positions are the integer values in the
/// trackbar's range of minimum to maximum slider positions.
/// </summary>
TBM_GETPOS = WindowMessage.WM_USER,
@ -40,8 +37,8 @@ namespace Vanara.PInvoke
TBM_GETRANGEMAX = WindowMessage.WM_USER + 2,
/// <summary>
/// Retrieves the logical position of a tick mark in a trackbar. The logical position can be any of the integer values in the trackbar's range of
/// minimum to maximum slider positions.
/// Retrieves the logical position of a tick mark in a trackbar. The logical position can be any of the integer values in the
/// trackbar's range of minimum to maximum slider positions.
/// </summary>
TBM_GETTIC = WindowMessage.WM_USER + 3,
@ -61,8 +58,8 @@ namespace Vanara.PInvoke
TBM_SETRANGEMAX = WindowMessage.WM_USER + 8,
/// <summary>
/// Removes the current tick marks from a trackbar. This message does not remove the first and last tick marks, which are created automatically by
/// the trackbar.
/// Removes the current tick marks from a trackbar. This message does not remove the first and last tick marks, which are created
/// automatically by the trackbar.
/// </summary>
TBM_CLEARTICS = WindowMessage.WM_USER + 9,
@ -70,14 +67,14 @@ namespace Vanara.PInvoke
TBM_SETSEL = WindowMessage.WM_USER + 10,
/// <summary>
/// Sets the starting logical position of the current selection range in a trackbar. This message is ignored if the trackbar does not have the
/// TBS_ENABLESELRANGE style.
/// Sets the starting logical position of the current selection range in a trackbar. This message is ignored if the trackbar does
/// not have the TBS_ENABLESELRANGE style.
/// </summary>
TBM_SETSELSTART = WindowMessage.WM_USER + 11,
/// <summary>
/// Sets the ending logical position of the current selection range in a trackbar. This message is ignored if the trackbar does not have the
/// TBS_ENABLESELRANGE style.
/// Sets the ending logical position of the current selection range in a trackbar. This message is ignored if the trackbar does
/// not have the TBS_ENABLESELRANGE style.
/// </summary>
TBM_SETSELEND = WindowMessage.WM_USER + 12,
@ -100,32 +97,35 @@ namespace Vanara.PInvoke
TBM_CLEARSEL = WindowMessage.WM_USER + 19,
/// <summary>
/// Sets the interval frequency for tick marks in a trackbar. For example, if the frequency is set to two, a tick mark is displayed for every other
/// increment in the trackbar's range. The default setting for the frequency is one; that is, every increment in the range is associated with a tick mark.
/// Sets the interval frequency for tick marks in a trackbar. For example, if the frequency is set to two, a tick mark is
/// displayed for every other increment in the trackbar's range. The default setting for the frequency is one; that is, every
/// increment in the range is associated with a tick mark.
/// </summary>
TBM_SETTICFREQ = WindowMessage.WM_USER + 20,
/// <summary>
/// Sets the number of logical positions the trackbar's slider moves in response to keyboard input, such as the or keys, or mouse input, such as
/// clicks in the trackbar's channel. The logical positions are the integer increments in the trackbar's range of minimum to maximum slider positions.
/// Sets the number of logical positions the trackbar's slider moves in response to keyboard input, such as the or keys, or mouse
/// input, such as clicks in the trackbar's channel. The logical positions are the integer increments in the trackbar's range of
/// minimum to maximum slider positions.
/// </summary>
TBM_SETPAGESIZE = WindowMessage.WM_USER + 21,
/// <summary>
/// Retrieves the number of logical positions the trackbar's slider moves in response to keyboard input, such as the or keys, or mouse input, such as
/// clicks in the trackbar's channel. The logical positions are the integer increments in the trackbar's range of minimum to maximum slider positions.
/// Retrieves the number of logical positions the trackbar's slider moves in response to keyboard input, such as the or keys, or
/// mouse input, such as clicks in the trackbar's channel. The logical positions are the integer increments in the trackbar's
/// range of minimum to maximum slider positions.
/// </summary>
TBM_GETPAGESIZE = WindowMessage.WM_USER + 22,
/// <summary>
/// Sets the number of logical positions the trackbar's slider moves in response to keyboard input from the arrow keys, such as the or keys. The
/// logical positions are the integer increments in the trackbar's range of minimum to maximum slider positions.
/// Sets the number of logical positions the trackbar's slider moves in response to keyboard input from the arrow keys, such as
/// the or keys. The logical positions are the integer increments in the trackbar's range of minimum to maximum slider positions.
/// </summary>
TBM_SETLINESIZE = WindowMessage.WM_USER + 23,
/// <summary>
/// Retrieves the number of logical positions the trackbar's slider moves in response to keyboard input from the arrow keys, such as the or keys. The
/// logical positions are the integer increments in the trackbar's range of minimum to maximum slider positions.
/// Retrieves the number of logical positions the trackbar's slider moves in response to keyboard input from the arrow keys, such
/// as the or keys. The logical positions are the integer increments in the trackbar's range of minimum to maximum slider positions.
/// </summary>
TBM_GETLINESIZE = WindowMessage.WM_USER + 24,
@ -133,12 +133,14 @@ namespace Vanara.PInvoke
TBM_GETTHUMBRECT = WindowMessage.WM_USER + 25,
/// <summary>
/// Retrieves the size and position of the bounding rectangle for a trackbar's channel. (The channel is the area over which the slider moves. It
/// contains the highlight when a range is selected.)
/// Retrieves the size and position of the bounding rectangle for a trackbar's channel. (The channel is the area over which the
/// slider moves. It contains the highlight when a range is selected.)
/// </summary>
TBM_GETCHANNELRECT = WindowMessage.WM_USER + 26,
/// <summary>Sets the length of the slider in a trackbar. This message is ignored if the trackbar does not have the TBS_FIXEDLENGTH style.</summary>
/// <summary>
/// Sets the length of the slider in a trackbar. This message is ignored if the trackbar does not have the TBS_FIXEDLENGTH style.
/// </summary>
TBM_SETTHUMBLENGTH = WindowMessage.WM_USER + 27,
/// <summary>Retrieves the length of the slider in a trackbar.</summary>
@ -150,18 +152,20 @@ namespace Vanara.PInvoke
/// <summary>Retrieves the handle to the tooltip control assigned to the trackbar, if any.</summary>
TBM_GETTOOLTIPS = WindowMessage.WM_USER + 30,
/// <summary>Positions a tooltip control used by a trackbar control. TrackBar controls that use the TBS_TOOLTIPS style display tooltips.</summary>
/// <summary>
/// Positions a tooltip control used by a trackbar control. TrackBar controls that use the TBS_TOOLTIPS style display tooltips.
/// </summary>
TBM_SETTIPSIDE = WindowMessage.WM_USER + 31,
/// <summary>
/// Assigns a window as the buddy window for a trackbar control. TrackBar buddy windows are automatically displayed in a location relative to the
/// control's orientation (horizontal or vertical).
/// Assigns a window as the buddy window for a trackbar control. TrackBar buddy windows are automatically displayed in a location
/// relative to the control's orientation (horizontal or vertical).
/// </summary>
TBM_SETBUDDY = WindowMessage.WM_USER + 32,
/// <summary>
/// Retrieves the handle to a trackbar control buddy window at a given location. The specified location is relative to the control's orientation
/// (horizontal or vertical).
/// Retrieves the handle to a trackbar control buddy window at a given location. The specified location is relative to the
/// control's orientation (horizontal or vertical).
/// </summary>
TBM_GETBUDDY = WindowMessage.WM_USER + 33,
@ -169,8 +173,8 @@ namespace Vanara.PInvoke
TBM_SETPOSNOTIFY = WindowMessage.WM_USER + 34,
/// <summary>
/// Sets the Unicode character format flag for the control. This message allows you to change the character set used by the control at run time
/// rather than having to re-create the control.
/// Sets the Unicode character format flag for the control. This message allows you to change the character set used by the
/// control at run time rather than having to re-create the control.
/// </summary>
TBM_SETUNICODEFORMAT = CommonControlMessage.CCM_SETUNICODEFORMAT,
@ -181,11 +185,13 @@ namespace Vanara.PInvoke
[PInvokeData("Commctrl.h", MSDNShortId = "bb760172")]
public enum TrackBarNotification
{
/// <summary>Notifies that the thumb position on a trackbar is changing. This notification code is sent in the form of a WM_NOTIFY message.</summary>
/// <summary>
/// Notifies that the thumb position on a trackbar is changing. This notification code is sent in the form of a WM_NOTIFY message.
/// </summary>
/// <remarks>Send this notification to clients that do not listen for WM_HSCROLL or WM_VSCROLL messages.</remarks>
/// <paramref name="lParam">
/// Pointer to a NMTRBTHUMBPOSCHANGING structure. The caller is responsible for allocating this structure and setting its members, including the
/// members of the contained NMHDR structure.
/// Pointer to a NMTRBTHUMBPOSCHANGING structure. The caller is responsible for allocating this structure and setting its
/// members, including the members of the contained NMHDR structure.
/// </paramref>
/// <returns>The return value is ignored.</returns>
TRBN_THUMBPOSCHANGING = TRBN_FIRST
@ -249,8 +255,8 @@ namespace Vanara.PInvoke
TBS_RIGHT = 0x0000,
/// <summary>
/// The trackbar control displays tick marks on both sides of the control. This will be both top and bottom when used with TBS_HORZ or both left and
/// right if used with TBS_VERT.
/// The trackbar control displays tick marks on both sides of the control. This will be both top and bottom when used with
/// TBS_HORZ or both left and right if used with TBS_VERT.
/// </summary>
TBS_BOTH = 0x0008,
@ -258,8 +264,8 @@ namespace Vanara.PInvoke
TBS_NOTICKS = 0x0010,
/// <summary>
/// The trackbar control displays a selection range only. The tick marks at the starting and ending positions of a selection range are displayed as
/// triangles (instead of vertical dashes), and the selection range is highlighted.
/// The trackbar control displays a selection range only. The tick marks at the starting and ending positions of a selection
/// range are displayed as triangles (instead of vertical dashes), and the selection range is highlighted.
/// </summary>
TBS_ENABLESELRANGE = 0x0020,
@ -270,20 +276,22 @@ namespace Vanara.PInvoke
TBS_NOTHUMB = 0x0080,
/// <summary>
/// The trackbar control supports tooltips. When a trackbar control is created using this style, it automatically creates a default tooltip control
/// that displays the slider's current position. You can change where the tooltips are displayed by using the TBM_SETTIPSIDE message.
/// The trackbar control supports tooltips. When a trackbar control is created using this style, it automatically creates a
/// default tooltip control that displays the slider's current position. You can change where the tooltips are displayed by using
/// the TBM_SETTIPSIDE message.
/// </summary>
TBS_TOOLTIPS = 0x0100,
/// <summary>
/// This style bit is used for "reversed" trackbars, where a smaller number indicates "higher" and a larger number indicates "lower." It has no
/// effect on the control; it is simply a label that can be checked to determine whether a trackbar is normal or reversed.
/// This style bit is used for "reversed" trackbars, where a smaller number indicates "higher" and a larger number indicates
/// "lower." It has no effect on the control; it is simply a label that can be checked to determine whether a trackbar is normal
/// or reversed.
/// </summary>
TBS_REVERSED = 0x0200,
/// <summary>
/// By default, the trackbar control uses down equal to right and up equal to left. Use the TBS_DOWNISLEFT style to reverse the default, making down
/// equal left and up equal right.
/// By default, the trackbar control uses down equal to right and up equal to left. Use the TBS_DOWNISLEFT style to reverse the
/// default, making down equal left and up equal right.
/// </summary>
TBS_DOWNISLEFT = 0x0400,
@ -323,8 +331,8 @@ namespace Vanara.PInvoke
public NMHDR hdr;
/// <summary>
/// Type of movement as one of the following values: TB_LINEUP, TB_LINEDOWN, TB_PAGEUP, TB_PAGEDOWN, TB_THUMBPOSITION, TB_THUMBTRACK, TB_TOP,
/// TB_BOTTOM, or TB_ENDTRACK.
/// Type of movement as one of the following values: TB_LINEUP, TB_LINEDOWN, TB_PAGEUP, TB_PAGEDOWN, TB_THUMBPOSITION,
/// TB_THUMBTRACK, TB_TOP, TB_BOTTOM, or TB_ENDTRACK.
/// </summary>
public TrackBarScrollNotification nReason;
}

File diff suppressed because it is too large Load Diff

View File

@ -1,68 +1,94 @@
using System;
using System.Runtime.InteropServices;
using static Vanara.PInvoke.Kernel32;
using static Vanara.PInvoke.User32_Gdi;
// ReSharper disable InconsistentNaming
// ReSharper disable FieldCanBeMadeReadOnly.Global
// ReSharper disable InconsistentNaming
namespace Vanara.PInvoke
{
public static partial class ComCtl32
{
private const int UDN_FIRST = -721;
/// <summary>Maximum value for an up-down control.</summary>
public const short UD_MAXVAL = 0x7fff;
/// <summary>Minimum value for an up-down control.</summary>
public const short UD_MINVAL = -UD_MAXVAL;
/// <summary>Window class for the up-down control.</summary>
public const string UPDOWN_CLASS = "msctls_updown32";
/// <summary>Maximum value for an up-down control.</summary>
public const short UD_MAXVAL = 0x7fff;
/// <summary>Minimum value for an up-down control.</summary>
public const short UD_MINVAL = -UD_MAXVAL;
private const int UDN_FIRST = -721;
/// <summary>Window messages for the up-down control.</summary>
public enum UpDownMessage : uint
{
/// <summary>Retrieves acceleration information for an up-down control.</summary>
UDM_GETACCEL = WindowMessage.WM_USER + 108,
/// <summary>Retrieves the current radix base (that is, either base 10 or 16) for an up-down control.</summary>
UDM_GETBASE = WindowMessage.WM_USER + 110,
/// <summary>Retrieves the handle to the current buddy window.</summary>
UDM_GETBUDDY = WindowMessage.WM_USER + 106,
/// <summary>Retrieves the current position of an up-down control with 16-bit precision.</summary>
UDM_GETPOS = WindowMessage.WM_USER + 104,
/// <summary>Returns the 32-bit position of an up-down control.</summary>
UDM_GETPOS32 = WindowMessage.WM_USER + 114,
/// <summary>Retrieves the minimum and maximum positions (range) for an up-down control.</summary>
UDM_GETRANGE = WindowMessage.WM_USER + 102,
/// <summary>Retrieves the 32-bit range of an up-down control.</summary>
UDM_GETRANGE32 = WindowMessage.WM_USER + 112,
/// <summary>Retrieves the Unicode character format flag for the control.</summary>
UDM_GETUNICODEFORMAT = CommonControlMessage.CCM_GETUNICODEFORMAT,
/// <summary>Sets the acceleration for an up-down control.</summary>
UDM_SETACCEL = WindowMessage.WM_USER + 107,
/// <summary>Sets the radix base for an up-down control. The base value determines whether the buddy window displays numbers in decimal or hexadecimal digits. Hexadecimal numbers are always unsigned, and decimal numbers are signed.</summary>
/// <summary>
/// Sets the radix base for an up-down control. The base value determines whether the buddy window displays numbers in decimal or
/// hexadecimal digits. Hexadecimal numbers are always unsigned, and decimal numbers are signed.
/// </summary>
UDM_SETBASE = WindowMessage.WM_USER + 109,
/// <summary>Sets the buddy window for an up-down control.</summary>
UDM_SETBUDDY = WindowMessage.WM_USER + 105,
/// <summary>Sets the current position for an up-down control with 16-bit precision.</summary>
UDM_SETPOS = WindowMessage.WM_USER + 103,
/// <summary>Sets the position of an up-down control with 32-bit precision.</summary>
UDM_SETPOS32 = WindowMessage.WM_USER + 113,
/// <summary>Sets the minimum and maximum positions (range) for an up-down control.</summary>
UDM_SETRANGE = WindowMessage.WM_USER + 101,
/// <summary>Sets the 32-bit range of an up-down control.</summary>
UDM_SETRANGE32 = WindowMessage.WM_USER + 111,
/// <summary>Sets the Unicode character format flag for the control. This message allows you to change the character set used by the control at run time rather than having to re-create the control.</summary>
/// <summary>
/// Sets the Unicode character format flag for the control. This message allows you to change the character set used by the
/// control at run time rather than having to re-create the control.
/// </summary>
UDM_SETUNICODEFORMAT = CommonControlMessage.CCM_SETUNICODEFORMAT,
}
/// <summary>Notifications for the up-down control.</summary>
public enum UpDownNotification : int
{
/// <summary>Notifies an up-down control's parent window that the control is releasing mouse capture. This notification is sent in the form of a WM_NOTIFY message.</summary>
/// <summary>
/// Notifies an up-down control's parent window that the control is releasing mouse capture. This notification is sent in the
/// form of a WM_NOTIFY message.
/// </summary>
NM_RELEASEDCAPTURE = UDN_FIRST - 1,
/// <summary>Sent by the operating system to the parent window of an up-down control when the position of the control is about to change.This happens when the user requests a change in the value by pressing the control's up or down arrow. The UDN_DELTAPOS message is sent in the form of a WM_NOTIFY message.</summary>
/// <summary>
/// Sent by the operating system to the parent window of an up-down control when the position of the control is about to
/// change.This happens when the user requests a change in the value by pressing the control's up or down arrow. The UDN_DELTAPOS
/// message is sent in the form of a WM_NOTIFY message.
/// </summary>
UDN_DELTAPOS = UDN_FIRST
}
@ -70,32 +96,58 @@ namespace Vanara.PInvoke
[Flags]
public enum UpDownStyle : uint
{
/// <summary>Positions the up-down control next to the left edge of the buddy window. The buddy window is moved to the right, and its width is decreased to accommodate the width of the up-down control.</summary>
/// <summary>
/// Positions the up-down control next to the left edge of the buddy window. The buddy window is moved to the right, and its
/// width is decreased to accommodate the width of the up-down control.
/// </summary>
UDS_ALIGNLEFT = 0x08,
/// <summary>Positions the up-down control next to the right edge of the buddy window. The width of the buddy window is decreased to accommodate the width of the up-down control.</summary>
/// <summary>
/// Positions the up-down control next to the right edge of the buddy window. The width of the buddy window is decreased to
/// accommodate the width of the up-down control.
/// </summary>
UDS_ALIGNRIGHT = 0x04,
/// <summary>Causes the up-down control to increment and decrement the position when the UP ARROW and DOWN ARROW keys are pressed.</summary>
/// <summary>
/// Causes the up-down control to increment and decrement the position when the UP ARROW and DOWN ARROW keys are pressed.
/// </summary>
UDS_ARROWKEYS = 0x20,
/// <summary>Automatically selects the previous window in the z-order as the up-down control's buddy window.</summary>
UDS_AUTOBUDDY = 0x10,
/// <summary>Causes the up-down control's arrows to point left and right instead of up and down.</summary>
UDS_HORZ = 0x40,
/// <summary>Causes the control to exhibit "hot tracking" behavior. That is, it highlights the UP ARROW and DOWN ARROW on the control as the pointer passes over them. This style requires Windows 98 or Windows 2000. If the system is running Windows 95 or Windows NT 4.0, the flag is ignored. To check whether hot tracking is enabled, call SystemParametersInfo.</summary>
/// <summary>
/// Causes the control to exhibit "hot tracking" behavior. That is, it highlights the UP ARROW and DOWN ARROW on the control as
/// the pointer passes over them. This style requires Windows 98 or Windows 2000. If the system is running Windows 95 or Windows
/// NT 4.0, the flag is ignored. To check whether hot tracking is enabled, call SystemParametersInfo.
/// </summary>
UDS_HOTTRACK = 0x100,
/// <summary>Does not insert a thousands separator between every three decimal digits.</summary>
UDS_NOTHOUSANDS = 0x80,
/// <summary>Causes the up-down control to set the text of the buddy window (using the WM_SETTEXT message) when the position changes. The text consists of the position formatted as a decimal or hexadecimal string.</summary>
/// <summary>
/// Causes the up-down control to set the text of the buddy window (using the WM_SETTEXT message) when the position changes. The
/// text consists of the position formatted as a decimal or hexadecimal string.
/// </summary>
UDS_SETBUDDYINT = 0x02,
/// <summary>Causes the position to "wrap" if it is incremented or decremented beyond the ending or beginning of the range.</summary>
UDS_WRAP = 0x01,
}
/// <summary>Creates an up-down control. Note: This function is obsolete. It is a 16 bit function and cannot handle 32 bit values for range and position.</summary>
/// <summary>
/// Creates an up-down control. Note: This function is obsolete. It is a 16 bit function and cannot handle 32 bit values for range
/// and position.
/// </summary>
/// <param name="dwStyle">
/// <para>Type: <c><c>DWORD</c></c></para>
/// <para>
/// Window styles for the control. This parameter should include the <c>WS_CHILD</c>, <c>WS_BORDER</c>, and <c>WS_VISIBLE</c> styles, and it may include
/// any of the window styles specific to the up-down control.
/// Window styles for the control. This parameter should include the <c>WS_CHILD</c>, <c>WS_BORDER</c>, and <c>WS_VISIBLE</c> styles,
/// and it may include any of the window styles specific to the up-down control.
/// </para>
/// </param>
/// <param name="x">
@ -144,38 +196,59 @@ namespace Vanara.PInvoke
/// </param>
/// <returns>
/// <para>Type: <c><c>HWND</c></c></para>
/// <para>If the function succeeds, the return value is the window handle to the up-down control. If the function fails, the return value is <c>NULL</c>.</para>
/// <para>
/// If the function succeeds, the return value is the window handle to the up-down control. If the function fails, the return value
/// is <c>NULL</c>.
/// </para>
/// </returns>
// HWND CreateUpDownControl( DWORD dwStyle, int x, int y, int cx, int cy, HWND hParent, int nID, HINSTANCE hInst, HWND hBuddy, int nUpper, int nLower, int nPos);
// https://msdn.microsoft.com/en-us/library/windows/desktop/bb759977(v=vs.85).aspx
// HWND CreateUpDownControl( DWORD dwStyle, int x, int y, int cx, int cy, HWND hParent, int nID, HINSTANCE hInst, HWND hBuddy, int
// nUpper, int nLower, int nPos); https://msdn.microsoft.com/en-us/library/windows/desktop/bb759977(v=vs.85).aspx
[DllImport(Lib.ComCtl32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("Commctrl.h", MSDNShortId = "bb759977")]
public static extern IntPtr CreateUpDownControl(uint dwStyle, int x, int y, int cx, int cy, HWND hParent, int nID, HINSTANCE hInst, HWND hBuddy, int nUpper, int nLower, int nPos);
/// <summary>Contains information specific to up-down control notification messages. It is identical to and replaces the <c>NM_UPDOWN</c> structure.</summary>
// typedef struct _NM_UPDOWN { NMHDR hdr; int iPos; int iDelta;} NMUPDOWN, *LPNMUPDOWN;
// https://msdn.microsoft.com/en-us/library/windows/desktop/bb759893(v=vs.85).aspx
/// <summary>
/// Contains information specific to up-down control notification messages. It is identical to and replaces the <c>NM_UPDOWN</c> structure.
/// </summary>
// typedef struct _NM_UPDOWN { NMHDR hdr; int iPos; int iDelta;} NMUPDOWN, *LPNMUPDOWN; https://msdn.microsoft.com/en-us/library/windows/desktop/bb759893(v=vs.85).aspx
[PInvokeData("Commctrl.h", MSDNShortId = "bb759893")]
public struct NMUPDOWN
{
/// <summary><para>Type: <c><c>NMHDR</c></c></para><para><c>NMHDR</c> structure that contains additional information about the notification.</para></summary>
/// <summary>
/// <para>Type: <c><c>NMHDR</c></c></para>
/// <para><c>NMHDR</c> structure that contains additional information about the notification.</para>
/// </summary>
public NMHDR hdr;
/// <summary><para>Type: <c>int</c></para><para>Signed integer value that represents the up-down control&#39;s current position.</para></summary>
public int iPos;
/// <summary><para>Type: <c>int</c></para><para>Signed integer value that represents the proposed change in the up-down control&#39;s position.</para></summary>
/// <summary>
/// <para>Type: <c>int</c></para>
/// <para>Signed integer value that represents the proposed change in the up-down control's position.</para>
/// </summary>
public int iDelta;
/// <summary>
/// <para>Type: <c>int</c></para>
/// <para>Signed integer value that represents the up-down control's current position.</para>
/// </summary>
public int iPos;
}
/// <summary>Contains acceleration information for an up-down control.</summary>
// typedef struct { UINT nSec; UINT nInc;} UDACCEL, *LPUDACCEL;
// https://msdn.microsoft.com/en-us/library/windows/desktop/bb759897(v=vs.85).aspx
// typedef struct { UINT nSec; UINT nInc;} UDACCEL, *LPUDACCEL; https://msdn.microsoft.com/en-us/library/windows/desktop/bb759897(v=vs.85).aspx
[PInvokeData("Commctrl.h", MSDNShortId = "bb759897")]
[StructLayout(LayoutKind.Sequential)]
public struct UDACCEL
{
/// <summary><para>Type: <c><c>UINT</c></c></para><para>Amount of elapsed time, in seconds, before the position change increment specified by <c>nInc</c> is used.</para></summary>
/// <summary>
/// <para>Type: <c><c>UINT</c></c></para>
/// <para>Amount of elapsed time, in seconds, before the position change increment specified by <c>nInc</c> is used.</para>
/// </summary>
public uint nSec;
/// <summary><para>Type: <c><c>UINT</c></c></para><para>Position change increment to use after the time specified by <c>nSec</c> elapses.</para></summary>
/// <summary>
/// <para>Type: <c><c>UINT</c></c></para>
/// <para>Position change increment to use after the time specified by <c>nSec</c> elapses.</para>
/// </summary>
public uint nInc;
}
}

View File

@ -1,11 +1,8 @@
using System;
using System.Runtime.InteropServices;
using static Vanara.PInvoke.Gdi32;
using static Vanara.PInvoke.Kernel32;
using static Vanara.PInvoke.User32;
using static Vanara.PInvoke.User32_Gdi;
// ReSharper disable FieldCanBeMadeReadOnly.Global ReSharper disable InconsistentNaming
namespace Vanara.PInvoke
{
public static partial class ComCtl32
@ -47,18 +44,25 @@ namespace Vanara.PInvoke
/// </param>
/// <param name="dwRefData">
/// <para>Type: <c>DWORD_PTR</c></para>
/// <para>The reference data provided to the <c>SetWindowSubclass</c> function. This can be used to associate the subclass instance with a "this" pointer.</para>
/// <para>
/// The reference data provided to the <c>SetWindowSubclass</c> function. This can be used to associate the subclass instance with a
/// "this" pointer.
/// </para>
/// </param>
/// <returns>
/// <para>Type: <c>LRESULT</c></para>
/// <para>The return value is the result of the message processing and depends on the message sent.</para>
/// </returns>
// typedef LRESULT ( CALLBACK *SUBCLASSPROC)( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, UINT_PTR uIdSubclass, DWORD_PTR dwRefData); https://msdn.microsoft.com/en-us/library/windows/desktop/bb776774(v=vs.85).aspx
// typedef LRESULT ( CALLBACK *SUBCLASSPROC)( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, UINT_PTR uIdSubclass, DWORD_PTR
// dwRefData); https://msdn.microsoft.com/en-us/library/windows/desktop/bb776774(v=vs.85).aspx
[PInvokeData("Commctrl.h", MSDNShortId = "bb776774")]
[UnmanagedFunctionPointer(CallingConvention.Winapi)]
public delegate IntPtr SUBCLASSPROC(IntPtr hWnd, uint uMsg, IntPtr wParam, IntPtr lParam, [MarshalAs(UnmanagedType.SysUInt)] uint uIdSubclass, IntPtr dwRefData);
public delegate IntPtr SUBCLASSPROC(HWND hWnd, uint uMsg, IntPtr wParam, IntPtr lParam, [MarshalAs(UnmanagedType.SysUInt)] uint uIdSubclass, IntPtr dwRefData);
/// <summary>The set of bit flags that indicate which common control classes will be loaded from the DLL when calling <see cref="InitCommonControlsEx(ref INITCOMMONCONTROLSEX)"/>.</summary>
/// <summary>
/// The set of bit flags that indicate which common control classes will be loaded from the DLL when calling <see
/// cref="InitCommonControlsEx(ref INITCOMMONCONTROLSEX)"/>.
/// </summary>
[PInvokeData("Commctrl.h", MSDNShortId = "bb775507")]
[Flags]
public enum CommonControlClass
@ -97,7 +101,8 @@ namespace Vanara.PInvoke
ICC_PROGRESS_CLASS = 0X00000020,
/// <summary>
/// Load one of the intrinsic User32_Gdi control classes. The user controls include button, edit, static, listbox, combobox, and scroll bar.
/// Load one of the intrinsic User32_Gdi control classes. The user controls include button, edit, static, listbox, combobox, and
/// scroll bar.
/// </summary>
ICC_STANDARD_CLASSES = 0X00004000,
@ -114,7 +119,8 @@ namespace Vanara.PInvoke
ICC_USEREX_CLASSES = 0X00000200,
/// <summary>
/// Load animate control, header, hot key, list-view, progress bar, status bar, tab, tooltip, toolbar, trackbar, tree-view, and up-down control classes.
/// Load animate control, header, hot key, list-view, progress bar, status bar, tab, tooltip, toolbar, trackbar, tree-view, and
/// up-down control classes.
/// </summary>
ICC_WIN95_CLASSES = 0X000000FF
}
@ -123,8 +129,8 @@ namespace Vanara.PInvoke
public enum CommonControlNotification
{
/// <summary>
/// Notifies a control's parent window that the control could not complete an operation because there was not enough memory available. This
/// notification code is sent in the form of a WM_NOTIFY message.
/// Notifies a control's parent window that the control could not complete an operation because there was not enough memory
/// available. This notification code is sent in the form of a WM_NOTIFY message.
/// <list>
/// <item>
/// <term>lParam</term>
@ -134,17 +140,20 @@ namespace Vanara.PInvoke
/// </summary>
NM_OUTOFMEMORY = NM_FIRST - 1,
/// <summary>Sent by a control when the user clicks with the left mouse button. This notification code is sent in the form of a WM_NOTIFY message.</summary>
/// <summary>
/// Sent by a control when the user clicks with the left mouse button. This notification code is sent in the form of a WM_NOTIFY message.
/// </summary>
NM_CLICK = NM_FIRST - 2,
/// <summary>
/// Sent by a control when the user double-clicks with the left mouse button. This notification code is sent in the form of a WM_NOTIFY message.
/// Sent by a control when the user double-clicks with the left mouse button. This notification code is sent in the form of a
/// WM_NOTIFY message.
/// </summary>
NM_DBLCLK = NM_FIRST - 3,
/// <summary>
/// Notifies a control's parent window that the control has the input focus and that the user has pressed the ENTER key. This notification code is
/// sent in the form of a WM_NOTIFY message.
/// Notifies a control's parent window that the control has the input focus and that the user has pressed the ENTER key. This
/// notification code is sent in the form of a WM_NOTIFY message.
/// <list>
/// <item>
/// <term>lParam</term>
@ -154,16 +163,20 @@ namespace Vanara.PInvoke
/// </summary>
NM_RETURN = NM_FIRST - 4,
/// <summary>Sent by a control when the user clicks with the right mouse button. This notification code is sent in the form of a WM_NOTIFY message.</summary>
/// <summary>
/// Sent by a control when the user clicks with the right mouse button. This notification code is sent in the form of a WM_NOTIFY message.
/// </summary>
NM_RCLICK = NM_FIRST - 5,
/// <summary>
/// Sent by a control when the user double-clicks with the right mouse button. This notification code is sent in the form of a WM_NOTIFY message.
/// Sent by a control when the user double-clicks with the right mouse button. This notification code is sent in the form of a
/// WM_NOTIFY message.
/// </summary>
NM_RDBLCLK = NM_FIRST - 6,
/// <summary>
/// Notifies a control's parent window that the control has received the input focus. This notification code is sent in the form of a WM_NOTIFY message.
/// Notifies a control's parent window that the control has received the input focus. This notification code is sent in the form
/// of a WM_NOTIFY message.
/// <list>
/// <item>
/// <term>lParam</term>
@ -174,7 +187,8 @@ namespace Vanara.PInvoke
NM_SETFOCUS = NM_FIRST - 7,
/// <summary>
/// Notifies a control's parent window that the control has lost the input focus. This notification code is sent in the form of a WM_NOTIFY message.
/// Notifies a control's parent window that the control has lost the input focus. This notification code is sent in the form of a
/// WM_NOTIFY message.
/// <list>
/// <item>
/// <term>lParam</term>
@ -190,8 +204,8 @@ namespace Vanara.PInvoke
/// <item>
/// <term>lParam</term>
/// <description>
/// A pointer to a custom draw-related structure that contains information about the drawing operation. The following list specifies the controls and
/// their associated structures.
/// A pointer to a custom draw-related structure that contains information about the drawing operation. The following list
/// specifies the controls and their associated structures.
/// <list type="table">
/// <listheader>
/// <term>Control</term>
@ -224,8 +238,8 @@ namespace Vanara.PInvoke
/// <item>
/// <term>Return value</term>
/// <description>
/// The value your application can return depends on the current drawing stage. The dwDrawStage member of the associated NMCUSTOMDRAW structure holds
/// a value that specifies the drawing stage.
/// The value your application can return depends on the current drawing stage. The dwDrawStage member of the associated
/// NMCUSTOMDRAW structure holds a value that specifies the drawing stage.
/// </description>
/// </item>
/// </summary>
@ -241,7 +255,8 @@ namespace Vanara.PInvoke
/// <item>
/// <term>Return value</term>
/// <description>
/// Unless otherwise specified, return zero to allow the control to process the hover normally, or nonzero to prevent the hover from being processed.
/// Unless otherwise specified, return zero to allow the control to process the hover normally, or nonzero to prevent the hover
/// from being processed.
/// </description>
/// </item>
/// </list>
@ -249,20 +264,21 @@ namespace Vanara.PInvoke
NM_HOVER = NM_FIRST - 13,
/// <summary>
/// Sent by a rebar control when the control receives a WM_NCHITTEST message. This notification code is sent in the form of a WM_NOTIFY message.
/// Sent by a rebar control when the control receives a WM_NCHITTEST message. This notification code is sent in the form of a
/// WM_NOTIFY message.
/// <list>
/// <item>
/// <term>lParam</term>
/// <description>
/// A pointer to a NMMOUSE structure that contains information about the notification code. The pt member contains the mouse coordinates of the hit
/// test message.
/// A pointer to a NMMOUSE structure that contains information about the notification code. The pt member contains the mouse
/// coordinates of the hit test message.
/// </description>
/// </item>
/// <item>
/// <term>Return value</term>
/// <description>
/// Unless otherwise specified, return zero to allow the control to perform default processing of the hit test message, or return one of the HT*
/// values documented under WM_NCHITTEST to override the default hit test processing.
/// Unless otherwise specified, return zero to allow the control to perform default processing of the hit test message, or return
/// one of the HT* values documented under WM_NCHITTEST to override the default hit test processing.
/// </description>
/// </item>
/// </list>
@ -270,11 +286,14 @@ namespace Vanara.PInvoke
NM_NCHITTEST = NM_FIRST - 14,
/// <summary>
/// Sent by a control when the control has the keyboard focus and the user presses a key. This notification code is sent in the form of a WM_NOTIFY message.
/// Sent by a control when the control has the keyboard focus and the user presses a key. This notification code is sent in the
/// form of a WM_NOTIFY message.
/// <list>
/// <item>
/// <term>lParam</term>
/// <description>A pointer to an NMKEY structure that contains additional information about the key that caused the notification code.</description>
/// <description>
/// A pointer to an NMKEY structure that contains additional information about the key that caused the notification code.
/// </description>
/// </item>
/// <item>
/// <term>Return value</term>
@ -285,7 +304,8 @@ namespace Vanara.PInvoke
NM_KEYDOWN = NM_FIRST - 15,
/// <summary>
/// Notifies a control's parent window that the control is releasing mouse capture. This notification code is sent in the form of a WM_NOTIFY message.
/// Notifies a control's parent window that the control is releasing mouse capture. This notification code is sent in the form of
/// a WM_NOTIFY message.
/// <list>
/// <item>
/// <term>lParam</term>
@ -296,8 +316,8 @@ namespace Vanara.PInvoke
NM_RELEASEDCAPTURE = NM_FIRST - 16,
/// <summary>
/// Notifies a control's parent window that the control is setting the cursor in response to a WM_SETCURSOR message. This notification code is sent
/// in the form of a WM_NOTIFY message.
/// Notifies a control's parent window that the control is setting the cursor in response to a WM_SETCURSOR message. This
/// notification code is sent in the form of a WM_NOTIFY message.
/// <list>
/// <item>
/// <term>lParam</term>
@ -305,25 +325,31 @@ namespace Vanara.PInvoke
/// </item>
/// <item>
/// <term>Return value</term>
/// <description>Return zero to enable the control to set the cursor or nonzero to prevent the control from setting the cursor.</description>
/// <description>
/// Return zero to enable the control to set the cursor or nonzero to prevent the control from setting the cursor.
/// </description>
/// </item>
/// </list>
/// </summary>
NM_SETCURSOR = NM_FIRST - 17,
/// <summary>
/// The NM_CHAR notification code is sent by a control when a character key is processed. This notification code is sent in the form of a WM_NOTIFY message.
/// The NM_CHAR notification code is sent by a control when a character key is processed. This notification code is sent in the
/// form of a WM_NOTIFY message.
/// <list>
/// <item>
/// <term>lParam</term>
/// <description>A pointer to an NMCHAR structure that contains additional information about the character that caused the notification code.</description>
/// <description>
/// A pointer to an NMCHAR structure that contains additional information about the character that caused the notification code.
/// </description>
/// </item>
/// </list>
/// </summary>
NM_CHAR = NM_FIRST - 18,
/// <summary>
/// Notifies a control's parent window that the control has created a tooltip control. This notification code is sent in the form of a WM_NOTIFY message.
/// Notifies a control's parent window that the control has created a tooltip control. This notification code is sent in the form
/// of a WM_NOTIFY message.
/// <list>
/// <item>
/// <term>lParam</term>
@ -334,7 +360,8 @@ namespace Vanara.PInvoke
NM_TOOLTIPSCREATED = NM_FIRST - 19,
/// <summary>
/// Notifies a control's parent window that the left mouse button has been pressed. This notification code is sent in the form of a WM_NOTIFY message.
/// Notifies a control's parent window that the left mouse button has been pressed. This notification code is sent in the form of
/// a WM_NOTIFY message.
/// <list>
/// <item>
/// <term>lParam</term>
@ -381,7 +408,8 @@ namespace Vanara.PInvoke
NM_CUSTOMTEXT = NM_FIRST - 24,
/// <summary>
/// Sent by a tree-view control to its parent window that the state image is changing. This notification code is sent in the form of a WM_NOTIFY message.
/// Sent by a tree-view control to its parent window that the state image is changing. This notification code is sent in the form
/// of a WM_NOTIFY message.
/// <list>
/// <item>
/// <term>lParam</term>
@ -419,8 +447,9 @@ namespace Vanara.PInvoke
CDIS_HOT = 0x0040,
/// <summary>
/// The item is marked. The meaning of this is determined by the implementation. <note>This flag does not work correctly for owner-drawn list-view
/// controls that have the LVS_SHOWSELALWAYS style. For these controls, you can determine whether an item is selected by using LVM_GETITEMSTATE (or
/// The item is marked. The meaning of this is determined by the implementation. <note>This flag does not work correctly for
/// owner-drawn list-view controls that have the LVS_SHOWSELALWAYS style. For these controls, you can determine whether an item
/// is selected by using LVM_GETITEMSTATE (or
/// ListView_GetItemState) and checking for the LVIS_SELECTED flag.</note>
/// </summary>
CDIS_MARKED = 0x0080,
@ -429,20 +458,20 @@ namespace Vanara.PInvoke
CDIS_INDETERMINATE = 0x0100,
/// <summary>
/// Version 6.0.The item is showing its keyboard cues. <note>Comctl32 version 6 is not redistributable. operating systems. To use Comctl32.dll
/// version 6, specify it in the manifest. For more information on manifests, see Enabling Visual Styles.</note>
/// Version 6.0.The item is showing its keyboard cues. <note>Comctl32 version 6 is not redistributable. operating systems. To use
/// Comctl32.dll version 6, specify it in the manifest. For more information on manifests, see Enabling Visual Styles.</note>
/// </summary>
CDIS_SHOWKEYBOARDCUES = 0x0200,
/// <summary>
/// The item is part of a control that is currently under the mouse pointer ("hot"), but the item is not "hot" itself. The meaning of this is
/// determined by the implementation.
/// The item is part of a control that is currently under the mouse pointer ("hot"), but the item is not "hot" itself. The
/// meaning of this is determined by the implementation.
/// </summary>
CDIS_NEARHOT = 0x0400,
/// <summary>
/// The item is part of a splitbutton that is currently under the mouse pointer ("hot"), but the item is not "hot" itself. The meaning of this is
/// determined by the implementation.
/// The item is part of a splitbutton that is currently under the mouse pointer ("hot"), but the item is not "hot" itself. The
/// meaning of this is determined by the implementation.
/// </summary>
CDIS_OTHERSIDEHOT = 0x0800,
@ -456,19 +485,20 @@ namespace Vanara.PInvoke
public enum CustomDrawResponse
{
/// <summary>
/// The control will draw itself. It will not send any additional NM_CUSTOMDRAW notification codes for this paint cycle. This occurs when the
/// dwDrawStage of the NMCUSTOMDRAW structure equals CDDS_PREPAINT.
/// The control will draw itself. It will not send any additional NM_CUSTOMDRAW notification codes for this paint cycle. This
/// occurs when the dwDrawStage of the NMCUSTOMDRAW structure equals CDDS_PREPAINT.
/// </summary>
CDRF_DODEFAULT = 0x00000000,
/// <summary>
/// The application specified a new font for the item; the control will use the new font. For more information about changing fonts, see Changing
/// fonts and colors. This occurs when the dwDrawStage of the NMCUSTOMDRAW structure equals CDDS_ITEMPREPAINT.
/// The application specified a new font for the item; the control will use the new font. For more information about changing
/// fonts, see Changing fonts and colors. This occurs when the dwDrawStage of the NMCUSTOMDRAW structure equals CDDS_ITEMPREPAINT.
/// </summary>
CDRF_NEWFONT = 0x00000002,
/// <summary>
/// The application drew the item manually. The control will not draw the item. This occurs when the dwDrawStage of the NMCUSTOMDRAW structure equals CDDS_ITEMPREPAINT.
/// The application drew the item manually. The control will not draw the item. This occurs when the dwDrawStage of the
/// NMCUSTOMDRAW structure equals CDDS_ITEMPREPAINT.
/// </summary>
CDRF_SKIPDEFAULT = 0x00000004,
@ -476,25 +506,27 @@ namespace Vanara.PInvoke
CDRF_DOERASE = 0x00000008,
/// <summary>
/// The control will notify the parent after painting an item. This occurs when the dwDrawStage of the NMCUSTOMDRAW structure equals CDDS_PREPAINT.
/// The control will notify the parent after painting an item. This occurs when the dwDrawStage of the NMCUSTOMDRAW structure
/// equals CDDS_PREPAINT.
/// </summary>
CDRF_NOTIFYPOSTPAINT = 0x00000010,
/// <summary>
/// The control will notify the parent of any item-related drawing operations. It will send NM_CUSTOMDRAW notification codes before and after drawing
/// items. This occurs when the dwDrawStage of the NMCUSTOMDRAW structure equals CDDS_PREPAINT.
/// The control will notify the parent of any item-related drawing operations. It will send NM_CUSTOMDRAW notification codes
/// before and after drawing items. This occurs when the dwDrawStage of the NMCUSTOMDRAW structure equals CDDS_PREPAINT.
/// </summary>
CDRF_NOTIFYITEMDRAW = 0x00000020,
/// <summary>
/// Internet Explorer 4.0 and later. The control will notify the parent of any item-related drawing operations. It will send NM_CUSTOMDRAW
/// notification codes before and after drawing items. This occurs when the dwDrawStage of the NMCUSTOMDRAW structure equals CDDS_PREPAINT. This flag
/// is identical to CDRF_NOTIFYITEMDRAW and its use is context-dependent.
/// Internet Explorer 4.0 and later. The control will notify the parent of any item-related drawing operations. It will send
/// NM_CUSTOMDRAW notification codes before and after drawing items. This occurs when the dwDrawStage of the NMCUSTOMDRAW
/// structure equals CDDS_PREPAINT. This flag is identical to CDRF_NOTIFYITEMDRAW and its use is context-dependent.
/// </summary>
CDRF_NOTIFYSUBITEMDRAW = 0x00000020,
/// <summary>
/// The control will notify the parent after erasing an item. This occurs when the dwDrawStage of the NMCUSTOMDRAW structure equals CDDS_PREPAINT.
/// The control will notify the parent after erasing an item. This occurs when the dwDrawStage of the NMCUSTOMDRAW structure
/// equals CDDS_PREPAINT.
/// </summary>
CDRF_NOTIFYPOSTERASE = 0x00000040,
@ -535,8 +567,8 @@ namespace Vanara.PInvoke
CDDS_ITEMPOSTERASE = (CDDS_ITEM | CDDS_POSTERASE),
/// <summary>
/// Flag combined with CDDS_ITEMPREPAINT or CDDS_ITEMPOSTPAINT if a subitem is being drawn. This will only be set if CDRF_NOTIFYITEMDRAW is returned
/// from CDDS_PREPAINT.
/// Flag combined with CDDS_ITEMPREPAINT or CDDS_ITEMPOSTPAINT if a subitem is being drawn. This will only be set if
/// CDRF_NOTIFYITEMDRAW is returned from CDDS_PREPAINT.
/// </summary>
CDDS_SUBITEM = 0x00020000,
}
@ -547,8 +579,8 @@ namespace Vanara.PInvoke
public enum HotItemChangeFlags
{
/// <summary>
/// The change in the hot item resulted from an event that could not be determined. This will most often be due to a change in focus or the
/// TB_SETHOTITEM message.
/// The change in the hot item resulted from an event that could not be determined. This will most often be due to a change in
/// focus or the TB_SETHOTITEM message.
/// </summary>
HICF_OTHER = 0x00000000,
@ -564,10 +596,14 @@ namespace Vanara.PInvoke
/// <summary>Modifies HICF_ACCELERATOR. If this flag is set, more than one item has the same shortcut key character.</summary>
HICF_DUPACCEL = 0x00000008,
/// <summary>Modifies the other reason flags. If this flag is set, there is no previous hot item and idOld does not contain valid information.</summary>
/// <summary>
/// Modifies the other reason flags. If this flag is set, there is no previous hot item and idOld does not contain valid information.
/// </summary>
HICF_ENTERING = 0x00000010,
/// <summary>Modifies the other reason flags. If this flag is set, there is no new hot item and idNew does not contain valid information.</summary>
/// <summary>
/// Modifies the other reason flags. If this flag is set, there is no new hot item and idNew does not contain valid information.
/// </summary>
HICF_LEAVING = 0x00000020,
/// <summary>The change in the hot item resulted from the user entering the shortcut key for an item that was already hot.</summary>
@ -601,13 +637,14 @@ namespace Vanara.PInvoke
{
/// <summary>Corresponds to SM_CXSMICON, the recommended pixel width of a small icon.</summary>
LIM_SMALL,
/// <summary>Corresponds toSM_CXICON, the default pixel width of an icon.</summary>
LIM_LARGE,
}
/// <summary>
/// Posts messages when the mouse pointer leaves a window or hovers over a window for a specified amount of time. This function calls TrackMouseEvent if
/// it exists, otherwise it emulates it.
/// Posts messages when the mouse pointer leaves a window or hovers over a window for a specified amount of time. This function calls
/// TrackMouseEvent if it exists, otherwise it emulates it.
/// </summary>
/// <param name="lpEventTrack">
/// <para>Type: <c>LPTRACKMOUSEEVENT</c></para>
@ -622,10 +659,11 @@ namespace Vanara.PInvoke
[DllImport(Lib.ComCtl32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("CommCtrl.h", MSDNShortId = "ms646266")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool _TrackMouseEvent(ref User32.TRACKMOUSEEVENT lpEventTrack);
public static extern bool _TrackMouseEvent(ref TRACKMOUSEEVENT lpEventTrack);
/// <summary>
/// Calls the next handler in a window's subclass chain. The last handler in the subclass chain calls the original window procedure for the window.
/// Calls the next handler in a window's subclass chain. The last handler in the subclass chain calls the original window procedure
/// for the window.
/// </summary>
/// <param name="hWnd">
/// <para>Type: <c>HWND</c></para>
@ -642,8 +680,8 @@ namespace Vanara.PInvoke
/// <param name="LPARAM">
/// <para>Type: <c>LPARAM</c></para>
/// <para>
/// Specifies additional message information. The contents of this parameter depend on the value of the window message. Note: On 64-bit versions of
/// Windows LPARAM is a 64-bit value.
/// Specifies additional message information. The contents of this parameter depend on the value of the window message. Note: On
/// 64-bit versions of Windows LPARAM is a 64-bit value.
/// </para>
/// </param>
/// <returns>
@ -696,11 +734,11 @@ namespace Vanara.PInvoke
/// <para>Type: <c>int</c></para>
/// <para>Returns the height of the text in logical units if the function succeeds, otherwise returns zero.</para>
/// </returns>
// int DrawShadowText( HDC hdc, LPCWSTR pszText, UINT cch, const RECT *pRect, DWORD dwFlags, COLORREF crText, COLORREF crShadow, int ixOffset, int
// iyOffset); https://msdn.microsoft.com/en-us/library/windows/desktop/bb775639(v=vs.85).aspx
// int DrawShadowText( HDC hdc, LPCWSTR pszText, UINT cch, const RECT *pRect, DWORD dwFlags, COLORREF crText, COLORREF crShadow, int
// ixOffset, int iyOffset); https://msdn.microsoft.com/en-us/library/windows/desktop/bb775639(v=vs.85).aspx
[DllImport(Lib.ComCtl32, SetLastError = false, ExactSpelling = true, CharSet = CharSet.Unicode)]
[PInvokeData("Commctrl.h", MSDNShortId = "bb775639")]
public static extern int DrawShadowText(HDC hdc, string pszText, uint cch, ref RECT pRect, uint dwFlags, COLORREF crText, COLORREF crShadow, int ixOffset, int iyOffset);
public static extern int DrawShadowText(HDC hdc, string pszText, uint cch, in RECT pRect, uint dwFlags, COLORREF crText, COLORREF crShadow, int ixOffset, int iyOffset);
/// <summary>Calculates the dimensions of a rectangle in the client area that contains all the specified controls.</summary>
/// <param name="hWnd">
@ -714,9 +752,9 @@ namespace Vanara.PInvoke
/// <param name="lpInfo">
/// <para>Type: <c>const <c>INT</c>*</c></para>
/// <para>
/// A pointer to a null-terminated array of integers that identify controls in the client area. Each control requires a pair of consecutive elements. The
/// first element of the pair must be nonzero and the second element of the pair must be the control identifier. The first pair represents the menu and
/// is ignored. The last element must be zero to identify the end of the array.
/// A pointer to a null-terminated array of integers that identify controls in the client area. Each control requires a pair of
/// consecutive elements. The first element of the pair must be nonzero and the second element of the pair must be the control
/// identifier. The first pair represents the menu and is ignored. The last element must be zero to identify the end of the array.
/// </para>
/// </param>
/// <returns>No return value.</returns>
@ -734,7 +772,7 @@ namespace Vanara.PInvoke
public static RECT GetEffectiveClientRect(HWND hWnd, int[] controlIdentifiers)
{
var lpInfo = new int[(controlIdentifiers.Length + 2) * 2];
for (int i = 0; i < controlIdentifiers.Length; i++)
for (var i = 0; i < controlIdentifiers.Length; i++)
{
lpInfo[(i + 1) * 2] = 1;
lpInfo[((i + 1) * 2) + 1] = controlIdentifiers[i];
@ -748,9 +786,10 @@ namespace Vanara.PInvoke
/// <returns>
/// <para>Type: <c><c>LANGID</c></c></para>
/// <para>
/// Returns the language identifier of the language an application has specified for the common controls by calling <c>InitMUILanguage</c>.
/// <c>GetMUILanguage</c> returns the value for the process from which it is called. If <c>InitMUILanguage</c> has not been called or was not called from
/// the same process, <c>GetMUILanguage</c> returns the language-neutral LANGID, <c>MAKELANGID</c>(LANG_NEUTRAL, SUBLANG_NEUTRAL).
/// Returns the language identifier of the language an application has specified for the common controls by calling
/// <c>InitMUILanguage</c>. <c>GetMUILanguage</c> returns the value for the process from which it is called. If
/// <c>InitMUILanguage</c> has not been called or was not called from the same process, <c>GetMUILanguage</c> returns the
/// language-neutral LANGID, <c>MAKELANGID</c>(LANG_NEUTRAL, SUBLANG_NEUTRAL).
/// </para>
/// </returns>
// LANGID GetMUILanguage(void); https://msdn.microsoft.com/en-us/library/windows/desktop/bb775676(v=vs.85).aspx
@ -770,13 +809,15 @@ namespace Vanara.PInvoke
/// <param name="uIdSubclass">
/// <para>Type: <c>UINT_PTR</c></para>
/// <para>
/// <c>UINT_PTR</c> subclass ID. This ID and the callback pointer uniquely identify this subclass callback. Note: On 64-bit versions of Windows this is a
/// 64-bit value.
/// <c>UINT_PTR</c> subclass ID. This ID and the callback pointer uniquely identify this subclass callback. Note: On 64-bit versions
/// of Windows this is a 64-bit value.
/// </para>
/// </param>
/// <param name="pdwRefData">
/// <para>Type: <c>DWORD_PTR*</c></para>
/// <para>A pointer to a <c>DWORD</c> which will return the reference data. Note: On 64-bit versions of Windows, pointers are 64-bit values.</para>
/// <para>
/// A pointer to a <c>DWORD</c> which will return the reference data. Note: On 64-bit versions of Windows, pointers are 64-bit values.
/// </para>
/// </param>
/// <returns>
/// <para>Type: <c>BOOL</c></para>
@ -804,30 +845,30 @@ namespace Vanara.PInvoke
public static extern bool GetWindowSubclass(HWND hWnd, SUBCLASSPROC pfnSubclass, [MarshalAs(UnmanagedType.SysUInt)] uint uIdSubclass, out IntPtr pdwRefData);
/// <summary>
/// Ensures that the common control DLL (Comctl32.dll) is loaded, and registers specific common control classes from the DLL. An application must call
/// this function before creating a common control.
/// Ensures that the common control DLL (Comctl32.dll) is loaded, and registers specific common control classes from the DLL. An
/// application must call this function before creating a common control.
/// </summary>
/// <param name="icc">A pointer to an INITCOMMONCONTROLSEX structure that contains information specifying which control classes will be registered.</param>
/// <param name="icc">
/// A pointer to an INITCOMMONCONTROLSEX structure that contains information specifying which control classes will be registered.
/// </param>
/// <returns>Returns TRUE if successful, or FALSE otherwise.</returns>
[PInvokeData("Commctrl.h", MSDNShortId = "bb775697")]
[DllImport(Lib.ComCtl32, ExactSpelling = true)]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool InitCommonControlsEx(ref INITCOMMONCONTROLSEX icc);
public static extern bool InitCommonControlsEx(in INITCOMMONCONTROLSEX icc);
/// <summary>
/// Ensures that the common control DLL (Comctl32.dll) is loaded, and registers specific common control classes from the DLL. An application must call
/// this function before creating a common control.
/// Ensures that the common control DLL (Comctl32.dll) is loaded, and registers specific common control classes from the DLL. An
/// application must call this function before creating a common control.
/// </summary>
/// <param name="ccc">The <see cref="CommonControlClass"/> value to assign to the dwICC field in <see cref="INITCOMMONCONTROLSEX"/>.</param>
/// <returns>Returns TRUE if successful, or FALSE otherwise.</returns>
[PInvokeData("Commctrl.h", MSDNShortId = "bb775697")]
public static bool InitCommonControlsEx(CommonControlClass ccc)
{
var icc = new INITCOMMONCONTROLSEX(ccc);
return InitCommonControlsEx(ref icc);
}
public static bool InitCommonControlsEx(CommonControlClass ccc) => InitCommonControlsEx(new INITCOMMONCONTROLSEX(ccc));
/// <summary>Enables an application to specify a language to be used with the common controls that is different from the system language.</summary>
/// <summary>
/// Enables an application to specify a language to be used with the common controls that is different from the system language.
/// </summary>
/// <param name="uiLang">
/// <para>Type: <c><c>LANGID</c></c></para>
/// <para>The language identifier of the language to be used by the common controls.</para>
@ -841,12 +882,16 @@ namespace Vanara.PInvoke
/// <summary>Loads a specified icon resource with a client-specified system metric.</summary>
/// <param name="hinst">
/// <para>Type: <c><c>HINSTANCE</c></c></para>
/// <para>A handle to the module of either a DLL or executable (.exe) file that contains the icon to be loaded. For more information, see <c>GetModuleHandle</c>.</para>
/// <para>
/// A handle to the module of either a DLL or executable (.exe) file that contains the icon to be loaded. For more information, see <c>GetModuleHandle</c>.
/// </para>
/// <para>To load a predefined icon or a standalone icon file, set this parameter to <c>NULL</c>.</para>
/// </param>
/// <param name="pszName">
/// <para>Type: <c><c>PCWSTR</c></c></para>
/// <para>A pointer to a null-terminated, Unicode buffer that contains location information about the icon to load. It is interpreted as follows:</para>
/// <para>
/// A pointer to a null-terminated, Unicode buffer that contains location information about the icon to load. It is interpreted as follows:
/// </para>
/// <para>If hinst is <c>NULL</c>, pszName can specify one of two things.</para>
/// <para>If hinst is non-null, pszName can specify one of two things.</para>
/// </param>
@ -893,25 +938,30 @@ namespace Vanara.PInvoke
// HRESULT LoadIconMetric( _In_ HINSTANCE hinst, _In_ PCWSTR pszName, _In_ int lims, _Out_ HICON *phico); https://msdn.microsoft.com/en-us/library/windows/desktop/bb775701(v=vs.85).aspx
[DllImport(Lib.ComCtl32, SetLastError = false, ExactSpelling = true, CharSet = CharSet.Unicode)]
[PInvokeData("Commctrl.h", MSDNShortId = "bb775701")]
public static extern HRESULT LoadIconMetric(HINSTANCE hinst, string pszName, LI_METRIC lims, out IntPtr phico);
public static extern HRESULT LoadIconMetric(HINSTANCE hinst, string pszName, LI_METRIC lims, out SafeHICON phico);
/// <summary>Loads an icon. If the icon is not a standard size, this function scales down a larger image instead of scaling up a smaller image.</summary>
/// <summary>
/// Loads an icon. If the icon is not a standard size, this function scales down a larger image instead of scaling up a smaller image.
/// </summary>
/// <param name="hinst">
/// <para>Type: <c><c>HINSTANCE</c></c></para>
/// <para>A handle to the module of either a DLL or executable (.exe) file that contains the icon to be loaded. For more information, see <c>GetModuleHandle</c>.</para>
/// <para>
/// A handle to the module of either a DLL or executable (.exe) file that contains the icon to be loaded. For more information, see <c>GetModuleHandle</c>.
/// </para>
/// <para>To load a predefined icon or a standalone icon file, set this parameter to <c>NULL</c>.</para>
/// </param>
/// <param name="pszName">
/// <para>Type: <c><c>PCWSTR</c></c></para>
/// <para>A pointer to a null-terminated, Unicode buffer that contains location information about the icon to load.</para>
/// <para>
/// If hinst is non- <c>NULL</c>, pszName specifies the icon resource either by name or ordinal. This ordinal must be packaged by using the
/// <c>MAKEINTRESOURCE</c> macro.
/// If hinst is non- <c>NULL</c>, pszName specifies the icon resource either by name or ordinal. This ordinal must be packaged by
/// using the <c>MAKEINTRESOURCE</c> macro.
/// </para>
/// <para>
/// If hinst is <c>NULL</c>, pszName specifies either the name of a standalone icon (.ico) file or the identifier of a predefined icon to load. The
/// following identifiers are recognized. To pass these constants to the <c>LoadIconWithScaleDown</c> function, use the <c>MAKEINTRESOURCE</c> macro. For
/// example, to load the IDI_ERROR icon, pass as the pszName parameter and <c>NULL</c> as the hinst parameter.
/// If hinst is <c>NULL</c>, pszName specifies either the name of a standalone icon (.ico) file or the identifier of a predefined
/// icon to load. The following identifiers are recognized. To pass these constants to the <c>LoadIconWithScaleDown</c> function, use
/// the <c>MAKEINTRESOURCE</c> macro. For example, to load the IDI_ERROR icon, pass as the pszName parameter and <c>NULL</c> as the
/// hinst parameter.
/// </para>
/// <para>
/// <list type="table">
@ -1003,14 +1053,15 @@ namespace Vanara.PInvoke
/// <param name="pfnSubclass">
/// <para>Type: <c><c>SUBCLASSPROC</c></c></para>
/// <para>
/// A pointer to a window procedure. This pointer and the subclass ID uniquely identify this subclass callback. For the callback function prototype, see <c>SUBCLASSPROC</c>.
/// A pointer to a window procedure. This pointer and the subclass ID uniquely identify this subclass callback. For the callback
/// function prototype, see <c>SUBCLASSPROC</c>.
/// </para>
/// </param>
/// <param name="uIdSubclass">
/// <para>Type: <c>UINT_PTR</c></para>
/// <para>
/// The <c>UINT_PTR</c> subclass ID. This ID and the callback pointer uniquely identify this subclass callback. Note: On 64-bit versions of Windows this
/// is a 64-bit value.
/// The <c>UINT_PTR</c> subclass ID. This ID and the callback pointer uniquely identify this subclass callback. Note: On 64-bit
/// versions of Windows this is a 64-bit value.
/// </para>
/// </param>
/// <returns>
@ -1031,21 +1082,24 @@ namespace Vanara.PInvoke
/// <param name="pfnSubclass">
/// <para>Type: <c><c>SUBCLASSPROC</c></c></para>
/// <para>
/// A pointer to a window procedure. This pointer and the subclass ID uniquely identify this subclass callback. For the callback function prototype, see <c>SUBCLASSPROC</c>.
/// A pointer to a window procedure. This pointer and the subclass ID uniquely identify this subclass callback. For the callback
/// function prototype, see <c>SUBCLASSPROC</c>.
/// </para>
/// </param>
/// <param name="uIdSubclass">
/// <para>Type: <c>UINT_PTR</c></para>
/// <para>
/// The subclass ID. This ID together with the subclass procedure uniquely identify a subclass. To remove a subclass, pass the subclass procedure and
/// this value to the <c>RemoveWindowSubclass</c> function. This value is passed to the subclass procedure in the uIdSubclass parameter.
/// The subclass ID. This ID together with the subclass procedure uniquely identify a subclass. To remove a subclass, pass the
/// subclass procedure and this value to the <c>RemoveWindowSubclass</c> function. This value is passed to the subclass procedure in
/// the uIdSubclass parameter.
/// </para>
/// </param>
/// <param name="dwRefData">
/// <para>Type: <c>DWORD_PTR</c></para>
/// <para>
/// <c>DWORD_PTR</c> to reference data. The meaning of this value is determined by the calling application. This value is passed to the subclass
/// procedure in the dwRefData parameter. A different dwRefData is associated with each combination of window handle, subclass procedure and uIdSubclass.
/// <c>DWORD_PTR</c> to reference data. The meaning of this value is determined by the calling application. This value is passed to
/// the subclass procedure in the dwRefData parameter. A different dwRefData is associated with each combination of window handle,
/// subclass procedure and uIdSubclass.
/// </para>
/// </param>
/// <returns>
@ -1060,13 +1114,13 @@ namespace Vanara.PInvoke
/// <summary>
/// <para>
/// [ <c>ShowHideMenuCtl</c> is available for use in the operating systems specified in the Requirements section. It may be altered or unavailable in
/// subsequent versions.]
/// [ <c>ShowHideMenuCtl</c> is available for use in the operating systems specified in the Requirements section. It may be altered
/// or unavailable in subsequent versions.]
/// </para>
/// <para>
/// Sets or removes the specified menu item's check mark attribute and shows or hides the corresponding control. The function adds a check mark to the
/// specified menu item if it does not have one and then displays the corresponding control. If the menu item already has a check mark, the function
/// removes the check mark and hides the corresponding control.
/// Sets or removes the specified menu item's check mark attribute and shows or hides the corresponding control. The function adds a
/// check mark to the specified menu item if it does not have one and then displays the corresponding control. If the menu item
/// already has a check mark, the function removes the check mark and hides the corresponding control.
/// </para>
/// </summary>
/// <param name="hWnd">
@ -1080,9 +1134,10 @@ namespace Vanara.PInvoke
/// <param name="lpInfo">
/// <para>Type: <c><c>LPINT</c></c></para>
/// <para>
/// A pointer to an array that contains pairs of values. The second value in the first pair must be the handle to the application's main menu. Each
/// subsequent pair consists of a menu item identifier and a control window identifier. The function searches the array for a value that matches uFlags
/// and, if the value is found, checks or unchecks the menu item and shows or hides the corresponding control.
/// A pointer to an array that contains pairs of values. The second value in the first pair must be the handle to the application's
/// main menu. Each subsequent pair consists of a menu item identifier and a control window identifier. The function searches the
/// array for a value that matches uFlags and, if the value is found, checks or unchecks the menu item and shows or hides the
/// corresponding control.
/// </para>
/// </param>
/// <returns>
@ -1102,16 +1157,18 @@ namespace Vanara.PInvoke
/// <summary>The size of this structure, in bytes.</summary>
public uint dwSize;
/// <summary>The COLORREF value that represents the highlight color of the buttons. Use CLR_DEFAULT for the default highlight color.</summary>
public uint clrBtnHighlight;
/// <summary>
/// The COLORREF value that represents the highlight color of the buttons. Use CLR_DEFAULT for the default highlight color.
/// </summary>
public COLORREF clrBtnHighlight;
/// <summary>The COLORREF value that represents the shadow color of the buttons. Use CLR_DEFAULT for the default shadow color.</summary>
public uint clrBtnShadow;
public COLORREF clrBtnShadow;
}
/// <summary>
/// Carries information used to load common control classes from the dynamic-link library (DLL). This structure is used with the
/// <see cref="InitCommonControlsEx(ref INITCOMMONCONTROLSEX)"/> function.
/// Carries information used to load common control classes from the dynamic-link library (DLL). This structure is used with the <see
/// cref="InitCommonControlsEx(ref INITCOMMONCONTROLSEX)"/> function.
/// </summary>
[PInvokeData("Commctrl.h", MSDNShortId = "bb775507")]
[StructLayout(LayoutKind.Sequential)]
@ -1120,7 +1177,10 @@ namespace Vanara.PInvoke
/// <summary>The size of the structure, in bytes.</summary>
public int dwSize;
/// <summary>The set of bit flags that indicate which common control classes will be loaded from the DLL when calling <see cref="InitCommonControlsEx(ref INITCOMMONCONTROLSEX)"/>.</summary>
/// <summary>
/// The set of bit flags that indicate which common control classes will be loaded from the DLL when calling <see
/// cref="InitCommonControlsEx(ref INITCOMMONCONTROLSEX)"/>.
/// </summary>
public CommonControlClass dwICC;
/// <summary>Initializes a new instance of the <see cref="INITCOMMONCONTROLSEX"/> class and sets the dwICC field.</summary>
@ -1143,16 +1203,19 @@ namespace Vanara.PInvoke
/// <para>An <c>NMHDR</c> structure that contains additional information about this notification.</para>
/// </summary>
public NMHDR hdr;
/// <summary>
/// <para>Type: <c><c>UINT</c></c></para>
/// <para>The character that is being processed.</para>
/// </summary>
public uint ch;
/// <summary>
/// <para>Type: <c><c>DWORD</c></c></para>
/// <para>A 32-bit value that is determined by the control that is sending the notification.</para>
/// </summary>
public uint dwItemPrev;
/// <summary>
/// <para>Type: <c><c>DWORD</c></c></para>
/// <para>A 32-bit value that is determined by the control that is sending the notification.</para>
@ -1172,17 +1235,17 @@ namespace Vanara.PInvoke
public CustomDrawStage dwDrawStage;
/// <summary>A handle to the control's device context. Use this HDC to perform any GDI functions.</summary>
public IntPtr hdc;
public HDC hdc;
/// <summary>
/// The RECT structure that describes the bounding rectangle of the area being drawn. This member is initialized only by the CDDS_ITEMPREPAINT
/// notification. Version 5.80. This member is also initialized by the CDDS_PREPAINT notification.
/// The RECT structure that describes the bounding rectangle of the area being drawn. This member is initialized only by the
/// CDDS_ITEMPREPAINT notification. Version 5.80. This member is also initialized by the CDDS_PREPAINT notification.
/// </summary>
public RECT rc;
/// <summary>
/// The item number. What is contained in this member will depend on the type of control that is sending the notification. See the NM_CUSTOMDRAW
/// notification reference for the specific control to determine what, if anything, is contained in this member.
/// The item number. What is contained in this member will depend on the type of control that is sending the notification. See
/// the NM_CUSTOMDRAW notification reference for the specific control to determine what, if anything, is contained in this member.
/// </summary>
public IntPtr dwItemSpec;
@ -1223,33 +1286,40 @@ namespace Vanara.PInvoke
/// <para>An <c>NMHDR</c> structure that contains additional information about this notification.</para>
/// </summary>
public NMHDR hdr;
/// <summary>
/// <para>Type: <c><c>HDC</c></c></para>
/// <para>The device context to draw to.</para>
/// </summary>
public IntPtr hDC;
public HDC hDC;
/// <summary>
/// <para>Type: <c><c>LPCWSTR</c></c></para>
/// <para>The string to draw.</para>
/// </summary>
public string lpString;
/// <summary>
/// <para>Type: <c>int</c></para>
/// <para>Length of lpString.</para>
/// </summary>
public int nCount;
/// <summary>
/// <para>Type: <c>LPRECT</c></para>
/// <para>The rect to draw in.</para>
/// </summary>
public IntPtr lpRect;
/// <summary>
/// <para>Type: <c><c>UINT</c></c></para>
/// <para>
/// One or more of the DT_* flags. For more information, see the description of the uFormat parameter of the <c>DrawText</c> function. This may be <c>NULL</c>.
/// One or more of the DT_* flags. For more information, see the description of the uFormat parameter of the <c>DrawText</c>
/// function. This may be <c>NULL</c>.
/// </para>
/// </summary>
public uint uFormat;
/// <summary>
/// <para>Type: <c><c>BOOL</c></c></para>
/// <para>Whether the text is a link.</para>
@ -1269,22 +1339,26 @@ namespace Vanara.PInvoke
/// <para>An <c>NMHDR</c> structure that contains additional information about this notification.</para>
/// </summary>
public NMHDR hdr;
/// <summary>
/// <para>Type: <c><c>UINT</c></c></para>
/// <para>A virtual key code of the key that caused the event.</para>
/// </summary>
public uint nVKey;
/// <summary>
/// <para>Type: <c><c>UINT</c></c></para>
/// <para>
/// Flags associated with the key. These are the same flags that are passed in the high word of the lParam parameter of the <c>WM_KEYDOWN</c> message.
/// Flags associated with the key. These are the same flags that are passed in the high word of the lParam parameter of the
/// <c>WM_KEYDOWN</c> message.
/// </para>
/// </summary>
public uint uFlags;
}
/// <summary>Contains information used with mouse notification messages.</summary>
// typedef struct tagNMMOUSE { NMHDR hdr; DWORD_PTR dwItemSpec; DWORD_PTR dwItemData; POINT pt; LPARAM dwHitInfo;} NMMOUSE, *LPNMMOUSE; https://msdn.microsoft.com/en-us/library/windows/desktop/bb775518(v=vs.85).aspx
// typedef struct tagNMMOUSE { NMHDR hdr; DWORD_PTR dwItemSpec; DWORD_PTR dwItemData; POINT pt; LPARAM dwHitInfo;} NMMOUSE,
// *LPNMMOUSE; https://msdn.microsoft.com/en-us/library/windows/desktop/bb775518(v=vs.85).aspx
[PInvokeData("Commctrl.h", MSDNShortId = "bb775518")]
[StructLayout(LayoutKind.Sequential)]
public struct NMMOUSE
@ -1294,21 +1368,25 @@ namespace Vanara.PInvoke
/// <para>An <c>NMHDR</c> structure that contains additional information about this notification.</para>
/// </summary>
public NMHDR hdr;
/// <summary>
/// <para>Type: <c><c>DWORD_PTR</c></c></para>
/// <para>A control-specific item identifier.</para>
/// </summary>
public IntPtr dwItemSpec;
/// <summary>
/// <para>Type: <c><c>DWORD_PTR</c></c></para>
/// <para>A control-specific item data.</para>
/// </summary>
public IntPtr dwItemData;
/// <summary>
/// <para>Type: <c><c>POINT</c></c></para>
/// <para>A <c>POINT</c> structure that contains the client coordinates of the mouse when the click occurred.</para>
/// </summary>
public System.Drawing.Point pt;
/// <summary>
/// <para>Type: <c><c>LPARAM</c></c></para>
/// <para>Carries information about where on the item or control the cursor is pointing.</para>
@ -1317,7 +1395,8 @@ namespace Vanara.PInvoke
}
/// <summary>Contains information used with the TBN_GETOBJECT, TCN_GETOBJECT, and PSN_GETOBJECT notification codes.</summary>
// typedef struct tagNMOBJECTNOTIFY { NMHDR hdr; int iItem; IID *piid; IUnknown *pObject; HRESULT hResult;} NMOBJECTNOTIFY, *LPNMOBJECTNOTIFY; https://msdn.microsoft.com/en-us/library/windows/desktop/bb775520(v=vs.85).aspx
// typedef struct tagNMOBJECTNOTIFY { NMHDR hdr; int iItem; IID *piid; IUnknown *pObject; HRESULT hResult;} NMOBJECTNOTIFY,
// *LPNMOBJECTNOTIFY; https://msdn.microsoft.com/en-us/library/windows/desktop/bb775520(v=vs.85).aspx
[PInvokeData("Commctrl.h", MSDNShortId = "bb775520")]
[StructLayout(LayoutKind.Sequential)]
public struct NMOBJECTNOTIFY
@ -1327,31 +1406,37 @@ namespace Vanara.PInvoke
/// <para>An <c>NMHDR</c> structure that contains additional information about this notification.</para>
/// </summary>
public NMHDR hdr;
/// <summary>
/// <para>Type: <c>int</c></para>
/// <para>
/// A control-specific item identifier. This value will comply to item identification standards for the control sending the notification. However,
/// this member is not used with the PSN_GETOBJECT notification code.
/// A control-specific item identifier. This value will comply to item identification standards for the control sending the
/// notification. However, this member is not used with the PSN_GETOBJECT notification code.
/// </para>
/// </summary>
public int iItem;
/// <summary>
/// <para>Type: <c>IID*</c></para>
/// <para>A pointer to an interface identifier of the requested object.</para>
/// </summary>
public IntPtr piid;
/// <summary>
/// <para>Type: <c><c>IUnknown</c>*</c></para>
/// <para>
/// A pointer to an object provided by the window processing the notification code. The application processing the notification code sets this member.
/// A pointer to an object provided by the window processing the notification code. The application processing the notification
/// code sets this member.
/// </para>
/// </summary>
public IntPtr pObject;
/// <summary>
/// <para>Type: <c><c>HRESULT</c></c></para>
/// <para>COM success or failure flags. The application processing the notification code sets this member.</para>
/// </summary>
public HRESULT hResult;
/// <summary>Undocumented</summary>
public uint dwFlags;
}
@ -1367,11 +1452,12 @@ namespace Vanara.PInvoke
/// <para>An <c>NMHDR</c> structure that contains additional information about this notification.</para>
/// </summary>
public NMHDR hdr;
/// <summary>
/// <para>Type: <c><c>HWND</c></c></para>
/// <para>The window handle to the tooltip control created.</para>
/// </summary>
public IntPtr hwndToolTips;
public HWND hwndToolTips;
}
}
}

View File

@ -66,6 +66,8 @@ Native Method | Native DLL | Header | Managed Method
[MenuHelp](http://msdn2.microsoft.com/en-us/library/bb760765) | comctl32.dll | Commctrl.h | Vanara.PInvoke.ComCtl32.MenuHelp
[PropertySheet](https://www.google.com/search?num=5&q=PropertySheet+site%3Amicrosoft.com) | comctl32.dll | Prsht.h | Vanara.PInvoke.ComCtl32.PropertySheet
[RemoveWindowSubclass](http://msdn2.microsoft.com/en-us/library/bb762094) | comctl32.dll | Commctrl.h | Vanara.PInvoke.ComCtl32.RemoveWindowSubclass
[SendMessageA](https://www.google.com/search?num=5&q=SendMessageA+site%3Amicrosoft.com) | user32.dll | | Vanara.PInvoke.ComCtl32.SendMessage
[SendMessageW](https://www.google.com/search?num=5&q=SendMessageW+site%3Amicrosoft.com) | user32.dll | | Vanara.PInvoke.ComCtl32.SendMessage
[SetWindowSubclass](http://msdn2.microsoft.com/en-us/library/bb762102) | comctl32.dll | Commctrl.h | Vanara.PInvoke.ComCtl32.SetWindowSubclass
[ShowHideMenuCtl](http://msdn2.microsoft.com/en-us/library/bb775731) | comctl32.dll | Commctrl.h | Vanara.PInvoke.ComCtl32.ShowHideMenuCtl
[Str_SetPtrW](http://msdn2.microsoft.com/en-us/library/bb775735) | comctl32.dll | Commctrl.h | Vanara.PInvoke.ComCtl32.Str_SetPtr
@ -74,23 +76,17 @@ Native Method | Native DLL | Header | Managed Method
### Structures
Native Structure | Header | Managed Structure
--- | --- | ---
[BUTTON_IMAGELIST](http://msdn2.microsoft.com/en-us/library/bb775953) | Commctrl.h | Vanara.PInvoke.ComCtl32+BUTTON_IMAGELIST
[BUTTON_SPLITINFO](http://msdn2.microsoft.com/en-us/library/bb775955) | Commctrl.h | Vanara.PInvoke.ComCtl32+BUTTON_SPLITINFO
[COLORMAP](http://msdn2.microsoft.com/en-us/library/bb760448) | Commctrl.h | Vanara.PInvoke.ComCtl32+COLORMAP
[COLORSCHEME](https://www.google.com/search?num=5&q=COLORSCHEME+site%3Amicrosoft.com) | | Vanara.PInvoke.ComCtl32+COLORSCHEME
[COMBOBOXEXITEM](http://msdn2.microsoft.com/en-us/library/bb775746) | Commctrl.h | Vanara.PInvoke.ComCtl32+COMBOBOXEXITEM
[COMBOBOXINFO](http://msdn2.microsoft.com/en-us/library/bb775798) | Winuser.h | Vanara.PInvoke.ComCtl32+COMBOBOXINFO
[DPASTREAMINFO](http://msdn2.microsoft.com/en-us/library/bb775504) | Dpa_dsa.h | Vanara.PInvoke.ComCtl32+DPASTREAMINFO
[EDITBALLOONTIP](http://msdn2.microsoft.com/en-us/library/bb775466) | Commctrl.h | Vanara.PInvoke.ComCtl32+EDITBALLOONTIP
[HDHITTESTINFO](http://msdn2.microsoft.com/en-us/library/bb775245) | Commctrl.h | Vanara.PInvoke.ComCtl32+HDHITTESTINFO
[HDITEM](http://msdn2.microsoft.com/en-us/library/bb775247) | Commctrl.h | Vanara.PInvoke.ComCtl32+HDITEM
[HDLAYOUT](http://msdn2.microsoft.com/en-us/library/bb775249) | Commctrl.h | Vanara.PInvoke.ComCtl32+HDLAYOUT
[HDTEXTFILTER](http://msdn2.microsoft.com/en-us/library/bb775251) | Commctrl.h | Vanara.PInvoke.ComCtl32+HDTEXTFILTER
[IMAGEINFO](http://msdn2.microsoft.com/en-us/library/bb761393) | Commctrl.h | Vanara.PInvoke.ComCtl32+IMAGEINFO
[IMAGELISTDRAWPARAMS](http://msdn2.microsoft.com/en-us/library/bb761395) | Commctrl.h | Vanara.PInvoke.ComCtl32+IMAGELISTDRAWPARAMS
[HTREEITEM](https://www.google.com/search?num=5&q=HTREEITEM+site%3Amicrosoft.com) | | Vanara.PInvoke.ComCtl32+HTREEITEM
[IMAGELISTSTATS](http://msdn2.microsoft.com/en-us/library/bb761397) | Commoncontrols.h | Vanara.PInvoke.ComCtl32+IMAGELISTSTATS
[INITCOMMONCONTROLSEX](http://msdn2.microsoft.com/en-us/library/bb775507) | Commctrl.h | Vanara.PInvoke.ComCtl32+INITCOMMONCONTROLSEX
[LVBKIMAGE](http://msdn2.microsoft.com/en-us/library/bb774742) | Commctrl.h | Vanara.PInvoke.ComCtl32+LVBKIMAGE
[LVCOLUMN](http://msdn2.microsoft.com/en-us/library/bb774743) | Commctrl.h | Vanara.PInvoke.ComCtl32+LVCOLUMN
[LVFINDINFO](http://msdn2.microsoft.com/en-us/library/bb774745) | Commctrl.h | Vanara.PInvoke.ComCtl32+LVFINDINFO
[LVGROUP](http://msdn2.microsoft.com/en-us/library/bb774769) | Commctrl.h | Vanara.PInvoke.ComCtl32+LVGROUP
@ -101,64 +97,19 @@ Native Structure | Header | Managed Structure
[LVITEMCOLUMNINFO](http://msdn2.microsoft.com/en-us/library/bb774760) | Commctrl.h | Vanara.PInvoke.ComCtl32+LVITEMCOLUMNINFO
[LVITEMINDEX](http://msdn2.microsoft.com/en-us/library/bb761385) | Commctrl.h | Vanara.PInvoke.ComCtl32+LVITEMINDEX
[LVTILEVIEWINFO](http://msdn2.microsoft.com/en-us/library/bb774768) | Commctrl.h | Vanara.PInvoke.ComCtl32+LVTILEVIEWINFO
[NMBCDROPDOWN](http://msdn2.microsoft.com/en-us/library/bb775957) | Commctrl.h | Vanara.PInvoke.ComCtl32+NMBCDROPDOWN
[NMBCHOTITEM](http://msdn2.microsoft.com/en-us/library/bb775959) | Commctrl.h | Vanara.PInvoke.ComCtl32+NMBCHOTITEM
[NMCBEDRAGBEGIN](http://msdn2.microsoft.com/en-us/library/bb775748) | Commctrl.h | Vanara.PInvoke.ComCtl32+NMCBEDRAGBEGIN
[NMCBEENDEDIT](http://msdn2.microsoft.com/en-us/library/bb775750) | Commctrl.h | Vanara.PInvoke.ComCtl32+NMCBEENDEDIT
[NMCHAR](http://msdn2.microsoft.com/en-us/library/bb775508) | Commctrl.h | Vanara.PInvoke.ComCtl32+NMCHAR
[NMCOMBOBOXEX](http://msdn2.microsoft.com/en-us/library/bb775752) | Commctrl.h | Vanara.PInvoke.ComCtl32+NMCOMBOBOXEX
[NMCUSTOMDRAW](http://msdn2.microsoft.com/en-us/library/bb775483) | Commctrl.h | Vanara.PInvoke.ComCtl32+NMCUSTOMDRAW
[NMCUSTOMSPLITRECTINFO](http://msdn2.microsoft.com/en-us/library/bb775510) | Commctrl.h | Vanara.PInvoke.ComCtl32+NMCUSTOMSPLITRECTINFO
[NMCUSTOMTEXT](http://msdn2.microsoft.com/en-us/library/bb775512) | Commctrl.h | Vanara.PInvoke.ComCtl32+NMCUSTOMTEXT
[NMHDDISPINFO](http://msdn2.microsoft.com/en-us/library/bb775253) | Commctrl.h | Vanara.PInvoke.ComCtl32+NMHDDISPINFO
[NMHDFILTERBTNCLICK](http://msdn2.microsoft.com/en-us/library/bb775255) | Commctrl.h | Vanara.PInvoke.ComCtl32+NMHDFILTERBTNCLICK
[NMHEADER](http://msdn2.microsoft.com/en-us/library/bb775257) | Commctrl.h | Vanara.PInvoke.ComCtl32+NMHEADER
[NMIPADDRESS](http://msdn2.microsoft.com/en-us/library/bb761375) | Commctrl.h | Vanara.PInvoke.ComCtl32+NMIPADDRESS
[NMKEY](http://msdn2.microsoft.com/en-us/library/bb775516) | Commctrl.h | Vanara.PInvoke.ComCtl32+NMKEY
[NMLISTVIEW](http://msdn2.microsoft.com/en-us/library/bb774773) | Commctrl.h | Vanara.PInvoke.ComCtl32+NMLISTVIEW
[NMMOUSE](http://msdn2.microsoft.com/en-us/library/bb775518) | Commctrl.h | Vanara.PInvoke.ComCtl32+NMMOUSE
[NMOBJECTNOTIFY](http://msdn2.microsoft.com/en-us/library/bb775520) | Commctrl.h | Vanara.PInvoke.ComCtl32+NMOBJECTNOTIFY
[NMTBDISPINFO](http://msdn2.microsoft.com/en-us/library/bb760452) | Commctrl.h | Vanara.PInvoke.ComCtl32+NMTBDISPINFO
[NMTBGETINFOTIP](http://msdn2.microsoft.com/en-us/library/bb760454) | Commctrl.h | Vanara.PInvoke.ComCtl32+NMTBGETINFOTIP
[NMTBHOTITEM](http://msdn2.microsoft.com/en-us/library/bb760456) | Commctrl.h | Vanara.PInvoke.ComCtl32+NMTBHOTITEM
[NMTBRESTORE](http://msdn2.microsoft.com/en-us/library/bb760458) | Commctrl.h | Vanara.PInvoke.ComCtl32+NMTBRESTORE
[NMTBSAVE](http://msdn2.microsoft.com/en-us/library/bb760471) | Commctrl.h | Vanara.PInvoke.ComCtl32+NMTBSAVE
[NMTOOLBAR](http://msdn2.microsoft.com/en-us/library/bb760473) | Commctrl.h | Vanara.PInvoke.ComCtl32+NMTOOLBAR
[NMTOOLTIPSCREATED](http://msdn2.microsoft.com/en-us/library/bb775522) | Commctrl.h | Vanara.PInvoke.ComCtl32+NMTOOLTIPSCREATED
[NMTRBTHUMBPOSCHANGING](http://msdn2.microsoft.com/en-us/library/bb760153) | Commctrl.h | Vanara.PInvoke.ComCtl32+NMTRBTHUMBPOSCHANGING
[NMTREEVIEW](http://msdn2.microsoft.com/en-us/library/bb773411) | Commctrl.h | Vanara.PInvoke.ComCtl32+NMTREEVIEW
[NMTTDISPINFO](http://msdn2.microsoft.com/en-us/library/bb760258) | Commctrl.h | Vanara.PInvoke.ComCtl32+NMTTDISPINFO
[NMTVASYNCDRAW](http://msdn2.microsoft.com/en-us/library/bb773413) | Commctrl.h | Vanara.PInvoke.ComCtl32+NMTVASYNCDRAW
[NMTVCUSTOMDRAW](http://msdn2.microsoft.com/en-us/library/bb773415) | Commctrl.h | Vanara.PInvoke.ComCtl32+NMTVCUSTOMDRAW
[NMTVDISPINFO](http://msdn2.microsoft.com/en-us/library/bb773418) | Commctrl.h | Vanara.PInvoke.ComCtl32+NMTVDISPINFO
[NMTVDISPINFOEX](http://msdn2.microsoft.com/en-us/library/bb760143) | Commctrl.h | Vanara.PInvoke.ComCtl32+NMTVDISPINFOEX
[NMTVGETINFOTIP](http://msdn2.microsoft.com/en-us/library/bb773421) | Commctrl.h | Vanara.PInvoke.ComCtl32+NMTVGETINFOTIP
[NMTVITEMCHANGE](http://msdn2.microsoft.com/en-us/library/bb773425) | Commctrl.h | Vanara.PInvoke.ComCtl32+NMTVITEMCHANGE
[NMTVKEYDOWN](http://msdn2.microsoft.com/en-us/library/bb773433) | Commctrl.h | Vanara.PInvoke.ComCtl32+NMTVKEYDOWN
[NMUPDOWN](http://msdn2.microsoft.com/en-us/library/bb759893) | Commctrl.h | Vanara.PInvoke.ComCtl32+NMUPDOWN
[PBRANGE](http://msdn2.microsoft.com/en-us/library/bb760822) | Commctrl.h | Vanara.PInvoke.ComCtl32+PBRANGE
[PROPSHEETHEADER](http://msdn2.microsoft.com/en-us/library/bb774546) | Commctrl.h | Vanara.PInvoke.ComCtl32+PROPSHEETHEADER
[PROPSHEETPAGE](http://msdn2.microsoft.com/en-us/library/bb774548) | Commctrl.h | Vanara.PInvoke.ComCtl32+PROPSHEETPAGE
[TASKDIALOG_BUTTON](http://msdn2.microsoft.com/en-us/library/bb787475) | Commctrl.h | Vanara.PInvoke.ComCtl32+TASKDIALOG_BUTTON
[TASKDIALOGCONFIG](http://msdn2.microsoft.com/en-us/library/bb787473) | commctrl.h | Vanara.PInvoke.ComCtl32+TASKDIALOGCONFIG
[TBADDBITMAP](http://msdn2.microsoft.com/en-us/library/bb760475) | Commctrl.h | Vanara.PInvoke.ComCtl32+TBADDBITMAP
[TBBUTTON](http://msdn2.microsoft.com/en-us/library/bb760476) | Commctrl.h | Vanara.PInvoke.ComCtl32+TBBUTTON
[TBBUTTONINFO](http://msdn2.microsoft.com/en-us/library/bb760478) | Commctrl.h | Vanara.PInvoke.ComCtl32+TBBUTTONINFO
[TBINSERTMARK](http://msdn2.microsoft.com/en-us/library/bb760480) | Commctrl.h | Vanara.PInvoke.ComCtl32+TBINSERTMARK
[TBMETRICS](http://msdn2.microsoft.com/en-us/library/bb760482) | Commctrl.h | Vanara.PInvoke.ComCtl32+TBMETRICS
[TBREPLACEBITMAP](http://msdn2.microsoft.com/en-us/library/bb760484) | Commctrl.h | Vanara.PInvoke.ComCtl32+TBREPLACEBITMAP
[TBSAVEPARAMS](http://msdn2.microsoft.com/en-us/library/bb760486) | Commctrl.h | Vanara.PInvoke.ComCtl32+TBSAVEPARAMS
[TCHITTESTINFO](http://msdn2.microsoft.com/en-us/library/bb760553) | Commctrl.h | Vanara.PInvoke.ComCtl32+TCHITTESTINFO
[TCITEM](http://msdn2.microsoft.com/en-us/library/bb760554) | Commctrl.h | Vanara.PInvoke.ComCtl32+TCITEM
[TCITEMHEADER](http://msdn2.microsoft.com/en-us/library/bb760813) | Commctrl.h | Vanara.PInvoke.ComCtl32+TCITEMHEADER
[TOOLINFO](http://msdn2.microsoft.com/en-us/library/bb760256) | Commctrl.h | Vanara.PInvoke.ComCtl32+TOOLINFO
[TTGETTITLE](http://msdn2.microsoft.com/en-us/library/bb760260) | Commctrl.h | Vanara.PInvoke.ComCtl32+TTGETTITLE
[TTHITTESTINFO](http://msdn2.microsoft.com/en-us/library/bb760262) | Commctrl.h | Vanara.PInvoke.ComCtl32+TTHITTESTINFO
[TVGETITEMPARTRECTINFO](http://msdn2.microsoft.com/en-us/library/bb773442) | Commctrl.h | Vanara.PInvoke.ComCtl32+TVGETITEMPARTRECTINFO
[TVHITTESTINFO](http://msdn2.microsoft.com/en-us/library/bb773448) | Commctrl.h | Vanara.PInvoke.ComCtl32+TVHITTESTINFO
[TVINSERTSTRUCT](http://msdn2.microsoft.com/en-us/library/bb773452) | Commctrl.h | Vanara.PInvoke.ComCtl32+TVINSERTSTRUCT
[TVITEM](http://msdn2.microsoft.com/en-us/library/bb773456) | Commctrl.h | Vanara.PInvoke.ComCtl32+TVITEM
[TVITEMEX](http://msdn2.microsoft.com/en-us/library/bb773459) | Commctrl.h | Vanara.PInvoke.ComCtl32+TVITEMEX
[TVSORTCB](http://msdn2.microsoft.com/en-us/library/bb773462) | Commctrl.h | Vanara.PInvoke.ComCtl32+TVSORTCB
[UDACCEL](http://msdn2.microsoft.com/en-us/library/bb759897) | Commctrl.h | Vanara.PInvoke.ComCtl32+UDACCEL
### Interfaces

View File

@ -28,13 +28,13 @@ Functions
_TrackMouseEvent, CreateMappedBitmap, CreatePropertySheetPageA, CreatePropertySheetPageW, CreateUpDownControl, DefSubclassProc, DestroyPropertySheetPage, DPA_Clone, DPA_Create, DPA_CreateEx, DPA_DeleteAllPtrs, DPA_DeletePtr, DPA_Destroy, DPA_DestroyCallback, DPA_EnumCallback, DPA_GetPtr, DPA_GetPtrIndex, DPA_GetSize, DPA_Grow, DPA_InsertPtr, DPA_LoadStream, DPA_Merge, DPA_SaveStream, DPA_Search, DPA_SetPtr, DPA_Sort, DrawInsert, DrawShadowText, DrawStatusTextA, DrawStatusTextW, DSA_Clone, DSA_Create, DSA_DeleteAllItems, DSA_DeleteItem, DSA_Destroy, DSA_DestroyCallback, DSA_EnumCallback, DSA_GetItem, DSA_GetItemPtr, DSA_GetSize, DSA_InsertItem, DSA_SetItem, DSA_Sort, GetEffectiveClientRect, GetMUILanguage, GetWindowSubclass, HIMAGELIST_QueryInterface, ImageList_CoCreateInstance, ImageList_Create, ImageList_Destroy, ImageList_Duplicate, ImageList_GetIcon, ImageList_LoadImageA, ImageList_LoadImageW, ImageList_Read, ImageList_ReadEx, ImageList_Write, ImageList_WriteEx, InitCommonControlsEx, InitMUILanguage, LBItemFromPt, LoadIconMetric, LoadIconWithScaleDown, MakeDragList, MenuHelp, PropertySheetA, PropertySheetW, RemoveWindowSubclass, SendMessageA, SendMessageW, SetWindowSubclass, ShowHideMenuCtl, Str_SetPtrW, TaskDialog, TaskDialogIndirect
Structures
BUTTON_IMAGELIST, BUTTON_SPLITINFO, NMBCDROPDOWN, NMBCHOTITEM, COMBOBOXINFO, NMCBEDRAGBEGIN, NMCBEENDEDIT, NMCOMBOBOXEX, COMBOBOXEXITEM, COLORSCHEME, INITCOMMONCONTROLSEX, NMCHAR, NMCUSTOMDRAW, NMCUSTOMSPLITRECTINFO, NMCUSTOMTEXT, NMKEY, NMMOUSE, NMOBJECTNOTIFY, NMTOOLTIPSCREATED, EDITBALLOONTIP, HDTEXTFILTER, HDHITTESTINFO, HDITEM, HDLAYOUT, NMHDDISPINFO, NMHDFILTERBTNCLICK, NMHEADER, IMAGEINFO, IMAGELISTSTATS, IMAGELISTDRAWPARAMS, NMIPADDRESS, LVFINDINFO, LVGROUPMETRICS, LVHITTESTINFO, LVINSERTMARK, LVITEMCOLUMNINFO, LVITEMINDEX, NMLISTVIEW, LVBKIMAGE, LVCOLUMN, LVGROUP, LVITEM, LVTILEVIEWINFO, PBRANGE, PROPSHEETHEADER, PROPSHEETPAGE, TCHITTESTINFO, TCITEM, TCITEMHEADER, TASKDIALOG_BUTTON, TASKDIALOGCONFIG, COLORMAP, NMTBDISPINFO, NMTBGETINFOTIP, NMTBHOTITEM, NMTBRESTORE, NMTBSAVE, NMTOOLBAR, TBADDBITMAP, TBBUTTON, TBBUTTONINFO, TBINSERTMARK, TBMETRICS, TBREPLACEBITMAP, TBSAVEPARAMS, NMTTDISPINFO, TTHITTESTINFO, TTGETTITLE, TOOLINFO, NMTRBTHUMBPOSCHANGING, NMTREEVIEW, NMTVASYNCDRAW, NMTVCUSTOMDRAW, NMTVDISPINFO, NMTVDISPINFOEX, NMTVGETINFOTIP, NMTVKEYDOWN, TVGETITEMPARTRECTINFO, TVHITTESTINFO, TVINSERTSTRUCT, NMTVITEMCHANGE, TVITEM, TVITEMEX, TVSORTCB, NMUPDOWN, UDACCEL, DPASTREAMINFO
COMBOBOXEXITEM, COLORSCHEME, INITCOMMONCONTROLSEX, EDITBALLOONTIP, HDTEXTFILTER, HDHITTESTINFO, HDLAYOUT, IMAGELISTSTATS, LVFINDINFO, LVGROUPMETRICS, LVHITTESTINFO, LVINSERTMARK, LVITEMCOLUMNINFO, LVITEMINDEX, LVTILEVIEWINFO, LVCOLUMN, LVGROUP, LVITEM, PBRANGE, TCHITTESTINFO, TCITEM, TCITEMHEADER, TASKDIALOG_BUTTON, COLORMAP, TBBUTTON, TBBUTTONINFO, TBINSERTMARK, TBMETRICS, TTGETTITLE, HTREEITEM, TVHITTESTINFO, TVITEM, TVSORTCB, TVGETITEMPARTRECTINFO, UDACCEL, DPASTREAMINFO
Interfaces
IImageList, IImageList2
</PackageReleaseNotes>
<LangVersion>latest</LangVersion>
<LangVersion>latest</LangVersion>
<ApplicationManifest>Library.manifest</ApplicationManifest>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)'=='Release'">

View File

@ -1,10 +1,8 @@
using System;
using System.Runtime.InteropServices;
using System.Runtime.InteropServices.ComTypes;
using Vanara.InteropServices;
// ReSharper disable FieldCanBeMadeReadOnly.Global
// ReSharper disable InconsistentNaming
using Vanara.Extensions;
using static Vanara.PInvoke.Kernel32;
namespace Vanara.PInvoke
{
@ -12,6 +10,7 @@ namespace Vanara.PInvoke
{
/// <summary>Indicates a failure on the DSA_InsertItem when returned.</summary>
public const int DA_ERR = -1;
/// <summary>Used by DSA_InsertItem to indicate that the item should be inserted at the end of the array.</summary>
public const int DA_LAST = 0x7FFFFFFF;
@ -31,7 +30,8 @@ namespace Vanara.PInvoke
/// <returns>
/// <para>Type: <c>int</c></para>
/// <para>
/// The meaning of the return values depends on the function that uses this callback prototype. The return values for <c>DSA_Sort</c> are the following.
/// The meaning of the return values depends on the function that uses this callback prototype. The return values for <c>DSA_Sort</c>
/// are the following.
/// </para>
/// <para>
/// <list type="table">
@ -55,7 +55,9 @@ namespace Vanara.PInvoke
[UnmanagedFunctionPointer(CallingConvention.Winapi)]
public delegate int PFNDACOMPARE(IntPtr p1, IntPtr p2, IntPtr lParam);
/// <summary>Defines the prototype for the compare function used by <c>DSA_Sort</c> when the items being compared are constant objects.</summary>
/// <summary>
/// Defines the prototype for the compare function used by <c>DSA_Sort</c> when the items being compared are constant objects.
/// </summary>
/// <param name="p1">
/// <para>Type: <c>const void*</c></para>
/// <para>A pointer to the first item in the comparison.</para>
@ -70,7 +72,10 @@ namespace Vanara.PInvoke
/// </param>
/// <returns>
/// <para>Type: <c>int</c></para>
/// <para>The meaning of the return values depends on the function that uses this callback prototype. The return values for <c>DSA_Sort</c> are as follows:</para>
/// <para>
/// The meaning of the return values depends on the function that uses this callback prototype. The return values for <c>DSA_Sort</c>
/// are as follows:
/// </para>
/// <para>
/// <list type="table">
/// <listheader>
@ -93,7 +98,9 @@ namespace Vanara.PInvoke
[UnmanagedFunctionPointer(CallingConvention.Winapi)]
public delegate int PFNDACOMPARECONST(IntPtr p1, IntPtr p2, IntPtr lParam);
/// <summary>Defines the prototype for the callback function used by dynamic structure array (DSA) and dynamic pointer array (DPA) functions.</summary>
/// <summary>
/// Defines the prototype for the callback function used by dynamic structure array (DSA) and dynamic pointer array (DPA) functions.
/// </summary>
/// <param name="p">
/// <para>Type: <c>void*</c></para>
/// <para>A pointer to the structure to be enumerated.</para>
@ -105,8 +112,8 @@ namespace Vanara.PInvoke
/// <returns>
/// <para>Type: <c>int</c></para>
/// <para>
/// 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.
/// 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.
/// </para>
/// </returns>
// 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
@ -115,8 +122,8 @@ namespace Vanara.PInvoke
public delegate int PFNDAENUMCALLBACK(IntPtr p, IntPtr pData);
/// <summary>
/// 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.
/// 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.
/// </summary>
/// <param name="p">
/// <para>Type: <c>const void*</c></para>
@ -129,8 +136,8 @@ namespace Vanara.PInvoke
/// <returns>
/// <para>Type: <c>int</c></para>
/// <para>
/// 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.
/// 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.
/// </para>
/// </returns>
// 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
@ -151,9 +158,9 @@ namespace Vanara.PInvoke
/// <item>
/// <term>DPAMM_MERGE0x1</term>
/// <term>
/// 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.
/// 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.
/// </term>
/// </item>
/// <item>
@ -163,8 +170,9 @@ namespace Vanara.PInvoke
/// <item>
/// <term>DPAMM_INSERT0x3</term>
/// <term>
/// 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.
/// 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.
/// </term>
/// </item>
/// </list>
@ -183,7 +191,8 @@ namespace Vanara.PInvoke
/// <para>Additional data that can be used by the merge callback.</para>
/// </param>
/// <returns>
/// A pointer to the item which results from the merge or <c>NULL</c> if there is a failure when <c>DPAMM_MERGE</c> or <c>DPAMM_INSERT</c> is used.
/// A pointer to the item which results from the merge or <c>NULL</c> if there is a failure when <c>DPAMM_MERGE</c> or
/// <c>DPAMM_INSERT</c> is used.
/// </returns>
// 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")]
@ -203,7 +212,8 @@ namespace Vanara.PInvoke
/// <item>
/// <term>DPAMM_MERGE0x1</term>
/// <term>
/// 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.
/// 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.
/// </term>
/// </item>
/// <item>
@ -213,8 +223,8 @@ namespace Vanara.PInvoke
/// <item>
/// <term>DPAMM_INSERT0x3</term>
/// <term>
/// 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.
/// 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.
/// </term>
/// </item>
/// </list>
@ -234,9 +244,12 @@ namespace Vanara.PInvoke
/// </param>
/// <returns>
/// <para>Type: <c>const void*</c></para>
/// <para>A pointer to constant data which results from the merge, or <c>NULL</c> if there is a failure when DPAMM_MERGE or DPAMM_INSERT is used.</para>
/// <para>
/// A pointer to constant data which results from the merge, or <c>NULL</c> if there is a failure when DPAMM_MERGE or DPAMM_INSERT is used.
/// </para>
/// </returns>
// 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
// 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);
@ -264,29 +277,34 @@ namespace Vanara.PInvoke
public delegate HRESULT PFNDPASTREAM(ref DPASTREAMINFO pinfo, IStream pstream, IntPtr pvInstData);
/// <summary>
/// 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.
/// 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.
/// </summary>
[Flags]
public enum DPAM
{
/// <summary>The arrays are presorted; skip sorting. If this flag is not set, the arrays are sorted before they are merged.</summary>
DPAM_SORTED = 0x00000001,
/// <summary>
/// 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.
/// 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.
/// </summary>
DPAM_NORMAL = 0x00000002,
/// <summary>
/// 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.
/// 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.
/// </summary>
DPAM_UNION = 0x00000004,
/// <summary>
/// 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.
/// 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.
/// </summary>
DPAM_INTERSECT = 0x00000008,
}
@ -295,16 +313,21 @@ namespace Vanara.PInvoke
public enum DPAMM
{
/// <summary>
/// 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.
/// 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.
/// </summary>
DPAMM_MERGE = 1,
/// <summary>Perform any additional processing needed when a delete occurs as part of the merge. The function should return NULL.</summary>
DPAMM_DELETE = 2,
/// <summary>
/// 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.
/// Perform any additional processing needed when a delete occurs as part of the merge. The function should return NULL.
/// </summary>
DPAMM_DELETE = 2,
/// <summary>
/// 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.
/// </summary>
DPAMM_INSERT = 3
}
@ -315,14 +338,16 @@ namespace Vanara.PInvoke
{
/// <summary>Indicates that the DPA is sorted.</summary>
DPAS_SORTED = 0x0001,
/// <summary>
/// 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.
/// 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.
/// </summary>
DPAS_INSERTBEFORE = 0x0002,
/// <summary>
/// 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.
/// 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.
/// </summary>
DPAS_INSERTAFTER = 0x0004
}
@ -336,7 +361,9 @@ namespace Vanara.PInvoke
public static int DPA_AppendPtr(HDPA hdpa, IntPtr pitem) => DPA_InsertPtr(hdpa, DA_LAST, pitem);
/// <summary>
/// <para>[ <c>DPA_Clone</c> is available through Windows XP with Service Pack 2 (SP2). It might be altered or unavailable in subsequent versions.]</para>
/// <para>
/// [ <c>DPA_Clone</c> is available through Windows XP with Service Pack 2 (SP2). It might be altered or unavailable in subsequent versions.]
/// </para>
/// <para>Duplicates a dynamic pointer array (DPA).</para>
/// </summary>
/// <param name="hdpaSource">
@ -347,8 +374,8 @@ namespace Vanara.PInvoke
/// <para>Type: <c>HDPA</c></para>
/// <para>When <c>NULL</c>, a new array is copied from hdpaSource.</para>
/// <para>
/// This parameter can also contain an array created with <c>DPA_Create</c> or <c>DPA_CreateEx</c>. The data is overwritten but the original delta size
/// and heap handle retained.
/// This parameter can also contain an array created with <c>DPA_Create</c> or <c>DPA_CreateEx</c>. The data is overwritten but the
/// original delta size and heap handle retained.
/// </para>
/// </param>
/// <returns>
@ -362,8 +389,8 @@ namespace Vanara.PInvoke
/// <summary>
/// <para>
/// [ <c>DPA_Create</c> is available for use in the operating systems specified in the Requirements section. It may be altered or unavailable in
/// subsequent versions.]
/// [ <c>DPA_Create</c> is available for use in the operating systems specified in the Requirements section. It may be altered or
/// unavailable in subsequent versions.]
/// </para>
/// <para>Creates a dynamic pointer array (DPA).</para>
/// </summary>
@ -396,12 +423,12 @@ namespace Vanara.PInvoke
// 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] IntPtr hheap);
public static extern SafeHDPA DPA_CreateEx(int cpGrow, [Optional] HHEAP hheap);
/// <summary>
/// <para>
/// [ <c>DPA_DeleteAllPtrs</c> is available for use in the operating systems specified in the Requirements section. It may be altered or unavailable in
/// subsequent versions.]
/// [ <c>DPA_DeleteAllPtrs</c> is available for use in the operating systems specified in the Requirements section. It may be altered
/// or unavailable in subsequent versions.]
/// </para>
/// <para>Removes all items from a dynamic pointer array (DPA) and shrinks the DPA accordingly.</para>
/// </summary>
@ -421,8 +448,8 @@ namespace Vanara.PInvoke
/// <summary>
/// <para>
/// [ <c>DPA_DeletePtr</c> is available for use in the operating systems specified in the Requirements section. It may be altered or unavailable in
/// subsequent versions.]
/// [ <c>DPA_DeletePtr</c> is available for use in the operating systems specified in the Requirements section. It may be altered or
/// unavailable in subsequent versions.]
/// </para>
/// <para>Removes an item from a dynamic pointer array (DPA). The DPA shrinks if necessary to accommodate the removed item.</para>
/// </summary>
@ -442,8 +469,8 @@ namespace Vanara.PInvoke
/// <summary>
/// <para>
/// [ <c>DPA_Destroy</c> is available for use in the operating systems specified in the Requirements section. It may be altered or unavailable in
/// subsequent versions.]
/// [ <c>DPA_Destroy</c> is available for use in the operating systems specified in the Requirements section. It may be altered or
/// unavailable in subsequent versions.]
/// </para>
/// <para>Frees a Dynamic Pointer Array (DPA).</para>
/// </summary>
@ -463,8 +490,8 @@ namespace Vanara.PInvoke
/// <summary>
/// <para>
/// [ <c>DPA_DestroyCallback</c> is available for use in the operating systems specified in the Requirements section. It may be altered or unavailable in
/// subsequent versions.]
/// [ <c>DPA_DestroyCallback</c> is available for use in the operating systems specified in the Requirements section. It may be
/// altered or unavailable in subsequent versions.]
/// </para>
/// <para>Calls pfnCB on each element of the dynamic pointer array (DPA), then frees the DPA.</para>
/// </summary>
@ -488,8 +515,8 @@ namespace Vanara.PInvoke
/// <summary>
/// <para>
/// [ <c>DPA_EnumCallback</c> is available for use in the operating systems specified in the Requirements section. It may be altered or unavailable in
/// subsequent versions.]
/// [ <c>DPA_EnumCallback</c> is available for use in the operating systems specified in the Requirements section. It may be altered
/// or unavailable in subsequent versions.]
/// </para>
/// <para>Iterates through the Dynamic Pointer Array (DPA) and calls pfnCB on each item.</para>
/// </summary>
@ -528,8 +555,8 @@ namespace Vanara.PInvoke
/// <summary>
/// <para>
/// [ <c>DPA_GetPtr</c> is available for use in the operating systems specified in the Requirements section. It may be altered or unavailable in
/// subsequent versions.]
/// [ <c>DPA_GetPtr</c> is available for use in the operating systems specified in the Requirements section. It may be altered or
/// unavailable in subsequent versions.]
/// </para>
/// <para>Gets an item from a dynamic pointer array (DPA).</para>
/// </summary>
@ -552,10 +579,13 @@ namespace Vanara.PInvoke
/// <returns>Returns the number of pointers (elements) the DPA contains.</returns>
// 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(hdpa.DangerousGetHandle());
public static int DPA_GetPtrCount(HDPA hdpa) => Marshal.ReadInt32((IntPtr)hdpa);
/// <summary>
/// <para>[ <c>DPA_GetPtrIndex</c> is available through Windows XP with Service Pack 2 (SP2). It might be altered or unavailable in subsequent versions.]</para>
/// <para>
/// [ <c>DPA_GetPtrIndex</c> is available through Windows XP with Service Pack 2 (SP2). It might be altered or unavailable in
/// subsequent versions.]
/// </para>
/// <para>Gets the index of a matching item found in a dynamic pointer array (DPA).</para>
/// </summary>
/// <param name="hdpa">
@ -577,10 +607,12 @@ namespace Vanara.PInvoke
/// <summary>Gets the pointer to the internal pointer array of a dynamic pointer array (DPA).</summary>
/// <param name="hdpa">A handle to an existing DPA.</param>
/// <returns>Returns a pointer to the array of pointers managed by the DPA. To retrieve the number of pointers in the array, call macro <c>DPA_GetPtrCount</c>.</returns>
/// <returns>
/// Returns a pointer to the array of pointers managed by the DPA. To retrieve the number of pointers in the array, call macro <c>DPA_GetPtrCount</c>.
/// </returns>
// 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) => new IntPtr(hdpa.DangerousGetHandle().ToInt64() + IntPtr.Size);
public static IntPtr DPA_GetPtrPtr(HDPA hdpa) => ((IntPtr)hdpa).Offset(IntPtr.Size);
/// <summary>Gets the size of a dynamic pointer array (DPA).</summary>
/// <param name="pdpa">
@ -589,7 +621,9 @@ namespace Vanara.PInvoke
/// </param>
/// <returns>
/// <para>Type: <c><c>ULONGLONG</c></c></para>
/// <para>Returns the size of the DPA, including the internal bookkeeping information. If pdpa is <c>NULL</c>, the function returns zero.</para>
/// <para>
/// Returns the size of the DPA, including the internal bookkeeping information. If pdpa is <c>NULL</c>, the function returns zero.
/// </para>
/// </returns>
// 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)]
@ -617,10 +651,13 @@ namespace Vanara.PInvoke
/// <summary>
/// <para>
/// [ <c>DPA_InsertPtr</c> is available for use in the operating systems specified in the Requirements section. It may be altered or unavailable in
/// subsequent versions.]
/// [ <c>DPA_InsertPtr</c> is available for use in the operating systems specified in the Requirements section. It may be altered or
/// unavailable in subsequent versions.]
/// </para>
/// <para>
/// Inserts a new item at a specified position in a dynamic pointer array (DPA). If neccessary, the DPA expands to accommodate the
/// new item.
/// </para>
/// <para>Inserts a new item at a specified position in a dynamic pointer array (DPA). If neccessary, the DPA expands to accommodate the new item.</para>
/// </summary>
/// <param name="pdpa">
/// <para>Type: <c>HDPA</c></para>
@ -701,12 +738,16 @@ namespace Vanara.PInvoke
public static extern HRESULT DPA_LoadStream(out SafeHDPA ppdpa, PFNDPASTREAM pfn, IStream pstm, IntPtr pvInstData);
/// <summary>
/// <para>[ <c>DPA_Merge</c> is available through Windows XP with Service Pack 2 (SP2). It might be altered or unavailable in subsequent versions.]</para>
/// <para>
/// [ <c>DPA_Merge</c> is available through Windows XP with Service Pack 2 (SP2). It might be altered or unavailable in subsequent versions.]
/// </para>
/// <para>Combines the contents of two dynamic pointer arrays (DPAs).</para>
/// </summary>
/// <param name="hdpaDest">
/// <para>Type: <c>HDPA</c></para>
/// <para>A handle to the first DPA. This array can be optionally presorted. When this function returns, contains the handle to the merged array.</para>
/// <para>
/// A handle to the first DPA. This array can be optionally presorted. When this function returns, contains the handle to the merged array.
/// </para>
/// </param>
/// <param name="hdpaSrc">
/// <para>Type: <c>HDPA</c></para>
@ -715,8 +756,8 @@ namespace Vanara.PInvoke
/// <param name="dwFlags">
/// <para>Type: <c><c>DWORD</c></c></para>
/// <para>
/// 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.
/// 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.
/// </para>
/// <para>
/// <list type="table">
@ -731,24 +772,26 @@ namespace Vanara.PInvoke
/// <item>
/// <term>DPAM_NORMAL0x00000002</term>
/// <term>
/// 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.
/// 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.
/// </term>
/// </item>
/// <item>
/// <term>DPAM_UNION0x00000004</term>
/// <term>
/// 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.
/// 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.
/// </term>
/// </item>
/// <item>
/// <term>DPAM_INTERSECT0x00000008</term>
/// <term>
/// 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.
/// 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.
/// </term>
/// </item>
/// </list>
@ -757,14 +800,15 @@ namespace Vanara.PInvoke
/// <param name="pfnCompare">
/// <para>Type: <c><c>PFNDPACOMPARE</c></c></para>
/// <para>
/// The <c>PFNDPACOMPARE</c> 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.
/// The <c>PFNDPACOMPARE</c> 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.
/// </para>
/// </param>
/// <param name="pfnMerge">
/// <para>Type: <c><c>PFNDPAMERGE</c></c></para>
/// <para>
/// The <c>PFNDPAMERGE</c> callback function that merges the contents when an element is found in both DPAs and is found to be the same item by <c>PFNDPACOMPARE</c>.
/// The <c>PFNDPAMERGE</c> callback function that merges the contents when an element is found in both DPAs and is found to be the
/// same item by <c>PFNDPACOMPARE</c>.
/// </para>
/// </param>
/// <param name="lParam">
@ -775,8 +819,8 @@ namespace Vanara.PInvoke
/// <para>Type: <c><c>BOOL</c></c></para>
/// <para><c>TRUE</c> if successful; otherwise, <c>FALSE</c>.</para>
/// </returns>
// 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
// 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)]
@ -785,7 +829,8 @@ namespace Vanara.PInvoke
/// <summary>
/// <para>[ <c>DPA_SaveStream</c> is available in Windows Vista. It might be altered or unavailable in subsequent versions. ]</para>
/// <para>
/// 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.
/// 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.
/// </para>
/// </summary>
/// <param name="pdpa">
@ -835,8 +880,8 @@ namespace Vanara.PInvoke
/// <summary>
/// <para>
/// [ <c>DPA_Search</c> is available for use in the operating systems specified in the Requirements section. It may be altered or unavailable in
/// subsequent versions.]
/// [ <c>DPA_Search</c> is available for use in the operating systems specified in the Requirements section. It may be altered or
/// unavailable in subsequent versions.]
/// </para>
/// <para>Finds an item in a dynamic pointer array (DPA).</para>
/// </summary>
@ -876,15 +921,15 @@ namespace Vanara.PInvoke
/// <item>
/// <term>DPAS_INSERTBEFORE</term>
/// <term>
/// 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.
/// 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.
/// </term>
/// </item>
/// <item>
/// <term>DPAS_INSERTAFTER</term>
/// <term>
/// 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.
/// 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.
/// </term>
/// </item>
/// </list>
@ -901,8 +946,8 @@ namespace Vanara.PInvoke
/// <summary>
/// <para>
/// [ <c>DPA_SetPtr</c> is available for use in the operating systems specified in the Requirements section. It may be altered or unavailable in
/// subsequent versions.]
/// [ <c>DPA_SetPtr</c> is available for use in the operating systems specified in the Requirements section. It may be altered or
/// unavailable in subsequent versions.]
/// </para>
/// <para>Assigns a value to an item in a dynamic pointer array (DPA).</para>
/// </summary>
@ -934,11 +979,12 @@ namespace Vanara.PInvoke
/// <returns>Returns the number of pointers (elements) the DPA contains.</returns>
// 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(hdpa.DangerousGetHandle(), cItems); return cItems; }
public static int DPA_SetPtrCount(HDPA hdpa, int cItems) { Marshal.WriteInt32((IntPtr)hdpa, cItems); return cItems; }
/// <summary>
/// <para>
/// [ <c>DPA_Sort</c> is available for use in the operating systems specified in the Requirements section. It may be altered or unavailable in subsequent versions.]
/// [ <c>DPA_Sort</c> is available for use in the operating systems specified in the Requirements section. It may be altered or
/// unavailable in subsequent versions.]
/// </para>
/// <para>Sorts the items in a Dynamic Pointer Array (DPA).</para>
/// </summary>
@ -979,7 +1025,9 @@ namespace Vanara.PInvoke
/// </param>
/// <param name="pfnCmp">
/// <para>Type: <c><c>PFNDPACOMPARE</c></c></para>
/// <para>A pointer to the comparison function. See <c>PFNDPACOMPARE</c> or <c>PFNDPACOMPARECONST</c> for the comparison function prototype.</para>
/// <para>
/// A pointer to the comparison function. See <c>PFNDPACOMPARE</c> or <c>PFNDPACOMPARECONST</c> for the comparison function prototype.
/// </para>
/// </param>
/// <param name="lParam">
/// <para>Type: <c><c>LPARAM</c></c></para>
@ -1039,8 +1087,8 @@ namespace Vanara.PInvoke
/// <summary>
/// <para>
/// [ <c>DSA_Create</c> is available for use in the operating systems specified in the Requirements section. It may be altered or unavailable in
/// subsequent versions.]
/// [ <c>DSA_Create</c> is available for use in the operating systems specified in the Requirements section. It may be altered or
/// unavailable in subsequent versions.]
/// </para>
/// <para>Creates a dynamic structure array (DSA).</para>
/// </summary>
@ -1077,7 +1125,10 @@ namespace Vanara.PInvoke
public static extern bool DSA_DeleteAllItems(HDSA hdsa);
/// <summary>
/// <para>[ <c>DSA_DeleteItem</c> is available through Windows XP with Service Pack 2 (SP2). It might be altered or unavailable in subsequent versions.]</para>
/// <para>
/// [ <c>DSA_DeleteItem</c> is available through Windows XP with Service Pack 2 (SP2). It might be altered or unavailable in
/// subsequent versions.]
/// </para>
/// <para>Deletes an item from a dynamic structure array (DSA).</para>
/// </summary>
/// <param name="hdsa">
@ -1100,8 +1151,8 @@ namespace Vanara.PInvoke
/// <summary>
/// <para>
/// [ <c>DSA_Destroy</c> is available for use in the operating systems specified in the Requirements section. It may be altered or unavailable in
/// subsequent versions.]
/// [ <c>DSA_Destroy</c> is available for use in the operating systems specified in the Requirements section. It may be altered or
/// unavailable in subsequent versions.]
/// </para>
/// <para>Frees a dynamic structure array (DSA).</para>
/// </summary>
@ -1121,11 +1172,12 @@ namespace Vanara.PInvoke
/// <summary>
/// <para>
/// [ <c>DSA_DestroyCallback</c> is available for use in the operating systems specified in the Requirements section. It may be altered or unavailable in
/// subsequent versions.]
/// [ <c>DSA_DestroyCallback</c> is available for use in the operating systems specified in the Requirements section. It may be
/// altered or unavailable in subsequent versions.]
/// </para>
/// <para>
/// 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.
/// 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.
/// </para>
/// </summary>
/// <param name="pdsa">
@ -1193,12 +1245,12 @@ namespace Vanara.PInvoke
/// <returns>Returns the number of items in the DSA.</returns>
// 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(hdsa.DangerousGetHandle());
public static int DSA_GetItemCount(HDSA hdsa) => Marshal.ReadInt32((IntPtr)hdsa);
/// <summary>
/// <para>
/// [ <c>DSA_GetItemPtr</c> is available for use in the operating systems specified in the Requirements section. It may be altered or unavailable in
/// subsequent versions.]
/// [ <c>DSA_GetItemPtr</c> is available for use in the operating systems specified in the Requirements section. It may be altered or
/// unavailable in subsequent versions.]
/// </para>
/// <para>Gets a pointer to an element from a dynamic structure array (DSA).</para>
/// </summary>
@ -1223,7 +1275,10 @@ namespace Vanara.PInvoke
/// </param>
/// <returns>
/// <para>Type: <c><c>ULONGLONG</c></c></para>
/// <para>Returns the size of the DSA, including the internal bookkeeping information, in bytes. If hdsa is <c>NULL</c>, the function returns zero.</para>
/// <para>
/// Returns the size of the DSA, including the internal bookkeeping information, in bytes. If hdsa is <c>NULL</c>, the function
/// returns zero.
/// </para>
/// </returns>
// 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)]
@ -1232,8 +1287,8 @@ namespace Vanara.PInvoke
/// <summary>
/// <para>
/// [ <c>DSA_InsertItem</c> is available for use in the operating systems specified in the Requirements section. It may be altered or unavailable in
/// subsequent versions.]
/// [ <c>DSA_InsertItem</c> is available for use in the operating systems specified in the Requirements section. It may be altered or
/// unavailable in subsequent versions.]
/// </para>
/// <para>Inserts a new item into a dynamic structure array (DSA). If necessary, the DSA expands to accommodate the new item.</para>
/// </summary>
@ -1260,8 +1315,8 @@ namespace Vanara.PInvoke
/// <summary>
/// <para>
/// [ <c>DSA_SetItem</c> is available for use in the operating systems specified in the Requirements section. It may be altered or unavailable in
/// subsequent versions.]
/// [ <c>DSA_SetItem</c> is available for use in the operating systems specified in the Requirements section. It may be altered or
/// unavailable in subsequent versions.]
/// </para>
/// <para>Inserts a new item into a dynamic structure array (DSA). If necessary, the DSA expands to accommodate the new item.</para>
/// </summary>
@ -1340,6 +1395,7 @@ namespace Vanara.PInvoke
/// <para>An index of the item in the DPA.</para>
/// </summary>
public int iPos;
/// <summary>
/// <para>Type: <c>void*</c></para>
/// <para>A void pointer to the item data.</para>
@ -1347,26 +1403,44 @@ namespace Vanara.PInvoke
public IntPtr pvItem;
}
/// <summary>Provides a <see cref="SafeHandle"/> to a that releases a created HDPA instance at disposal using DPA_Destroy.</summary>
public class SafeHDPA : HDPA
/// <summary>Provides a <see cref="SafeHandle"/> to a that releases a created HDPA instance at disposal using DPA_Destroy.</summary>
public class SafeHDPA : HANDLE
{
/// <summary>Initializes a new instance of the <see cref="HDPA"/> class and assigns an existing handle.</summary>
/// <param name="preexistingHandle">An <see cref="IntPtr"/> object that represents the pre-existing handle to use.</param>
/// <param name="ownsHandle"><see langword="true"/> to reliably release the handle during the finalization phase; otherwise, <see langword="false"/> (not recommended).</param>
/// <param name="ownsHandle">
/// <see langword="true"/> to reliably release the handle during the finalization phase; otherwise, <see langword="false"/> (not recommended).
/// </param>
public SafeHDPA(IntPtr preexistingHandle, bool ownsHandle = true) : base(preexistingHandle, ownsHandle) { }
private SafeHDPA() : base() { }
/// <summary>Performs an implicit conversion from <see cref="SafeHDPA"/> to <see cref="HDPA"/>.</summary>
/// <param name="h">The safe handle instance.</param>
/// <returns>The result of the conversion.</returns>
public static implicit operator HDPA(SafeHDPA h) => h.handle;
/// <inheritdoc/>
protected override bool InternalReleaseHandle() => DPA_Destroy(this);
}
/// <summary>Provides a <see cref="SafeHandle"/> to a that releases a created HDSA instance at disposal using DSA_Destroy.</summary>
public class SafeHDSA : HDSA
/// <summary>Provides a <see cref="SafeHandle"/> to a that releases a created HDSA instance at disposal using DSA_Destroy.</summary>
public class SafeHDSA : HANDLE
{
/// <summary>Initializes a new instance of the <see cref="HDSA"/> class and assigns an existing handle.</summary>
/// <param name="preexistingHandle">An <see cref="IntPtr"/> object that represents the pre-existing handle to use.</param>
/// <param name="ownsHandle"><see langword="true"/> to reliably release the handle during the finalization phase; otherwise, <see langword="false"/> (not recommended).</param>
/// <param name="ownsHandle">
/// <see langword="true"/> to reliably release the handle during the finalization phase; otherwise, <see langword="false"/> (not recommended).
/// </param>
public SafeHDSA(IntPtr preexistingHandle, bool ownsHandle = true) : base(preexistingHandle, ownsHandle) { }
private SafeHDSA() : base() { }
/// <summary>Performs an implicit conversion from <see cref="SafeHDSA"/> to <see cref="HDSA"/>.</summary>
/// <param name="h">The safe handle instance.</param>
/// <returns>The result of the conversion.</returns>
public static implicit operator HDSA(SafeHDSA h) => h.handle;
/// <inheritdoc/>
protected override bool InternalReleaseHandle() => DSA_Destroy(this);
}

View File

@ -19,6 +19,5 @@ Native Method | Native DLL | Header | Managed Method
### Structures
Native Structure | Header | Managed Structure
--- | --- | ---
[CREDUI_INFO](http://msdn2.microsoft.com/en-us/library/aa375183) | wincred.h | Vanara.PInvoke.CredUI+CREDUI_INFO
[PSEC_WINNT_CREDUI_CONTEXT](https://www.google.com/search?num=5&q=PSEC_WINNT_CREDUI_CONTEXT+site%3Amicrosoft.com) | | Vanara.PInvoke.CredUI+PSEC_WINNT_CREDUI_CONTEXT
[PSEC_WINNT_CREDUI_CONTEXT_VECTOR](https://www.google.com/search?num=5&q=PSEC_WINNT_CREDUI_CONTEXT_VECTOR+site%3Amicrosoft.com) | | Vanara.PInvoke.CredUI+PSEC_WINNT_CREDUI_CONTEXT_VECTOR

View File

@ -2,91 +2,172 @@
using System.Runtime.InteropServices;
using Vanara.InteropServices;
using static Vanara.PInvoke.AdvApi32;
using PSEC_WINNT_AUTH_IDENTITY_OPAQUE = System.IntPtr;
// ReSharper disable InconsistentNaming
// ReSharper disable FieldCanBeMadeReadOnly.Global
using static Vanara.PInvoke.Secur32;
namespace Vanara.PInvoke
{
/// <summary>Functions and definitions from CredUI.dll</summary>
public static partial class CredUI
{
/// <summary>The credential is a password.</summary>
public static readonly Guid SEC_WINNT_AUTH_DATA_TYPE_PASSWORD = new Guid("{0x28bfc32f, 0x10f6, 0x4738, 0x98, 0xd1, 0x1a, 0xc0, 0x61, 0xdf, 0x71, 0x6a}");
/// <summary>The credential is a certificate.</summary>
public static readonly Guid SEC_WINNT_AUTH_DATA_TYPE_CERT = new Guid("{0x235f69ad, 0x73fb, 0x4dbc, 0x82, 0x3, 0x6, 0x29, 0xe7, 0x39, 0x33, 0x9b}");
/// <summary>The credential is authentication data from a cryptographic service provider (CSP).</summary>
public static readonly Guid SEC_WINNT_AUTH_DATA_TYPE_CSP_DATA = new Guid("{0x68fd9879, 0x79c, 0x4dfe, 0x82, 0x81, 0x57, 0x8a, 0xad, 0xc1, 0xc1, 0x0}");
/// <summary>The credential is a password.</summary>
public static readonly Guid SEC_WINNT_AUTH_DATA_TYPE_PASSWORD = new Guid("{0x28bfc32f, 0x10f6, 0x4738, 0x98, 0xd1, 0x1a, 0xc0, 0x61, 0xdf, 0x71, 0x6a}");
/// <summary>Flags that determine the behavior of this function.</summary>
[Flags]
public enum SSPIPFC
{
/// <summary>The value of the pfSave parameter is ignored, and the credentials collected by this function are not saved.
/// <para>Windows 7 and Windows Server 2008 R2: The value of the pfSave parameter is ignored, and the credentials collected by this function are not saved. Only the name of this possible value was SSPIPFC_SAVE_CRED_BY_CALLER.</para></summary>
/// <summary>
/// The value of the pfSave parameter is ignored, and the credentials collected by this function are not saved.
/// <para>
/// Windows 7 and Windows Server 2008 R2: The value of the pfSave parameter is ignored, and the credentials collected by this
/// function are not saved. Only the name of this possible value was SSPIPFC_SAVE_CRED_BY_CALLER.
/// </para>
/// </summary>
SSPIPFC_CREDPROV_DO_NOT_SAVE = 0x00000001,
/// <summary>The value signifies that password and smart card credential providers will not display the "Remember my credentials" checkbox to the user. The SspiPromptForCredentials function passes this flag value, SSPIPFC_NO_CHECKBOX, in the pvInAuthBuffer parameter of CredUIPromptForWindowsCredentials function.</summary>
/// <summary>
/// The value signifies that password and smart card credential providers will not display the "Remember my credentials" checkbox
/// to the user. The SspiPromptForCredentials function passes this flag value, SSPIPFC_NO_CHECKBOX, in the pvInAuthBuffer
/// parameter of CredUIPromptForWindowsCredentials function.
/// </summary>
SSPIPFC_NO_CHECKBOX = 0x00000002,
}
/// <summary>Retrieves context information from a credential provider.</summary>
/// <param name="ContextHandle">A pointer to a SEC_WINNT_CREDUI_CONTEXT structure retrieved during a previous call to the SspiUnmarshalCredUIContext function.</param>
/// <param name="ContextHandle">
/// A pointer to a SEC_WINNT_CREDUI_CONTEXT structure retrieved during a previous call to the SspiUnmarshalCredUIContext function.
/// </param>
/// <param name="CredType">The type of credential specified by the ContextHandle parameter.</param>
/// <param name="LogonId">The logon ID associated with the credential specified by the ContextHandle parameter. The caller must be running as LocalSystem to specify a logon ID.</param>
/// <param name="CredUIContexts">A pointer to a SEC_WINNT_CREDUI_CONTEXT_VECTOR structure that specifies the offset and size of the data in the structure specified by the ContextHandle parameter.</param>
/// <param name="LogonId">
/// The logon ID associated with the credential specified by the ContextHandle parameter. The caller must be running as LocalSystem
/// to specify a logon ID.
/// </param>
/// <param name="CredUIContexts">
/// A pointer to a SEC_WINNT_CREDUI_CONTEXT_VECTOR structure that specifies the offset and size of the data in the structure
/// specified by the ContextHandle parameter.
/// </param>
/// <param name="TokenHandle">A handle to the specified user's token.</param>
/// <returns>If the function succeeds, it returns SEC_E_OK. If the function fails, it returns a nonzero error code.</returns>
[DllImport(Lib.CredUI, ExactSpelling = true)]
[DllImport(Lib.CredUI, SetLastError = false, ExactSpelling = true)]
[PInvokeData("Sspi.h")]
public static extern NTStatus SspiGetCredUIContext(IntPtr ContextHandle, [MarshalAs(UnmanagedType.LPStruct)] Guid CredType, LUID LogonId, out PSEC_WINNT_CREDUI_CONTEXT_VECTOR CredUIContexts, out SafeHTOKEN TokenHandle);
public static extern Win32Error SspiGetCredUIContext(PSEC_WINNT_CREDUI_CONTEXT ContextHandle, in Guid CredType, LUID LogonId, out PSEC_WINNT_CREDUI_CONTEXT_VECTOR CredUIContexts, out SafeHTOKEN TokenHandle);
/// <summary>Indicates whether an error returned after a call to either the InitializeSecurityContext or the AcceptSecurityContext function requires an additional call to the SspiPromptForCredentials function.</summary>
/// <summary>
/// Indicates whether an error returned after a call to either the InitializeSecurityContext or the AcceptSecurityContext function
/// requires an additional call to the SspiPromptForCredentials function.
/// </summary>
/// <param name="ErrorOrNtStatus">The error to test.</param>
/// <returns>TRUE if the error specified by the ErrorOrNtStatus parameter indicates that an additional call to SspiPromptForCredentials is necessary; otherwise, FALSE.</returns>
[DllImport(Lib.CredUI, ExactSpelling = true)]
/// <returns>
/// TRUE if the error specified by the ErrorOrNtStatus parameter indicates that an additional call to SspiPromptForCredentials is
/// necessary; otherwise, FALSE.
/// </returns>
[DllImport(Lib.CredUI, SetLastError = false, ExactSpelling = true)]
[PInvokeData("Sspi.h")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SspiIsPromptingNeeded(uint ErrorOrNtStatus);
/// <summary>Allows a Security Support Provider Interface (SSPI) application to prompt a user to enter credentials.</summary>
/// <param name="pszTargetName">The name of the target to use.</param>
/// <param name="pUiInfo">A pointer to a CREDUI_INFO structure that contains information for customizing the appearance of the dialog box that this function displays.
/// <para>If the hwndParent member of the CREDUI_INFO structure is not NULL, this function displays a modal dialog box centered on the parent window.</para>
/// <param name="pUiInfo">
/// A pointer to a CREDUI_INFO structure that contains information for customizing the appearance of the dialog box that this
/// function displays.
/// <para>
/// If the hwndParent member of the CREDUI_INFO structure is not NULL, this function displays a modal dialog box centered on the
/// parent window.
/// </para>
/// <para>If the hwndParent member of the CREDUI_INFO structure is NULL, the function displays a dialog box centered on the screen.</para>
/// <para>This function ignores the hbmBanner member of the CREDUI_INFO structure.</para></param>
/// <param name="dwAuthError">A Windows error code, defined in Winerror.h, that is displayed in the dialog box. If credentials previously collected were not valid, the caller uses this parameter to pass the error message from the API that collected the credentials (for example, Winlogon) to this function. The corresponding error message is formatted and displayed in the dialog box. Set the value of this parameter to zero to display no error message.</param>
/// <para>This function ignores the hbmBanner member of the CREDUI_INFO structure.</para>
/// </param>
/// <param name="dwAuthError">
/// A Windows error code, defined in Winerror.h, that is displayed in the dialog box. If credentials previously collected were not
/// valid, the caller uses this parameter to pass the error message from the API that collected the credentials (for example,
/// Winlogon) to this function. The corresponding error message is formatted and displayed in the dialog box. Set the value of this
/// parameter to zero to display no error message.
/// </param>
/// <param name="pszPackage">The name of the security package to use.</param>
/// <param name="pInputAuthIdentity">An identity structure that is used to populate credential fields in the dialog box. To leave the credential fields empty, set the value of this parameter to NULL.</param>
/// <param name="ppAuthIdentity">An identity structure that represents the credentials this function collects. When you have finished using this structure, free it by calling the SspiFreeAuthIdentity function.</param>
/// <param name="pfSave">A pointer to a Boolean value that, on input, specifies whether the Save check box is selected in the dialog box that this function displays. On output, the value of this parameter specifies whether the Save check box was selected when the user clicked the Submit button in the dialog box. Set this parameter to NULL to ignore the Save check box.
/// <para>This parameter is ignored if the CREDUIWIN_CHECKBOX flag is not set in the dwFlags parameter.</para></param>
/// <param name="pInputAuthIdentity">
/// An identity structure that is used to populate credential fields in the dialog box. To leave the credential fields empty, set the
/// value of this parameter to NULL.
/// </param>
/// <param name="ppAuthIdentity">
/// An identity structure that represents the credentials this function collects. When you have finished using this structure, free
/// it by calling the SspiFreeAuthIdentity function.
/// </param>
/// <param name="pfSave">
/// A pointer to a Boolean value that, on input, specifies whether the Save check box is selected in the dialog box that this
/// function displays. On output, the value of this parameter specifies whether the Save check box was selected when the user clicked
/// the Submit button in the dialog box. Set this parameter to NULL to ignore the Save check box.
/// <para>This parameter is ignored if the CREDUIWIN_CHECKBOX flag is not set in the dwFlags parameter.</para>
/// </param>
/// <param name="dwFlags">Flags that determine the behavior of this function.</param>
/// <returns>If the function succeeds, it returns SEC_E_OK. If the function fails, it returns a nonzero error code.</returns>
[DllImport(Lib.CredUI, CharSet = CharSet.Auto)]
[DllImport(Lib.CredUI, SetLastError = false, CharSet = CharSet.Auto)]
[PInvokeData("Sspi.h")]
public static extern NTStatus SspiPromptForCredentials([MarshalAs(UnmanagedType.LPTStr)] string pszTargetName, ref CREDUI_INFO pUiInfo, uint dwAuthError, [MarshalAs(UnmanagedType.LPTStr)] string pszPackage, PSEC_WINNT_AUTH_IDENTITY_OPAQUE pInputAuthIdentity, out PSEC_WINNT_AUTH_IDENTITY_OPAQUE ppAuthIdentity, ref bool pfSave, SSPIPFC dwFlags);
public static extern Win32Error SspiPromptForCredentials(string pszTargetName, in CREDUI_INFO pUiInfo, uint dwAuthError, string pszPackage, PSEC_WINNT_AUTH_IDENTITY_OPAQUE pInputAuthIdentity, out PSEC_WINNT_AUTH_IDENTITY_OPAQUE ppAuthIdentity, ref bool pfSave, SSPIPFC dwFlags);
/// <summary>Deserializes credential information obtained by a credential provider during a previous call to the ICredentialProvider::SetSerialization method.</summary>
/// <param name="MarshaledCredUIContext">The serialized credential information obtained as the rgbSerialization member of the CREDENTIAL_PROVIDER_CREDENTIAL_SERIALIZATION structure retrieved from a call to the ICredentialProvider::SetSerialization method.</param>
/// <summary>
/// Deserializes credential information obtained by a credential provider during a previous call to the
/// ICredentialProvider::SetSerialization method.
/// </summary>
/// <param name="MarshaledCredUIContext">
/// The serialized credential information obtained as the rgbSerialization member of the CREDENTIAL_PROVIDER_CREDENTIAL_SERIALIZATION
/// structure retrieved from a call to the ICredentialProvider::SetSerialization method.
/// </param>
/// <param name="MarshaledCredUIContextLength">The size, in bytes, of the MarshaledCredUIContext buffer.</param>
/// <param name="CredUIContext">A pointer to a SEC_WINNT_CREDUI_CONTEXT structure that specifies the deserialized credential information.</param>
/// <returns></returns>
[DllImport(Lib.CredUI, ExactSpelling = true)]
[DllImport(Lib.CredUI, SetLastError = false, ExactSpelling = true)]
[PInvokeData("Sspi.h")]
public static extern NTStatus SspiUnmarshalCredUIContext([MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)] byte[] MarshaledCredUIContext, uint MarshaledCredUIContextLength, out PSEC_WINNT_CREDUI_CONTEXT CredUIContext);
public static extern Win32Error SspiUnmarshalCredUIContext([MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)] byte[] MarshaledCredUIContext, uint MarshaledCredUIContextLength, out PSEC_WINNT_CREDUI_CONTEXT CredUIContext);
/// <summary>Updates the credentials associated with the specified context.</summary>
/// <param name="ContextHandle">A pointer to a SEC_WINNT_CREDUI_CONTEXT structure retrieved during a previous call to the SspiUnmarshalCredUIContext function.</param>
/// <param name="ContextHandle">
/// A pointer to a SEC_WINNT_CREDUI_CONTEXT structure retrieved during a previous call to the SspiUnmarshalCredUIContext function.
/// </param>
/// <param name="CredType">The type of credential specified by the ContextHandle parameter.</param>
/// <param name="FlatCredUIContextLength">The size, in bytes, of the FlatCredUIContext buffer.</param>
/// <param name="FlatCredUIContext">The values with which to update the specified credentials.</param>
/// <returns>If the function succeeds, it returns SEC_E_OK. If the function fails, it returns a nonzero error code.</returns>
[DllImport(Lib.CredUI, ExactSpelling = true)]
[DllImport(Lib.CredUI, SetLastError = false, ExactSpelling = true)]
[PInvokeData("Sspi.h")]
public static extern NTStatus SspiUpdateCredentials(IntPtr ContextHandle, [MarshalAs(UnmanagedType.LPStruct)] Guid CredType, uint FlatCredUIContextLength, [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] byte[] FlatCredUIContext);
public static extern Win32Error SspiUpdateCredentials(IntPtr ContextHandle, in Guid CredType, uint FlatCredUIContextLength, [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] byte[] FlatCredUIContext);
/// <summary>
/// Specifies unserialized credential information. The credential information can be serialized by passing it as the rgbSerialization
/// member of a CREDENTIAL_PROVIDER_CREDENTIAL_SERIALIZATION structure in a call to the ICredentialProvider::SetSerialization method.
/// <para>The unserialized information can be obtained by calling the SspiUnmarshalCredUIContext function.</para>
/// </summary>
[StructLayout(LayoutKind.Sequential)]
public class PSEC_WINNT_CREDUI_CONTEXT
{
/// <summary>The size, in bytes, of the header.</summary>
public ushort cbHeaderLength;
/// <summary>A handle to the credential context.</summary>
public IntPtr CredUIContextHandle;
/// <summary>
/// Specifies why prompting for credentials is needed. A caller can pass this Windows error parameter, returned by another
/// authentication call, to allow the dialog box to accommodate certain errors. For example, if the password expired status code
/// is passed, the dialog box prompts the user to change the password on the account.
/// </summary>
public Win32Error dwAuthError;
/// <summary>The opaque authentication identity data. SEC_WINNT_AUTH_IDENTITY_OPAQUE.</summary>
public IntPtr pInputAuthIdentity;
/// <summary>The name of the target.</summary>
public StrPtrUni TargetName;
/// <summary>A pointer to a CREDUI_INFO structure that specifies information for the credential prompt dialog box.</summary>
public IntPtr UIInfo;
}
/// <summary>Specifies the offset and size of the credential context data in a SEC_WINNT_CREDUI_CONTEXT structure.</summary>
[StructLayout(LayoutKind.Sequential)]
@ -94,28 +175,9 @@ namespace Vanara.PInvoke
{
/// <summary>The number of bytes from the beginning of the structure to the context data.</summary>
public uint CredUIContextArrayOffset;
/// <summary>The size, in bytes, of the context data.</summary>
public ushort CredUIContextCount;
}
/// <summary>
/// Specifies unserialized credential information. The credential information can be serialized by passing it as the rgbSerialization member of a CREDENTIAL_PROVIDER_CREDENTIAL_SERIALIZATION structure in a call to the ICredentialProvider::SetSerialization method.
/// <para>The unserialized information can be obtained by calling the SspiUnmarshalCredUIContext function.</para></summary>
[StructLayout(LayoutKind.Sequential)]
public class PSEC_WINNT_CREDUI_CONTEXT
{
/// <summary>The size, in bytes, of the header.</summary>
public ushort cbHeaderLength;
/// <summary>A handle to the credential context.</summary>
public IntPtr CredUIContextHandle;
/// <summary>A pointer to a CREDUI_INFO structure that specifies information for the credential prompt dialog box.</summary>
public IntPtr UIInfo;
/// <summary>Specifies why prompting for credentials is needed. A caller can pass this Windows error parameter, returned by another authentication call, to allow the dialog box to accommodate certain errors. For example, if the password expired status code is passed, the dialog box prompts the user to change the password on the account.</summary>
public uint dwAuthError;
/// <summary>The opaque authentication identity data. SEC_WINNT_AUTH_IDENTITY_OPAQUE.</summary>
public IntPtr pInputAuthIdentity;
/// <summary>The name of the target.</summary>
public StrPtrUni TargetName;
}
}
}

View File

@ -28,10 +28,10 @@ Functions
CredPackAuthenticationBufferA, CredPackAuthenticationBufferW, CredUICmdLinePromptForCredentialsA, CredUICmdLinePromptForCredentialsW, CredUIConfirmCredentialsA, CredUIConfirmCredentialsW, CredUIParseUserNameA, CredUIParseUserNameW, CredUIPromptForCredentialsA, CredUIPromptForCredentialsW, CredUIPromptForWindowsCredentialsA, CredUIPromptForWindowsCredentialsW, CredUIReadSSOCredA, CredUIReadSSOCredW, CredUIStoreSSOCredA, CredUIStoreSSOCredW, CredUnPackAuthenticationBufferA, CredUnPackAuthenticationBufferW, SspiGetCredUIContext, SspiIsPromptingNeeded, SspiPromptForCredentialsA, SspiPromptForCredentialsW, SspiUnmarshalCredUIContext, SspiUpdateCredentials
Structures
PSEC_WINNT_CREDUI_CONTEXT_VECTOR, PSEC_WINNT_CREDUI_CONTEXT, CREDUI_INFO
PSEC_WINNT_CREDUI_CONTEXT, PSEC_WINNT_CREDUI_CONTEXT_VECTOR
</PackageReleaseNotes>
<LangVersion>latest</LangVersion>
<LangVersion>latest</LangVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)'=='Release'">
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>

View File

@ -3,25 +3,28 @@ using System.Runtime.InteropServices;
using System.Text;
using Vanara.InteropServices;
// ReSharper disable InconsistentNaming
// ReSharper disable FieldCanBeMadeReadOnly.Global
namespace Vanara.PInvoke
{
public static partial class CredUI
{
/// <summary>The maximum domain target name length.</summary>
public const int CRED_MAX_DOMAIN_TARGET_NAME_LENGTH = 256 + 1 + 80;
/// <summary>The maximum username length</summary>
public const int CRED_MAX_USERNAME_LENGTH = (256 + 1 + 256);
/// <summary>The maximum caption length</summary>
public const int CREDUI_MAX_CAPTION_LENGTH = 128;
/// <summary>The maximum domain target length</summary>
public const int CREDUI_MAX_DOMAIN_TARGET_LENGTH = CREDUI_MAX_USERNAME_LENGTH;
/// <summary>The maximum message length</summary>
public const int CREDUI_MAX_MESSAGE_LENGTH = 32767;
/// <summary>The maximum password length</summary>
public const int CREDUI_MAX_PASSWORD_LENGTH = (512 / 2);
/// <summary>The maximum username length</summary>
public const int CREDUI_MAX_USERNAME_LENGTH = CRED_MAX_USERNAME_LENGTH;
@ -31,8 +34,8 @@ namespace Vanara.PInvoke
public enum CredentialsDialogOptions
{
/// <summary>
/// Default flags settings These are the following values: <see cref="CREDUI_FLAGS_GENERIC_CREDENTIALS"/>, <see cref="CREDUI_FLAGS_ALWAYS_SHOW_UI"/>
/// and <see cref="CREDUI_FLAGS_EXPECT_CONFIRMATION"/>
/// Default flags settings These are the following values: <see cref="CREDUI_FLAGS_GENERIC_CREDENTIALS"/>, <see
/// cref="CREDUI_FLAGS_ALWAYS_SHOW_UI"/> and <see cref="CREDUI_FLAGS_EXPECT_CONFIRMATION"/>
/// </summary>
CREDUI_FLAGS_DEFAULT = CREDUI_FLAGS_GENERIC_CREDENTIALS | CREDUI_FLAGS_ALWAYS_SHOW_UI | CREDUI_FLAGS_EXPECT_CONFIRMATION,
@ -43,29 +46,31 @@ namespace Vanara.PInvoke
CREDUI_FLAGS_INCORRECT_PASSWORD = 0x00001,
/// <summary>
/// Do not store credentials or display check boxes. You can pass ShowSaveCheckBox with this newDS to display the Save check box only, and the result
/// is returned in the CredentialsDialog.SaveChecked property.
/// Do not store credentials or display check boxes. You can pass ShowSaveCheckBox with this newDS to display the Save check box
/// only, and the result is returned in the CredentialsDialog.SaveChecked property.
/// </summary>
CREDUI_FLAGS_DO_NOT_PERSIST = 0x00002,
/// <summary>Populate the combo box with local administrators only.</summary>
CREDUI_FLAGS_REQUEST_ADMINISTRATOR = 0x00004,
/// <summary>Populate the combo box with user name/password only. Do not display certificates or smart cards in the combo box.</summary>
/// <summary>
/// Populate the combo box with user name/password only. Do not display certificates or smart cards in the combo box.
/// </summary>
CREDUI_FLAGS_EXCLUDE_CERTIFICATES = 0x00008,
/// <summary>Populate the combo box with certificates and smart cards only. Do not allow a user name to be entered.</summary>
CREDUI_FLAGS_REQUIRE_CERTIFICATE = 0x00010,
/// <summary>
/// If the check box is selected, show the Save check box and return <c>true</c> in the CredentialsDialog.SaveChecked property, otherwise, return
/// <c>false</c>. Check box uses the value in the CredentialsDialog.SaveChecked property by default.
/// If the check box is selected, show the Save check box and return <c>true</c> in the CredentialsDialog.SaveChecked property,
/// otherwise, return <c>false</c>. Check box uses the value in the CredentialsDialog.SaveChecked property by default.
/// </summary>
CREDUI_FLAGS_SHOW_SAVE_CHECK_BOX = 0x00040,
/// <summary>
/// Specifies that a user interface will be shown even if the credentials can be returned from an existing credential in credential manager. This
/// newDS is permitted only if GenericCredentials is also specified.
/// Specifies that a user interface will be shown even if the credentials can be returned from an existing credential in
/// credential manager. This newDS is permitted only if GenericCredentials is also specified.
/// </summary>
CREDUI_FLAGS_ALWAYS_SHOW_UI = 0x00080,
@ -85,16 +90,17 @@ namespace Vanara.PInvoke
CREDUI_FLAGS_PERSIST = 0x01000,
/// <summary>
/// This newDS is meaningful only in locating a matching credential to pre-fill the dialog box, should authentication fail. When this newDS is
/// specified, wildcard credentials will not be matched. It has no effect when writing a credential. CredUI does not create credentials that contain
/// wildcard characters. Any found were either created explicitly by the user or created programmatically, as happens when a RAS connection is made.
/// This newDS is meaningful only in locating a matching credential to pre-fill the dialog box, should authentication fail. When
/// this newDS is specified, wildcard credentials will not be matched. It has no effect when writing a credential. CredUI does
/// not create credentials that contain wildcard characters. Any found were either created explicitly by the user or created
/// programmatically, as happens when a RAS connection is made.
/// </summary>
CREDUI_FLAGS_SERVER_CREDENTIAL = 0x04000,
/// <summary>
/// Specifies that the caller will call ConfirmCredentials after checking to determine whether the returned credentials are actually valid. This
/// mechanism ensures that credentials that are not valid are not saved to the credential manager. Specify this newDS in all cases unless
/// DoNotPersist is specified.
/// Specifies that the caller will call ConfirmCredentials after checking to determine whether the returned credentials are
/// actually valid. This mechanism ensures that credentials that are not valid are not saved to the credential manager. Specify
/// this newDS in all cases unless DoNotPersist is specified.
/// </summary>
CREDUI_FLAGS_EXPECT_CONFIRMATION = 0x20000,
@ -102,8 +108,8 @@ namespace Vanara.PInvoke
CREDUI_FLAGS_GENERIC_CREDENTIALS = 0x40000,
/// <summary>
/// The credential is a "RunAs" credential. The TargetName parameter specifies the name of the command or program being run. It is used for prompting
/// purposes only.
/// The credential is a "RunAs" credential. The TargetName parameter specifies the name of the command or program being run. It
/// is used for prompting purposes only.
/// </summary>
CREDUI_FLAGS_USERNAME_TARGET_CREDENTIALS = 0x80000,
@ -125,8 +131,8 @@ namespace Vanara.PInvoke
CRED_PACK_GENERIC_CREDENTIALS = 0x4,
/// <summary>
/// Encrypts the credential of an online identity into a SEC_WINNT_AUTH_IDENTITY_EX2 structure.If CRED_PACK_GENERIC_CREDENTIALS and
/// CRED_PACK_ID_PROVIDER_CREDENTIALS are not set, encrypts the credentials in a KERB_INTERACTIVE_LOGON buffer.
/// Encrypts the credential of an online identity into a SEC_WINNT_AUTH_IDENTITY_EX2 structure.If CRED_PACK_GENERIC_CREDENTIALS
/// and CRED_PACK_ID_PROVIDER_CREDENTIALS are not set, encrypts the credentials in a KERB_INTERACTIVE_LOGON buffer.
/// <para><c>Windows 7, Windows Server 2008 R2, Windows Vista, Windows Server 2008:</c> This value is not supported.</para>
/// </summary>
CRED_PACK_ID_PROVIDER_CREDENTIALS = 0x8
@ -141,7 +147,8 @@ namespace Vanara.PInvoke
CREDUIWIN_NONE = 0,
/// <summary>
/// The caller is requesting that the credential provider return the user name and password in plain text. This value cannot be combined with SecurePrompt.
/// The caller is requesting that the credential provider return the user name and password in plain text. This value cannot be
/// combined with SecurePrompt.
/// </summary>
CREDUIWIN_GENERIC = 0x00000001,
@ -149,41 +156,45 @@ namespace Vanara.PInvoke
CREDUIWIN_CHECKBOX = 0x00000002,
/// <summary>
/// Only credential providers that support the authentication package specified by the authPackage parameter should be enumerated. This value cannot
/// be combined with InAuthBufferCredentialsOnly.
/// Only credential providers that support the authentication package specified by the authPackage parameter should be
/// enumerated. This value cannot be combined with InAuthBufferCredentialsOnly.
/// </summary>
CREDUIWIN_AUTHPACKAGE_ONLY = 0x00000010,
/// <summary>
/// Only the credentials specified by the InAuthBuffer parameter for the authentication package specified by the authPackage parameter should be
/// enumerated. If this flag is set, and the InAuthBuffer parameter is NULL, the function fails. This value cannot be combined with AuthPackageOnly.
/// Only the credentials specified by the InAuthBuffer parameter for the authentication package specified by the authPackage
/// parameter should be enumerated. If this flag is set, and the InAuthBuffer parameter is NULL, the function fails. This value
/// cannot be combined with AuthPackageOnly.
/// </summary>
CREDUIWIN_IN_CRED_ONLY = 0x00000020,
/// <summary>
/// Credential providers should enumerate only administrators. This value is intended for User Account Control (UAC) purposes only. We recommend that
/// external callers not set this flag.
/// Credential providers should enumerate only administrators. This value is intended for User Account Control (UAC) purposes
/// only. We recommend that external callers not set this flag.
/// </summary>
CREDUIWIN_ENUMERATE_ADMINS = 0x00000100,
/// <summary>Only the incoming credentials for the authentication package specified by the authPackage parameter should be enumerated.</summary>
/// <summary>
/// Only the incoming credentials for the authentication package specified by the authPackage parameter should be enumerated.
/// </summary>
CREDUIWIN_ENUMERATE_CURRENT_USER = 0x00000200,
/// <summary>
/// The credential dialog box should be displayed on the secure desktop. This value cannot be combined with Generic. Windows Vista: This value is not
/// supported until Windows Vista with SP1.
/// The credential dialog box should be displayed on the secure desktop. This value cannot be combined with Generic. Windows
/// Vista: This value is not supported until Windows Vista with SP1.
/// </summary>
CREDUIWIN_SECURE_PROMPT = 0x00001000,
/// <summary>
/// The credential provider should align the credential BLOB pointed to by the refOutAuthBuffer parameter to a 32-bit boundary, even if the provider
/// is running on a 64-bit system.
/// The credential provider should align the credential BLOB pointed to by the refOutAuthBuffer parameter to a 32-bit boundary,
/// even if the provider is running on a 64-bit system.
/// </summary>
CREDUIWIN_PACK_32_WOW = 0x10000000,
/// <summary>
/// The credential dialog box is invoked by the SspiPromptForCredentials function, and the client is prompted before a prior handshake. If
/// SSPIPFC_NO_CHECKBOX is passed in the pvInAuthBuffer parameter, then the credential provider should not display the check box.
/// The credential dialog box is invoked by the SspiPromptForCredentials function, and the client is prompted before a prior
/// handshake. If SSPIPFC_NO_CHECKBOX is passed in the pvInAuthBuffer parameter, then the credential provider should not display
/// the check box.
/// </summary>
CREDUIWIN_PREPROMPTING = 0X00002000
}
@ -191,93 +202,143 @@ namespace Vanara.PInvoke
/// <summary>
/// The CredPackAuthenticationBuffer function converts a string user name and password into an authentication buffer.
/// <para>
/// Beginning with Windows 8 and Windows Server 2012, the CredPackAuthenticationBuffer function converts an identity credential into an authentication
/// buffer, which is a SEC_WINNT_AUTH_IDENTITY_EX2 structure. This buffer can be passed to LsaLogonUser, AcquireCredentialsHandle, or other identity
/// provider interfaces.
/// Beginning with Windows 8 and Windows Server 2012, the CredPackAuthenticationBuffer function converts an identity credential into
/// an authentication buffer, which is a SEC_WINNT_AUTH_IDENTITY_EX2 structure. This buffer can be passed to LsaLogonUser,
/// AcquireCredentialsHandle, or other identity provider interfaces.
/// </para>
/// </summary>
/// <param name="dwFlags">Specifies how the credential should be packed.</param>
/// <param name="pszUserName">
/// A pointer to a null-terminated string that specifies the user name to be converted. For domain users, the string must be in the following format:
/// A pointer to a null-terminated string that specifies the user name to be converted. For domain users, the string must be in the
/// following format:
/// <para>DomainName\UserName</para>
/// <para>
/// For online identities, if the credential is a plaintext password, the user name format is ProviderName\UserName. If the credential is a
/// SEC_WINNT_AUTH_IDENTITY_EX2 structure, the user name is an encoded string that is the UserName parameter output of a function call to SspiEncodeAuthIdentityAsStrings.
/// For online identities, if the credential is a plaintext password, the user name format is ProviderName\UserName. If the
/// credential is a SEC_WINNT_AUTH_IDENTITY_EX2 structure, the user name is an encoded string that is the UserName parameter output
/// of a function call to SspiEncodeAuthIdentityAsStrings.
/// </para>
/// <para>
/// For smart card or certificate credentials, the user name is an encoded string that is the output of a function call to CredMarshalCredential with the
/// CertCredential option.
/// For smart card or certificate credentials, the user name is an encoded string that is the output of a function call to
/// CredMarshalCredential with the CertCredential option.
/// </para>
/// <para><c>Windows Server 2008 R2, Windows 7, Windows Server 2008 and Windows Vista:</c> Online identities are not supported.</para>
/// </param>
/// <param name="pszPassword">
/// A pointer to a null-terminated string that specifies the password to be converted.
/// <para>
/// For SEC_WINNT_AUTH_IDENTITY_EX2 credentials, the password is an encoded string that is in the ppszPackedCredentialsString output of a function call
/// to SspiEncodeAuthIdentityAsStrings.
/// For SEC_WINNT_AUTH_IDENTITY_EX2 credentials, the password is an encoded string that is in the ppszPackedCredentialsString output
/// of a function call to SspiEncodeAuthIdentityAsStrings.
/// </para>
/// <para>For smart card credentials, this is the smart card PIN.</para>
/// <para><c>Windows Server 2008 R2, Windows 7, Windows Server 2008 and Windows Vista:</c> Online identities are not supported.</para>
/// </param>
/// <param name="pPackedCredentials">
/// A pointer to an array of bytes that, on output, receives the packed authentication buffer. This parameter can be NULL to receive the required buffer
/// size in the pcbPackedCredentials parameter.
/// A pointer to an array of bytes that, on output, receives the packed authentication buffer. This parameter can be NULL to receive
/// the required buffer size in the pcbPackedCredentials parameter.
/// </param>
/// <param name="pcbPackedCredentials">
/// A pointer to a DWORD value that specifies the size, in bytes, of the pPackedCredentials buffer. On output, if the buffer is not of sufficient size,
/// specifies the required size, in bytes, of the pPackedCredentials buffer.
/// A pointer to a DWORD value that specifies the size, in bytes, of the pPackedCredentials buffer. On output, if the buffer is not
/// of sufficient size, specifies the required size, in bytes, of the pPackedCredentials buffer.
/// </param>
/// <returns>TRUE if the function succeeds; otherwise, FALSE. For extended error information, call the GetLastError function.</returns>
[DllImport(Lib.CredUI, CharSet = CharSet.Auto, SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
[PInvokeData("wincred.h", MSDNShortId = "aa374802")]
public static extern bool CredPackAuthenticationBuffer(CredPackFlags dwFlags, IntPtr pszUserName, IntPtr pszPassword, IntPtr pPackedCredentials, ref int pcbPackedCredentials);
public static extern bool CredPackAuthenticationBuffer(CredPackFlags dwFlags, string pszUserName, string pszPassword, IntPtr pPackedCredentials, ref int pcbPackedCredentials);
/// <summary>The CredUICmdLinePromptForCredentials function prompts for and accepts credential information from a user working in a command-line (console) application. The name and password typed by the user are passed back to the calling application for verification.</summary>
/// <param name="pszTargetName">A pointer to a null-terminated string that contains the name of the target for the credentials, typically a server name. For DFS connections, this string is of the form ServerName\ShareName. The pszTargetName parameter is used to identify the target information and is used to store and retrieve the credential.</param>
/// <summary>
/// The CredUICmdLinePromptForCredentials function prompts for and accepts credential information from a user working in a
/// command-line (console) application. The name and password typed by the user are passed back to the calling application for verification.
/// </summary>
/// <param name="pszTargetName">
/// A pointer to a null-terminated string that contains the name of the target for the credentials, typically a server name. For DFS
/// connections, this string is of the form ServerName\ShareName. The pszTargetName parameter is used to identify the target
/// information and is used to store and retrieve the credential.
/// </param>
/// <param name="pContext">Currently reserved and must be NULL.</param>
/// <param name="dwAuthError">Specifies why prompting for credentials is needed. A caller can pass this Windows error parameter, returned by another authentication call, to allow the dialog box to accommodate certain errors. For example, if the password expired status code is passed, the dialog box prompts the user to change the password on the account.</param>
/// <param name="UserName">A pointer to a null-terminated string that contains the credential user name. If a nonzero-length string is specified for pszUserName, the user will be prompted only for the password. In the case of credentials other than user name/password, a marshaled format of the credential can be passed in. This string is created by calling CredMarshalCredential.
/// <para>This function writes the user-supplied name to this buffer, copying a maximum of ulUserNameMaxChars characters. The string in this format can be converted to the user name/password format by calling the CredUIParseUsername function. The string in its marshaled format can be passed directly to a security support provider (SSP).</para>
/// <para>If the CREDUI_FLAGS_DO_NOT_PERSIST flag is not specified, the value returned in this parameter is of a form that should not be inspected, printed, or persisted other than passing it to CredUIParseUsername. The subsequent results of CredUIParseUsername can be passed only to a client-side authentication API such as WNetAddConnection or the SSP API.</para></param>
/// <param name="ulUserBufferSize">The maximum number of characters that can be copied to pszUserName including the terminating null character. <note>CREDUI_MAX_USERNAME_LENGTH does not include the terminating null character.</note></param>
/// <param name="pszPassword">A pointer to a null-terminated string that contains the password for the credentials. If a nonzero-length string is specified for pszPassword, the password parameter will be prefilled with the string.
/// <para>This function writes the user-supplied password to this buffer, copying a maximum of ulPasswordMaxChars characters. If the CREDUI_FLAGS_DO_NOT_PERSIST flag is not specified, the value returned in this parameter is of a form that should not be inspected, printed, or persisted other than passing it to a client-side authentication function such as WNetAddConnection or an SSP function.</para>
/// <para>When you have finished using the password, clear the password from memory by calling the SecureZeroMemory function. For more information about protecting passwords, see Handling Passwords.</para></param>
/// <param name="ulPasswordBufferSize">The maximum number of characters that can be copied to pszPassword including the terminating null character. <note>CREDUI_MAX_USERNAME_LENGTH does not include the terminating null character.</note></param>
/// <param name="pfSave">A pointer to a BOOL that specifies the initial state of the Save message and receives the state of the Save message after the user has responded to the command prompt. If pfSave is not NULL and CredUIPromptForCredentials returns NO_ERROR, pfSave returns the state of the Save message. If the CREDUI_FLAGS_PERSIST flag is specified, the Save message is not displayed but is considered to be "y". If the CREDUI_FLAGS_DO_NOT_PERSIST flag is specified and CREDUI_FLAGS_SHOW_SAVE_CHECK_BOX is not specified, the Save message is not displayed but is considered to be "n".</param>
/// <param name="dwAuthError">
/// Specifies why prompting for credentials is needed. A caller can pass this Windows error parameter, returned by another
/// authentication call, to allow the dialog box to accommodate certain errors. For example, if the password expired status code is
/// passed, the dialog box prompts the user to change the password on the account.
/// </param>
/// <param name="UserName">
/// A pointer to a null-terminated string that contains the credential user name. If a nonzero-length string is specified for
/// pszUserName, the user will be prompted only for the password. In the case of credentials other than user name/password, a
/// marshaled format of the credential can be passed in. This string is created by calling CredMarshalCredential.
/// <para>
/// This function writes the user-supplied name to this buffer, copying a maximum of ulUserNameMaxChars characters. The string in
/// this format can be converted to the user name/password format by calling the CredUIParseUsername function. The string in its
/// marshaled format can be passed directly to a security support provider (SSP).
/// </para>
/// <para>
/// If the CREDUI_FLAGS_DO_NOT_PERSIST flag is not specified, the value returned in this parameter is of a form that should not be
/// inspected, printed, or persisted other than passing it to CredUIParseUsername. The subsequent results of CredUIParseUsername can
/// be passed only to a client-side authentication API such as WNetAddConnection or the SSP API.
/// </para>
/// </param>
/// <param name="ulUserBufferSize">
/// The maximum number of characters that can be copied to pszUserName including the terminating null character.
/// <note>CREDUI_MAX_USERNAME_LENGTH does not include the terminating null character.</note>
/// </param>
/// <param name="pszPassword">
/// A pointer to a null-terminated string that contains the password for the credentials. If a nonzero-length string is specified for
/// pszPassword, the password parameter will be prefilled with the string.
/// <para>
/// This function writes the user-supplied password to this buffer, copying a maximum of ulPasswordMaxChars characters. If the
/// CREDUI_FLAGS_DO_NOT_PERSIST flag is not specified, the value returned in this parameter is of a form that should not be
/// inspected, printed, or persisted other than passing it to a client-side authentication function such as WNetAddConnection or an
/// SSP function.
/// </para>
/// <para>
/// When you have finished using the password, clear the password from memory by calling the SecureZeroMemory function. For more
/// information about protecting passwords, see Handling Passwords.
/// </para>
/// </param>
/// <param name="ulPasswordBufferSize">
/// The maximum number of characters that can be copied to pszPassword including the terminating null character.
/// <note>CREDUI_MAX_USERNAME_LENGTH does not include the terminating null character.</note>
/// </param>
/// <param name="pfSave">
/// A pointer to a BOOL that specifies the initial state of the Save message and receives the state of the Save message after the
/// user has responded to the command prompt. If pfSave is not NULL and CredUIPromptForCredentials returns NO_ERROR, pfSave returns
/// the state of the Save message. If the CREDUI_FLAGS_PERSIST flag is specified, the Save message is not displayed but is considered
/// to be "y". If the CREDUI_FLAGS_DO_NOT_PERSIST flag is specified and CREDUI_FLAGS_SHOW_SAVE_CHECK_BOX is not specified, the Save
/// message is not displayed but is considered to be "n".
/// </param>
/// <param name="dwFlags">A DWORD value that specifies special behavior for this function.</param>
/// <returns>The result of the operation.</returns>
[DllImport(Lib.CredUI, CharSet = CharSet.Auto, SetLastError = true)]
[PInvokeData("wincred.h", MSDNShortId = "aa374802")]
public static extern Win32Error CredUICmdLinePromptForCredentials([In, Optional] string pszTargetName, IntPtr pContext, Win32Error dwAuthError, StringBuilder UserName, uint ulUserBufferSize,
public static extern Win32Error CredUICmdLinePromptForCredentials([In, Optional] string pszTargetName, [Optional] IntPtr pContext, Win32Error dwAuthError, StringBuilder UserName, uint ulUserBufferSize,
StringBuilder pszPassword, uint ulPasswordBufferSize, [MarshalAs(UnmanagedType.Bool)] ref bool pfSave, CredentialsDialogOptions dwFlags);
/// <summary>
/// The CredUIConfirmCredentials function is called after CredUIPromptForCredentials or CredUICmdLinePromptForCredentials, to confirm the validity of the
/// credential harvested. CredUIConfirmCredentials must be called if the CREDUI_FLAGS_EXPECT_CONFIRMATION flag was passed to the "prompt" function,
/// either CredUIPromptForCredentials or CredUICmdLinePromptForCredentials, and the "prompt" function returned NO_ERROR.
/// The CredUIConfirmCredentials function is called after CredUIPromptForCredentials or CredUICmdLinePromptForCredentials, to confirm
/// the validity of the credential harvested. CredUIConfirmCredentials must be called if the CREDUI_FLAGS_EXPECT_CONFIRMATION flag
/// was passed to the "prompt" function, either CredUIPromptForCredentials or CredUICmdLinePromptForCredentials, and the "prompt"
/// function returned NO_ERROR.
/// <para>
/// After calling the "prompt" function and before calling CredUIConfirmCredentials, the caller must determine whether the credentials are actually valid
/// by using the credentials to access the resource specified by pszTargetName. The results of that validation test are passed to
/// CredUIConfirmCredentials in the bConfirm parameter.
/// After calling the "prompt" function and before calling CredUIConfirmCredentials, the caller must determine whether the
/// credentials are actually valid by using the credentials to access the resource specified by pszTargetName. The results of that
/// validation test are passed to CredUIConfirmCredentials in the bConfirm parameter.
/// </para>
/// </summary>
/// <param name="targetName">
/// Pointer to a null-terminated string that contains the name of the target for the credentials, typically a domain or server application name. This
/// must be the same value passed as pszTargetName to CredUIPromptForCredentials or CredUICmdLinePromptForCredentials
/// Pointer to a null-terminated string that contains the name of the target for the credentials, typically a domain or server
/// application name. This must be the same value passed as pszTargetName to CredUIPromptForCredentials or CredUICmdLinePromptForCredentials
/// </param>
/// <param name="confirm">
/// Specifies whether the credentials returned from the prompt function are valid. If TRUE, the credentials are stored in the credential manager as
/// defined by CredUIPromptForCredentials or CredUICmdLinePromptForCredentials. If FALSE, the credentials are not stored and various pieces of memory are
/// cleaned up.
/// Specifies whether the credentials returned from the prompt function are valid. If TRUE, the credentials are stored in the
/// credential manager as defined by CredUIPromptForCredentials or CredUICmdLinePromptForCredentials. If FALSE, the credentials are
/// not stored and various pieces of memory are cleaned up.
/// </param>
/// <returns>
/// Status of the operation is returned. The caller can check this status to determine whether the credential confirm operation succeeded. Most
/// applications ignore this status code because the application's connection to the resource has already been done. The operation can fail because the
/// credential was not found on the list of credentials awaiting confirmation, or because the attempt to write or delete the credential failed. Failure
/// to find the credential on the list can occur because the credential was never queued or as a result of too many credentials being queued. Up to five
/// credentials can be queued before older ones are discarded as newer ones are queued.
/// Status of the operation is returned. The caller can check this status to determine whether the credential confirm operation
/// succeeded. Most applications ignore this status code because the application's connection to the resource has already been done.
/// The operation can fail because the credential was not found on the list of credentials awaiting confirmation, or because the
/// attempt to write or delete the credential failed. Failure to find the credential on the list can occur because the credential was
/// never queued or as a result of too many credentials being queued. Up to five credentials can be queued before older ones are
/// discarded as newer ones are queued.
/// </returns>
[DllImport(Lib.CredUI, CharSet = CharSet.Auto)]
[PInvokeData("wincred.h", MSDNShortId = "aa375173")]
@ -285,20 +346,20 @@ namespace Vanara.PInvoke
/// <summary>The CredUIParseUserName function extracts the domain and user account name from a fully qualified user name.</summary>
/// <param name="pszUserName">
/// Pointer to a null-terminated string that contains the user name to be parsed. The name must be in UPN or down-level format, or a certificate.
/// Typically, pszUserName is received from the CredUIPromptForCredentials or CredUICmdLinePromptForCredentials.
/// Pointer to a null-terminated string that contains the user name to be parsed. The name must be in UPN or down-level format, or a
/// certificate. Typically, pszUserName is received from the CredUIPromptForCredentials or CredUICmdLinePromptForCredentials.
/// </param>
/// <param name="pszUser">Pointer to a null-terminated string that receives the user account name.</param>
/// <param name="ulUserMaxChars">
/// Maximum number of characters to write to the pszUser string including the terminating null character. <note>CREDUI_MAX_USERNAME_LENGTH does NOT
/// include the terminating null character.</note>
/// Maximum number of characters to write to the pszUser string including the terminating null character.
/// <note>CREDUI_MAX_USERNAME_LENGTH does NOT include the terminating null character.</note>
/// </param>
/// <param name="pszDomain">
/// Pointer to a null-terminated string that receives the domain name. If pszUserName specifies a certificate, pszDomain will be NULL.
/// </param>
/// <param name="ulDomainMaxChars">
/// Maximum number of characters to write to the pszDomain string including the terminating null character. <note>CREDUI_MAX_DOMAIN_TARGET_LENGTH does
/// NOT include the terminating null character.</note>
/// Maximum number of characters to write to the pszDomain string including the terminating null character.
/// <note>CREDUI_MAX_DOMAIN_TARGET_LENGTH does NOT include the terminating null character.</note>
/// </param>
/// <returns>Status of the operation is returned.</returns>
[DllImport(Lib.CredUI, CharSet = CharSet.Auto)]
@ -306,10 +367,11 @@ namespace Vanara.PInvoke
public static extern Win32Error CredUIParseUserName(string pszUserName, StringBuilder pszUser, int ulUserMaxChars, StringBuilder pszDomain, int ulDomainMaxChars);
/// <summary>
/// The CredUIPromptForCredentials function creates and displays a configurable dialog box that accepts credentials information from a user.
/// The CredUIPromptForCredentials function creates and displays a configurable dialog box that accepts credentials information from
/// a user.
/// <para>
/// Applications that target Windows Vista or Windows Server 2008 should call CredUIPromptForWindowsCredentials instead of this function, for the
/// following reasons:
/// Applications that target Windows Vista or Windows Server 2008 should call CredUIPromptForWindowsCredentials instead of this
/// function, for the following reasons:
/// </para>
/// <list type="bullet">
/// <item>
@ -317,7 +379,8 @@ namespace Vanara.PInvoke
/// </item>
/// <item>
/// <term>
/// CredUIPromptForWindowsCredentials is more extensible, allowing integration of additional authentication mechanisms such as biometrics and smart cards.
/// CredUIPromptForWindowsCredentials is more extensible, allowing integration of additional authentication mechanisms such as
/// biometrics and smart cards.
/// </term>
/// </item>
/// <item>
@ -325,71 +388,77 @@ namespace Vanara.PInvoke
/// </item>
/// </list>
/// </summary>
/// <param name="pUiInfo">A pointer to a CREDUI_INFO structure that contains information for customizing the appearance of the dialog box.</param>
/// <param name="pUiInfo">
/// A pointer to a CREDUI_INFO structure that contains information for customizing the appearance of the dialog box.
/// </param>
/// <param name="pszTargetName">
/// A pointer to a null-terminated string that contains the name of the target for the credentials, typically a server name. For Distributed File System
/// (DFS) connections, this string is of the form ServerName\ShareName. This parameter is used to identify target information when storing and retrieving credentials.
/// A pointer to a null-terminated string that contains the name of the target for the credentials, typically a server name. For
/// Distributed File System (DFS) connections, this string is of the form ServerName\ShareName. This parameter is used to identify
/// target information when storing and retrieving credentials.
/// </param>
/// <param name="Reserved">This parameter is reserved for future use. It must be NULL.</param>
/// <param name="dwAuthError">
/// Specifies why the credential dialog box is needed. A caller can pass this Windows error parameter, returned by another authentication call, to allow
/// the dialog box to accommodate certain errors. For example, if the password expired status code is passed, the dialog box could prompt the user to
/// change the password on the account.
/// Specifies why the credential dialog box is needed. A caller can pass this Windows error parameter, returned by another
/// authentication call, to allow the dialog box to accommodate certain errors. For example, if the password expired status code is
/// passed, the dialog box could prompt the user to change the password on the account.
/// </param>
/// <param name="pszUserName">
/// A pointer to a null-terminated string that contains the user name for the credentials. If a nonzero-length string is passed, the UserName option of
/// the dialog box is prefilled with the string. In the case of credentials other than UserName/Password, a marshaled format of the credential can be
/// passed in. This string is created by calling CredMarshalCredential.
/// A pointer to a null-terminated string that contains the user name for the credentials. If a nonzero-length string is passed, the
/// UserName option of the dialog box is prefilled with the string. In the case of credentials other than UserName/Password, a
/// marshaled format of the credential can be passed in. This string is created by calling CredMarshalCredential.
/// <para>
/// This function copies the user-supplied name to this buffer, copying a maximum of ulUserNameMaxChars characters. This format can be converted to
/// UserName/Password format by using CredUIParseUsername. A marshaled format can be passed directly to a security support provider (SSP).
/// This function copies the user-supplied name to this buffer, copying a maximum of ulUserNameMaxChars characters. This format can
/// be converted to UserName/Password format by using CredUIParseUsername. A marshaled format can be passed directly to a security
/// support provider (SSP).
/// </para>
/// <para>
/// If the CREDUI_FLAGS_DO_NOT_PERSIST flag is not specified, the value returned in this parameter is of a form that should not be inspected, printed, or
/// persisted other than passing it to CredUIParseUsername. The subsequent results of CredUIParseUsername can be passed only to a client-side
/// authentication function such as WNetAddConnection or an SSP function.
/// If the CREDUI_FLAGS_DO_NOT_PERSIST flag is not specified, the value returned in this parameter is of a form that should not be
/// inspected, printed, or persisted other than passing it to CredUIParseUsername. The subsequent results of CredUIParseUsername can
/// be passed only to a client-side authentication function such as WNetAddConnection or an SSP function.
/// </para>
/// <para>
/// If no domain or server is specified as part of this parameter, the value of the pszTargetName parameter is used as the domain to form a
/// DomainName\UserName pair. On output, this parameter receives a string that contains that DomainName\UserName pair.
/// If no domain or server is specified as part of this parameter, the value of the pszTargetName parameter is used as the domain to
/// form a DomainName\UserName pair. On output, this parameter receives a string that contains that DomainName\UserName pair.
/// </para>
/// </param>
/// <param name="ulUserNameMaxChars">
/// The maximum number of characters that can be copied to pszUserName including the terminating null character. <note>CREDUI_MAX_USERNAME_LENGTH does
/// not include the terminating null character.</note>
/// The maximum number of characters that can be copied to pszUserName including the terminating null character.
/// <note>CREDUI_MAX_USERNAME_LENGTH does not include the terminating null character.</note>
/// </param>
/// <param name="pszPassword">
/// A pointer to a null-terminated string that contains the password for the credentials. If a nonzero-length string is specified for pszPassword, the
/// password option of the dialog box will be prefilled with the string.
/// A pointer to a null-terminated string that contains the password for the credentials. If a nonzero-length string is specified for
/// pszPassword, the password option of the dialog box will be prefilled with the string.
/// <para>
/// This function copies the user-supplied password to this buffer, copying a maximum of ulPasswordMaxChars characters. If the
/// CREDUI_FLAGS_DO_NOT_PERSIST flag is not specified, the value returned in this parameter is of a form that should not be inspected, printed, or
/// persisted other than passing it to a client-side authentication function such as WNetAddConnection or an SSP function.
/// CREDUI_FLAGS_DO_NOT_PERSIST flag is not specified, the value returned in this parameter is of a form that should not be
/// inspected, printed, or persisted other than passing it to a client-side authentication function such as WNetAddConnection or an
/// SSP function.
/// </para>
/// <para>
/// When you have finished using the password, clear the password from memory by calling the SecureZeroMemory function. For more information about
/// protecting passwords, see Handling Passwords.
/// When you have finished using the password, clear the password from memory by calling the SecureZeroMemory function. For more
/// information about protecting passwords, see Handling Passwords.
/// </para>
/// </param>
/// <param name="ulPasswordMaxChars">
/// The maximum number of characters that can be copied to pszPassword including the terminating null character. <note>CREDUI_MAX_USERNAME_LENGTH does
/// not include the terminating null character.</note>
/// The maximum number of characters that can be copied to pszPassword including the terminating null character.
/// <note>CREDUI_MAX_USERNAME_LENGTH does not include the terminating null character.</note>
/// </param>
/// <param name="pfSave">
/// A pointer to a BOOL that specifies the initial state of the Save check box and receives the state of the Save check box after the user has responded
/// to the dialog box. If this value is not NULL and CredUIPromptForCredentials returns NO_ERROR, then pfSave returns the state of the Save check box
/// when the user chose OK in the dialog box.
/// A pointer to a BOOL that specifies the initial state of the Save check box and receives the state of the Save check box after the
/// user has responded to the dialog box. If this value is not NULL and CredUIPromptForCredentials returns NO_ERROR, then pfSave
/// returns the state of the Save check box when the user chose OK in the dialog box.
/// <para>If the CREDUI_FLAGS_PERSIST flag is specified, the Save check box is not displayed, but is considered to be selected.</para>
/// <para>
/// If the CREDUI_FLAGS_DO_NOT_PERSIST flag is specified and CREDUI_FLAGS_SHOW_SAVE_CHECK_BOX is not specified, the Save check box is not displayed, but
/// is considered to be cleared.
/// If the CREDUI_FLAGS_DO_NOT_PERSIST flag is specified and CREDUI_FLAGS_SHOW_SAVE_CHECK_BOX is not specified, the Save check box is
/// not displayed, but is considered to be cleared.
/// </para>
/// <para>
/// An application that needs to use CredUI to prompt the user for credentials, but does not need the credential management services provided by the
/// credential manager, can use pfSave to receive the state of the Save check box after the user closes the dialog box. To do this, the caller must
/// specify CREDUI_FLAGS_DO_NOT_PERSIST and CREDUI_FLAGS_SHOW_SAVE_CHECK_BOX in dwFlags. When CREDUI_FLAGS_DO_NOT_PERSIST and
/// CREDUI_FLAGS_SHOW_SAVE_CHECK_BOX are set, the application is responsible for examining *pfSave after the function returns, and if *pfSave is TRUE,
/// then the application must take the appropriate action to save the user credentials within the resources of the application.
/// An application that needs to use CredUI to prompt the user for credentials, but does not need the credential management services
/// provided by the credential manager, can use pfSave to receive the state of the Save check box after the user closes the dialog
/// box. To do this, the caller must specify CREDUI_FLAGS_DO_NOT_PERSIST and CREDUI_FLAGS_SHOW_SAVE_CHECK_BOX in dwFlags. When
/// CREDUI_FLAGS_DO_NOT_PERSIST and CREDUI_FLAGS_SHOW_SAVE_CHECK_BOX are set, the application is responsible for examining *pfSave
/// after the function returns, and if *pfSave is TRUE, then the application must take the appropriate action to save the user
/// credentials within the resources of the application.
/// </para>
/// </param>
/// <param name="dwFlags">
@ -398,51 +467,59 @@ namespace Vanara.PInvoke
/// <returns>Status of the operation is returned.</returns>
[DllImport(Lib.CredUI, CharSet = CharSet.Auto)]
[PInvokeData("wincred.h", MSDNShortId = "aa375177")]
public static extern Win32Error CredUIPromptForCredentials(ref CREDUI_INFO pUiInfo, string pszTargetName, IntPtr Reserved, int dwAuthError, StringBuilder pszUserName, int ulUserNameMaxChars, StringBuilder pszPassword, int ulPasswordMaxChars, [MarshalAs(UnmanagedType.Bool)] ref bool pfSave, CredentialsDialogOptions dwFlags);
public static extern Win32Error CredUIPromptForCredentials(in CREDUI_INFO pUiInfo, string pszTargetName, [Optional] IntPtr Reserved, Win32Error dwAuthError, StringBuilder pszUserName, int ulUserNameMaxChars, StringBuilder pszPassword, int ulPasswordMaxChars, [MarshalAs(UnmanagedType.Bool)] ref bool pfSave, CredentialsDialogOptions dwFlags);
/// <summary>
/// The CredUIPromptForWindowsCredentials function creates and displays a configurable dialog box that allows users to supply credential information by
/// using any credential provider installed on the local computer.
/// The CredUIPromptForWindowsCredentials function creates and displays a configurable dialog box that allows users to supply
/// credential information by using any credential provider installed on the local computer.
/// </summary>
/// <param name="pUiInfo">
/// A pointer to a CREDUI_INFO structure that contains information for customizing the appearance of the dialog box that this function displays.
/// <para>If the hwndParent member of the CREDUI_INFO structure is not NULL, this function displays a modal dialog box centered on the parent window.</para>
/// A pointer to a CREDUI_INFO structure that contains information for customizing the appearance of the dialog box that this
/// function displays.
/// <para>
/// If the hwndParent member of the CREDUI_INFO structure is not NULL, this function displays a modal dialog box centered on the
/// parent window.
/// </para>
/// <para>If the hwndParent member of the CREDUI_INFO structure is NULL, the function displays a dialog box centered on the screen.</para>
/// <para>This function ignores the hbmBanner member of the CREDUI_INFO structure.</para>
/// </param>
/// <param name="dwAuthError">
/// A Windows error code, defined in Winerror.h, that is displayed in the dialog box. If credentials previously collected were not valid, the caller uses
/// this parameter to pass the error message from the API that collected the credentials (for example, Winlogon) to this function. The corresponding
/// error message is formatted and displayed in the dialog box. Set the value of this parameter to zero to display no error message.
/// A Windows error code, defined in Winerror.h, that is displayed in the dialog box. If credentials previously collected were not
/// valid, the caller uses this parameter to pass the error message from the API that collected the credentials (for example,
/// Winlogon) to this function. The corresponding error message is formatted and displayed in the dialog box. Set the value of this
/// parameter to zero to display no error message.
/// </param>
/// <param name="pulAuthPackage">
/// On input, the value of this parameter is used to specify the authentication package for which the credentials in the pvInAuthBuffer buffer are
/// serialized. If the value of pvInAuthBuffer is NULL and the CREDUIWIN_AUTHPACKAGE_ONLY flag is set in the dwFlags parameter, only credential providers
/// capable of serializing credentials for the specified authentication package are to be enumerated.
/// On input, the value of this parameter is used to specify the authentication package for which the credentials in the
/// pvInAuthBuffer buffer are serialized. If the value of pvInAuthBuffer is NULL and the CREDUIWIN_AUTHPACKAGE_ONLY flag is set in
/// the dwFlags parameter, only credential providers capable of serializing credentials for the specified authentication package are
/// to be enumerated.
/// <para>
/// To get the appropriate value to use for this parameter on input, call the LsaLookupAuthenticationPackage function and use the value of the
/// AuthenticationPackage parameter of that function.
/// To get the appropriate value to use for this parameter on input, call the LsaLookupAuthenticationPackage function and use the
/// value of the AuthenticationPackage parameter of that function.
/// </para>
/// <para>
/// On output, this parameter specifies the authentication package for which the credentials in the ppvOutAuthBuffer buffer are serialized.
/// </para>
/// <para>On output, this parameter specifies the authentication package for which the credentials in the ppvOutAuthBuffer buffer are serialized.</para>
/// </param>
/// <param name="pvInAuthBuffer">
/// A pointer to a credential BLOB that is used to populate the credential fields in the dialog box. Set the value of this parameter to NULL to leave the
/// credential fields empty.
/// A pointer to a credential BLOB that is used to populate the credential fields in the dialog box. Set the value of this parameter
/// to NULL to leave the credential fields empty.
/// </param>
/// <param name="ulInAuthBufferSize">The size, in bytes, of the pvInAuthBuffer buffer.</param>
/// <param name="ppvOutAuthBuffer">
/// The address of a pointer that, on output, specifies the credential BLOB. For Kerberos, NTLM, or Negotiate credentials, call the
/// CredUnPackAuthenticationBuffer function to convert this BLOB to string representations of the credentials.
/// <para>
/// When you have finished using the credential BLOB, clear it from memory by calling the SecureZeroMemory function, and free it by calling the
/// CoTaskMemFree function.
/// When you have finished using the credential BLOB, clear it from memory by calling the SecureZeroMemory function, and free it by
/// calling the CoTaskMemFree function.
/// </para>
/// </param>
/// <param name="pulOutAuthBufferSize">The size, in bytes, of the ppvOutAuthBuffer buffer.</param>
/// <param name="pfSave">
/// A pointer to a Boolean value that, on input, specifies whether the Save check box is selected in the dialog box that this function displays. On
/// output, the value of this parameter specifies whether the Save check box was selected when the user clicks the Submit button in the dialog box. Set
/// this parameter to NULL to ignore the Save check box.
/// A pointer to a Boolean value that, on input, specifies whether the Save check box is selected in the dialog box that this
/// function displays. On output, the value of this parameter specifies whether the Save check box was selected when the user clicks
/// the Submit button in the dialog box. Set this parameter to NULL to ignore the Save check box.
/// <para>This parameter is ignored if the CREDUIWIN_CHECKBOX flag is not set in the dwFlags parameter.</para>
/// </param>
/// <param name="dwFlags">
@ -451,53 +528,68 @@ namespace Vanara.PInvoke
/// <returns>Status of the operation is returned.</returns>
[DllImport(Lib.CredUI, CharSet = CharSet.Auto)]
[PInvokeData("wincred.h", MSDNShortId = "aa375178")]
public static extern int CredUIPromptForWindowsCredentials(ref CREDUI_INFO pUiInfo, int dwAuthError, ref uint pulAuthPackage, IntPtr pvInAuthBuffer, uint ulInAuthBufferSize, out IntPtr ppvOutAuthBuffer, out uint pulOutAuthBufferSize, [MarshalAs(UnmanagedType.Bool)] ref bool pfSave, WindowsCredentialsDialogOptions dwFlags);
public static extern Win32Error CredUIPromptForWindowsCredentials(in CREDUI_INFO pUiInfo, Win32Error dwAuthError, ref uint pulAuthPackage, IntPtr pvInAuthBuffer, uint ulInAuthBufferSize, out IntPtr ppvOutAuthBuffer, out uint pulOutAuthBufferSize, [MarshalAs(UnmanagedType.Bool)] ref bool pfSave, WindowsCredentialsDialogOptions dwFlags);
/// <summary>The CredUIReadSSOCred function retrieves the user name for a single logon credential.</summary>
/// <param name="pszRealm">Pointer to a null-terminated string that specifies the realm. If this parameter is NULL, the default realm is used.</param>
/// <param name="ppszUsername">Pointer to a pointer to a null-terminated string. When you have finished using the string, free ppszUsername by calling the LocalFree function.</param>
/// <param name="pszRealm">
/// Pointer to a null-terminated string that specifies the realm. If this parameter is NULL, the default realm is used.
/// </param>
/// <param name="ppszUsername">
/// Pointer to a pointer to a null-terminated string. When you have finished using the string, free ppszUsername by calling the
/// LocalFree function.
/// </param>
/// <returns>Status of the operation is returned.</returns>
[DllImport(Lib.CredUI, CharSet = CharSet.Auto)]
[PInvokeData("wincred.h", MSDNShortId = "aa375177")]
public static extern Win32Error CredUIReadSSOCred(string pszRealm, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(LocalStringMarshaler), MarshalCookie = "Auto")] out string ppszUsername);
/// <summary>The CredUIStoreSSOCred function stores a single logon credential.</summary>
/// <param name="pszRealm">Pointer to a null-terminated string that specifies the realm. If this parameter is NULL, the default realm is used.</param>
/// <param name="pszRealm">
/// Pointer to a null-terminated string that specifies the realm. If this parameter is NULL, the default realm is used.
/// </param>
/// <param name="pszUsername">Pointer to a null-terminated string that specifies the user's name.</param>
/// <param name="pszPassword">Pointer to a null-terminated string that specifies the user's password. When you have finished using the password, clear the password from memory by calling the SecureZeroMemory function. For more information about protecting passwords, see Handling Passwords.</param>
/// <param name="bPersist">Boolean value that specifies whether the credentials are persisted. If this value is TRUE, the credentials are persisted. If this value is FALSE, the credentials are not persisted.</param>
/// <param name="pszPassword">
/// Pointer to a null-terminated string that specifies the user's password. When you have finished using the password, clear the
/// password from memory by calling the SecureZeroMemory function. For more information about protecting passwords, see Handling Passwords.
/// </param>
/// <param name="bPersist">
/// Boolean value that specifies whether the credentials are persisted. If this value is TRUE, the credentials are persisted. If this
/// value is FALSE, the credentials are not persisted.
/// </param>
/// <returns>Status of the operation is returned.</returns>
[DllImport(Lib.CredUI, CharSet = CharSet.Auto)]
[PInvokeData("wincred.h", MSDNShortId = "aa375181")]
public static extern Win32Error CredUIStoreSSOCred(string pszRealm, string pszUsername, string pszPassword, [MarshalAs(UnmanagedType.Bool)] bool bPersist);
/// <summary>
/// The CredUnPackAuthenticationBuffer function converts an authentication buffer returned by a call to the CredUIPromptForWindowsCredentials function
/// into a string user name and password.
/// The CredUnPackAuthenticationBuffer function converts an authentication buffer returned by a call to the
/// CredUIPromptForWindowsCredentials function into a string user name and password.
/// </summary>
/// <param name="dwFlags">
/// Setting the value of this parameter to CRED_PACK_PROTECTED_CREDENTIALS specifies that the function attempts to decrypt the credentials in the
/// authentication buffer. If the credential cannot be decrypted, the function returns FALSE, and a call to the GetLastError function will return the
/// value ERROR_NOT_CAPABLE.
/// Setting the value of this parameter to CRED_PACK_PROTECTED_CREDENTIALS specifies that the function attempts to decrypt the
/// credentials in the authentication buffer. If the credential cannot be decrypted, the function returns FALSE, and a call to the
/// GetLastError function will return the value ERROR_NOT_CAPABLE.
/// <para>How the decryption is done depends on the format of the authentication buffer.</para>
/// <para>
/// If the authentication buffer is a SEC_WINNT_AUTH_IDENTITY_EX2 structure, the function can decrypt the buffer if it is encrypted by using
/// SspiEncryptAuthIdentityEx with the SEC_WINNT_AUTH_IDENTITY_ENCRYPT_SAME_LOGON option.
/// If the authentication buffer is a SEC_WINNT_AUTH_IDENTITY_EX2 structure, the function can decrypt the buffer if it is encrypted
/// by using SspiEncryptAuthIdentityEx with the SEC_WINNT_AUTH_IDENTITY_ENCRYPT_SAME_LOGON option.
/// </para>
/// <para>
/// If the authentication buffer is one of the marshaled KERB_*_LOGON structures, the function decrypts the password before returning it in the
/// pszPassword buffer.
/// If the authentication buffer is one of the marshaled KERB_*_LOGON structures, the function decrypts the password before returning
/// it in the pszPassword buffer.
/// </para>
/// </param>
/// <param name="pAuthBuffer">
/// A pointer to the authentication buffer to be converted.
/// <para>
/// This buffer is typically the output of the CredUIPromptForWindowsCredentials or CredPackAuthenticationBuffer function. This must be one of the
/// following types:
/// This buffer is typically the output of the CredUIPromptForWindowsCredentials or CredPackAuthenticationBuffer function. This must
/// be one of the following types:
/// </para>
/// <list type="bullet">
/// <item>
/// <term>A SEC_WINNT_AUTH_IDENTITY_EX2 structure for identity credentials. The function does not accept other SEC_WINNT_AUTH_IDENTITY structures.</term>
/// <term>
/// A SEC_WINNT_AUTH_IDENTITY_EX2 structure for identity credentials. The function does not accept other SEC_WINNT_AUTH_IDENTITY structures.
/// </term>
/// </item>
/// <item>
/// <term>A KERB_INTERACTIVE_LOGON or KERB_INTERACTIVE_UNLOCK_LOGON structure for password credentials.</term>
@ -516,57 +608,59 @@ namespace Vanara.PInvoke
/// <para>This string can be a marshaled credential. See Remarks.</para>
/// </param>
/// <param name="pcchMaxUserName">
/// A pointer to a DWORD value that specifies the size, in characters, of the pszUserName buffer. On output, if the buffer is not of sufficient size,
/// specifies the required size, in characters, of the pszUserName buffer. The size includes terminating null character.
/// A pointer to a DWORD value that specifies the size, in characters, of the pszUserName buffer. On output, if the buffer is not of
/// sufficient size, specifies the required size, in characters, of the pszUserName buffer. The size includes terminating null character.
/// </param>
/// <param name="pszDomainName">A pointer to a null-terminated string that receives the name of the user's domain.</param>
/// <param name="pcchMaxDomainame">
/// A pointer to a DWORD value that specifies the size, in characters, of the pszDomainName buffer. On output, if the buffer is not of sufficient size,
/// specifies the required size, in characters, of the pszDomainName buffer. The size includes the terminating null character. The required size can be
/// zero if there is no domain name.
/// A pointer to a DWORD value that specifies the size, in characters, of the pszDomainName buffer. On output, if the buffer is not
/// of sufficient size, specifies the required size, in characters, of the pszDomainName buffer. The size includes the terminating
/// null character. The required size can be zero if there is no domain name.
/// </param>
/// <param name="pszPassword">A pointer to a null-terminated string that receives the password.</param>
/// <param name="pcchMaxPassword">
/// A pointer to a DWORD value that specifies the size, in characters, of the pszPassword buffer. On output, if the buffer is not of sufficient size,
/// specifies the required size, in characters, of the pszPassword buffer. The size includes the terminating null character.
/// A pointer to a DWORD value that specifies the size, in characters, of the pszPassword buffer. On output, if the buffer is not of
/// sufficient size, specifies the required size, in characters, of the pszPassword buffer. The size includes the terminating null character.
/// <para>This string can be a marshaled credential. See Remarks.</para>
/// </param>
/// <returns>
/// TRUE if the function succeeds; otherwise, FALSE. For extended error information, call the GetLastError function.The following table shows common
/// values for the GetLastError function.
/// TRUE if the function succeeds; otherwise, FALSE. For extended error information, call the GetLastError function.The following
/// table shows common values for the GetLastError function.
/// </returns>
[DllImport(Lib.CredUI, CharSet = CharSet.Auto, SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
[PInvokeData("wincred.h", MSDNShortId = "aa375185")]
public static extern bool CredUnPackAuthenticationBuffer(int dwFlags, IntPtr pAuthBuffer, int cbAuthBuffer, StringBuilder pszUserName, ref int pcchMaxUserName, StringBuilder pszDomainName, ref int pcchMaxDomainame, StringBuilder pszPassword, ref int pcchMaxPassword);
public static extern bool CredUnPackAuthenticationBuffer(CredPackFlags dwFlags, IntPtr pAuthBuffer, int cbAuthBuffer, StringBuilder pszUserName, ref int pcchMaxUserName, StringBuilder pszDomainName, ref int pcchMaxDomainame, StringBuilder pszPassword, ref int pcchMaxPassword);
/// <summary>
/// The CredUnPackAuthenticationBuffer function converts an authentication buffer returned by a call to the CredUIPromptForWindowsCredentials function
/// into a string user name and password.
/// The CredUnPackAuthenticationBuffer function converts an authentication buffer returned by a call to the
/// CredUIPromptForWindowsCredentials function into a string user name and password.
/// </summary>
/// <param name="dwFlags">
/// Setting the value of this parameter to CRED_PACK_PROTECTED_CREDENTIALS specifies that the function attempts to decrypt the credentials in the
/// authentication buffer. If the credential cannot be decrypted, the function returns FALSE, and a call to the GetLastError function will return the
/// value ERROR_NOT_CAPABLE.
/// Setting the value of this parameter to CRED_PACK_PROTECTED_CREDENTIALS specifies that the function attempts to decrypt the
/// credentials in the authentication buffer. If the credential cannot be decrypted, the function returns FALSE, and a call to the
/// GetLastError function will return the value ERROR_NOT_CAPABLE.
/// <para>How the decryption is done depends on the format of the authentication buffer.</para>
/// <para>
/// If the authentication buffer is a SEC_WINNT_AUTH_IDENTITY_EX2 structure, the function can decrypt the buffer if it is encrypted by using
/// SspiEncryptAuthIdentityEx with the SEC_WINNT_AUTH_IDENTITY_ENCRYPT_SAME_LOGON option.
/// If the authentication buffer is a SEC_WINNT_AUTH_IDENTITY_EX2 structure, the function can decrypt the buffer if it is encrypted
/// by using SspiEncryptAuthIdentityEx with the SEC_WINNT_AUTH_IDENTITY_ENCRYPT_SAME_LOGON option.
/// </para>
/// <para>
/// If the authentication buffer is one of the marshaled KERB_*_LOGON structures, the function decrypts the password before returning it in the
/// pszPassword buffer.
/// If the authentication buffer is one of the marshaled KERB_*_LOGON structures, the function decrypts the password before returning
/// it in the pszPassword buffer.
/// </para>
/// </param>
/// <param name="pAuthBuffer">
/// A pointer to the authentication buffer to be converted.
/// <para>
/// This buffer is typically the output of the CredUIPromptForWindowsCredentials or CredPackAuthenticationBuffer function. This must be one of the
/// following types:
/// This buffer is typically the output of the CredUIPromptForWindowsCredentials or CredPackAuthenticationBuffer function. This must
/// be one of the following types:
/// </para>
/// <list type="bullet">
/// <item>
/// <term>A SEC_WINNT_AUTH_IDENTITY_EX2 structure for identity credentials. The function does not accept other SEC_WINNT_AUTH_IDENTITY structures.</term>
/// <term>
/// A SEC_WINNT_AUTH_IDENTITY_EX2 structure for identity credentials. The function does not accept other SEC_WINNT_AUTH_IDENTITY structures.
/// </term>
/// </item>
/// <item>
/// <term>A KERB_INTERACTIVE_LOGON or KERB_INTERACTIVE_UNLOCK_LOGON structure for password credentials.</term>
@ -585,32 +679,33 @@ namespace Vanara.PInvoke
/// <para>This string can be a marshaled credential. See Remarks.</para>
/// </param>
/// <param name="pcchMaxUserName">
/// A pointer to a DWORD value that specifies the size, in characters, of the pszUserName buffer. On output, if the buffer is not of sufficient size,
/// specifies the required size, in characters, of the pszUserName buffer. The size includes terminating null character.
/// A pointer to a DWORD value that specifies the size, in characters, of the pszUserName buffer. On output, if the buffer is not of
/// sufficient size, specifies the required size, in characters, of the pszUserName buffer. The size includes terminating null character.
/// </param>
/// <param name="pszDomainName">A pointer to a null-terminated string that receives the name of the user's domain.</param>
/// <param name="pcchMaxDomainame">
/// A pointer to a DWORD value that specifies the size, in characters, of the pszDomainName buffer. On output, if the buffer is not of sufficient size,
/// specifies the required size, in characters, of the pszDomainName buffer. The size includes the terminating null character. The required size can be
/// zero if there is no domain name.
/// A pointer to a DWORD value that specifies the size, in characters, of the pszDomainName buffer. On output, if the buffer is not
/// of sufficient size, specifies the required size, in characters, of the pszDomainName buffer. The size includes the terminating
/// null character. The required size can be zero if there is no domain name.
/// </param>
/// <param name="pszPassword">A pointer to a null-terminated string that receives the password.</param>
/// <param name="pcchMaxPassword">
/// A pointer to a DWORD value that specifies the size, in characters, of the pszPassword buffer. On output, if the buffer is not of sufficient size,
/// specifies the required size, in characters, of the pszPassword buffer. The size includes the terminating null character.
/// A pointer to a DWORD value that specifies the size, in characters, of the pszPassword buffer. On output, if the buffer is not of
/// sufficient size, specifies the required size, in characters, of the pszPassword buffer. The size includes the terminating null character.
/// <para>This string can be a marshaled credential. See Remarks.</para>
/// </param>
/// <returns>
/// TRUE if the function succeeds; otherwise, FALSE. For extended error information, call the GetLastError function.The following table shows common
/// values for the GetLastError function.
/// TRUE if the function succeeds; otherwise, FALSE. For extended error information, call the GetLastError function.The following
/// table shows common values for the GetLastError function.
/// </returns>
[DllImport(Lib.CredUI, CharSet = CharSet.Auto, SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
[PInvokeData("wincred.h", MSDNShortId = "aa375173")]
public static extern bool CredUnPackAuthenticationBuffer(int dwFlags, IntPtr pAuthBuffer, int cbAuthBuffer, IntPtr pszUserName, ref int pcchMaxUserName, IntPtr pszDomainName, ref int pcchMaxDomainame, IntPtr pszPassword, ref int pcchMaxPassword);
public static extern bool CredUnPackAuthenticationBuffer(CredPackFlags dwFlags, IntPtr pAuthBuffer, int cbAuthBuffer, IntPtr pszUserName, ref int pcchMaxUserName, IntPtr pszDomainName, ref int pcchMaxDomainame, IntPtr pszPassword, ref int pcchMaxPassword);
/// <summary>
/// The CREDUI_INFO structure is used to pass information to the CredUIPromptForCredentials function that creates a dialog box used to obtain credentials information.
/// The CREDUI_INFO structure is used to pass information to the CredUIPromptForCredentials function that creates a dialog box used
/// to obtain credentials information.
/// </summary>
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
[PInvokeData("wincred.h", MSDNShortId = "aa375183")]
@ -620,19 +715,23 @@ namespace Vanara.PInvoke
public int cbSize;
/// <summary>
/// Specifies the handle to the parent window of the dialog box. The dialog box is modal with respect to the parent window. If this member is NULL,
/// the desktop is the parent window of the dialog box.
/// Specifies the handle to the parent window of the dialog box. The dialog box is modal with respect to the parent window. If
/// this member is NULL, the desktop is the parent window of the dialog box.
/// </summary>
public IntPtr hwndParent;
public HWND hwndParent;
/// <summary>Pointer to a string containing a brief message to display in the dialog box. The length of this string should not exceed CREDUI_MAX_MESSAGE_LENGTH.</summary>
/// <summary>
/// Pointer to a string containing a brief message to display in the dialog box. The length of this string should not exceed CREDUI_MAX_MESSAGE_LENGTH.
/// </summary>
public string pszMessageText;
/// <summary>Pointer to a string containing the title for the dialog box. The length of this string should not exceed CREDUI_MAX_CAPTION_LENGTH.</summary>
public string pszCaptionText;
/// <summary>Bitmap to display in the dialog box. If this member is NULL, a default bitmap is used. The bitmap size is limited to 320x60 pixels.</summary>
public IntPtr hbmBanner;
/// <summary>
/// Bitmap to display in the dialog box. If this member is NULL, a default bitmap is used. The bitmap size is limited to 320x60 pixels.
/// </summary>
public HBITMAP hbmBanner;
/// <summary>Initializes a new instance of the <see cref="CREDUI_INFO"/> struct.</summary>
/// <param name="hwndOwner">Specifies the handle to the parent window of the dialog box.</param>
@ -648,7 +747,7 @@ namespace Vanara.PInvoke
if (message?.Length > CREDUI_MAX_MESSAGE_LENGTH)
throw new ArgumentOutOfRangeException(nameof(message), $"The message may not be longer than {CREDUI_MAX_MESSAGE_LENGTH}.");
pszMessageText = message;
hbmBanner = IntPtr.Zero;
hbmBanner = HBITMAP.NULL;
}
}
}

View File

@ -28,7 +28,7 @@ Structures
CERT_CONTEXT, CERT_EXTENSION, CERT_INFO, CERT_PUBLIC_KEY_INFO, CRYPT_ALGORITHM_IDENTIFIER, CRYPTOAPI_BLOB
</PackageReleaseNotes>
<LangVersion>latest</LangVersion>
<LangVersion>latest</LangVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)'=='Release'">
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>

View File

@ -2,11 +2,6 @@
using System.Runtime.InteropServices;
using Vanara.InteropServices;
using FILETIME = System.Runtime.InteropServices.ComTypes.FILETIME;
// ReSharper disable FieldCanBeMadeReadOnly.Global
// ReSharper disable UnusedMember.Global
// ReSharper disable InconsistentNaming
// ReSharper disable MemberCanBePrivate.Global
// ReSharper disable UnusedMember.Local
namespace Vanara.PInvoke
{
@ -14,47 +9,55 @@ namespace Vanara.PInvoke
public static partial class Crypt32
{
/// <summary>
/// The CERT_CONTEXT structure contains both the encoded and decoded representations of a certificate. A certificate context returned by one of the
/// functions defined in Wincrypt.h must be freed by calling the CertFreeCertificateContext function. The CertDuplicateCertificateContext function can be
/// called to make a duplicate copy (which also must be freed by calling CertFreeCertificateContext).
/// The CERT_CONTEXT structure contains both the encoded and decoded representations of a certificate. A certificate context returned
/// by one of the functions defined in Wincrypt.h must be freed by calling the CertFreeCertificateContext function. The
/// CertDuplicateCertificateContext function can be called to make a duplicate copy (which also must be freed by calling CertFreeCertificateContext).
/// </summary>
[StructLayout(LayoutKind.Sequential)]
public struct CERT_CONTEXT
{
/// <summary>
/// Type of encoding used. It is always acceptable to specify both the certificate and message encoding types by combining them with a bitwise-OR operation.
/// Type of encoding used. It is always acceptable to specify both the certificate and message encoding types by combining them
/// with a bitwise-OR operation.
/// </summary>
public uint dwCertEncodingType;
/// <summary>A pointer to a buffer that contains the encoded certificate.</summary>
public IntPtr pbCertEncoded;
/// <summary>The size, in bytes, of the encoded certificate.</summary>
public uint cbCertEncoded;
/// <summary>The address of a CERT_INFO structure that contains the certificate information.</summary>
public IntPtr pCertInfo;
/// <summary>A handle to the certificate store that contains the certificate context.</summary>
public IntPtr hCertStore;
}
/// <summary>
/// The CERT_EXTENSION structure contains the extension information for a certificate, Certificate Revocation List (CRL) or Certificate Trust List (CTL).
/// The CERT_EXTENSION structure contains the extension information for a certificate, Certificate Revocation List (CRL) or
/// Certificate Trust List (CTL).
/// </summary>
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
public struct CERT_EXTENSION
{
/// <summary>
/// Object identifier (OID) that specifies the structure of the extension data contained in the Value member. For specifics on extension OIDs and
/// their related structures, see X.509 Certificate Extension Structures.
/// Object identifier (OID) that specifies the structure of the extension data contained in the Value member. For specifics on
/// extension OIDs and their related structures, see X.509 Certificate Extension Structures.
/// </summary>
public StrPtrAnsi pszObjId;
/// <summary>
/// If TRUE, any limitations specified by the extension in the Value member of this structure are imperative. If FALSE, limitations set by this
/// extension can be ignored.
/// If TRUE, any limitations specified by the extension in the Value member of this structure are imperative. If FALSE,
/// limitations set by this extension can be ignored.
/// </summary>
[MarshalAs(UnmanagedType.Bool)]
public bool fCritical;
/// <summary>
/// A CRYPT_OBJID_BLOB structure that contains the encoded extension data. The cbData member of Value indicates the length in bytes of the pbData
/// member. The pbData member byte string is the encoded extension.e
/// A CRYPT_OBJID_BLOB structure that contains the encoded extension data. The cbData member of Value indicates the length in
/// bytes of the pbData member. The pbData member byte string is the encoded extension.e
/// </summary>
public CRYPTOAPI_BLOB Value;
}
@ -65,43 +68,59 @@ namespace Vanara.PInvoke
{
/// <summary>The version number of a certificate.</summary>
public uint dwVersion;
/// <summary>
/// A BLOB that contains the serial number of a certificate. The least significant byte is the zero byte of the pbData member of SerialNumber. The
/// index for the last byte of pbData, is one less than the value of the cbData member of SerialNumber. The most significant byte is the last byte of
/// pbData. Leading 0x00 or 0xFF bytes are removed. For more information, see CertCompareIntegerBlob.
/// A BLOB that contains the serial number of a certificate. The least significant byte is the zero byte of the pbData member of
/// SerialNumber. The index for the last byte of pbData, is one less than the value of the cbData member of SerialNumber. The
/// most significant byte is the last byte of pbData. Leading 0x00 or 0xFF bytes are removed. For more information, see CertCompareIntegerBlob.
/// </summary>
public CRYPTOAPI_BLOB SerialNumber;
/// <summary>A CRYPT_ALGORITHM_IDENTIFIER structure that contains the signature algorithm type and encoded additional encryption parameters.</summary>
/// <summary>
/// A CRYPT_ALGORITHM_IDENTIFIER structure that contains the signature algorithm type and encoded additional encryption parameters.
/// </summary>
public CRYPT_ALGORITHM_IDENTIFIER SignatureAlgorithm;
/// <summary>The name, in encoded form, of the issuer of the certificate.</summary>
public CRYPTOAPI_BLOB Issuer;
/// <summary>
/// Date and time before which the certificate is not valid. For dates between 1950 and 2049 inclusive, the date and time is encoded Coordinated
/// Universal Time (Greenwich Mean Time) format in the form YYMMDDHHMMSS. This member uses a two-digit year and is precise to seconds. For dates
/// before 1950 or after 2049, encoded generalized time is used. Encoded generalized time is in the form YYYYMMDDHHMMSSMMM, using a four-digit year,
/// and is precise to milliseconds. Even though generalized time supports millisecond resolution, the NotBefore time is only precise to seconds.
/// Date and time before which the certificate is not valid. For dates between 1950 and 2049 inclusive, the date and time is
/// encoded Coordinated Universal Time (Greenwich Mean Time) format in the form YYMMDDHHMMSS. This member uses a two-digit year
/// and is precise to seconds. For dates before 1950 or after 2049, encoded generalized time is used. Encoded generalized time is
/// in the form YYYYMMDDHHMMSSMMM, using a four-digit year, and is precise to milliseconds. Even though generalized time supports
/// millisecond resolution, the NotBefore time is only precise to seconds.
/// </summary>
public FILETIME NotBefore;
/// <summary>
/// Date and time after which the certificate is not valid. For dates between 1950 and 2049 inclusive, the date and time is encoded Coordinated
/// Universal Time format in the form YYMMDDHHMMSS. This member uses a two-digit year and is precise to seconds. For dates before 1950 or after 2049,
/// encoded generalized time is used. Encoded generalized time is in the form YYYYMMDDHHMMSSMMM, using a four-digit year, and is precise to
/// milliseconds. Even though generalized time supports millisecond resolution, the NotAfter time is only precise to seconds.
/// Date and time after which the certificate is not valid. For dates between 1950 and 2049 inclusive, the date and time is
/// encoded Coordinated Universal Time format in the form YYMMDDHHMMSS. This member uses a two-digit year and is precise to
/// seconds. For dates before 1950 or after 2049, encoded generalized time is used. Encoded generalized time is in the form
/// YYYYMMDDHHMMSSMMM, using a four-digit year, and is precise to milliseconds. Even though generalized time supports millisecond
/// resolution, the NotAfter time is only precise to seconds.
/// </summary>
public FILETIME NotAfter;
/// <summary>The encoded name of the subject of the certificate.</summary>
public CRYPTOAPI_BLOB Subject;
/// <summary>
/// A CERT_PUBLIC_KEY_INFO structure that contains the encoded public key and its algorithm. The PublicKey member of the CERT_PUBLIC_KEY_INFO
/// structure contains the encoded public key as a CRYPT_BIT_BLOB, and the Algorithm member contains the encoded algorithm as a CRYPT_ALGORITHM_IDENTIFIER.
/// A CERT_PUBLIC_KEY_INFO structure that contains the encoded public key and its algorithm. The PublicKey member of the
/// CERT_PUBLIC_KEY_INFO structure contains the encoded public key as a CRYPT_BIT_BLOB, and the Algorithm member contains the
/// encoded algorithm as a CRYPT_ALGORITHM_IDENTIFIER.
/// </summary>
public CERT_PUBLIC_KEY_INFO SubjectPublicKeyInfo;
/// <summary>A BLOB that contains a unique identifier of the issuer.</summary>
public CRYPTOAPI_BLOB IssuerUniqueId;
/// <summary>A BLOB that contains a unique identifier of the subject.</summary>
public CRYPTOAPI_BLOB SubjectUniqueId;
/// <summary>The number of elements in the rgExtension array.</summary>
public uint cExtension;
/// <summary>An array of pointers to CERT_EXTENSION structures, each of which contains extension information about the certificate.</summary>
public IntPtr rgExtension;
}
@ -112,31 +131,39 @@ namespace Vanara.PInvoke
{
/// <summary>CRYPT_ALGORITHM_IDENTIFIER structure that contains the public key algorithm type and associated additional parameters.</summary>
public CRYPT_ALGORITHM_IDENTIFIER Algorithm;
/// <summary>BLOB containing an encoded public key.</summary>
public CRYPTOAPI_BLOB PublicKey;
}
/// <summary>
/// The CRYPT_ALGORITHM_IDENTIFIER structure specifies an algorithm used to encrypt a private key. The structure includes the object identifier (OID) of
/// the algorithm and any needed parameters for that algorithm. The parameters contained in its CRYPT_OBJID_BLOB are encoded.
/// The CRYPT_ALGORITHM_IDENTIFIER structure specifies an algorithm used to encrypt a private key. The structure includes the object
/// identifier (OID) of the algorithm and any needed parameters for that algorithm. The parameters contained in its CRYPT_OBJID_BLOB
/// are encoded.
/// </summary>
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
public struct CRYPT_ALGORITHM_IDENTIFIER
{
/// <summary>An OID of an algorithm.</summary>
public StrPtrAnsi pszObjId;
/// <summary>A BLOB that provides encoded algorithm-specific parameters. In many cases, there are no parameters. This is indicated by setting the cbData member of the Parameters BLOB to zero.</summary>
/// <summary>
/// A BLOB that provides encoded algorithm-specific parameters. In many cases, there are no parameters. This is indicated by
/// setting the cbData member of the Parameters BLOB to zero.
/// </summary>
public CRYPTOAPI_BLOB Parameters;
}
/// <summary>
/// The BLOB structure contains an arbitrary array of bytes. The structure definition includes aliases appropriate to the various functions that use it.
/// The BLOB structure contains an arbitrary array of bytes. The structure definition includes aliases appropriate to the various
/// functions that use it.
/// </summary>
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
public struct CRYPTOAPI_BLOB
{
/// <summary>A DWORD variable that contains the count, in bytes, of data.</summary>
public uint cbData;
/// <summary>A pointer to the data buffer.</summary>
public IntPtr pbData;
}

View File

@ -30,7 +30,6 @@ Native Method | Native DLL | Header | Managed Method
### Structures
Native Structure | Header | Managed Structure
--- | --- | ---
[DWM_BLURBEHIND](https://www.google.com/search?num=5&q=DWM_BLURBEHIND+site%3Amicrosoft.com) | dwmapi.h | Vanara.PInvoke.DwmApi+DWM_BLURBEHIND
[DWM_COLORIZATION_PARAMS](https://www.google.com/search?num=5&q=DWM_COLORIZATION_PARAMS+site%3Amicrosoft.com) | dwmapi.h | Vanara.PInvoke.DwmApi+DWM_COLORIZATION_PARAMS
[DWM_THUMBNAIL_PROPERTIES](http://msdn2.microsoft.com/en-us/library/aa969502) | Dwmapi.h | Vanara.PInvoke.DwmApi+DWM_THUMBNAIL_PROPERTIES
[DWM_TIMING_INFO](https://www.google.com/search?num=5&q=DWM_TIMING_INFO+site%3Amicrosoft.com) | dwmapi.h | Vanara.PInvoke.DwmApi+DWM_TIMING_INFO

View File

@ -102,7 +102,9 @@ namespace Vanara.PInvoke
[PInvokeData("dwmapi.h")]
public enum DWMFLIP3DWINDOWPOLICY
{
/// <summary>Use the window's style and visibility settings to determine whether to hide or include the window in Flip3D rendering.</summary>
/// <summary>
/// Use the window's style and visibility settings to determine whether to hide or include the window in Flip3D rendering.
/// </summary>
DWMFLIP3D_DEFAULT,
/// <summary>Exclude the window from Flip3D and display it below the Flip3D rendering.</summary>
@ -143,93 +145,101 @@ namespace Vanara.PInvoke
DWMTRANSITION_OWNEDWINDOW_REPOSITION = 0,
}
/// <summary>Flags used by the DwmGetWindowAttribute and DwmSetWindowAttribute functions to specify window attributes for non-client rendering.</summary>
/// <summary>
/// Flags used by the DwmGetWindowAttribute and DwmSetWindowAttribute functions to specify window attributes for non-client rendering.
/// </summary>
[PInvokeData("dwmapi.h")]
public enum DWMWINDOWATTRIBUTE
{
/// <summary>
/// Use with DwmGetWindowAttribute. Discovers whether non-client rendering is enabled. The retrieved value is of type BOOL. TRUE if non-client
/// rendering is enabled; otherwise, FALSE.
/// Use with DwmGetWindowAttribute. Discovers whether non-client rendering is enabled. The retrieved value is of type BOOL. TRUE
/// if non-client rendering is enabled; otherwise, FALSE.
/// </summary>
[CorrespondingType(typeof(bool), CorrepsondingAction.Get)]
DWMWA_NCRENDERING_ENABLED = 1,
/// <summary>
/// Use with DwmSetWindowAttribute. Sets the non-client rendering policy. The pvAttribute parameter points to a value from the DWMNCRENDERINGPOLICY enumeration.
/// Use with DwmSetWindowAttribute. Sets the non-client rendering policy. The pvAttribute parameter points to a value from the
/// DWMNCRENDERINGPOLICY enumeration.
/// </summary>
[CorrespondingType(typeof(DWMNCRENDERINGPOLICY), CorrepsondingAction.Set)]
DWMWA_NCRENDERING_POLICY,
/// <summary>
/// Use with DwmSetWindowAttribute. Enables or forcibly disables DWM transitions. The pvAttribute parameter points to a value of TRUE to disable
/// transitions or FALSE to enable transitions.
/// Use with DwmSetWindowAttribute. Enables or forcibly disables DWM transitions. The pvAttribute parameter points to a value of
/// TRUE to disable transitions or FALSE to enable transitions.
/// </summary>
[CorrespondingType(typeof(bool), CorrepsondingAction.Set)]
DWMWA_TRANSITIONS_FORCEDISABLED,
/// <summary>
/// Use with DwmSetWindowAttribute. Enables content rendered in the non-client area to be visible on the frame drawn by DWM. The pvAttribute
/// parameter points to a value of TRUE to enable content rendered in the non-client area to be visible on the frame; otherwise, it points to FALSE.
/// Use with DwmSetWindowAttribute. Enables content rendered in the non-client area to be visible on the frame drawn by DWM. The
/// pvAttribute parameter points to a value of TRUE to enable content rendered in the non-client area to be visible on the frame;
/// otherwise, it points to FALSE.
/// </summary>
[CorrespondingType(typeof(bool), CorrepsondingAction.Set)]
DWMWA_ALLOW_NCPAINT,
/// <summary>
/// Use with DwmGetWindowAttribute. Retrieves the bounds of the caption button area in the window-relative space. The retrieved value is of type RECT.
/// Use with DwmGetWindowAttribute. Retrieves the bounds of the caption button area in the window-relative space. The retrieved
/// value is of type RECT.
/// </summary>
[CorrespondingType(typeof(RECT), CorrepsondingAction.Get)]
DWMWA_CAPTION_BUTTON_BOUNDS,
/// <summary>
/// Use with DwmSetWindowAttribute. Specifies whether non-client content is right-to-left (RTL) mirrored. The pvAttribute parameter points to a value
/// of TRUE if the non-client content is right-to-left (RTL) mirrored; otherwise, it points to FALSE.
/// Use with DwmSetWindowAttribute. Specifies whether non-client content is right-to-left (RTL) mirrored. The pvAttribute
/// parameter points to a value of TRUE if the non-client content is right-to-left (RTL) mirrored; otherwise, it points to FALSE.
/// </summary>
[CorrespondingType(typeof(bool), CorrepsondingAction.Set)]
DWMWA_NONCLIENT_RTL_LAYOUT,
/// <summary>
/// Use with DwmSetWindowAttribute. Forces the window to display an iconic thumbnail or peek representation (a static bitmap), even if a live or
/// snapshot representation of the window is available. This value normally is set during a window's creation and not changed throughout the window's
/// lifetime. Some scenarios, however, might require the value to change over time. The pvAttribute parameter points to a value of TRUE to require a
/// iconic thumbnail or peek representation; otherwise, it points to FALSE.
/// Use with DwmSetWindowAttribute. Forces the window to display an iconic thumbnail or peek representation (a static bitmap),
/// even if a live or snapshot representation of the window is available. This value normally is set during a window's creation
/// and not changed throughout the window's lifetime. Some scenarios, however, might require the value to change over time. The
/// pvAttribute parameter points to a value of TRUE to require a iconic thumbnail or peek representation; otherwise, it points to FALSE.
/// </summary>
[CorrespondingType(typeof(bool), CorrepsondingAction.Set)]
DWMWA_FORCE_ICONIC_REPRESENTATION,
/// <summary>
/// Use with DwmSetWindowAttribute. Sets how Flip3D treats the window. The pvAttribute parameter points to a value from the DWMFLIP3DWINDOWPOLICY enumeration.
/// Use with DwmSetWindowAttribute. Sets how Flip3D treats the window. The pvAttribute parameter points to a value from the
/// DWMFLIP3DWINDOWPOLICY enumeration.
/// </summary>
[CorrespondingType(typeof(DWMFLIP3DWINDOWPOLICY), CorrepsondingAction.Set)]
DWMWA_FLIP3D_POLICY,
/// <summary>Use with DwmGetWindowAttribute. Retrieves the extended frame bounds rectangle in screen space. The retrieved value is of type RECT.</summary>
/// <summary>
/// Use with DwmGetWindowAttribute. Retrieves the extended frame bounds rectangle in screen space. The retrieved value is of type RECT.
/// </summary>
[CorrespondingType(typeof(RECT), CorrepsondingAction.Get)]
DWMWA_EXTENDED_FRAME_BOUNDS,
/// <summary>
/// Use with DwmSetWindowAttribute. The window will provide a bitmap for use by DWM as an iconic thumbnail or peek representation (a static bitmap)
/// for the window. DWMWA_HAS_ICONIC_BITMAP can be specified with DWMWA_FORCE_ICONIC_REPRESENTATION. DWMWA_HAS_ICONIC_BITMAP normally is set during a
/// window's creation and not changed throughout the window's lifetime. Some scenarios, however, might require the value to change over time. The
/// pvAttribute parameter points to a value of TRUE to inform DWM that the window will provide an iconic thumbnail or peek representation; otherwise,
/// it points to FALSE.
/// Use with DwmSetWindowAttribute. The window will provide a bitmap for use by DWM as an iconic thumbnail or peek representation
/// (a static bitmap) for the window. DWMWA_HAS_ICONIC_BITMAP can be specified with DWMWA_FORCE_ICONIC_REPRESENTATION.
/// DWMWA_HAS_ICONIC_BITMAP normally is set during a window's creation and not changed throughout the window's lifetime. Some
/// scenarios, however, might require the value to change over time. The pvAttribute parameter points to a value of TRUE to
/// inform DWM that the window will provide an iconic thumbnail or peek representation; otherwise, it points to FALSE.
/// <para><c>Windows Vista and earlier:</c> This value is not supported.</para>
/// </summary>
[CorrespondingType(typeof(bool), CorrepsondingAction.Set)]
DWMWA_HAS_ICONIC_BITMAP,
/// <summary>
/// Use with DwmSetWindowAttribute. Do not show peek preview for the window. The peek view shows a full-sized preview of the window when the mouse
/// hovers over the window's thumbnail in the taskbar. If this attribute is set, hovering the mouse pointer over the window's thumbnail dismisses
/// peek (in case another window in the group has a peek preview showing). The pvAttribute parameter points to a value of TRUE to prevent peek
/// functionality or FALSE to allow it.
/// Use with DwmSetWindowAttribute. Do not show peek preview for the window. The peek view shows a full-sized preview of the
/// window when the mouse hovers over the window's thumbnail in the taskbar. If this attribute is set, hovering the mouse pointer
/// over the window's thumbnail dismisses peek (in case another window in the group has a peek preview showing). The pvAttribute
/// parameter points to a value of TRUE to prevent peek functionality or FALSE to allow it.
/// <para><c>Windows Vista and earlier:</c> This value is not supported.</para>
/// </summary>
[CorrespondingType(typeof(bool), CorrepsondingAction.Set)]
DWMWA_DISALLOW_PEEK,
/// <summary>
/// Use with DwmSetWindowAttribute. Prevents a window from fading to a glass sheet when peek is invoked. The pvAttribute parameter points to a value
/// of TRUE to prevent the window from fading during another window's peek or FALSE for normal behavior.
/// Use with DwmSetWindowAttribute. Prevents a window from fading to a glass sheet when peek is invoked. The pvAttribute
/// parameter points to a value of TRUE to prevent the window from fading during another window's peek or FALSE for normal behavior.
/// <para><c>Windows Vista and earlier:</c> This value is not supported.</para>
/// </summary>
[CorrespondingType(typeof(bool), CorrepsondingAction.Set)]
@ -238,9 +248,9 @@ namespace Vanara.PInvoke
/// <summary>
/// Use with DwmSetWindowAttribute. Cloaks the window such that it is not visible to the user. The window is still composed by DWM.
/// <para>
/// <c>Using with DirectComposition:</c> Use the DWMWA_CLOAK flag to cloak the layered child window when animating a representation of the window's
/// content via a DirectComposition visual which has been associated with the layered child window. For more details on this usage case, see How to
/// How to animate the bitmap of a layered child window.
/// <c>Using with DirectComposition:</c> Use the DWMWA_CLOAK flag to cloak the layered child window when animating a
/// representation of the window's content via a DirectComposition visual which has been associated with the layered child
/// window. For more details on this usage case, see How to How to animate the bitmap of a layered child window.
/// </para>
/// <para><c>Windows 7 and earlier:</c> This value is not supported.</para>
/// </summary>
@ -273,8 +283,8 @@ namespace Vanara.PInvoke
DWMWA_CLOAKED,
/// <summary>
/// Use with DwmSetWindowAttribute. Freeze the window's thumbnail image with its current visuals. Do no further live updates on the thumbnail image
/// to match the window's contents.
/// Use with DwmSetWindowAttribute. Freeze the window's thumbnail image with its current visuals. Do no further live updates on
/// the thumbnail image to match the window's contents.
/// <para><c>Windows 7 and earlier:</c> This value is not supported.</para>
/// </summary>
[CorrespondingType(typeof(bool), CorrepsondingAction.Set)]
@ -322,9 +332,15 @@ namespace Vanara.PInvoke
/// <summary>Default window procedure for Desktop Window Manager (DWM) hit testing within the non-client area.</summary>
/// <param name="hwnd">A handle to the window procedure that received the message.</param>
/// <param name="msg">The message.</param>
/// <param name="wParam">Specifies additional message information. The content of this parameter depends on the value of the msg parameter.</param>
/// <param name="lParam">Specifies additional message information. The content of this parameter depends on the value of the msg parameter.</param>
/// <param name="plResult">A pointer to an LRESULT value that, when this method returns successfully,receives the result of the hit test.</param>
/// <param name="wParam">
/// Specifies additional message information. The content of this parameter depends on the value of the msg parameter.
/// </param>
/// <param name="lParam">
/// Specifies additional message information. The content of this parameter depends on the value of the msg parameter.
/// </param>
/// <param name="plResult">
/// A pointer to an LRESULT value that, when this method returns successfully,receives the result of the hit test.
/// </param>
/// <returns>TRUE if DwmDefWindowProc handled the message; otherwise, FALSE.</returns>
[DllImport(Lib.DwmApi, ExactSpelling = true)]
[return: MarshalAs(UnmanagedType.Bool)]
@ -338,26 +354,29 @@ namespace Vanara.PInvoke
[DllImport(Lib.DwmApi, SetLastError = false, ExactSpelling = true)]
[System.Security.SecurityCritical]
[PInvokeData("dwmapi.h")]
public static extern HRESULT DwmEnableBlurBehindWindow(HWND hWnd, ref DWM_BLURBEHIND pDwmBlurbehind);
public static extern HRESULT DwmEnableBlurBehindWindow(HWND hWnd, in DWM_BLURBEHIND pDwmBlurbehind);
/// <summary>
/// Enables or disables Desktop Window Manager (DWM) composition. <note>This function is deprecated as of Windows 8. DWM can no longer be
/// programmatically disabled.</note>
/// Enables or disables Desktop Window Manager (DWM) composition. <note>This function is deprecated as of Windows 8. DWM can no
/// longer be programmatically disabled.</note>
/// </summary>
/// <param name="uCompositionAction">
/// DWM_EC_ENABLECOMPOSITION to enable DWM composition; DWM_EC_DISABLECOMPOSITION to disable composition. <note>As of Windows 8, calling this function
/// with DWM_EC_DISABLECOMPOSITION has no effect. However, the function will still return a success code.</note>
/// DWM_EC_ENABLECOMPOSITION to enable DWM composition; DWM_EC_DISABLECOMPOSITION to disable composition. <note>As of Windows 8,
/// calling this function with DWM_EC_DISABLECOMPOSITION has no effect. However, the function will still return a success code.</note>
/// </param>
/// <returns>If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.</returns>
[DllImport(Lib.DwmApi, SetLastError = false, ExactSpelling = true)]
[System.Security.SecurityCritical]
[PInvokeData("dwmapi.h")]
public static extern HRESULT DwmEnableComposition(int uCompositionAction);
public static extern HRESULT DwmEnableComposition([MarshalAs(UnmanagedType.Bool)] bool uCompositionAction);
/// <summary>
/// Notifies the Desktop Window Manager (DWM) to opt in to or out of Multimedia Class Schedule Service (MMCSS) scheduling while the calling process is alive.
/// Notifies the Desktop Window Manager (DWM) to opt in to or out of Multimedia Class Schedule Service (MMCSS) scheduling while the
/// calling process is alive.
/// </summary>
/// <param name="fEnableMMCSS">TRUE to instruct DWM to participate in MMCSS scheduling; FALSE to opt out or end participation in MMCSS scheduling.</param>
/// <param name="fEnableMMCSS">
/// TRUE to instruct DWM to participate in MMCSS scheduling; FALSE to opt out or end participation in MMCSS scheduling.
/// </param>
/// <returns>If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.</returns>
[DllImport(Lib.DwmApi, SetLastError = false, ExactSpelling = true)]
[PInvokeData("dwmapi.h")]
@ -365,16 +384,18 @@ namespace Vanara.PInvoke
/// <summary>Extends the window frame into the client area.</summary>
/// <param name="hWnd">The handle to the window in which the frame will be extended into the client area.</param>
/// <param name="pMarInset">A pointer to a MARGINS structure that describes the margins to use when extending the frame into the client area.</param>
/// <param name="pMarInset">
/// A pointer to a MARGINS structure that describes the margins to use when extending the frame into the client area.
/// </param>
/// <returns>If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.</returns>
[DllImport(Lib.DwmApi, SetLastError = false, ExactSpelling = true)]
[System.Security.SecurityCritical]
[PInvokeData("dwmapi.h")]
public static extern HRESULT DwmExtendFrameIntoClientArea(HWND hWnd, ref MARGINS pMarInset);
public static extern HRESULT DwmExtendFrameIntoClientArea(HWND hWnd, in MARGINS pMarInset);
/// <summary>
/// Issues a flush call that blocks the caller until the next present, when all of the Microsoft DirectX surface updates that are currently outstanding
/// have been made. This compensates for very complex scenes or calling processes with very low priority.
/// Issues a flush call that blocks the caller until the next present, when all of the Microsoft DirectX surface updates that are
/// currently outstanding have been made. This compensates for very complex scenes or calling processes with very low priority.
/// </summary>
/// <returns>If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.</returns>
[DllImport(Lib.DwmApi, SetLastError = false, ExactSpelling = true)]
@ -382,38 +403,30 @@ namespace Vanara.PInvoke
public static extern HRESULT DwmFlush();
/// <summary>
/// Retrieves the current color used for Desktop Window Manager (DWM) glass composition. This value is based on the current color scheme and can be
/// modified by the user. Applications can listen for color changes by handling the WM_DWMCOLORIZATIONCOLORCHANGED notification.
/// Retrieves the current color used for Desktop Window Manager (DWM) glass composition. This value is based on the current color
/// scheme and can be modified by the user. Applications can listen for color changes by handling the WM_DWMCOLORIZATIONCOLORCHANGED notification.
/// </summary>
/// <param name="pcrColorization">
/// A pointer to a value that, when this function returns successfully, receives the current color used for glass composition. The color format of the
/// value is 0xAARRGGBB.
/// A pointer to a value that, when this function returns successfully, receives the current color used for glass composition. The
/// color format of the value is 0xAARRGGBB.
/// </param>
/// <param name="pfOpaqueBlend">
/// A pointer to a value that, when this function returns successfully, indicates whether the color is an opaque blend. TRUE if the color is an opaque
/// blend; otherwise, FALSE.
/// A pointer to a value that, when this function returns successfully, indicates whether the color is an opaque blend. TRUE if the
/// color is an opaque blend; otherwise, FALSE.
/// </param>
/// <returns>If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.</returns>
[DllImport(Lib.DwmApi, SetLastError = false, ExactSpelling = true)]
[PInvokeData("dwmapi.h")]
public static extern HRESULT DwmGetColorizationColor(out uint pcrColorization, [MarshalAs(UnmanagedType.Bool)] out bool pfOpaqueBlend);
/// <summary>Gets the colorization parameters.</summary>
/// <param name="parameters">The parameters.</param>
/// <returns>If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.</returns>
[DllImport(Lib.DwmApi, SetLastError = false, ExactSpelling = true)]
[System.Security.SecurityCritical]
[PInvokeData("dwmapi.h")]
public static extern HRESULT DwmpGetColorizationParameters(out DWM_COLORIZATION_PARAMS parameters);
/// <summary>Retrieves the current composition timing information for a specified window.</summary>
/// <param name="hwnd">
/// The handle to the window for which the composition timing information should be retrieved. Starting with Windows 8.1, this parameter must be set to
/// NULL. If this parameter is not set to NULL, DwmGetCompositionTimingInfo returns E_INVALIDARG.
/// The handle to the window for which the composition timing information should be retrieved. Starting with Windows 8.1, this
/// parameter must be set to NULL. If this parameter is not set to NULL, DwmGetCompositionTimingInfo returns E_INVALIDARG.
/// </param>
/// <param name="dwAttribute">
/// A pointer to a DWM_TIMING_INFO structure that, when this function returns successfully, receives the current composition timing information for the
/// window. The cbSize member of this structure must be set before this function is called.
/// A pointer to a DWM_TIMING_INFO structure that, when this function returns successfully, receives the current composition timing
/// information for the window. The cbSize member of this structure must be set before this function is called.
/// </param>
/// <returns>If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.</returns>
[DllImport(Lib.DwmApi, SetLastError = false, ExactSpelling = true)]
@ -422,7 +435,8 @@ namespace Vanara.PInvoke
/// <summary>Retrieves transport attributes.</summary>
/// <param name="pfIsRemoting">
/// A pointer to a BOOL value that indicates whether the transport supports remoting. TRUE if the transport supports remoting; otherwise, FALSE.
/// A pointer to a BOOL value that indicates whether the transport supports remoting. TRUE if the transport supports remoting;
/// otherwise, FALSE.
/// </param>
/// <param name="pfIsConnected">
/// A pointer to a BOOL value that indicates whether the transport is connected. TRUE if the transport is connected; otherwise, FALSE.
@ -437,10 +451,12 @@ namespace Vanara.PInvoke
/// <param name="hwnd">The handle to the window from which the attribute data is retrieved.</param>
/// <param name="dwAttribute">The attribute to retrieve, specified as a DWMWINDOWATTRIBUTE value.</param>
/// <param name="pvAttribute">
/// A pointer to a value that, when this function returns successfully, receives the current value of the attribute. The type of the retrieved value
/// depends on the value of the dwAttribute parameter.
/// A pointer to a value that, when this function returns successfully, receives the current value of the attribute. The type of the
/// retrieved value depends on the value of the dwAttribute parameter.
/// </param>
/// <param name="cbAttribute">
/// The size of the DWMWINDOWATTRIBUTE value being retrieved. The size is dependent on the type of the pvAttribute parameter.
/// </param>
/// <param name="cbAttribute">The size of the DWMWINDOWATTRIBUTE value being retrieved. The size is dependent on the type of the pvAttribute parameter.</param>
/// <returns>If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.</returns>
[DllImport(Lib.DwmApi, SetLastError = false, ExactSpelling = true)]
[System.Security.SecurityCritical]
@ -451,8 +467,8 @@ namespace Vanara.PInvoke
/// <param name="hwnd">The handle to the window from which the attribute data is retrieved.</param>
/// <param name="dwAttribute">The attribute to retrieve, specified as a DWMWINDOWATTRIBUTE value.</param>
/// <param name="pvAttribute">
/// A value that, when this function returns successfully, receives the current value of the attribute. The type of the retrieved value depends on the
/// value of the dwAttribute parameter.
/// A value that, when this function returns successfully, receives the current value of the attribute. The type of the retrieved
/// value depends on the value of the dwAttribute parameter.
/// </param>
/// <returns>If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.</returns>
[PInvokeData("dwmapi.h")]
@ -469,32 +485,34 @@ namespace Vanara.PInvoke
}
/// <summary>
/// Called by an application to indicate that all previously provided iconic bitmaps from a window, both thumbnails and peek representations, should be refreshed.
/// Called by an application to indicate that all previously provided iconic bitmaps from a window, both thumbnails and peek
/// representations, should be refreshed.
/// </summary>
/// <param name="hwnd">
/// A handle to the window or tab whose bitmaps are being invalidated through this call. This window must belong to the calling process.
/// </param>
/// <returns>If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.</returns>
/// <remarks>
/// Calling this function causes the Desktop Window Manager (DWM) to invalidate its current bitmaps for the window and request new bitmaps from the
/// window when they are next needed. DwmInvalidateIconicBitmaps should not be called frequently. Doing so can lead to poor performance as new bitmaps
/// are created and retrieved.
/// Calling this function causes the Desktop Window Manager (DWM) to invalidate its current bitmaps for the window and request new
/// bitmaps from the window when they are next needed. DwmInvalidateIconicBitmaps should not be called frequently. Doing so can lead
/// to poor performance as new bitmaps are created and retrieved.
/// </remarks>
[DllImport(Lib.DwmApi, SetLastError = false, ExactSpelling = true)]
[PInvokeData("dwmapi.h")]
public static extern HRESULT DwmInvalidateIconicBitmaps(HWND hwnd);
/// <summary>
/// Obtains a value that indicates whether Desktop Window Manager (DWM) composition is enabled. Applications on machines running Windows 7 or earlier can
/// listen for composition state changes by handling the WM_DWMCOMPOSITIONCHANGED notification.
/// Obtains a value that indicates whether Desktop Window Manager (DWM) composition is enabled. Applications on machines running
/// Windows 7 or earlier can listen for composition state changes by handling the WM_DWMCOMPOSITIONCHANGED notification.
/// </summary>
/// <param name="pfEnabled">
/// A pointer to a value that, when this function returns successfully, receives TRUE if DWM composition is enabled; otherwise, FALSE. <note>As of
/// Windows 8, DWM composition is always enabled. If an app declares Windows 8 compatibility in their manifest, this function will receive a value of
/// TRUE through pfEnabled. If no such manifest entry is found, Windows 8 compatibility is not assumed and this function receives a value of FALSE
/// through pfEnabled. This is done so that older programs that interpret a value of TRUE to imply that high contrast mode is off can continue to make
/// the correct decisions about rendering their images. (Note that this is a bad practice—you should use the SystemParametersInfo function with the
/// SPI_GETHIGHCONTRAST flag to determine the state of high contrast mode.)</note>
/// A pointer to a value that, when this function returns successfully, receives TRUE if DWM composition is enabled; otherwise,
/// FALSE. <note>As of Windows 8, DWM composition is always enabled. If an app declares Windows 8 compatibility in their manifest,
/// this function will receive a value of TRUE through pfEnabled. If no such manifest entry is found, Windows 8 compatibility is not
/// assumed and this function receives a value of FALSE through pfEnabled. This is done so that older programs that interpret a value
/// of TRUE to imply that high contrast mode is off can continue to make the correct decisions about rendering their images. (Note
/// that this is a bad practice—you should use the SystemParametersInfo function with the SPI_GETHIGHCONTRAST flag to determine the
/// state of high contrast mode.)</note>
/// </param>
/// <returns>If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.</returns>
[DllImport(Lib.DwmApi, SetLastError = false, ExactSpelling = true)]
@ -502,31 +520,53 @@ namespace Vanara.PInvoke
[PInvokeData("dwmapi.h")]
public static extern HRESULT DwmIsCompositionEnabled([MarshalAs(UnmanagedType.Bool)] out bool pfEnabled);
/// <summary>Gets the colorization parameters.</summary>
/// <param name="parameters">The parameters.</param>
/// <returns>If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.</returns>
[DllImport(Lib.DwmApi, SetLastError = false, ExactSpelling = true)]
[System.Security.SecurityCritical]
[PInvokeData("dwmapi.h")]
public static extern HRESULT DwmpGetColorizationParameters(out DWM_COLORIZATION_PARAMS parameters);
/// <summary>Sets the colorization parameters.</summary>
/// <param name="parameters">The parameters.</param>
/// <param name="unk">Always set to 1.</param>
/// <returns>If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.</returns>
[DllImport(Lib.DwmApi, SetLastError = false, ExactSpelling = true)]
[System.Security.SecurityCritical]
[PInvokeData("dwmapi.h")]
public static extern HRESULT DwmpSetColorizationParameters(in DWM_COLORIZATION_PARAMS parameters, uint unk = 1);
/// <summary>Retrieves the source size of the Desktop Window Manager (DWM) thumbnail.</summary>
/// <param name="hThumbnail">A handle to the thumbnail to retrieve the source window size from.</param>
/// <param name="pSize">A pointer to a SIZE structure that, when this function returns successfully, receives the size of the source thumbnail.</param>
/// <param name="pSize">
/// A pointer to a SIZE structure that, when this function returns successfully, receives the size of the source thumbnail.
/// </param>
/// <returns>If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.</returns>
[DllImport(Lib.DwmApi, SetLastError = false, ExactSpelling = true)]
[PInvokeData("dwmapi.h")]
public static extern HRESULT DwmQueryThumbnailSourceSize(HTHUMBNAIL hThumbnail, ref SIZE pSize);
public static extern HRESULT DwmQueryThumbnailSourceSize(HTHUMBNAIL hThumbnail, out SIZE pSize);
/// <summary>Creates a Desktop Window Manager (DWM) thumbnail relationship between the destination and source windows.</summary>
/// <param name="hwndDestination">
/// The handle to the window that will use the DWM thumbnail. Setting the destination window handle to anything other than a top-level window type will
/// result in a return value of E_INVALIDARG.
/// The handle to the window that will use the DWM thumbnail. Setting the destination window handle to anything other than a
/// top-level window type will result in a return value of E_INVALIDARG.
/// </param>
/// <param name="hwndSource">
/// The handle to the window to use as the thumbnail source. Setting the source window handle to anything other than a top-level window type will result
/// in a return value of E_INVALIDARG.
/// The handle to the window to use as the thumbnail source. Setting the source window handle to anything other than a top-level
/// window type will result in a return value of E_INVALIDARG.
/// </param>
/// <param name="phThumbnailId">
/// A pointer to a handle that, when this function returns successfully, represents the registration of the DWM thumbnail.
/// </param>
/// <param name="phThumbnailId">A pointer to a handle that, when this function returns successfully, represents the registration of the DWM thumbnail.</param>
/// <returns>If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.</returns>
[DllImport(Lib.DwmApi, SetLastError = false, ExactSpelling = true)]
[PInvokeData("dwmapi.h")]
public static extern HRESULT DwmRegisterThumbnail(HWND hwndDestination, HWND hwndSource, out HTHUMBNAIL phThumbnailId);
/// <summary>
/// Notifies Desktop Window Manager (DWM) that a touch contact has been recognized as a gesture, and that DWM should draw feedback for that gesture.
/// Notifies Desktop Window Manager (DWM) that a touch contact has been recognized as a gesture, and that DWM should draw feedback
/// for that gesture.
/// </summary>
/// <param name="gt">The type of gesture, specified as one of the GESTURE_TYPE values.</param>
/// <param name="cContacts">The number of contact points.</param>
@ -537,50 +577,41 @@ namespace Vanara.PInvoke
[PInvokeData("dwmapi.h")]
public static extern HRESULT DwmRenderGesture(GESTURE_TYPE gt, uint cContacts, ref uint pdwPointerID, [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)] System.Drawing.Point[] pPoints);
/// <summary>Sets the colorization parameters.</summary>
/// <param name="parameters">The parameters.</param>
/// <param name="unk">Always set to 1.</param>
/// <returns>If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.</returns>
[DllImport(Lib.DwmApi, SetLastError = false, ExactSpelling = true)]
[System.Security.SecurityCritical]
[PInvokeData("dwmapi.h")]
public static extern HRESULT DwmpSetColorizationParameters(ref DWM_COLORIZATION_PARAMS parameters, uint unk);
/// <summary>
/// Sets a static, iconic bitmap to display a live preview (also known as a Peek preview) of a window or tab. The taskbar can use this bitmap to show a
/// full-sized preview of a window or tab.
/// Sets a static, iconic bitmap to display a live preview (also known as a Peek preview) of a window or tab. The taskbar can use
/// this bitmap to show a full-sized preview of a window or tab.
/// </summary>
/// <param name="hwnd">A handle to the window. This window must belong to the calling process.</param>
/// <param name="hbmp">A handle to the bitmap to represent the window that hwnd specifies.</param>
/// <param name="pptClient">
/// The offset of a tab window's client region (the content area inside the client window frame) from the host window's frame. This offset enables the
/// tab window's contents to be drawn correctly in a live preview when it is drawn without its frame.
/// The offset of a tab window's client region (the content area inside the client window frame) from the host window's frame. This
/// offset enables the tab window's contents to be drawn correctly in a live preview when it is drawn without its frame.
/// </param>
/// <param name="dwSITFlags">The display options for the live preview.</param>
/// <returns>If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.</returns>
[DllImport(Lib.DwmApi, SetLastError = false, ExactSpelling = true)]
[PInvokeData("dwmapi.h")]
public static extern HRESULT DwmSetIconicLivePreviewBitmap(HWND hwnd, SafeHBITMAP hbmp, ref System.Drawing.Point pptClient, DWM_SETICONICPREVIEW_Flags dwSITFlags);
public static extern HRESULT DwmSetIconicLivePreviewBitmap(HWND hwnd, HBITMAP hbmp, in System.Drawing.Point pptClient, DWM_SETICONICPREVIEW_Flags dwSITFlags);
/// <summary>
/// Sets a static, iconic bitmap to display a live preview (also known as a Peek preview) of a window or tab. The taskbar can use this bitmap to show a
/// full-sized preview of a window or tab.
/// Sets a static, iconic bitmap to display a live preview (also known as a Peek preview) of a window or tab. The taskbar can use
/// this bitmap to show a full-sized preview of a window or tab.
/// </summary>
/// <param name="hwnd">A handle to the window. This window must belong to the calling process.</param>
/// <param name="hbmp">A handle to the bitmap to represent the window that hwnd specifies.</param>
/// <param name="pptClient">
/// The offset of a tab window's client region (the content area inside the client window frame) from the host window's frame. This offset enables the
/// tab window's contents to be drawn correctly in a live preview when it is drawn without its frame.
/// The offset of a tab window's client region (the content area inside the client window frame) from the host window's frame. This
/// offset enables the tab window's contents to be drawn correctly in a live preview when it is drawn without its frame.
/// </param>
/// <param name="dwSITFlags">The display options for the live preview.</param>
/// <returns>If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.</returns>
[DllImport(Lib.DwmApi, SetLastError = false, ExactSpelling = true)]
[PInvokeData("dwmapi.h")]
public static extern HRESULT DwmSetIconicLivePreviewBitmap(HWND hwnd, SafeHBITMAP hbmp, IntPtr pptClient, DWM_SETICONICPREVIEW_Flags dwSITFlags);
public static extern HRESULT DwmSetIconicLivePreviewBitmap(HWND hwnd, HBITMAP hbmp, [Optional] IntPtr pptClient, DWM_SETICONICPREVIEW_Flags dwSITFlags);
/// <summary>
/// Sets a static, iconic bitmap on a window or tab to use as a thumbnail representation. The taskbar can use this bitmap as a thumbnail switch target
/// for the window or tab.
/// Sets a static, iconic bitmap on a window or tab to use as a thumbnail representation. The taskbar can use this bitmap as a
/// thumbnail switch target for the window or tab.
/// </summary>
/// <param name="hwnd">A handle to the window. This window must belong to the calling process.</param>
/// <param name="hbmp">A handle to the bitmap to represent the window that hwnd specifies.</param>
@ -588,16 +619,17 @@ namespace Vanara.PInvoke
/// <returns>If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.</returns>
[DllImport(Lib.DwmApi, SetLastError = false, ExactSpelling = true)]
[PInvokeData("dwmapi.h")]
public static extern HRESULT DwmSetIconicThumbnail(HWND hwnd, SafeHBITMAP hbmp, DWM_SETICONICPREVIEW_Flags dwSITFlags);
public static extern HRESULT DwmSetIconicThumbnail(HWND hwnd, HBITMAP hbmp, DWM_SETICONICPREVIEW_Flags dwSITFlags);
/// <summary>Sets the value of non-client rendering attributes for a window.</summary>
/// <param name="hwnd">The handle to the window that will receive the attributes.</param>
/// <param name="dwAttribute">
/// A single DWMWINDOWATTRIBUTE flag to apply to the window. This parameter specifies the attribute and the pvAttribute parameter points to the value of
/// that attribute.
/// A single DWMWINDOWATTRIBUTE flag to apply to the window. This parameter specifies the attribute and the pvAttribute parameter
/// points to the value of that attribute.
/// </param>
/// <param name="pvAttribute">
/// A pointer to the value of the attribute specified in the dwAttribute parameter. Different DWMWINDOWATTRIBUTE flags require different value types.
/// A pointer to the value of the attribute specified in the dwAttribute parameter. Different DWMWINDOWATTRIBUTE flags require
/// different value types.
/// </param>
/// <param name="cbAttribute">The size, in bytes, of the value type pointed to by the pvAttribute parameter.</param>
/// <returns>If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.</returns>
@ -609,8 +641,8 @@ namespace Vanara.PInvoke
/// <summary>Sets the value of non-client rendering attributes for a window.</summary>
/// <param name="hwnd">The handle to the window that will receive the attributes.</param>
/// <param name="dwAttribute">
/// A single DWMWINDOWATTRIBUTE flag to apply to the window. This parameter specifies the attribute and the pvAttribute parameter points to the value of
/// that attribute.
/// A single DWMWINDOWATTRIBUTE flag to apply to the window. This parameter specifies the attribute and the pvAttribute parameter
/// points to the value of that attribute.
/// </param>
/// <param name="pvAttribute">
/// The value of the attribute specified in the dwAttribute parameter. Different DWMWINDOWATTRIBUTE flags require different value types.
@ -625,14 +657,16 @@ namespace Vanara.PInvoke
return DwmSetWindowAttribute(hwnd, dwAttribute, p, Marshal.SizeOf(attr));
}
/// <summary>Called by an app or framework to specify the visual feedback type to draw in response to a particular touch or pen contact.</summary>
/// <summary>
/// Called by an app or framework to specify the visual feedback type to draw in response to a particular touch or pen contact.
/// </summary>
/// <param name="dwPointerID">The pointer ID of the contact. Each touch or pen contact is given a unique ID when it is detected.</param>
/// <param name="eShowContact">One or more of the following DWM_SHOWCONTACT visualizations that DWM should show for this contact.</param>
/// <returns>
/// If dwPointerID does not match that of a contact currently present on the screen, this function returns E_INVALIDARG; otherwise, it returns S_OK.
/// If dwPointerID does not match that of a contact currently present on the screen, this function returns E_INVALIDARG; otherwise,
/// it returns S_OK.
/// </returns>
// DWMAPI DwmShowContact( DWORD dwPointerID, DWM_SHOWCONTACT eShowContact);
// https://msdn.microsoft.com/en-us/library/windows/desktop/hh706496(v=vs.85).aspx
// DWMAPI DwmShowContact( DWORD dwPointerID, DWM_SHOWCONTACT eShowContact); https://msdn.microsoft.com/en-us/library/windows/desktop/hh706496(v=vs.85).aspx
[DllImport(Lib.DwmApi, SetLastError = false, ExactSpelling = true)]
[PInvokeData("Dwmapi.h", MSDNShortId = "hh706496")]
public static extern HRESULT DwmShowContact(uint dwPointerID, DWM_SHOWCONTACT eShowContact);
@ -661,20 +695,43 @@ namespace Vanara.PInvoke
[PInvokeData("dwmapi.h")]
public static extern HRESULT DwmUnregisterThumbnail(HTHUMBNAIL hThumbnailId);
/// <summary><para>Updates the properties for a Desktop Window Manager (DWM) thumbnail.</para></summary><param name="hThumbnailId"><para>The handle to the DWM thumbnail to be updated. Null or invalid thumbnails, as well as thumbnails owned by other processes will result in a return value of E_INVALIDARG.</para></param><param name="ptnProperties"><para>A pointer to a DWM_THUMBNAIL_PROPERTIES structure that contains the new thumbnail properties.</para></param><returns><para>If this function succeeds, it returns <c>S_OK</c>. Otherwise, it returns an <c>HRESULT</c> error code.</para></returns><remarks><para>Thumbnail relationships created by the DwmRegisterThumbnail function will not be rendered to the destination window until this function is called. Subsequent calls will update the thumbnail according to the provided properties.</para><para>Examples</para><para>The following example demonstrates how to register and display the desktop thumbnail.</para></remarks>
// https://docs.microsoft.com/en-us/windows/desktop/api/dwmapi/nf-dwmapi-dwmupdatethumbnailproperties
// DWMAPI DwmUpdateThumbnailProperties( HTHUMBNAIL hThumbnailId, const DWM_THUMBNAIL_PROPERTIES *ptnProperties );
/// <summary>
/// <para>Updates the properties for a Desktop Window Manager (DWM) thumbnail.</para>
/// </summary>
/// <param name="hThumbnailId">
/// <para>
/// The handle to the DWM thumbnail to be updated. Null or invalid thumbnails, as well as thumbnails owned by other processes will
/// result in a return value of E_INVALIDARG.
/// </para>
/// </param>
/// <param name="ptnProperties">
/// <para>A pointer to a DWM_THUMBNAIL_PROPERTIES structure that contains the new thumbnail properties.</para>
/// </param>
/// <returns>
/// <para>If this function succeeds, it returns <c>S_OK</c>. Otherwise, it returns an <c>HRESULT</c> error code.</para>
/// </returns>
/// <remarks>
/// <para>
/// Thumbnail relationships created by the DwmRegisterThumbnail function will not be rendered to the destination window until this
/// function is called. Subsequent calls will update the thumbnail according to the provided properties.
/// </para>
/// <para>Examples</para>
/// <para>The following example demonstrates how to register and display the desktop thumbnail.</para>
/// </remarks>
// https://docs.microsoft.com/en-us/windows/desktop/api/dwmapi/nf-dwmapi-dwmupdatethumbnailproperties DWMAPI
// DwmUpdateThumbnailProperties( HTHUMBNAIL hThumbnailId, const DWM_THUMBNAIL_PROPERTIES *ptnProperties );
[DllImport(Lib.DwmApi, SetLastError = false, ExactSpelling = true)]
[PInvokeData("dwmapi.h", MSDNShortId = "dwmupdatethumbnailproperties")]
// public static extern DWMAPI DwmUpdateThumbnailProperties(HTHUMBNAIL hThumbnailId, ref DWM_THUMBNAIL_PROPERTIES ptnProperties);
public static extern HRESULT DwmUpdateThumbnailProperties(HTHUMBNAIL hThumbnailId, ref DWM_THUMBNAIL_PROPERTIES ptnProperties);
public static extern HRESULT DwmUpdateThumbnailProperties(HTHUMBNAIL hThumbnailId, in DWM_THUMBNAIL_PROPERTIES ptnProperties);
/// <summary>Specifies Desktop Window Manager (DWM) blur-behind properties. Used by the DwmEnableBlurBehindWindow function.</summary>
[StructLayout(LayoutKind.Sequential)]
[PInvokeData("dwmapi.h")]
public struct DWM_BLURBEHIND
{
/// <summary>A bitwise combination of DWM Blur Behind constant values that indicates which of the members of this structure have been set.</summary>
/// <summary>
/// A bitwise combination of DWM Blur Behind constant values that indicates which of the members of this structure have been set.
/// </summary>
public DWM_BLURBEHIND_Mask dwFlags;
/// <summary>TRUE to register the window handle to DWM blur behind; FALSE to unregister the window handle from DWM blur behind.</summary>
@ -682,9 +739,10 @@ namespace Vanara.PInvoke
public bool fEnable;
/// <summary>
/// The region within the client area where the blur behind will be applied. A NULL value will apply the blur behind the entire client area.
/// The region within the client area where the blur behind will be applied. A NULL value will apply the blur behind the entire
/// client area.
/// </summary>
public IntPtr hRgnBlur;
public HRGN hRgnBlur;
/// <summary>TRUE if the window's colorization should transition to match the maximized windows; otherwise, FALSE.</summary>
[MarshalAs(UnmanagedType.Bool)]
@ -702,7 +760,7 @@ namespace Vanara.PInvoke
/// <summary>Gets the region.</summary>
/// <value>The region.</value>
public System.Drawing.Region Region => System.Drawing.Region.FromHrgn(hRgnBlur);
public System.Drawing.Region Region => System.Drawing.Region.FromHrgn((IntPtr)hRgnBlur);
/// <summary>Gets or sets a value indicating whether the window's colorization should transition to match the maximized windows.</summary>
/// <value><c>true</c> if the window's colorization should transition to match the maximized windows; otherwise, <c>false</c>.</value>
@ -732,22 +790,22 @@ namespace Vanara.PInvoke
public struct DWM_COLORIZATION_PARAMS
{
/// <summary>The ARGB accent color.</summary>
public uint clrColor;
public RGBQUAD clrColor;
/// <summary>The ARGB after glow color.</summary>
public uint clrAfterGlow;
public RGBQUAD clrAfterGlow;
/// <summary>Determines how much the glass streaks are visible in window borders.</summary>
public uint nIntensity;
/// <summary>Determines how bright the glass is (0 removes all color from borders).</summary>
public uint clrAfterGlowBalance;
public RGBQUAD clrAfterGlowBalance;
/// <summary>Determines how bright the blur is.</summary>
public uint clrBlurBalance;
public RGBQUAD clrBlurBalance;
/// <summary>Determines how much the glass reflection is visible.</summary>
public uint clrGlassReflectionIntensity;
public RGBQUAD clrGlassReflectionIntensity;
/// <summary>Determines if borders are opaque ( <c>true</c>) or transparent ( <c>false</c>).</summary>
[MarshalAs(UnmanagedType.Bool)]
@ -755,8 +813,8 @@ namespace Vanara.PInvoke
}
/// <summary>Specifies Desktop Window Manager (DWM) thumbnail properties. Used by the <c>DwmUpdateThumbnailProperties</c> function.</summary>
// typedef struct _DWM_THUMBNAIL_PROPERTIES { DWORD dwFlags; RECT rcDestination; RECT rcSource; BYTE opacity; BOOL fVisible; BOOL fSourceClientAreaOnly;} DWM_THUMBNAIL_PROPERTIES, *PDWM_THUMBNAIL_PROPERTIES;
// https://msdn.microsoft.com/en-us/library/windows/desktop/aa969502(v=vs.85).aspx
// typedef struct _DWM_THUMBNAIL_PROPERTIES { DWORD dwFlags; RECT rcDestination; RECT rcSource; BYTE opacity; BOOL fVisible; BOOL
// fSourceClientAreaOnly;} DWM_THUMBNAIL_PROPERTIES, *PDWM_THUMBNAIL_PROPERTIES; https://msdn.microsoft.com/en-us/library/windows/desktop/aa969502(v=vs.85).aspx
[PInvokeData("Dwmapi.h", MSDNShortId = "aa969502")]
[StructLayout(LayoutKind.Sequential, Pack = 1)]
public struct DWM_THUMBNAIL_PROPERTIES
@ -770,7 +828,9 @@ namespace Vanara.PInvoke
/// <summary>The region of the source window to use as the thumbnail. By default, the entire window is used as the thumbnail.</summary>
public RECT rcSource;
/// <summary>The opacity with which to render the thumbnail. 0 is fully transparent while 255 is fully opaque. The default value is 255.</summary>
/// <summary>
/// The opacity with which to render the thumbnail. 0 is fully transparent while 255 is fully opaque. The default value is 255.
/// </summary>
public byte opacity;
/// <summary>TRUE to make the thumbnail visible; otherwise, FALSE. The default is FALSE.</summary>
@ -863,7 +923,9 @@ namespace Vanara.PInvoke
/// <summary>The QPC time when the last frame was marked as pending.</summary>
public ulong qpcFramePending;
/// <summary>The number of unique frames displayed. This value is valid only after a second call to the DwmGetCompositionTimingInfo function.</summary>
/// <summary>
/// The number of unique frames displayed. This value is valid only after a second call to the DwmGetCompositionTimingInfo function.
/// </summary>
public ulong cFramesDisplayed;
/// <summary>The number of new completed frames that have been received.</summary>
@ -872,11 +934,14 @@ namespace Vanara.PInvoke
/// <summary>The number of new frames submitted to DirectX but not yet completed.</summary>
public ulong cFramesPending;
/// <summary>The number of frames available but not displayed, used, or dropped. This value is valid only after a second call to DwmGetCompositionTimingInfo.</summary>
/// <summary>
/// The number of frames available but not displayed, used, or dropped. This value is valid only after a second call to DwmGetCompositionTimingInfo.
/// </summary>
public ulong cFramesAvailable;
/// <summary>
/// The number of rendered frames that were never displayed because composition occurred too late. This value is valid only after a second call to DwmGetCompositionTimingInfo.
/// The number of rendered frames that were never displayed because composition occurred too late. This value is valid only after
/// a second call to DwmGetCompositionTimingInfo.
/// </summary>
public ulong cFramesDropped;
@ -889,10 +954,15 @@ namespace Vanara.PInvoke
/// <summary>The frame count at which the next DirectX present is scheduled to be displayed.</summary>
public ulong cRefreshNextPresented;
/// <summary>The total number of refreshes that have been displayed for the application since the DwmSetPresentParameters function was last called.</summary>
/// <summary>
/// The total number of refreshes that have been displayed for the application since the DwmSetPresentParameters function was
/// last called.
/// </summary>
public ulong cRefreshesDisplayed;
/// <summary>The total number of refreshes that have been presented by the application since DwmSetPresentParameters was last called.</summary>
/// <summary>
/// The total number of refreshes that have been presented by the application since DwmSetPresentParameters was last called.
/// </summary>
public ulong cRefreshesPresented;
/// <summary>The refresh number when content for this window started to be displayed.</summary>
@ -946,10 +1016,7 @@ namespace Vanara.PInvoke
/// <summary>Initializes a new instance of the <see cref="MARGINS"/> struct.</summary>
/// <param name="allMargins">Value to assign to all margins.</param>
public MARGINS(int allMargins)
{
cxLeftWidth = cxRightWidth = cyTopHeight = cyBottomHeight = allMargins;
}
public MARGINS(int allMargins) => cxLeftWidth = cxRightWidth = cyTopHeight = cyBottomHeight = allMargins;
/// <summary>Gets or sets the left border value.</summary>
/// <value>The left border.</value>
@ -1005,8 +1072,8 @@ namespace Vanara.PInvoke
}
/// <summary>
/// Defines a data type used by the Desktop Window Manager (DWM) APIs. It represents a generic ratio and is used for different purposes and units even
/// within a single API.
/// Defines a data type used by the Desktop Window Manager (DWM) APIs. It represents a generic ratio and is used for different
/// purposes and units even within a single API.
/// </summary>
[StructLayout(LayoutKind.Sequential)]
[PInvokeData("dwmapi.h")]

View File

@ -28,10 +28,10 @@ Functions
DwmDefWindowProc, DwmEnableBlurBehindWindow, DwmEnableComposition, DwmEnableMMCSS, DwmExtendFrameIntoClientArea, DwmFlush, DwmGetColorizationColor, DwmGetCompositionTimingInfo, DwmGetTransportAttributes, DwmGetWindowAttribute, DwmInvalidateIconicBitmaps, DwmIsCompositionEnabled, DwmpGetColorizationParameters, DwmpSetColorizationParameters, DwmQueryThumbnailSourceSize, DwmRegisterThumbnail, DwmRenderGesture, DwmSetIconicLivePreviewBitmap, DwmSetIconicThumbnail, DwmSetWindowAttribute, DwmShowContact, DwmTetherContact, DwmTransitionOwnedWindow, DwmUnregisterThumbnail, DwmUpdateThumbnailProperties
Structures
DWM_BLURBEHIND, DWM_COLORIZATION_PARAMS, DWM_THUMBNAIL_PROPERTIES, DWM_TIMING_INFO, MARGINS, UNSIGNED_RATIO
DWM_COLORIZATION_PARAMS, DWM_THUMBNAIL_PROPERTIES, DWM_TIMING_INFO, MARGINS, UNSIGNED_RATIO
</PackageReleaseNotes>
<LangVersion>latest</LangVersion>
<LangVersion>latest</LangVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)'=='Release'">
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>

View File

@ -1,5 +1,5 @@
## Correlation report for gdi32.dll
### Methods (1% complete)
### Methods (3% complete)
Native Method | Native DLL | Header | Managed Method
--- | --- | --- | ---
[AbortDoc](https://www.google.com/search?num=5&q=AbortDoc+site%3Amicrosoft.com) | gdi32.dll | |
@ -53,10 +53,11 @@ Native Method | Native DLL | Header | Managed Method
[CreateDC](https://www.google.com/search?num=5&q=CreateDCA+site%3Amicrosoft.com) | gdi32.dll | |
[CreateDCExW](https://www.google.com/search?num=5&q=CreateDCExW+site%3Amicrosoft.com) | gdi32.dll | |
[CreateDIBitmap](https://www.google.com/search?num=5&q=CreateDIBitmap+site%3Amicrosoft.com) | gdi32.dll | |
[CreateDIBPatternBrush](https://www.google.com/search?num=5&q=CreateDIBPatternBrush+site%3Amicrosoft.com) | gdi32.dll | |
[CreateDIBPatternBrushPt](https://www.google.com/search?num=5&q=CreateDIBPatternBrushPt+site%3Amicrosoft.com) | gdi32.dll | |
[CreateDIBPatternBrush](http://msdn2.microsoft.com/en-us/library/d123ef44-e047-4188-a2bc-20e479869dc3) | gdi32.dll | wingdi.h | Vanara.PInvoke.Gdi32.CreateDIBPatternBrush
[CreateDIBPatternBrushPt](http://msdn2.microsoft.com/en-us/library/0e34d108-fd35-4512-9eb3-c7710af36e95) | gdi32.dll | wingdi.h | Vanara.PInvoke.Gdi32.CreateDIBPatternBrushPt
[CreateDIBSection](http://msdn2.microsoft.com/en-us/library/dd183494) | gdi32.dll | Wingdi.h | Vanara.PInvoke.Gdi32.CreateDIBSection
[CreateDiscardableBitmap](https://www.google.com/search?num=5&q=CreateDiscardableBitmap+site%3Amicrosoft.com) | gdi32.dll | |
[CreateDPIScaledDIBSection](https://www.google.com/search?num=5&q=CreateDPIScaledDIBSection+site%3Amicrosoft.com) | gdi32.dll | |
[CreateEllipticRgn](https://www.google.com/search?num=5&q=CreateEllipticRgn+site%3Amicrosoft.com) | gdi32.dll | |
[CreateEllipticRgnIndirect](https://www.google.com/search?num=5&q=CreateEllipticRgnIndirect+site%3Amicrosoft.com) | gdi32.dll | |
[CreateEnhMetaFile](https://www.google.com/search?num=5&q=CreateEnhMetaFileA+site%3Amicrosoft.com) | gdi32.dll | |
@ -64,15 +65,15 @@ Native Method | Native DLL | Header | Managed Method
[CreateFontIndirect](https://www.google.com/search?num=5&q=CreateFontIndirectA+site%3Amicrosoft.com) | gdi32.dll | |
[CreateFontIndirectEx](https://www.google.com/search?num=5&q=CreateFontIndirectExA+site%3Amicrosoft.com) | gdi32.dll | |
[CreateHalftonePalette](https://www.google.com/search?num=5&q=CreateHalftonePalette+site%3Amicrosoft.com) | gdi32.dll | |
[CreateHatchBrush](https://www.google.com/search?num=5&q=CreateHatchBrush+site%3Amicrosoft.com) | gdi32.dll | |
[CreateHatchBrush](http://msdn2.microsoft.com/en-us/library/0b5849d6-1e22-4ac5-980c-2f2a73b16adb) | gdi32.dll | wingdi.h | Vanara.PInvoke.Gdi32.CreateHatchBrush
[CreateIC](https://www.google.com/search?num=5&q=CreateICA+site%3Amicrosoft.com) | gdi32.dll | |
[CreateMetaFile](https://www.google.com/search?num=5&q=CreateMetaFileA+site%3Amicrosoft.com) | gdi32.dll | |
[CreateOPMProtectedOutput](https://www.google.com/search?num=5&q=CreateOPMProtectedOutput+site%3Amicrosoft.com) | gdi32.dll | |
[CreateOPMProtectedOutputs](https://www.google.com/search?num=5&q=CreateOPMProtectedOutputs+site%3Amicrosoft.com) | gdi32.dll | |
[CreatePalette](https://www.google.com/search?num=5&q=CreatePalette+site%3Amicrosoft.com) | gdi32.dll | |
[CreatePatternBrush](https://www.google.com/search?num=5&q=CreatePatternBrush+site%3Amicrosoft.com) | gdi32.dll | |
[CreatePen](https://www.google.com/search?num=5&q=CreatePen+site%3Amicrosoft.com) | gdi32.dll | |
[CreatePenIndirect](https://www.google.com/search?num=5&q=CreatePenIndirect+site%3Amicrosoft.com) | gdi32.dll | |
[CreatePatternBrush](http://msdn2.microsoft.com/en-us/library/a3cf347e-9803-4bb0-bdb3-98929ef859ab) | gdi32.dll | wingdi.h | Vanara.PInvoke.Gdi32.CreatePatternBrush
[CreatePen](http://msdn2.microsoft.com/en-us/library/882facd2-7e06-48f6-82e4-f20e4d5adc92) | gdi32.dll | wingdi.h | Vanara.PInvoke.Gdi32.CreatePen
[CreatePenIndirect](http://msdn2.microsoft.com/en-us/library/638c0294-9a8f-44ed-a791-1be152cd92dd) | gdi32.dll | wingdi.h | Vanara.PInvoke.Gdi32.CreatePenIndirect
[CreatePolygonRgn](https://www.google.com/search?num=5&q=CreatePolygonRgn+site%3Amicrosoft.com) | gdi32.dll | |
[CreatePolyPolygonRgn](https://www.google.com/search?num=5&q=CreatePolyPolygonRgn+site%3Amicrosoft.com) | gdi32.dll | |
[CreateRectRgn](https://www.google.com/search?num=5&q=CreateRectRgn+site%3Amicrosoft.com) | gdi32.dll | |
@ -80,11 +81,12 @@ Native Method | Native DLL | Header | Managed Method
[CreateRoundRectRgn](https://www.google.com/search?num=5&q=CreateRoundRectRgn+site%3Amicrosoft.com) | gdi32.dll | |
[CreateScalableFontResource](https://www.google.com/search?num=5&q=CreateScalableFontResourceA+site%3Amicrosoft.com) | gdi32.dll | |
[CreateSessionMappedDIBSection](https://www.google.com/search?num=5&q=CreateSessionMappedDIBSection+site%3Amicrosoft.com) | gdi32.dll | |
[CreateSolidBrush](https://www.google.com/search?num=5&q=CreateSolidBrush+site%3Amicrosoft.com) | gdi32.dll | |
[CreateSolidBrush](http://msdn2.microsoft.com/en-us/library/e39b5f77-97d8-4ea6-8277-7da12b3367f3) | gdi32.dll | wingdi.h | Vanara.PInvoke.Gdi32.CreateSolidBrush
[D3DKMTAbandonSwapChain](https://www.google.com/search?num=5&q=D3DKMTAbandonSwapChain+site%3Amicrosoft.com) | gdi32.dll | |
[D3DKMTAcquireKeyedMutex](https://www.google.com/search?num=5&q=D3DKMTAcquireKeyedMutex+site%3Amicrosoft.com) | gdi32.dll | |
[D3DKMTAcquireKeyedMutex2](https://www.google.com/search?num=5&q=D3DKMTAcquireKeyedMutex2+site%3Amicrosoft.com) | gdi32.dll | |
[D3DKMTAcquireSwapChain](https://www.google.com/search?num=5&q=D3DKMTAcquireSwapChain+site%3Amicrosoft.com) | gdi32.dll | |
[D3DKMTAddSurfaceToSwapChain](https://www.google.com/search?num=5&q=D3DKMTAddSurfaceToSwapChain+site%3Amicrosoft.com) | gdi32.dll | |
[D3DKMTAdjustFullscreenGamma](https://www.google.com/search?num=5&q=D3DKMTAdjustFullscreenGamma+site%3Amicrosoft.com) | gdi32.dll | |
[D3DKMTCacheHybridQueryValue](https://www.google.com/search?num=5&q=D3DKMTCacheHybridQueryValue+site%3Amicrosoft.com) | gdi32.dll | |
[D3DKMTChangeVideoMemoryReservation](https://www.google.com/search?num=5&q=D3DKMTChangeVideoMemoryReservation+site%3Amicrosoft.com) | gdi32.dll | |
@ -100,6 +102,7 @@ Native Method | Native DLL | Header | Managed Method
[D3DKMTConfigureSharedResource](https://www.google.com/search?num=5&q=D3DKMTConfigureSharedResource+site%3Amicrosoft.com) | gdi32.dll | |
[D3DKMTCreateAllocation](https://www.google.com/search?num=5&q=D3DKMTCreateAllocation+site%3Amicrosoft.com) | gdi32.dll | |
[D3DKMTCreateAllocation2](https://www.google.com/search?num=5&q=D3DKMTCreateAllocation2+site%3Amicrosoft.com) | gdi32.dll | |
[D3DKMTCreateBundleObject](https://www.google.com/search?num=5&q=D3DKMTCreateBundleObject+site%3Amicrosoft.com) | gdi32.dll | |
[D3DKMTCreateContext](https://www.google.com/search?num=5&q=D3DKMTCreateContext+site%3Amicrosoft.com) | gdi32.dll | |
[D3DKMTCreateContextVirtual](https://www.google.com/search?num=5&q=D3DKMTCreateContextVirtual+site%3Amicrosoft.com) | gdi32.dll | |
[D3DKMTCreateDCFromMemory](https://www.google.com/search?num=5&q=D3DKMTCreateDCFromMemory+site%3Amicrosoft.com) | gdi32.dll | |
@ -111,9 +114,11 @@ Native Method | Native DLL | Header | Managed Method
[D3DKMTCreateOutputDupl](https://www.google.com/search?num=5&q=D3DKMTCreateOutputDupl+site%3Amicrosoft.com) | gdi32.dll | |
[D3DKMTCreateOverlay](https://www.google.com/search?num=5&q=D3DKMTCreateOverlay+site%3Amicrosoft.com) | gdi32.dll | |
[D3DKMTCreatePagingQueue](https://www.google.com/search?num=5&q=D3DKMTCreatePagingQueue+site%3Amicrosoft.com) | gdi32.dll | |
[D3DKMTCreateProtectedSession](https://www.google.com/search?num=5&q=D3DKMTCreateProtectedSession+site%3Amicrosoft.com) | gdi32.dll | |
[D3DKMTCreateSwapChain](https://www.google.com/search?num=5&q=D3DKMTCreateSwapChain+site%3Amicrosoft.com) | gdi32.dll | |
[D3DKMTCreateSynchronizationObject](https://www.google.com/search?num=5&q=D3DKMTCreateSynchronizationObject+site%3Amicrosoft.com) | gdi32.dll | |
[D3DKMTCreateSynchronizationObject2](https://www.google.com/search?num=5&q=D3DKMTCreateSynchronizationObject2+site%3Amicrosoft.com) | gdi32.dll | |
[D3DKMTDDisplayEnum](https://www.google.com/search?num=5&q=D3DKMTDDisplayEnum+site%3Amicrosoft.com) | gdi32.dll | |
[D3DKMTDestroyAllocation](https://www.google.com/search?num=5&q=D3DKMTDestroyAllocation+site%3Amicrosoft.com) | gdi32.dll | |
[D3DKMTDestroyAllocation2](https://www.google.com/search?num=5&q=D3DKMTDestroyAllocation2+site%3Amicrosoft.com) | gdi32.dll | |
[D3DKMTDestroyContext](https://www.google.com/search?num=5&q=D3DKMTDestroyContext+site%3Amicrosoft.com) | gdi32.dll | |
@ -125,11 +130,16 @@ Native Method | Native DLL | Header | Managed Method
[D3DKMTDestroyOutputDupl](https://www.google.com/search?num=5&q=D3DKMTDestroyOutputDupl+site%3Amicrosoft.com) | gdi32.dll | |
[D3DKMTDestroyOverlay](https://www.google.com/search?num=5&q=D3DKMTDestroyOverlay+site%3Amicrosoft.com) | gdi32.dll | |
[D3DKMTDestroyPagingQueue](https://www.google.com/search?num=5&q=D3DKMTDestroyPagingQueue+site%3Amicrosoft.com) | gdi32.dll | |
[D3DKMTDestroyProtectedSession](https://www.google.com/search?num=5&q=D3DKMTDestroyProtectedSession+site%3Amicrosoft.com) | gdi32.dll | |
[D3DKMTDestroySynchronizationObject](https://www.google.com/search?num=5&q=D3DKMTDestroySynchronizationObject+site%3Amicrosoft.com) | gdi32.dll | |
[D3DKMTDispMgrCreate](https://www.google.com/search?num=5&q=D3DKMTDispMgrCreate+site%3Amicrosoft.com) | gdi32.dll | |
[D3DKMTDispMgrSourceOperation](https://www.google.com/search?num=5&q=D3DKMTDispMgrSourceOperation+site%3Amicrosoft.com) | gdi32.dll | |
[D3DKMTDispMgrTargetOperation](https://www.google.com/search?num=5&q=D3DKMTDispMgrTargetOperation+site%3Amicrosoft.com) | gdi32.dll | |
[D3DKMTEnumAdapters](https://www.google.com/search?num=5&q=D3DKMTEnumAdapters+site%3Amicrosoft.com) | gdi32.dll | |
[D3DKMTEnumAdapters2](https://www.google.com/search?num=5&q=D3DKMTEnumAdapters2+site%3Amicrosoft.com) | gdi32.dll | |
[D3DKMTEscape](https://www.google.com/search?num=5&q=D3DKMTEscape+site%3Amicrosoft.com) | gdi32.dll | |
[D3DKMTEvict](https://www.google.com/search?num=5&q=D3DKMTEvict+site%3Amicrosoft.com) | gdi32.dll | |
[D3DKMTExtractBundleObject](https://www.google.com/search?num=5&q=D3DKMTExtractBundleObject+site%3Amicrosoft.com) | gdi32.dll | |
[D3DKMTFlipOverlay](https://www.google.com/search?num=5&q=D3DKMTFlipOverlay+site%3Amicrosoft.com) | gdi32.dll | |
[D3DKMTFlushHeapTransitions](https://www.google.com/search?num=5&q=D3DKMTFlushHeapTransitions+site%3Amicrosoft.com) | gdi32.dll | |
[D3DKMTFreeGpuVirtualAddress](https://www.google.com/search?num=5&q=D3DKMTFreeGpuVirtualAddress+site%3Amicrosoft.com) | gdi32.dll | |
@ -147,6 +157,7 @@ Native Method | Native DLL | Header | Managed Method
[D3DKMTGetPostCompositionCaps](https://www.google.com/search?num=5&q=D3DKMTGetPostCompositionCaps+site%3Amicrosoft.com) | gdi32.dll | |
[D3DKMTGetPresentHistory](https://www.google.com/search?num=5&q=D3DKMTGetPresentHistory+site%3Amicrosoft.com) | gdi32.dll | |
[D3DKMTGetPresentQueueEvent](https://www.google.com/search?num=5&q=D3DKMTGetPresentQueueEvent+site%3Amicrosoft.com) | gdi32.dll | |
[D3DKMTGetProcessDeviceLostSupport](https://www.google.com/search?num=5&q=D3DKMTGetProcessDeviceLostSupport+site%3Amicrosoft.com) | gdi32.dll | |
[D3DKMTGetProcessSchedulingPriorityBand](https://www.google.com/search?num=5&q=D3DKMTGetProcessSchedulingPriorityBand+site%3Amicrosoft.com) | gdi32.dll | |
[D3DKMTGetProcessSchedulingPriorityClass](https://www.google.com/search?num=5&q=D3DKMTGetProcessSchedulingPriorityClass+site%3Amicrosoft.com) | gdi32.dll | |
[D3DKMTGetResourcePresentPrivateDriverData](https://www.google.com/search?num=5&q=D3DKMTGetResourcePresentPrivateDriverData+site%3Amicrosoft.com) | gdi32.dll | |
@ -179,6 +190,7 @@ Native Method | Native DLL | Header | Managed Method
[D3DKMTOpenKeyedMutex](https://www.google.com/search?num=5&q=D3DKMTOpenKeyedMutex+site%3Amicrosoft.com) | gdi32.dll | |
[D3DKMTOpenKeyedMutex2](https://www.google.com/search?num=5&q=D3DKMTOpenKeyedMutex2+site%3Amicrosoft.com) | gdi32.dll | |
[D3DKMTOpenNtHandleFromName](https://www.google.com/search?num=5&q=D3DKMTOpenNtHandleFromName+site%3Amicrosoft.com) | gdi32.dll | |
[D3DKMTOpenProtectedSessionFromNtHandle](https://www.google.com/search?num=5&q=D3DKMTOpenProtectedSessionFromNtHandle+site%3Amicrosoft.com) | gdi32.dll | |
[D3DKMTOpenResource](https://www.google.com/search?num=5&q=D3DKMTOpenResource+site%3Amicrosoft.com) | gdi32.dll | |
[D3DKMTOpenResource2](https://www.google.com/search?num=5&q=D3DKMTOpenResource2+site%3Amicrosoft.com) | gdi32.dll | |
[D3DKMTOpenResourceFromNtHandle](https://www.google.com/search?num=5&q=D3DKMTOpenResourceFromNtHandle+site%3Amicrosoft.com) | gdi32.dll | |
@ -198,11 +210,14 @@ Native Method | Native DLL | Header | Managed Method
[D3DKMTPresentMultiPlaneOverlay](https://www.google.com/search?num=5&q=D3DKMTPresentMultiPlaneOverlay+site%3Amicrosoft.com) | gdi32.dll | |
[D3DKMTPresentMultiPlaneOverlay2](https://www.google.com/search?num=5&q=D3DKMTPresentMultiPlaneOverlay2+site%3Amicrosoft.com) | gdi32.dll | |
[D3DKMTPresentMultiPlaneOverlay3](https://www.google.com/search?num=5&q=D3DKMTPresentMultiPlaneOverlay3+site%3Amicrosoft.com) | gdi32.dll | |
[D3DKMTPresentRedirected](https://www.google.com/search?num=5&q=D3DKMTPresentRedirected+site%3Amicrosoft.com) | gdi32.dll | |
[D3DKMTQueryAdapterInfo](https://www.google.com/search?num=5&q=D3DKMTQueryAdapterInfo+site%3Amicrosoft.com) | gdi32.dll | |
[D3DKMTQueryAllocationResidency](https://www.google.com/search?num=5&q=D3DKMTQueryAllocationResidency+site%3Amicrosoft.com) | gdi32.dll | |
[D3DKMTQueryClockCalibration](https://www.google.com/search?num=5&q=D3DKMTQueryClockCalibration+site%3Amicrosoft.com) | gdi32.dll | |
[D3DKMTQueryFSEBlock](https://www.google.com/search?num=5&q=D3DKMTQueryFSEBlock+site%3Amicrosoft.com) | gdi32.dll | |
[D3DKMTQueryProcessOfferInfo](https://www.google.com/search?num=5&q=D3DKMTQueryProcessOfferInfo+site%3Amicrosoft.com) | gdi32.dll | |
[D3DKMTQueryProtectedSessionInfoFromNtHandle](https://www.google.com/search?num=5&q=D3DKMTQueryProtectedSessionInfoFromNtHandle+site%3Amicrosoft.com) | gdi32.dll | |
[D3DKMTQueryProtectedSessionStatus](https://www.google.com/search?num=5&q=D3DKMTQueryProtectedSessionStatus+site%3Amicrosoft.com) | gdi32.dll | |
[D3DKMTQueryRemoteVidPnSourceFromGdiDisplayName](https://www.google.com/search?num=5&q=D3DKMTQueryRemoteVidPnSourceFromGdiDisplayName+site%3Amicrosoft.com) | gdi32.dll | |
[D3DKMTQueryResourceInfo](https://www.google.com/search?num=5&q=D3DKMTQueryResourceInfo+site%3Amicrosoft.com) | gdi32.dll | |
[D3DKMTQueryResourceInfoFromNtHandle](https://www.google.com/search?num=5&q=D3DKMTQueryResourceInfoFromNtHandle+site%3Amicrosoft.com) | gdi32.dll | |
@ -216,11 +231,13 @@ Native Method | Native DLL | Header | Managed Method
[D3DKMTReleaseKeyedMutex2](https://www.google.com/search?num=5&q=D3DKMTReleaseKeyedMutex2+site%3Amicrosoft.com) | gdi32.dll | |
[D3DKMTReleaseProcessVidPnSourceOwners](https://www.google.com/search?num=5&q=D3DKMTReleaseProcessVidPnSourceOwners+site%3Amicrosoft.com) | gdi32.dll | |
[D3DKMTReleaseSwapChain](https://www.google.com/search?num=5&q=D3DKMTReleaseSwapChain+site%3Amicrosoft.com) | gdi32.dll | |
[D3DKMTRemoveSurfaceFromSwapChain](https://www.google.com/search?num=5&q=D3DKMTRemoveSurfaceFromSwapChain+site%3Amicrosoft.com) | gdi32.dll | |
[D3DKMTRender](https://www.google.com/search?num=5&q=D3DKMTRender+site%3Amicrosoft.com) | gdi32.dll | |
[D3DKMTReserveGpuVirtualAddress](https://www.google.com/search?num=5&q=D3DKMTReserveGpuVirtualAddress+site%3Amicrosoft.com) | gdi32.dll | |
[D3DKMTSetAllocationPriority](https://www.google.com/search?num=5&q=D3DKMTSetAllocationPriority+site%3Amicrosoft.com) | gdi32.dll | |
[D3DKMTSetContextInProcessSchedulingPriority](https://www.google.com/search?num=5&q=D3DKMTSetContextInProcessSchedulingPriority+site%3Amicrosoft.com) | gdi32.dll | |
[D3DKMTSetContextSchedulingPriority](https://www.google.com/search?num=5&q=D3DKMTSetContextSchedulingPriority+site%3Amicrosoft.com) | gdi32.dll | |
[D3DKMTSetDeviceLostSupport](https://www.google.com/search?num=5&q=D3DKMTSetDeviceLostSupport+site%3Amicrosoft.com) | gdi32.dll | |
[D3DKMTSetDisplayMode](https://www.google.com/search?num=5&q=D3DKMTSetDisplayMode+site%3Amicrosoft.com) | gdi32.dll | |
[D3DKMTSetDisplayPrivateDriverFormat](https://www.google.com/search?num=5&q=D3DKMTSetDisplayPrivateDriverFormat+site%3Amicrosoft.com) | gdi32.dll | |
[D3DKMTSetDodIndirectSwapchain](https://www.google.com/search?num=5&q=D3DKMTSetDodIndirectSwapchain+site%3Amicrosoft.com) | gdi32.dll | |
@ -228,6 +245,7 @@ Native Method | Native DLL | Header | Managed Method
[D3DKMTSetGammaRamp](https://www.google.com/search?num=5&q=D3DKMTSetGammaRamp+site%3Amicrosoft.com) | gdi32.dll | |
[D3DKMTSetHwProtectionTeardownRecovery](https://www.google.com/search?num=5&q=D3DKMTSetHwProtectionTeardownRecovery+site%3Amicrosoft.com) | gdi32.dll | |
[D3DKMTSetMemoryBudgetTarget](https://www.google.com/search?num=5&q=D3DKMTSetMemoryBudgetTarget+site%3Amicrosoft.com) | gdi32.dll | |
[D3DKMTSetMonitorColorSpaceTransform](https://www.google.com/search?num=5&q=D3DKMTSetMonitorColorSpaceTransform+site%3Amicrosoft.com) | gdi32.dll | |
[D3DKMTSetProcessSchedulingPriorityBand](https://www.google.com/search?num=5&q=D3DKMTSetProcessSchedulingPriorityBand+site%3Amicrosoft.com) | gdi32.dll | |
[D3DKMTSetProcessSchedulingPriorityClass](https://www.google.com/search?num=5&q=D3DKMTSetProcessSchedulingPriorityClass+site%3Amicrosoft.com) | gdi32.dll | |
[D3DKMTSetQueuedLimit](https://www.google.com/search?num=5&q=D3DKMTSetQueuedLimit+site%3Amicrosoft.com) | gdi32.dll | |
@ -237,6 +255,7 @@ Native Method | Native DLL | Header | Managed Method
[D3DKMTSetVidPnSourceHwProtection](https://www.google.com/search?num=5&q=D3DKMTSetVidPnSourceHwProtection+site%3Amicrosoft.com) | gdi32.dll | |
[D3DKMTSetVidPnSourceOwner](https://www.google.com/search?num=5&q=D3DKMTSetVidPnSourceOwner+site%3Amicrosoft.com) | gdi32.dll | |
[D3DKMTSetVidPnSourceOwner1](https://www.google.com/search?num=5&q=D3DKMTSetVidPnSourceOwner1+site%3Amicrosoft.com) | gdi32.dll | |
[D3DKMTSetVidPnSourceOwner2](https://www.google.com/search?num=5&q=D3DKMTSetVidPnSourceOwner2+site%3Amicrosoft.com) | gdi32.dll | |
[D3DKMTSetYieldPercentage](https://www.google.com/search?num=5&q=D3DKMTSetYieldPercentage+site%3Amicrosoft.com) | gdi32.dll | |
[D3DKMTSharedPrimaryLockNotification](https://www.google.com/search?num=5&q=D3DKMTSharedPrimaryLockNotification+site%3Amicrosoft.com) | gdi32.dll | |
[D3DKMTSharedPrimaryUnLockNotification](https://www.google.com/search?num=5&q=D3DKMTSharedPrimaryUnLockNotification+site%3Amicrosoft.com) | gdi32.dll | |
@ -253,6 +272,7 @@ Native Method | Native DLL | Header | Managed Method
[D3DKMTTrimProcessCommitment](https://www.google.com/search?num=5&q=D3DKMTTrimProcessCommitment+site%3Amicrosoft.com) | gdi32.dll | |
[D3DKMTUnlock](https://www.google.com/search?num=5&q=D3DKMTUnlock+site%3Amicrosoft.com) | gdi32.dll | |
[D3DKMTUnlock2](https://www.google.com/search?num=5&q=D3DKMTUnlock2+site%3Amicrosoft.com) | gdi32.dll | |
[D3DKMTUnOrderedPresentSwapChain](https://www.google.com/search?num=5&q=D3DKMTUnOrderedPresentSwapChain+site%3Amicrosoft.com) | gdi32.dll | |
[D3DKMTUnpinDirectFlipResources](https://www.google.com/search?num=5&q=D3DKMTUnpinDirectFlipResources+site%3Amicrosoft.com) | gdi32.dll | |
[D3DKMTUnregisterTrimNotification](https://www.google.com/search?num=5&q=D3DKMTUnregisterTrimNotification+site%3Amicrosoft.com) | gdi32.dll | |
[D3DKMTUpdateAllocationProperty](https://www.google.com/search?num=5&q=D3DKMTUpdateAllocationProperty+site%3Amicrosoft.com) | gdi32.dll | |
@ -349,7 +369,7 @@ Native Method | Native DLL | Header | Managed Method
[EudcLoadLinkW](https://www.google.com/search?num=5&q=EudcLoadLinkW+site%3Amicrosoft.com) | gdi32.dll | |
[EudcUnloadLinkW](https://www.google.com/search?num=5&q=EudcUnloadLinkW+site%3Amicrosoft.com) | gdi32.dll | |
[ExcludeClipRect](https://www.google.com/search?num=5&q=ExcludeClipRect+site%3Amicrosoft.com) | gdi32.dll | |
[ExtCreatePen](https://www.google.com/search?num=5&q=ExtCreatePen+site%3Amicrosoft.com) | gdi32.dll | |
[ExtCreatePen](http://msdn2.microsoft.com/en-us/library/a1e81314-4fe6-481f-af96-24ebf56332cf) | gdi32.dll | wingdi.h | Vanara.PInvoke.Gdi32.ExtCreatePen
[ExtCreateRegion](https://www.google.com/search?num=5&q=ExtCreateRegion+site%3Amicrosoft.com) | gdi32.dll | |
[ExtEscape](https://www.google.com/search?num=5&q=ExtEscape+site%3Amicrosoft.com) | gdi32.dll | |
[ExtFloodFill](https://www.google.com/search?num=5&q=ExtFloodFill+site%3Amicrosoft.com) | gdi32.dll | |
@ -370,6 +390,7 @@ Native Method | Native DLL | Header | Managed Method
[FONTOBJ_pxoGetXform](https://www.google.com/search?num=5&q=FONTOBJ_pxoGetXform+site%3Amicrosoft.com) | gdi32.dll | |
[FONTOBJ_vGetInfo](https://www.google.com/search?num=5&q=FONTOBJ_vGetInfo+site%3Amicrosoft.com) | gdi32.dll | |
[FrameRgn](https://www.google.com/search?num=5&q=FrameRgn+site%3Amicrosoft.com) | gdi32.dll | |
[g_systemCallFilterId](https://www.google.com/search?num=5&q=g_systemCallFilterId+site%3Amicrosoft.com) | gdi32.dll | |
[Gdi32DllInitialize](https://www.google.com/search?num=5&q=Gdi32DllInitialize+site%3Amicrosoft.com) | gdi32.dll | |
[GdiAddFontResourceW](https://www.google.com/search?num=5&q=GdiAddFontResourceW+site%3Amicrosoft.com) | gdi32.dll | |
[GdiAddGlsBounds](https://www.google.com/search?num=5&q=GdiAddGlsBounds+site%3Amicrosoft.com) | gdi32.dll | |
@ -483,7 +504,7 @@ Native Method | Native DLL | Header | Managed Method
[GetBkMode](https://www.google.com/search?num=5&q=GetBkMode+site%3Amicrosoft.com) | gdi32.dll | |
[GetBoundsRect](https://www.google.com/search?num=5&q=GetBoundsRect+site%3Amicrosoft.com) | gdi32.dll | |
[GetBrushAttributes](https://www.google.com/search?num=5&q=GetBrushAttributes+site%3Amicrosoft.com) | gdi32.dll | |
[GetBrushOrgEx](https://www.google.com/search?num=5&q=GetBrushOrgEx+site%3Amicrosoft.com) | gdi32.dll | |
[GetBrushOrgEx](http://msdn2.microsoft.com/en-us/library/0b938237-cb06-4776-86f8-14478abcee00) | gdi32.dll | wingdi.h | Vanara.PInvoke.Gdi32.GetBrushOrgEx
[GetCertificate](https://www.google.com/search?num=5&q=GetCertificate+site%3Amicrosoft.com) | gdi32.dll | |
[GetCertificateByHandle](https://www.google.com/search?num=5&q=GetCertificateByHandle+site%3Amicrosoft.com) | gdi32.dll | |
[GetCertificateSize](https://www.google.com/search?num=5&q=GetCertificateSize+site%3Amicrosoft.com) | gdi32.dll | |
@ -571,6 +592,7 @@ Native Method | Native DLL | Header | Managed Method
[GetStretchBltMode](https://www.google.com/search?num=5&q=GetStretchBltMode+site%3Amicrosoft.com) | gdi32.dll | |
[GetStringBitmap](https://www.google.com/search?num=5&q=GetStringBitmapA+site%3Amicrosoft.com) | gdi32.dll | |
[GetSuggestedOPMProtectedOutputArraySize](https://www.google.com/search?num=5&q=GetSuggestedOPMProtectedOutputArraySize+site%3Amicrosoft.com) | gdi32.dll | |
[GetSysColorBrush](http://msdn2.microsoft.com/en-us/library/07a1d8e3-eae8-40ab-9d0f-4efa9fac0117) | user32.dll | winuser.h | Vanara.PInvoke.Gdi32.GetSysColorBrush
[GetSystemPaletteEntries](https://www.google.com/search?num=5&q=GetSystemPaletteEntries+site%3Amicrosoft.com) | gdi32.dll | |
[GetSystemPaletteUse](https://www.google.com/search?num=5&q=GetSystemPaletteUse+site%3Amicrosoft.com) | gdi32.dll | |
[GetTextAlign](https://www.google.com/search?num=5&q=GetTextAlign+site%3Amicrosoft.com) | gdi32.dll | |
@ -607,7 +629,7 @@ Native Method | Native DLL | Header | Managed Method
[IsValidEnhMetaRecordOffExt](https://www.google.com/search?num=5&q=IsValidEnhMetaRecordOffExt+site%3Amicrosoft.com) | gdi32.dll | |
[LineDDA](https://www.google.com/search?num=5&q=LineDDA+site%3Amicrosoft.com) | gdi32.dll | |
[LineTo](https://www.google.com/search?num=5&q=LineTo+site%3Amicrosoft.com) | gdi32.dll | |
[LPtoDP](https://www.google.com/search?num=5&q=LPtoDP+site%3Amicrosoft.com) | gdi32.dll | |
[LPtoDP](http://msdn2.microsoft.com/en-us/library/670a16fb-842e-4250-9ad7-dc08e849c2ba) | gdi32.dll | wingdi.h | Vanara.PInvoke.Gdi32.LPtoDP
[MaskBlt](https://www.google.com/search?num=5&q=MaskBlt+site%3Amicrosoft.com) | gdi32.dll | |
[MirrorRgn](https://www.google.com/search?num=5&q=MirrorRgn+site%3Amicrosoft.com) | gdi32.dll | |
[ModerncoreGdiInit](https://www.google.com/search?num=5&q=ModerncoreGdiInit+site%3Amicrosoft.com) | gdi32.dll | |
@ -619,7 +641,7 @@ Native Method | Native DLL | Header | Managed Method
[OffsetViewportOrgEx](https://www.google.com/search?num=5&q=OffsetViewportOrgEx+site%3Amicrosoft.com) | gdi32.dll | |
[OffsetWindowOrgEx](https://www.google.com/search?num=5&q=OffsetWindowOrgEx+site%3Amicrosoft.com) | gdi32.dll | |
[PaintRgn](https://www.google.com/search?num=5&q=PaintRgn+site%3Amicrosoft.com) | gdi32.dll | |
[PatBlt](https://www.google.com/search?num=5&q=PatBlt+site%3Amicrosoft.com) | gdi32.dll | |
[PatBlt](http://msdn2.microsoft.com/en-us/library/6deea8ef-b55d-4086-a54e-3f89bb17c6cd) | gdi32.dll | wingdi.h | Vanara.PInvoke.Gdi32.PatBlt
[PATHOBJ_bEnum](https://www.google.com/search?num=5&q=PATHOBJ_bEnum+site%3Amicrosoft.com) | gdi32.dll | |
[PATHOBJ_bEnumClipLines](https://www.google.com/search?num=5&q=PATHOBJ_bEnumClipLines+site%3Amicrosoft.com) | gdi32.dll | |
[PATHOBJ_vEnumStart](https://www.google.com/search?num=5&q=PATHOBJ_vEnumStart+site%3Amicrosoft.com) | gdi32.dll | |
@ -718,10 +740,11 @@ Native Method | Native DLL | Header | Managed Method
[SetBkMode](http://msdn2.microsoft.com/en-us/library/dd162965) | gdi32.dll | Wingdi.h | Vanara.PInvoke.Gdi32.SetBkMode
[SetBoundsRect](https://www.google.com/search?num=5&q=SetBoundsRect+site%3Amicrosoft.com) | gdi32.dll | |
[SetBrushAttributes](https://www.google.com/search?num=5&q=SetBrushAttributes+site%3Amicrosoft.com) | gdi32.dll | |
[SetBrushOrgEx](https://www.google.com/search?num=5&q=SetBrushOrgEx+site%3Amicrosoft.com) | gdi32.dll | |
[SetBrushOrgEx](http://msdn2.microsoft.com/en-us/library/dcc7575a-49fd-4306-8baa-57e9e0d5ed1f) | gdi32.dll | wingdi.h | Vanara.PInvoke.Gdi32.SetBrushOrgEx
[SetColorAdjustment](https://www.google.com/search?num=5&q=SetColorAdjustment+site%3Amicrosoft.com) | gdi32.dll | |
[SetColorSpace](https://www.google.com/search?num=5&q=SetColorSpace+site%3Amicrosoft.com) | gdi32.dll | |
[SetDCBrushColor](https://www.google.com/search?num=5&q=SetDCBrushColor+site%3Amicrosoft.com) | gdi32.dll | |
[SetDCDpiScaleValue](https://www.google.com/search?num=5&q=SetDCDpiScaleValue+site%3Amicrosoft.com) | gdi32.dll | |
[SetDCPenColor](https://www.google.com/search?num=5&q=SetDCPenColor+site%3Amicrosoft.com) | gdi32.dll | |
[SetDeviceGammaRamp](https://www.google.com/search?num=5&q=SetDeviceGammaRamp+site%3Amicrosoft.com) | gdi32.dll | |
[SetDIBColorTable](https://www.google.com/search?num=5&q=SetDIBColorTable+site%3Amicrosoft.com) | gdi32.dll | |
@ -799,6 +822,8 @@ Native Structure | Header | Managed Structure
[BITMAPINFOHEADER](http://msdn2.microsoft.com/en-us/library/dd183376) | Wingdi.h | Vanara.PInvoke.Gdi32+BITMAPINFOHEADER
[BLENDFUNCTION](http://msdn2.microsoft.com/en-us/library/dd183393) | Wingdi.h | Vanara.PInvoke.Gdi32+BLENDFUNCTION
[DIBSECTION](http://msdn2.microsoft.com/en-us/library/dd183567) | Wingdi.h | Vanara.PInvoke.Gdi32+DIBSECTION
[EXTLOGPEN](http://msdn2.microsoft.com/en-us/library/34ffa71d-e94d-425e-9f9d-21e3df4990b7) | wingdi.h | Vanara.PInvoke.Gdi32+EXTLOGPEN
[LOGBRUSH](http://msdn2.microsoft.com/en-us/library/ded2c7a4-2248-4d01-95c6-ab4050719094) | wingdi.h | Vanara.PInvoke.Gdi32+LOGBRUSH
[LOGPEN](http://msdn2.microsoft.com/en-us/library/0e098b5a-e249-43ad-a6d8-2509b6562453) | wingdi.h | Vanara.PInvoke.Gdi32+LOGPEN
[RGBQUAD](http://msdn2.microsoft.com/en-us/library/dd162938) | Wingdi.h | Vanara.PInvoke.Gdi32+RGBQUAD
[TEXTMETRIC](https://www.google.com/search?num=5&q=TEXTMETRIC+site%3Amicrosoft.com) | | Vanara.PInvoke.Gdi32+TEXTMETRIC
[TEXTMETRIC](http://msdn2.microsoft.com/en-us/library/0a46da58-5d0f-4db4-bba6-9e1b6c1f892c) | wingdi.h | Vanara.PInvoke.Gdi32+TEXTMETRIC

View File

@ -0,0 +1,123 @@
using System;
using System.Drawing;
using System.Drawing.Drawing2D;
using Vanara.Extensions;
using static Vanara.PInvoke.Gdi32;
namespace Vanara.PInvoke
{
/// <summary>Extension methods to convert GdiObj handle variants to their .NET equivalents.</summary>
public static class GdiObjExtensions
{
/// <summary>Creates a <see cref="Bitmap"/> from an <see cref="HBITMAP"/>.</summary>
/// <param name="hbmp">The HBMP value.</param>
/// <returns>The Bitmap instance.</returns>
public static Bitmap ToBitmap(this in HBITMAP hbmp) => hbmp.IsNull ? null : Image.FromHbitmap((IntPtr)hbmp);
/// <summary>Creates a <see cref="Bitmap"/> from a <see cref="SafeHBITMAP"/>.</summary>
/// <param name="hbmp">The HBMP value.</param>
/// <returns>The Bitmap instance.</returns>
public static Bitmap ToBitmap(this SafeHBITMAP hbmp) => ((HBITMAP)hbmp).ToBitmap();
/// <summary>Creates a managed <see cref="System.Drawing.Brush"/> from this HBRUSH instance.</summary>
/// <param name="hbr">The HBRUSH value.</param>
/// <returns>A managed brush instance.</returns>
public static Brush ToBrush(this in HBRUSH hbr) => hbr.IsNull ? null : new NativeBrush(hbr);
/// <summary>Creates a managed <see cref="System.Drawing.Brush"/> from this HBRUSH instance.</summary>
/// <param name="hbr">The HBRUSH value.</param>
/// <returns>A managed brush instance.</returns>
public static Brush ToBrush(this SafeHBRUSH hbr) => ((HBRUSH)hbr).ToBrush();
/// <summary>Creates a <see cref="Font"/> from an <see cref="HFONT"/>.</summary>
/// <param name="hf">The HFONT value.</param>
/// <returns>The Font instance.</returns>
public static Font ToFont(this in HFONT hf) => hf.IsNull ? null : Font.FromHfont((IntPtr)hf);
/// <summary>Creates a <see cref="Font"/> from an <see cref="HFONT"/>.</summary>
/// <param name="hf">The HFONT value.</param>
/// <returns>The Font instance.</returns>
public static Font ToFont(this SafeHFONT hf) => ((HFONT)hf).ToFont();
/// <summary>Creates a <see cref="Pen"/> from an <see cref="HPEN"/>.</summary>
/// <param name="hpen">The HPEN value.</param>
/// <returns>The Pen instance.</returns>
public static Pen ToPen(this in HPEN hpen)
{
using (var ptr = GetObject(hpen))
{
var lpen = ptr.ToStructure<EXTLOGPEN>();
Pen pen = null;
switch (lpen.elpBrushStyle)
{
case BrushStyle.BS_DIBPATTERN:
case BrushStyle.BS_DIBPATTERNPT:
var lw = (DIBColorMode)(uint)lpen.elpColor;
var hb = CreateDIBPatternBrushPt(lpen.elpHatch, lw);
pen = new Pen(((HBRUSH)hb).ToBrush());
break;
case BrushStyle.BS_HATCHED:
var hbr = new HatchBrush((System.Drawing.Drawing2D.HatchStyle)lpen.elpHatch.ToInt32(), lpen.elpColor);
pen = new Pen(hbr);
break;
case BrushStyle.BS_PATTERN:
var pbr = new TextureBrush(Image.FromHbitmap(lpen.elpHatch));
pen = new Pen(pbr);
break;
case BrushStyle.BS_HOLLOW:
case BrushStyle.BS_SOLID:
default:
pen = new Pen(lpen.elpColor) { DashStyle = (DashStyle)lpen.Style };
if (pen.DashStyle == DashStyle.Custom && lpen.elpNumEntries > 0)
{
var styleArray = lpen.elpStyleEntry.ToArray<uint>((int)lpen.elpNumEntries);
pen.DashPattern = Array.ConvertAll(styleArray, i => (float)i);
}
break;
}
if (lpen.Type == Gdi32.PenType.PS_GEOMETRIC)
{
pen.LineJoin = lpen.Join == PenJoin.PS_JOIN_MITER ? LineJoin.Miter : (lpen.Join == PenJoin.PS_JOIN_BEVEL ? LineJoin.Bevel : LineJoin.Round);
pen.EndCap = pen.StartCap = lpen.EndCap == PenEndCap.PS_ENDCAP_FLAT ? LineCap.Flat : (lpen.EndCap == PenEndCap.PS_ENDCAP_SQUARE ? LineCap.Square : LineCap.Round);
pen.Width = LogicalWidthToDeviceWidth((int)lpen.elpWidth);
}
else
{
pen.Width = lpen.elpWidth;
}
return pen;
}
}
/// <summary>Creates a <see cref="Pen"/> from an <see cref="HPEN"/>.</summary>
/// <param name="hpen">The HPEN value.</param>
/// <returns>The Pen instance.</returns>
public static Pen ToPen(this SafeHPEN hpen) => ((HPEN)hpen).ToPen();
/// <summary>Creates a <see cref="Region"/> from an <see cref="HRGN"/>.</summary>
/// <param name="hpen">The HRGN value.</param>
/// <returns>The Region instance.</returns>
public static Region ToRegion(this in HRGN hrgn) => hrgn.IsNull ? null : Region.FromHrgn((IntPtr)hrgn);
/// <summary>Creates a <see cref="Region"/> from an <see cref="HRGN"/>.</summary>
/// <param name="hpen">The HRGN value.</param>
/// <returns>The Region instance.</returns>
public static Region ToRegion(this SafeHRGN hrgn) => ((HRGN)hrgn).ToRegion();
private class NativeBrush : Brush
{
public NativeBrush(HBRUSH hBrush)
{
var lb = GetObject<LOGBRUSH>(hBrush);
var b2 = CreateBrushIndirect(lb);
SetNativeBrush(b2.DangerousGetHandle());
b2.SetHandleAsInvalid();
}
public override object Clone() => this;
}
}
}

View File

@ -25,13 +25,13 @@
<PackageReleaseNotes>Currently implements:
Functions
BitBlt, CreateBrushIndirect, CreateCompatibleDC, CreateDIBSection, DeleteDC, DeleteObject, GdiAlphaBlend, GdiFlush, GdiTransparentBlt, GetDeviceCaps, GetDIBits, GetObjectA, GetObjectW, SelectObject, SetBkMode, SetLayout
BitBlt, CreateBrushIndirect, CreateCompatibleDC, CreateDIBPatternBrush, CreateDIBPatternBrushPt, CreateDIBSection, CreateHatchBrush, CreatePatternBrush, CreatePen, CreatePenIndirect, CreateSolidBrush, DeleteDC, DeleteObject, ExtCreatePen, GdiAlphaBlend, GdiFlush, GdiTransparentBlt, GetBrushOrgEx, GetDeviceCaps, GetDIBits, GetObjectA, GetObjectW, GetSysColorBrush, LPtoDP, PatBlt, SelectObject, SetBkMode, SetBrushOrgEx, SetLayout
Structures
BITMAP, BITMAPINFO, BITMAPINFOHEADER, DIBSECTION, RGBQUAD, BLENDFUNCTION, LOGBRUSH, TEXTMETRIC
BITMAP, BITMAPINFO, BITMAPINFOHEADER, DIBSECTION, RGBQUAD, BLENDFUNCTION, LOGBRUSH, EXTLOGPEN, LOGPEN, TEXTMETRIC
</PackageReleaseNotes>
<LangVersion>latest</LangVersion>
<LangVersion>latest</LangVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)'=='Release'">
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
@ -49,6 +49,12 @@ BITMAP, BITMAPINFO, BITMAPINFOHEADER, DIBSECTION, RGBQUAD, BLENDFUNCTION, LOGBRU
<ItemGroup Condition=" '$(TargetFramework)' == 'net45' ">
<Reference Include="System" />
</ItemGroup>
<ItemGroup>
<Compile Remove="WinGdi.Helpers.cs" />
</ItemGroup>
<ItemGroup>
<None Include="WinGdi.Helpers.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\Core\Vanara.Core.csproj" />
<ProjectReference Include="..\Shared\Vanara.PInvoke.Shared.csproj" />

View File

@ -172,7 +172,7 @@ namespace Vanara.PInvoke
/// </remarks>
[DllImport(Lib.Gdi32, ExactSpelling = true, SetLastError = true)]
[PInvokeData("Wingdi.h", MSDNShortId = "dd144879")]
public static extern int GetDIBits(HDC hdc, SafeHBITMAP hbmp, int uStartScan, int cScanLines, ref byte[] lpvBits, ref BITMAPINFO lpbi, DIBColorMode uUsage);
public static extern int GetDIBits(HDC hdc, HBITMAP hbmp, int uStartScan, int cScanLines, ref byte[] lpvBits, ref BITMAPINFO lpbi, DIBColorMode uUsage);
/// <summary>
/// The GetDIBits function retrieves the bits of the specified compatible bitmap and copies them into a buffer as a DIB using the specified format.
@ -240,7 +240,7 @@ namespace Vanara.PInvoke
/// </remarks>
[DllImport(Lib.Gdi32, ExactSpelling = true, SetLastError = true)]
[PInvokeData("Wingdi.h", MSDNShortId = "dd144879")]
public static extern int GetDIBits(HDC hdc, SafeHBITMAP hbmp, int uStartScan, int cScanLines, IntPtr lpvBits, ref BITMAPINFO lpbi, DIBColorMode uUsage);
public static extern int GetDIBits(HDC hdc, HBITMAP hbmp, int uStartScan, int cScanLines, IntPtr lpvBits, ref BITMAPINFO lpbi, DIBColorMode uUsage);
/// <summary>The BITMAP structure defines the type, width, height, color format, and bit values of a bitmap.</summary>
[StructLayout(LayoutKind.Sequential)]
@ -530,8 +530,19 @@ namespace Vanara.PInvoke
/// <value>The color.</value>
public System.Drawing.Color Color
{
get => System.Drawing.Color.FromArgb(rgbReserved, rgbRed, rgbGreen, rgbBlue); set { rgbReserved = value.A; rgbBlue = value.B; rgbGreen = value.G; rgbRed = value.R; }
get => System.Drawing.Color.FromArgb(rgbReserved, rgbRed, rgbGreen, rgbBlue);
set { rgbReserved = value.A; rgbBlue = value.B; rgbGreen = value.G; rgbRed = value.R; }
}
/// <summary>Performs an implicit conversion from <see cref="System.Drawing.Color"/> to <see cref="RGBQUAD"/>.</summary>
/// <param name="c">The c.</param>
/// <returns>The result of the conversion.</returns>
public static implicit operator RGBQUAD(System.Drawing.Color c) => new RGBQUAD() { Color = c };
/// <summary>Performs an implicit conversion from <see cref="RGBQUAD"/> to <see cref="System.Drawing.Color"/>.</summary>
/// <param name="c">The c.</param>
/// <returns>The result of the conversion.</returns>
public static implicit operator System.Drawing.Color(RGBQUAD c) => c.Color;
}
}
}

View File

@ -1,5 +1,4 @@
using System.Runtime.InteropServices;
// ReSharper disable InconsistentNaming
namespace Vanara.PInvoke
{

View File

@ -0,0 +1,747 @@
using System;
using System.Drawing;
using System.Runtime.InteropServices;
namespace Vanara.PInvoke
{
public static partial class Gdi32
{
/// <summary>
/// <para>The <c>CreateBrushIndirect</c> function creates a logical brush that has the specified style, color, and pattern.</para>
/// </summary>
/// <param name="plbrush">
/// <para>A pointer to a LOGBRUSH structure that contains information about the brush.</para>
/// </param>
/// <returns>
/// <para>If the function succeeds, the return value identifies a logical brush.</para>
/// <para>If the function fails, the return value is <c>NULL</c>.</para>
/// </returns>
/// <remarks>
/// <para>A brush is a bitmap that the system uses to paint the interiors of filled shapes.</para>
/// <para>
/// After an application creates a brush by calling <c>CreateBrushIndirect</c>, it can select it into any device context by calling
/// the SelectObject function.
/// </para>
/// <para>
/// A brush created by using a monochrome bitmap (one color plane, one bit per pixel) is drawn using the current text and background
/// colors. Pixels represented by a bit set to 0 are drawn with the current text color; pixels represented by a bit set to 1 are
/// drawn with the current background color.
/// </para>
/// <para>When you no longer need the brush, call the DeleteObject function to delete it.</para>
/// <para>
/// <c>ICM:</c> No color is done at brush creation. However, color management is performed when the brush is selected into an
/// ICM-enabled device context.
/// </para>
/// </remarks>
// https://docs.microsoft.com/en-us/windows/desktop/api/wingdi/nf-wingdi-createbrushindirect HBRUSH CreateBrushIndirect( CONST
// LOGBRUSH *plbrush );
[DllImport(Lib.Gdi32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("wingdi.h", MSDNShortId = "75f94ad1-ca25-4ad1-9e8c-ad1a4b8475a7")]
public static extern SafeHBRUSH CreateBrushIndirect(in LOGBRUSH plbrush);
/// <summary>
/// <para>
/// The <c>CreateDIBPatternBrush</c> function creates a logical brush that has the pattern specified by the specified
/// device-independent bitmap (DIB). The brush can subsequently be selected into any device context that is associated with a device
/// that supports raster operations.
/// </para>
/// <para>
/// <c>Note</c> This function is provided only for compatibility with 16-bit versions of Windows. Applications should use the
/// CreateDIBPatternBrushPt function.
/// </para>
/// </summary>
/// <param name="h">
/// <para>
/// A handle to a global memory object containing a packed DIB, which consists of a BITMAPINFO structure immediately followed by an
/// array of bytes defining the pixels of the bitmap.
/// </para>
/// </param>
/// <param name="iUsage">
/// <para>
/// Specifies whether the <c>bmiColors</c> member of the BITMAPINFO structure is initialized and, if so, whether this member contains
/// explicit red, green, blue (RGB) values or indexes into a logical palette. The fuColorSpec parameter must be one of the following values.
/// </para>
/// <list type="table">
/// <listheader>
/// <term>Value</term>
/// <term>Meaning</term>
/// </listheader>
/// <item>
/// <term>DIB_PAL_COLORS</term>
/// <term>
/// A color table is provided and consists of an array of 16-bit indexes into the logical palette of the device context into which
/// the brush is to be selected.
/// </term>
/// </item>
/// <item>
/// <term>DIB_RGB_COLORS</term>
/// <term>A color table is provided and contains literal RGB values.</term>
/// </item>
/// </list>
/// </param>
/// <returns>
/// <para>If the function succeeds, the return value identifies a logical brush.</para>
/// <para>If the function fails, the return value is <c>NULL</c>.</para>
/// </returns>
/// <remarks>
/// <para>
/// When an application selects a two-color DIB pattern brush into a monochrome device context, the system does not acknowledge the
/// colors specified in the DIB; instead, it displays the pattern brush using the current background and foreground colors of the
/// device context. Pixels mapped to the first color of the DIB (offset 0 in the DIB color table) are displayed using the foreground
/// color; pixels mapped to the second color (offset 1 in the color table) are displayed using the background color.
/// </para>
/// <para>When you no longer need the brush, call the DeleteObject function to delete it.</para>
/// <para>
/// <c>ICM:</c> No color is done at brush creation. However, color management is performed when the brush is selected into an
/// ICM-enabled device context.
/// </para>
/// </remarks>
// https://docs.microsoft.com/en-us/windows/desktop/api/wingdi/nf-wingdi-createdibpatternbrush HBRUSH CreateDIBPatternBrush( HGLOBAL
// h, UINT iUsage );
[DllImport(Lib.Gdi32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("wingdi.h", MSDNShortId = "d123ef44-e047-4188-a2bc-20e479869dc3")]
[Obsolete("This function is provided only for compatibility with 16-bit versions of Windows. Applications should use the CreateDIBPatternBrushPt function.")]
public static extern SafeHBRUSH CreateDIBPatternBrush(IntPtr h, DIBColorMode iUsage);
/// <summary>
/// <para>
/// The <c>CreateDIBPatternBrushPt</c> function creates a logical brush that has the pattern specified by the device-independent
/// bitmap (DIB).
/// </para>
/// </summary>
/// <param name="lpPackedDIB">
/// <para>
/// A pointer to a packed DIB consisting of a BITMAPINFO structure immediately followed by an array of bytes defining the pixels of
/// the bitmap.
/// </para>
/// </param>
/// <param name="iUsage">
/// <para>
/// Specifies whether the <c>bmiColors</c> member of the BITMAPINFO structure contains a valid color table and, if so, whether the
/// entries in this color table contain explicit red, green, blue (RGB) values or palette indexes. The iUsage parameter must be one
/// of the following values.
/// </para>
/// <list type="table">
/// <listheader>
/// <term>Value</term>
/// <term>Meaning</term>
/// </listheader>
/// <item>
/// <term>DIB_PAL_COLORS</term>
/// <term>
/// A color table is provided and consists of an array of 16-bit indexes into the logical palette of the device context into which
/// the brush is to be selected.
/// </term>
/// </item>
/// <item>
/// <term>DIB_RGB_COLORS</term>
/// <term>A color table is provided and contains literal RGB values.</term>
/// </item>
/// </list>
/// </param>
/// <returns>
/// <para>If the function succeeds, the return value identifies a logical brush.</para>
/// <para>If the function fails, the return value is <c>NULL</c>.</para>
/// </returns>
/// <remarks>
/// <para>A brush is a bitmap that the system uses to paint the interiors of filled shapes.</para>
/// <para>
/// After an application creates a brush by calling <c>CreateDIBPatternBrushPt</c>, it can select that brush into any device context
/// by calling the SelectObject function.
/// </para>
/// <para>When you no longer need the brush, call the DeleteObject function to delete it.</para>
/// <para>
/// <c>ICM:</c> No color is done at brush creation. However, color management is performed when the brush is selected into an
/// ICM-enabled device context.
/// </para>
/// </remarks>
// https://docs.microsoft.com/en-us/windows/desktop/api/wingdi/nf-wingdi-createdibpatternbrushpt HBRUSH CreateDIBPatternBrushPt(
// const VOID *lpPackedDIB, UINT iUsage );
[DllImport(Lib.Gdi32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("wingdi.h", MSDNShortId = "0e34d108-fd35-4512-9eb3-c7710af36e95")]
public static extern SafeHBRUSH CreateDIBPatternBrushPt(IntPtr lpPackedDIB, DIBColorMode iUsage);
/// <summary>
/// <para>The <c>CreateHatchBrush</c> function creates a logical brush that has the specified hatch pattern and color.</para>
/// </summary>
/// <param name="iHatch">
/// <para>The hatch style of the brush. This parameter can be one of the following values.</para>
/// <list type="table">
/// <listheader>
/// <term>Value</term>
/// <term>Meaning</term>
/// </listheader>
/// <item>
/// <term>HS_BDIAGONAL</term>
/// <term>45-degree upward left-to-right hatch</term>
/// </item>
/// <item>
/// <term>HS_CROSS</term>
/// <term>Horizontal and vertical crosshatch</term>
/// </item>
/// <item>
/// <term>HS_DIAGCROSS</term>
/// <term>45-degree crosshatch</term>
/// </item>
/// <item>
/// <term>HS_FDIAGONAL</term>
/// <term>45-degree downward left-to-right hatch</term>
/// </item>
/// <item>
/// <term>HS_HORIZONTAL</term>
/// <term>Horizontal hatch</term>
/// </item>
/// <item>
/// <term>HS_VERTICAL</term>
/// <term>Vertical hatch</term>
/// </item>
/// </list>
/// </param>
/// <param name="color">
/// <para>The foreground color of the brush that is used for the hatches. To create a COLORREF color value, use the RGB macro.</para>
/// </param>
/// <returns>
/// <para>If the function succeeds, the return value identifies a logical brush.</para>
/// <para>If the function fails, the return value is <c>NULL</c>.</para>
/// </returns>
/// <remarks>
/// <para>A brush is a bitmap that the system uses to paint the interiors of filled shapes.</para>
/// <para>
/// After an application creates a brush by calling <c>CreateHatchBrush</c>, it can select that brush into any device context by
/// calling the SelectObject function. It can also call SetBkMode to affect the rendering of the brush.
/// </para>
/// <para>
/// If an application uses a hatch brush to fill the backgrounds of both a parent and a child window with matching color, you must
/// set the brush origin before painting the background of the child window. You can do this by calling the SetBrushOrgEx function.
/// Your application can retrieve the current brush origin by calling the GetBrushOrgEx function.
/// </para>
/// <para>When you no longer need the brush, call the DeleteObject function to delete it.</para>
/// <para>
/// <c>ICM:</c> No color is defined at brush creation. However, color management is performed when the brush is selected into an
/// ICM-enabled device context.
/// </para>
/// <para>Examples</para>
/// <para>
/// The following example creates a logical brush that has the specified hatch pattern and color. You can also set a hatch brush
/// background to transparent or to opaque.
/// </para>
/// </remarks>
// https://docs.microsoft.com/en-us/windows/desktop/api/wingdi/nf-wingdi-createhatchbrush HBRUSH CreateHatchBrush( int iHatch,
// COLORREF color );
[DllImport(Lib.Gdi32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("wingdi.h", MSDNShortId = "0b5849d6-1e22-4ac5-980c-2f2a73b16adb")]
public static extern SafeHBRUSH CreateHatchBrush(HatchStyle iHatch, COLORREF color);
/// <summary>
/// <para>
/// The <c>CreatePatternBrush</c> function creates a logical brush with the specified bitmap pattern. The bitmap can be a DIB section
/// bitmap, which is created by the <c>CreateDIBSection</c> function, or it can be a device-dependent bitmap.
/// </para>
/// </summary>
/// <param name="hbm">
/// <para>A handle to the bitmap to be used to create the logical brush.</para>
/// </param>
/// <returns>
/// <para>If the function succeeds, the return value identifies a logical brush.</para>
/// <para>If the function fails, the return value is <c>NULL</c>.</para>
/// </returns>
/// <remarks>
/// <para>A pattern brush is a bitmap that the system uses to paint the interiors of filled shapes.</para>
/// <para>
/// After an application creates a brush by calling <c>CreatePatternBrush</c>, it can select that brush into any device context by
/// calling the SelectObject function.
/// </para>
/// <para>
/// You can delete a pattern brush without affecting the associated bitmap by using the DeleteObject function. Therefore, you can
/// then use this bitmap to create any number of pattern brushes.
/// </para>
/// <para>
/// A brush created by using a monochrome (1 bit per pixel) bitmap has the text and background colors of the device context to which
/// it is drawn. Pixels represented by a 0 bit are drawn with the current text color; pixels represented by a 1 bit are drawn with
/// the current background color.
/// </para>
/// <para>
/// <c>ICM:</c> No color is done at brush creation. However, color management is performed when the brush is selected into an
/// ICM-enabled device context.
/// </para>
/// <para>Examples</para>
/// <para>For an example, see Using Brushes.</para>
/// </remarks>
// https://docs.microsoft.com/en-us/windows/desktop/api/wingdi/nf-wingdi-createpatternbrush HBRUSH CreatePatternBrush( HBITMAP hbm );
[DllImport(Lib.Gdi32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("wingdi.h", MSDNShortId = "a3cf347e-9803-4bb0-bdb3-98929ef859ab")]
public static extern SafeHBRUSH CreatePatternBrush(HBITMAP hbm);
/// <summary>
/// <para>The <c>CreateSolidBrush</c> function creates a logical brush that has the specified solid color.</para>
/// </summary>
/// <param name="color">
/// <para>The color of the brush. To create a COLORREF color value, use the RGB macro.</para>
/// </param>
/// <returns>
/// <para>If the function succeeds, the return value identifies a logical brush.</para>
/// <para>If the function fails, the return value is <c>NULL</c>.</para>
/// </returns>
/// <remarks>
/// <para>When you no longer need the <c>HBRUSH</c> object, call the DeleteObject function to delete it.</para>
/// <para>A solid brush is a bitmap that the system uses to paint the interiors of filled shapes.</para>
/// <para>
/// After an application creates a brush by calling <c>CreateSolidBrush</c>, it can select that brush into any device context by
/// calling the SelectObject function.
/// </para>
/// <para>
/// To paint with a system color brush, an application should use instead of , because GetSysColorBrush returns a cached brush
/// instead of allocating a new one.
/// </para>
/// <para>
/// <c>ICM:</c> No color management is done at brush creation. However, color management is performed when the brush is selected into
/// an ICM-enabled device context.
/// </para>
/// <para>Examples</para>
/// <para>For an example, see Creating Colored Pens and Brushes.</para>
/// </remarks>
// https://docs.microsoft.com/en-us/windows/desktop/api/wingdi/nf-wingdi-createsolidbrush HBRUSH CreateSolidBrush( COLORREF color );
[DllImport(Lib.Gdi32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("wingdi.h", MSDNShortId = "e39b5f77-97d8-4ea6-8277-7da12b3367f3")]
public static extern SafeHBRUSH CreateSolidBrush(COLORREF color);
/// <summary>
/// <para>
/// The <c>GetBrushOrgEx</c> function retrieves the current brush origin for the specified device context. This function replaces the
/// <c>GetBrushOrg</c> function.
/// </para>
/// </summary>
/// <param name="hdc">
/// <para>A handle to the device context.</para>
/// </param>
/// <param name="lppt">
/// <para>A pointer to a POINT structure that receives the brush origin, in device coordinates.</para>
/// </param>
/// <returns>
/// <para>If the function succeeds, the return value is nonzero.</para>
/// <para>If the function fails, the return value is zero.</para>
/// </returns>
/// <remarks>
/// <para>A brush is a bitmap that the system uses to paint the interiors of filled shapes.</para>
/// <para>
/// The brush origin is a set of coordinates with values between 0 and 7, specifying the location of one pixel in the bitmap. The
/// default brush origin coordinates are (0,0). For horizontal coordinates, the value 0 corresponds to the leftmost column of pixels;
/// the value 7 corresponds to the rightmost column. For vertical coordinates, the value 0 corresponds to the uppermost row of
/// pixels; the value 7 corresponds to the lowermost row. When the system positions the brush at the start of any painting operation,
/// it maps the origin of the brush to the location in the window's client area specified by the brush origin. For example, if the
/// origin is set to (2,3), the system maps the origin of the brush (0,0) to the location (2,3) on the window's client area.
/// </para>
/// <para>
/// If an application uses a brush to fill the backgrounds of both a parent and a child window with matching colors, it may be
/// necessary to set the brush origin after painting the parent window but before painting the child window.
/// </para>
/// <para>
/// The system automatically tracks the origin of all window-managed device contexts and adjusts their brushes as necessary to
/// maintain an alignment of patterns on the surface.
/// </para>
/// </remarks>
// https://docs.microsoft.com/en-us/windows/desktop/api/wingdi/nf-wingdi-getbrushorgex BOOL GetBrushOrgEx( HDC hdc, LPPOINT lppt );
[DllImport(Lib.Gdi32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("wingdi.h", MSDNShortId = "0b938237-cb06-4776-86f8-14478abcee00")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool GetBrushOrgEx(HDC hdc, out Point lppt);
/// <summary>
/// <para>
/// The <c>GetSysColorBrush</c> function retrieves a handle identifying a logical brush that corresponds to the specified color index.
/// </para>
/// </summary>
/// <param name="nIndex">
/// <para>
/// A color index. This value corresponds to the color used to paint one of the window elements. See GetSysColor for system color
/// index values.
/// </para>
/// </param>
/// <returns>
/// <para>
/// The return value identifies a logical brush if the nIndex parameter is supported by the current platform. Otherwise, it returns <c>NULL</c>.
/// </para>
/// </returns>
/// <remarks>
/// <para>
/// A brush is a bitmap that the system uses to paint the interiors of filled shapes. An application can retrieve the current system
/// colors by calling the GetSysColor function. An application can set the current system colors by calling the SetSysColors function.
/// </para>
/// <para>
/// An application must not register a window class for a window using a system brush. To register a window class with a system
/// color, see the documentation of the <c>hbrBackground</c> member of the WNDCLASS or WNDCLASSEX structures.
/// </para>
/// <para>
/// System color brushes track changes in system colors. In other words, when the user changes a system color, the associated system
/// color brush automatically changes to the new color.
/// </para>
/// <para>
/// To paint with a system color brush, an application should use <c>GetSysColorBrush</c> (nIndex) instead of CreateSolidBrush (
/// GetSysColor (nIndex)), because <c>GetSysColorBrush</c> returns a cached brush instead of allocating a new one.
/// </para>
/// <para>
/// System color brushes are owned by the system so you don't need to destroy them. Although you don't need to delete the logical
/// brush that <c>GetSysColorBrush</c> returns, no harm occurs by calling DeleteObject.
/// </para>
/// </remarks>
// https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-getsyscolorbrush HBRUSH GetSysColorBrush( int nIndex );
[DllImport(Lib.User32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("winuser.h", MSDNShortId = "07a1d8e3-eae8-40ab-9d0f-4efa9fac0117")]
public static extern HBRUSH GetSysColorBrush(SystemColorIndex nIndex);
/// <summary>
/// <para>
/// The <c>PatBlt</c> function paints the specified rectangle using the brush that is currently selected into the specified device
/// context. The brush color and the surface color or colors are combined by using the specified raster operation.
/// </para>
/// </summary>
/// <param name="hdc">
/// <para>A handle to the device context.</para>
/// </param>
/// <param name="x">
/// <para>The x-coordinate, in logical units, of the upper-left corner of the rectangle to be filled.</para>
/// </param>
/// <param name="y">
/// <para>The y-coordinate, in logical units, of the upper-left corner of the rectangle to be filled.</para>
/// </param>
/// <param name="w">
/// <para>The width, in logical units, of the rectangle.</para>
/// </param>
/// <param name="h">
/// <para>The height, in logical units, of the rectangle.</para>
/// </param>
/// <param name="rop">
/// <para>The raster operation code. This code can be one of the following values.</para>
/// <list type="table">
/// <listheader>
/// <term>Value</term>
/// <term>Meaning</term>
/// </listheader>
/// <item>
/// <term>PATCOPY</term>
/// <term>Copies the specified pattern into the destination bitmap.</term>
/// </item>
/// <item>
/// <term>PATINVERT</term>
/// <term>Combines the colors of the specified pattern with the colors of the destination rectangle by using the Boolean XOR operator.</term>
/// </item>
/// <item>
/// <term>DSTINVERT</term>
/// <term>Inverts the destination rectangle.</term>
/// </item>
/// <item>
/// <term>BLACKNESS</term>
/// <term>
/// Fills the destination rectangle using the color associated with index 0 in the physical palette. (This color is black for the
/// default physical palette.)
/// </term>
/// </item>
/// <item>
/// <term>WHITENESS</term>
/// <term>
/// Fills the destination rectangle using the color associated with index 1 in the physical palette. (This color is white for the
/// default physical palette.)
/// </term>
/// </item>
/// </list>
/// </param>
/// <returns>
/// <para>If the function succeeds, the return value is nonzero.</para>
/// <para>If the function fails, the return value is zero.</para>
/// </returns>
/// <remarks>
/// <para>
/// The values of the dwRop parameter for this function are a limited subset of the full 256 ternary raster-operation codes; in
/// particular, an operation code that refers to a source rectangle cannot be used.
/// </para>
/// <para>
/// Not all devices support the <c>PatBlt</c> function. For more information, see the description of the RC_BITBLT capability in the
/// GetDeviceCaps function.
/// </para>
/// <para>Examples</para>
/// <para>For an example, see "Example of Menu-Item Bitmaps" in Using Menus.</para>
/// </remarks>
// https://docs.microsoft.com/en-us/windows/desktop/api/wingdi/nf-wingdi-patblt BOOL PatBlt( HDC hdc, int x, int y, int w, int h,
// DWORD rop );
[DllImport(Lib.Gdi32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("wingdi.h", MSDNShortId = "6deea8ef-b55d-4086-a54e-3f89bb17c6cd")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool PatBlt(HDC hdc, int x, int y, int w, int h, RasterOperationMode rop);
/// <summary>
/// <para>
/// The <c>SetBrushOrgEx</c> function sets the brush origin that GDI assigns to the next brush an application selects into the
/// specified device context.
/// </para>
/// </summary>
/// <param name="hdc">
/// <para>A handle to the device context.</para>
/// </param>
/// <param name="x">
/// <para>
/// The x-coordinate, in device units, of the new brush origin. If this value is greater than the brush width, its value is reduced
/// using the modulus operator (nXOrg <c>mod</c> brush width).
/// </para>
/// </param>
/// <param name="y">
/// <para>
/// The y-coordinate, in device units, of the new brush origin. If this value is greater than the brush height, its value is reduced
/// using the modulus operator (nYOrg <c>mod</c> brush height).
/// </para>
/// </param>
/// <param name="lppt">
/// <para>A pointer to a POINT structure that receives the previous brush origin.</para>
/// <para>This parameter can be <c>NULL</c> if the previous brush origin is not required.</para>
/// </param>
/// <returns>
/// <para>If the function succeeds, the return value is nonzero.</para>
/// <para>If the function fails, the return value is zero.</para>
/// </returns>
/// <remarks>
/// <para>A brush is a bitmap that the system uses to paint the interiors of filled shapes.</para>
/// <para>
/// The brush origin is a pair of coordinates specifying the location of one pixel in the bitmap. The default brush origin
/// coordinates are (0,0). For horizontal coordinates, the value 0 corresponds to the leftmost column of pixels; the width
/// corresponds to the rightmost column. For vertical coordinates, the value 0 corresponds to the uppermost row of pixels; the height
/// corresponds to the lowermost row.
/// </para>
/// <para>
/// The system automatically tracks the origin of all window-managed device contexts and adjusts their brushes as necessary to
/// maintain an alignment of patterns on the surface. The brush origin that is set with this call is relative to the upper-left
/// corner of the client area.
/// </para>
/// <para>
/// An application should call <c>SetBrushOrgEx</c> after setting the bitmap stretching mode to HALFTONE by using SetStretchBltMode.
/// This must be done to avoid brush misalignment.
/// </para>
/// <para>
/// The system automatically tracks the origin of all window-managed device contexts and adjusts their brushes as necessary to
/// maintain an alignment of patterns on the surface.
/// </para>
/// </remarks>
// https://docs.microsoft.com/en-us/windows/desktop/api/wingdi/nf-wingdi-setbrushorgex BOOL SetBrushOrgEx( HDC hdc, int x, int y,
// LPPOINT lppt );
[DllImport(Lib.Gdi32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("wingdi.h", MSDNShortId = "dcc7575a-49fd-4306-8baa-57e9e0d5ed1f")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SetBrushOrgEx(HDC hdc, int x, int y, in Point lppt);
/// <summary>
/// <para>
/// The <c>LOGBRUSH</c> structure defines the style, color, and pattern of a physical brush. It is used by the CreateBrushIndirect
/// and ExtCreatePen functions.
/// </para>
/// </summary>
/// <remarks>
/// <para>
/// Although <c>lbColor</c> controls the foreground color of a hatch brush, the SetBkMode and SetBkColor functions control the
/// background color.
/// </para>
/// </remarks>
// https://docs.microsoft.com/en-us/windows/desktop/api/wingdi/ns-wingdi-taglogbrush typedef struct tagLOGBRUSH { UINT lbStyle;
// COLORREF lbColor; ULONG_PTR lbHatch; } LOGBRUSH, *PLOGBRUSH, *NPLOGBRUSH, *LPLOGBRUSH;
[PInvokeData("wingdi.h", MSDNShortId = "ded2c7a4-2248-4d01-95c6-ab4050719094")]
[StructLayout(LayoutKind.Explicit)]
public struct LOGBRUSH
{
/// <summary>
/// <para>The brush style. The <c>lbStyle</c> member must be one of the following styles.</para>
/// <list type="table">
/// <listheader>
/// <term>Value</term>
/// <term>Meaning</term>
/// </listheader>
/// <item>
/// <term>BS_DIBPATTERN</term>
/// <term>
/// A pattern brush defined by a device-independent bitmap (DIB) specification. If lbStyle is BS_DIBPATTERN, the lbHatch member
/// contains a handle to a packed DIB. For more information, see discussion in lbHatch.
/// </term>
/// </item>
/// <item>
/// <term>BS_DIBPATTERN8X8</term>
/// <term>See BS_DIBPATTERN.</term>
/// </item>
/// <item>
/// <term>BS_DIBPATTERNPT</term>
/// <term>
/// A pattern brush defined by a device-independent bitmap (DIB) specification. If lbStyle is BS_DIBPATTERNPT, the lbHatch member
/// contains a pointer to a packed DIB. For more information, see discussion in lbHatch.
/// </term>
/// </item>
/// <item>
/// <term>BS_HATCHED</term>
/// <term>Hatched brush.</term>
/// </item>
/// <item>
/// <term>BS_HOLLOW</term>
/// <term>Hollow brush.</term>
/// </item>
/// <item>
/// <term>BS_NULL</term>
/// <term>Same as BS_HOLLOW.</term>
/// </item>
/// <item>
/// <term>BS_PATTERN</term>
/// <term>Pattern brush defined by a memory bitmap.</term>
/// </item>
/// <item>
/// <term>BS_PATTERN8X8</term>
/// <term>See BS_PATTERN.</term>
/// </item>
/// <item>
/// <term>BS_SOLID</term>
/// <term>Solid brush.</term>
/// </item>
/// </list>
/// </summary>
[FieldOffset(0)]
public BrushStyle lbStyle;
/// <summary>
/// <para>
/// The color in which the brush is to be drawn. If <c>lbStyle</c> is the BS_HOLLOW or BS_PATTERN style, <c>lbColor</c> is ignored.
/// </para>
/// <para>
/// If <c>lbStyle</c> is BS_DIBPATTERN or BS_DIBPATTERNPT, the low-order word of <c>lbColor</c> specifies whether the
/// <c>bmiColors</c> members of the BITMAPINFO structure contain explicit red, green, blue (RGB) values or indexes into the
/// currently realized logical palette. The <c>lbColor</c> member must be one of the following values.
/// </para>
/// <list type="table">
/// <listheader>
/// <term>Value</term>
/// <term>Meaning</term>
/// </listheader>
/// <item>
/// <term>DIB_PAL_COLORS</term>
/// <term>The color table consists of an array of 16-bit indexes into the currently realized logical palette.</term>
/// </item>
/// <item>
/// <term>DIB_RGB_COLORS</term>
/// <term>The color table contains literal RGB values.</term>
/// </item>
/// </list>
/// <para>
/// If <c>lbStyle</c> is BS_HATCHED or BS_SOLID, <c>lbColor</c> is a COLORREF color value. To create a <c>COLORREF</c> color
/// value, use the RGB macro.
/// </para>
/// </summary>
[FieldOffset(4)]
public COLORREF lbColor;
/// <summary>
/// <para>A hatch style. The meaning depends on the brush style defined by <c>lbStyle</c>.</para>
/// <para>
/// If <c>lbStyle</c> is BS_DIBPATTERN, the <c>lbHatch</c> member contains a handle to a packed DIB. To obtain this handle, an
/// application calls the GlobalAlloc function with GMEM_MOVEABLE (or LocalAlloc with LMEM_MOVEABLE) to allocate a block of
/// memory and then fills the memory with the packed DIB. A packed DIB consists of a BITMAPINFO structure immediately followed by
/// the array of bytes that define the pixels of the bitmap.
/// </para>
/// <para>
/// If <c>lbStyle</c> is BS_DIBPATTERNPT, the <c>lbHatch</c> member contains a pointer to a packed DIB. The pointer derives from
/// the memory block created by LocalAlloc with LMEM_FIXED set or by GlobalAlloc with GMEM_FIXED set, or it is the pointer
/// returned by a call like LocalLock (handle_to_the_dib). A packed DIB consists of a BITMAPINFO structure immediately followed
/// by the array of bytes that define the pixels of the bitmap.
/// </para>
/// <para>
/// If <c>lbStyle</c> is BS_HATCHED, the <c>lbHatch</c> member specifies the orientation of the lines used to create the hatch.
/// It can be one of the following values.
/// </para>
/// <list type="table">
/// <listheader>
/// <term>Value</term>
/// <term>Meaning</term>
/// </listheader>
/// <item>
/// <term>HS_BDIAGONAL</term>
/// <term>A 45-degree upward, left-to-right hatch</term>
/// </item>
/// <item>
/// <term>HS_CROSS</term>
/// <term>Horizontal and vertical cross-hatch</term>
/// </item>
/// <item>
/// <term>HS_DIAGCROSS</term>
/// <term>45-degree crosshatch</term>
/// </item>
/// <item>
/// <term>HS_FDIAGONAL</term>
/// <term>A 45-degree downward, left-to-right hatch</term>
/// </item>
/// <item>
/// <term>HS_HORIZONTAL</term>
/// <term>Horizontal hatch</term>
/// </item>
/// <item>
/// <term>HS_VERTICAL</term>
/// <term>Vertical hatch</term>
/// </item>
/// </list>
/// <para>
/// If <c>lbStyle</c> is BS_PATTERN, <c>lbHatch</c> is a handle to the bitmap that defines the pattern. The bitmap cannot be a
/// DIB section bitmap, which is created by the CreateDIBSection function.
/// </para>
/// <para>If <c>lbStyle</c> is BS_SOLID or BS_HOLLOW, <c>lbHatch</c> is ignored.</para>
/// </summary>
[FieldOffset(8)]
public HatchStyle lbHatchStyle;
/// <summary>
/// <para>A hatch style. The meaning depends on the brush style defined by <c>lbStyle</c>.</para>
/// <para>
/// If <c>lbStyle</c> is BS_DIBPATTERN, the <c>lbHatch</c> member contains a handle to a packed DIB. To obtain this handle, an
/// application calls the GlobalAlloc function with GMEM_MOVEABLE (or LocalAlloc with LMEM_MOVEABLE) to allocate a block of
/// memory and then fills the memory with the packed DIB. A packed DIB consists of a BITMAPINFO structure immediately followed by
/// the array of bytes that define the pixels of the bitmap.
/// </para>
/// <para>
/// If <c>lbStyle</c> is BS_DIBPATTERNPT, the <c>lbHatch</c> member contains a pointer to a packed DIB. The pointer derives from
/// the memory block created by LocalAlloc with LMEM_FIXED set or by GlobalAlloc with GMEM_FIXED set, or it is the pointer
/// returned by a call like LocalLock (handle_to_the_dib). A packed DIB consists of a BITMAPINFO structure immediately followed
/// by the array of bytes that define the pixels of the bitmap.
/// </para>
/// <para>
/// If <c>lbStyle</c> is BS_HATCHED, the <c>lbHatch</c> member specifies the orientation of the lines used to create the hatch.
/// It can be one of the following values.
/// </para>
/// <list type="table">
/// <listheader>
/// <term>Value</term>
/// <term>Meaning</term>
/// </listheader>
/// <item>
/// <term>HS_BDIAGONAL</term>
/// <term>A 45-degree upward, left-to-right hatch</term>
/// </item>
/// <item>
/// <term>HS_CROSS</term>
/// <term>Horizontal and vertical cross-hatch</term>
/// </item>
/// <item>
/// <term>HS_DIAGCROSS</term>
/// <term>45-degree crosshatch</term>
/// </item>
/// <item>
/// <term>HS_FDIAGONAL</term>
/// <term>A 45-degree downward, left-to-right hatch</term>
/// </item>
/// <item>
/// <term>HS_HORIZONTAL</term>
/// <term>Horizontal hatch</term>
/// </item>
/// <item>
/// <term>HS_VERTICAL</term>
/// <term>Vertical hatch</term>
/// </item>
/// </list>
/// <para>
/// If <c>lbStyle</c> is BS_PATTERN, <c>lbHatch</c> is a handle to the bitmap that defines the pattern. The bitmap cannot be a
/// DIB section bitmap, which is created by the CreateDIBSection function.
/// </para>
/// <para>If <c>lbStyle</c> is BS_SOLID or BS_HOLLOW, <c>lbHatch</c> is ignored.</para>
/// </summary>
[FieldOffset(8)]
public IntPtr lbHatch;
}
}
}

View File

@ -0,0 +1,95 @@
using System;
using System.Drawing;
using System.IO;
using Vanara.InteropServices;
namespace Vanara.PInvoke
{
public static partial class Gdi32
{
Stream dib = null;
byte[] header = null;
public static Bitmap BitmapFromDib(IntPtr dib)
{
var reader = new MarshalingStream(dib, );
int headerSize = reader.ReadInt32();
int pixelSize = (int)dib.Length - headerSize;
int fileSize = 14 + headerSize + pixelSize;
MemoryStream bmp = new MemoryStream(14);
BinaryWriter writer = new BinaryWriter(bmp);
/* Get the palette size
* The Palette size is stored as an int32 at offset 32
* Actually stored as number of colours, so multiply by 4
*/
dib.Position = 32;
int paletteSize = 4 * reader.ReadInt32();
// Get the palette size from the bbp if none was specified
if (paletteSize == 0)
{
/* Get the bits per pixel
* The bits per pixel is store as an int16 at offset 14
*/
dib.Position = 14;
int bpp = reader.ReadInt16();
// Only set the palette size if the bpp < 16
if (bpp < 16)
paletteSize = 4 * (2 << (bpp - 1));
}
// 1. Write Bitmap File Header:
writer.Write((byte)'B');
writer.Write((byte)'M');
writer.Write(fileSize);
writer.Write((int)0);
writer.Write(14 + headerSize + paletteSize);
header = bmp.GetBuffer();
writer.Close();
dib.Position = 0;
}
public override int Read(byte[] buffer, int offset, int count)
{
int dibCount = count;
int dibOffset = offset - 14;
int result = 0;
if (_position & lt; 14){
int headerCount = Math.Min(count + (int)_position, 14);
Array.Copy(header, _position, buffer, offset, headerCount);
dibCount -= headerCount;
_position += headerCount;
result = headerCount;
}
if (_position & gt;= 14 ) {
result += dib.Read(buffer, offset + result, dibCount);
_position = 14 + dib.Position;
}
return (int)result;
}
public override long Length
{
get { return 14 + dib.Length; }
}
private long _position = 0;
public override long Position
{
get { return _position; }
set
{
_position = value;
if (_position > 14)
dib.Position = _position - 14;
}
}
}
}

749
PInvoke/Gdi32/WinGdi.Pen.cs Normal file
View File

@ -0,0 +1,749 @@
using System;
using System.Runtime.InteropServices;
namespace Vanara.PInvoke
{
public static partial class Gdi32
{
/// <summary>End caps used by Pen functions and structures.</summary>
[PInvokeData("wingdi.h", MSDNShortId = "34ffa71d-e94d-425e-9f9d-21e3df4990b7")]
public enum PenEndCap : uint
{
/// <summary>End caps are round.</summary>
PS_ENDCAP_ROUND = 0x00000000,
/// <summary>End caps are square.</summary>
PS_ENDCAP_SQUARE = 0x00000100,
/// <summary>End caps are flat.</summary>
PS_ENDCAP_FLAT = 0x00000200,
}
/// <summary>Joins used by Pen functions and structures.</summary>
[PInvokeData("wingdi.h", MSDNShortId = "34ffa71d-e94d-425e-9f9d-21e3df4990b7")]
public enum PenJoin : uint
{
/// <summary>Joins are round.</summary>
PS_JOIN_ROUND = 0x00000000,
/// <summary>Joins are beveled.</summary>
PS_JOIN_BEVEL = 0x00001000,
/// <summary>
/// Joins are mitered when they are within the current limit set by the SetMiterLimit function. If it exceeds this limit, the
/// join is beveled.
/// </summary>
PS_JOIN_MITER = 0x00002000,
}
/// <summary>Styles used by Pen functions and structures.</summary>
[PInvokeData("wingdi.h", MSDNShortId = "34ffa71d-e94d-425e-9f9d-21e3df4990b7")]
public enum PenStyle : uint
{
/// <summary>The pen is solid.</summary>
PS_SOLID = 0,
/// <summary>The pen is dashed.</summary>
PS_DASH = 1,
/// <summary>The pen is dotted.</summary>
PS_DOT = 2,
/// <summary>The pen has alternating dashes and dots.</summary>
PS_DASHDOT = 3,
/// <summary>The pen has alternating dashes and double dots.</summary>
PS_DASHDOTDOT = 4,
/// <summary>The pen is invisible.</summary>
PS_NULL = 5,
/// <summary>
/// The pen is solid. When this pen is used in any GDI drawing function that takes a bounding rectangle, the dimensions of the
/// figure are shrunk so that it fits entirely in the bounding rectangle, taking into account the width of the pen. This applies
/// only to geometric pens.
/// </summary>
PS_INSIDEFRAME = 6,
/// <summary>The pen uses a styling array supplied by the user.</summary>
PS_USERSTYLE = 7,
/// <summary>The pen sets every other pixel. (This style is applicable only for cosmetic pens.)</summary>
PS_ALTERNATE = 8,
}
/// <summary>Joins used by Pen functions and structures.</summary>
[PInvokeData("wingdi.h", MSDNShortId = "34ffa71d-e94d-425e-9f9d-21e3df4990b7")]
public enum PenType : uint
{
/// <summary>The pen is cosmetic.</summary>
PS_COSMETIC = 0x00000000,
/// <summary>The pen is geometric.</summary>
PS_GEOMETRIC = 0x00010000,
}
/// <summary>
/// <para>
/// The <c>CreatePen</c> function creates a logical pen that has the specified style, width, and color. The pen can subsequently be
/// selected into a device context and used to draw lines and curves.
/// </para>
/// </summary>
/// <param name="iStyle">
/// <para>The pen style. It can be any one of the following values.</para>
/// <list type="table">
/// <listheader>
/// <term>Value</term>
/// <term>Meaning</term>
/// </listheader>
/// <item>
/// <term>PS_SOLID</term>
/// <term>The pen is solid.</term>
/// </item>
/// <item>
/// <term>PS_DASH</term>
/// <term>The pen is dashed. This style is valid only when the pen width is one or less in device units.</term>
/// </item>
/// <item>
/// <term>PS_DOT</term>
/// <term>The pen is dotted. This style is valid only when the pen width is one or less in device units.</term>
/// </item>
/// <item>
/// <term>PS_DASHDOT</term>
/// <term>The pen has alternating dashes and dots. This style is valid only when the pen width is one or less in device units.</term>
/// </item>
/// <item>
/// <term>PS_DASHDOTDOT</term>
/// <term>The pen has alternating dashes and double dots. This style is valid only when the pen width is one or less in device units.</term>
/// </item>
/// <item>
/// <term>PS_NULL</term>
/// <term>The pen is invisible.</term>
/// </item>
/// <item>
/// <term>PS_INSIDEFRAME</term>
/// <term>
/// The pen is solid. When this pen is used in any GDI drawing function that takes a bounding rectangle, the dimensions of the figure
/// are shrunk so that it fits entirely in the bounding rectangle, taking into account the width of the pen. This applies only to
/// geometric pens.
/// </term>
/// </item>
/// </list>
/// </param>
/// <param name="cWidth">
/// <para>The width of the pen, in logical units. If nWidth is zero, the pen is a single pixel wide, regardless of the current transformation.</para>
/// <para>
/// <c>CreatePen</c> returns a pen with the specified width bit with the PS_SOLID style if you specify a width greater than one for
/// the following styles: PS_DASH, PS_DOT, PS_DASHDOT, PS_DASHDOTDOT.
/// </para>
/// </param>
/// <param name="color">
/// <para>A color reference for the pen color. To generate a COLORREF structure, use the RGB macro.</para>
/// </param>
/// <returns>
/// <para>If the function succeeds, the return value is a handle that identifies a logical pen.</para>
/// <para>If the function fails, the return value is <c>NULL</c>.</para>
/// </returns>
/// <remarks>
/// <para>
/// After an application creates a logical pen, it can select that pen into a device context by calling the SelectObject function.
/// After a pen is selected into a device context, it can be used to draw lines and curves.
/// </para>
/// <para>
/// If the value specified by the nWidth parameter is zero, a line drawn with the created pen always is a single pixel wide
/// regardless of the current transformation.
/// </para>
/// <para>If the value specified by nWidth is greater than 1, the fnPenStyle parameter must be PS_NULL, PS_SOLID, or PS_INSIDEFRAME.</para>
/// <para>
/// If the value specified by nWidth is greater than 1 and fnPenStyle is PS_INSIDEFRAME, the line associated with the pen is drawn
/// inside the frame of all primitives except polygons and polylines.
/// </para>
/// <para>
/// If the value specified by nWidth is greater than 1, fnPenStyle is PS_INSIDEFRAME, and the color specified by the crColor
/// parameter does not match one of the entries in the logical palette, the system draws lines by using a dithered color. Dithered
/// colors are not available with solid pens.
/// </para>
/// <para>When you no longer need the pen, call the DeleteObject function to delete it.</para>
/// <para>
/// <c>ICM:</c> No color management is done at creation. However, color management is performed when the pen is selected into an
/// ICM-enabled device context.
/// </para>
/// <para>Examples</para>
/// <para>For an example, see Creating Colored Pens and Brushes.</para>
/// </remarks>
// https://docs.microsoft.com/en-us/windows/desktop/api/wingdi/nf-wingdi-createpen HPEN CreatePen( int iStyle, int cWidth, COLORREF
// color );
[DllImport(Lib.Gdi32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("wingdi.h", MSDNShortId = "882facd2-7e06-48f6-82e4-f20e4d5adc92")]
public static extern SafeHPEN CreatePen(uint iStyle, int cWidth, COLORREF color);
/// <summary>
/// <para>
/// The <c>CreatePenIndirect</c> function creates a logical cosmetic pen that has the style, width, and color specified in a structure.
/// </para>
/// </summary>
/// <param name="plpen">
/// <para>Pointer to a LOGPEN structure that specifies the pen's style, width, and color.</para>
/// </param>
/// <returns>
/// <para>If the function succeeds, the return value is a handle that identifies a logical cosmetic pen.</para>
/// <para>If the function fails, the return value is <c>NULL</c>.</para>
/// </returns>
/// <remarks>
/// <para>
/// After an application creates a logical pen, it can select that pen into a device context by calling the SelectObject function.
/// After a pen is selected into a device context, it can be used to draw lines and curves.
/// </para>
/// <para>When you no longer need the pen, call the DeleteObject function to delete it.</para>
/// </remarks>
// https://docs.microsoft.com/en-us/windows/desktop/api/wingdi/nf-wingdi-createpenindirect HPEN CreatePenIndirect( const LOGPEN
// *plpen );
[DllImport(Lib.Gdi32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("wingdi.h", MSDNShortId = "638c0294-9a8f-44ed-a791-1be152cd92dd")]
public static extern SafeHPEN CreatePenIndirect(in LOGPEN plpen);
/// <summary>
/// <para>
/// The <c>ExtCreatePen</c> function creates a logical cosmetic or geometric pen that has the specified style, width, and brush attributes.
/// </para>
/// </summary>
/// <param name="iPenStyle">
/// <para>
/// A combination of type, style, end cap, and join attributes. The values from each category are combined by using the bitwise OR
/// operator ( | ).
/// </para>
/// <para>The pen type can be one of the following values.</para>
/// <list type="table">
/// <listheader>
/// <term>Value</term>
/// <term>Meaning</term>
/// </listheader>
/// <item>
/// <term>PS_GEOMETRIC</term>
/// <term>The pen is geometric.</term>
/// </item>
/// <item>
/// <term>PS_COSMETIC</term>
/// <term>The pen is cosmetic.</term>
/// </item>
/// </list>
/// <para>The pen style can be one of the following values.</para>
/// <list type="table">
/// <listheader>
/// <term>Value</term>
/// <term>Meaning</term>
/// </listheader>
/// <item>
/// <term>PS_ALTERNATE</term>
/// <term>The pen sets every other pixel. (This style is applicable only for cosmetic pens.)</term>
/// </item>
/// <item>
/// <term>PS_SOLID</term>
/// <term>The pen is solid.</term>
/// </item>
/// <item>
/// <term>PS_DASH</term>
/// <term>The pen is dashed.</term>
/// </item>
/// <item>
/// <term>PS_DOT</term>
/// <term>The pen is dotted.</term>
/// </item>
/// <item>
/// <term>PS_DASHDOT</term>
/// <term>The pen has alternating dashes and dots.</term>
/// </item>
/// <item>
/// <term>PS_DASHDOTDOT</term>
/// <term>The pen has alternating dashes and double dots.</term>
/// </item>
/// <item>
/// <term>PS_NULL</term>
/// <term>The pen is invisible.</term>
/// </item>
/// <item>
/// <term>PS_USERSTYLE</term>
/// <term>The pen uses a styling array supplied by the user.</term>
/// </item>
/// <item>
/// <term>PS_INSIDEFRAME</term>
/// <term>
/// The pen is solid. When this pen is used in any GDI drawing function that takes a bounding rectangle, the dimensions of the figure
/// are shrunk so that it fits entirely in the bounding rectangle, taking into account the width of the pen. This applies only to
/// geometric pens.
/// </term>
/// </item>
/// </list>
/// <para>The end cap is only specified for geometric pens. The end cap can be one of the following values.</para>
/// <list type="table">
/// <listheader>
/// <term>Value</term>
/// <term>Meaning</term>
/// </listheader>
/// <item>
/// <term>PS_ENDCAP_ROUND</term>
/// <term>End caps are round.</term>
/// </item>
/// <item>
/// <term>PS_ENDCAP_SQUARE</term>
/// <term>End caps are square.</term>
/// </item>
/// <item>
/// <term>PS_ENDCAP_FLAT</term>
/// <term>End caps are flat.</term>
/// </item>
/// </list>
/// <para>The join is only specified for geometric pens. The join can be one of the following values.</para>
/// <list type="table">
/// <listheader>
/// <term>Value</term>
/// <term>Meaning</term>
/// </listheader>
/// <item>
/// <term>PS_JOIN_BEVEL</term>
/// <term>Joins are beveled.</term>
/// </item>
/// <item>
/// <term>PS_JOIN_MITER</term>
/// <term>
/// Joins are mitered when they are within the current limit set by the SetMiterLimit function. If it exceeds this limit, the join is beveled.
/// </term>
/// </item>
/// <item>
/// <term>PS_JOIN_ROUND</term>
/// <term>Joins are round.</term>
/// </item>
/// </list>
/// </param>
/// <param name="cWidth">
/// <para>
/// The width of the pen. If the dwPenStyle parameter is PS_GEOMETRIC, the width is given in logical units. If dwPenStyle is
/// PS_COSMETIC, the width must be set to 1.
/// </para>
/// </param>
/// <param name="plbrush">
/// <para>
/// A pointer to a LOGBRUSH structure. If dwPenStyle is PS_COSMETIC, the <c>lbColor</c> member specifies the color of the pen and the
/// <c>lpStyle</c> member must be set to BS_SOLID. If dwPenStyle is PS_GEOMETRIC, all members must be used to specify the brush
/// attributes of the pen.
/// </para>
/// </param>
/// <param name="cStyle">
/// <para>The length, in <c>DWORD</c> units, of the lpStyle array. This value must be zero if dwPenStyle is not PS_USERSTYLE.</para>
/// <para>The style count is limited to 16.</para>
/// </param>
/// <param name="pstyle">
/// <para>
/// A pointer to an array. The first value specifies the length of the first dash in a user-defined style, the second value specifies
/// the length of the first space, and so on. This pointer must be <c>NULL</c> if dwPenStyle is not PS_USERSTYLE.
/// </para>
/// <para>
/// If the lpStyle array is exceeded during line drawing, the pointer is reset to the beginning of the array. When this happens and
/// dwStyleCount is an even number, the pattern of dashes and spaces repeats. However, if dwStyleCount is odd, the pattern reverses
/// when the pointer is reset -- the first element of lpStyle now refers to spaces, the second refers to dashes, and so forth.
/// </para>
/// </param>
/// <returns>
/// <para>If the function succeeds, the return value is a handle that identifies a logical pen.</para>
/// <para>If the function fails, the return value is zero.</para>
/// </returns>
/// <remarks>
/// <para>
/// A geometric pen can have any width and can have any of the attributes of a brush, such as dithers and patterns. A cosmetic pen
/// can only be a single pixel wide and must be a solid color, but cosmetic pens are generally faster than geometric pens.
/// </para>
/// <para>The width of a geometric pen is always specified in world units. The width of a cosmetic pen is always 1.</para>
/// <para>End caps and joins are only specified for geometric pens.</para>
/// <para>
/// After an application creates a logical pen, it can select that pen into a device context by calling the SelectObject function.
/// After a pen is selected into a device context, it can be used to draw lines and curves.
/// </para>
/// <para>
/// If dwPenStyle is PS_COSMETIC and PS_USERSTYLE, the entries in the lpStyle array specify lengths of dashes and spaces in style
/// units. A style unit is defined by the device where the pen is used to draw a line.
/// </para>
/// <para>
/// If dwPenStyle is PS_GEOMETRIC and PS_USERSTYLE, the entries in the lpStyle array specify lengths of dashes and spaces in logical units.
/// </para>
/// <para>If dwPenStyle is PS_ALTERNATE, the style unit is ignored and every other pixel is set.</para>
/// <para>
/// If the <c>lbStyle</c> member of the LOGBRUSH structure pointed to by lplb is BS_PATTERN, the bitmap pointed to by the
/// <c>lbHatch</c> member of that structure cannot be a DIB section. A DIB section is a bitmap created by CreateDIBSection. If that
/// bitmap is a DIB section, the <c>ExtCreatePen</c> function fails.
/// </para>
/// <para>When an application no longer requires a specified pen, it should call the DeleteObject function to delete the pen.</para>
/// <para>
/// <c>ICM:</c> No color management is done at pen creation. However, color management is performed when the pen is selected into an
/// ICM-enabled device context.
/// </para>
/// <para>Examples</para>
/// <para>For an example, see Using Pens.</para>
/// </remarks>
// https://docs.microsoft.com/en-us/windows/desktop/api/wingdi/nf-wingdi-extcreatepen HPEN ExtCreatePen( DWORD iPenStyle, DWORD
// cWidth, const LOGBRUSH *plbrush, DWORD cStyle, const DWORD *pstyle );
[DllImport(Lib.Gdi32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("wingdi.h", MSDNShortId = "a1e81314-4fe6-481f-af96-24ebf56332cf")]
public static extern SafeHPEN ExtCreatePen(uint iPenStyle, uint cWidth, in LOGBRUSH plbrush, uint cStyle, [In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 3)] uint[] pstyle);
/// <summary>
/// <para>
/// The <c>EXTLOGPEN</c> structure defines the pen style, width, and brush attributes for an extended pen. This structure is used by
/// the GetObject function when it retrieves a description of a pen that was created when an application called the ExtCreatePen function.
/// </para>
/// </summary>
// https://docs.microsoft.com/en-us/windows/desktop/api/wingdi/ns-wingdi-tagextlogpen typedef struct tagEXTLOGPEN { DWORD
// elpPenStyle; DWORD elpWidth; UINT elpBrushStyle; COLORREF elpColor; ULONG_PTR elpHatch; DWORD elpNumEntries; DWORD
// elpStyleEntry[1]; } EXTLOGPEN, *PEXTLOGPEN, *NPEXTLOGPEN, *LPEXTLOGPEN;
[PInvokeData("wingdi.h", MSDNShortId = "34ffa71d-e94d-425e-9f9d-21e3df4990b7")]
[StructLayout(LayoutKind.Sequential, Pack = 4)]
public struct EXTLOGPEN
{
/// <summary>
/// <para>
/// A combination of pen type, style, end cap style, and join style. The values from each category can be retrieved by using a
/// bitwise AND operator with the appropriate mask.
/// </para>
/// <para>The <c>elpPenStyle</c> member masked with PS_TYPE_MASK has one of the following pen type values.</para>
/// <list type="table">
/// <listheader>
/// <term>Value</term>
/// <term>Meaning</term>
/// </listheader>
/// <item>
/// <term>PS_GEOMETRIC</term>
/// <term>The pen is geometric.</term>
/// </item>
/// <item>
/// <term>PS_COSMETIC</term>
/// <term>The pen is cosmetic.</term>
/// </item>
/// </list>
/// <para>The <c>elpPenStyle</c> member masked with PS_STYLE_MASK has one of the following pen styles values:</para>
/// <list type="table">
/// <listheader>
/// <term>Value</term>
/// <term>Meaning</term>
/// </listheader>
/// <item>
/// <term>PS_DASH</term>
/// <term>The pen is dashed.</term>
/// </item>
/// <item>
/// <term>PS_DASHDOT</term>
/// <term>The pen has alternating dashes and dots.</term>
/// </item>
/// <item>
/// <term>PS_DASHDOTDOT</term>
/// <term>The pen has alternating dashes and double dots.</term>
/// </item>
/// <item>
/// <term>PS_DOT</term>
/// <term>The pen is dotted.</term>
/// </item>
/// <item>
/// <term>PS_INSIDEFRAME</term>
/// <term>
/// The pen is solid. When this pen is used in any GDI drawing function that takes a bounding rectangle, the dimensions of the
/// figure are shrunk so that it fits entirely in the bounding rectangle, taking into account the width of the pen. This applies
/// only to PS_GEOMETRIC pens.
/// </term>
/// </item>
/// <item>
/// <term>PS_NULL</term>
/// <term>The pen is invisible.</term>
/// </item>
/// <item>
/// <term>PS_SOLID</term>
/// <term>The pen is solid.</term>
/// </item>
/// <item>
/// <term>PS_USERSTYLE</term>
/// <term>The pen uses a styling array supplied by the user.</term>
/// </item>
/// </list>
/// <para>
/// The following category applies only to PS_GEOMETRIC pens. The <c>elpPenStyle</c> member masked with PS_ENDCAP_MASK has one of
/// the following end cap values.
/// </para>
/// <list type="table">
/// <listheader>
/// <term>Value</term>
/// <term>Meaning</term>
/// </listheader>
/// <item>
/// <term>PS_ENDCAP_FLAT</term>
/// <term>Line end caps are flat.</term>
/// </item>
/// <item>
/// <term>PS_ENDCAP_ROUND</term>
/// <term>Line end caps are round.</term>
/// </item>
/// <item>
/// <term>PS_ENDCAP_SQUARE</term>
/// <term>Line end caps are square.</term>
/// </item>
/// </list>
/// <para>
/// The following category applies only to PS_GEOMETRIC pens. The <c>elpPenStyle</c> member masked with PS_JOIN_MASK has one of
/// the following join values.
/// </para>
/// <list type="table">
/// <listheader>
/// <term>Value</term>
/// <term>Meaning</term>
/// </listheader>
/// <item>
/// <term>PS_JOIN_BEVEL</term>
/// <term>Line joins are beveled.</term>
/// </item>
/// <item>
/// <term>PS_JOIN_MITER</term>
/// <term>
/// Line joins are mitered when they are within the current limit set by the SetMiterLimit function. A join is beveled when it
/// would exceed the limit.
/// </term>
/// </item>
/// <item>
/// <term>PS_JOIN_ROUND</term>
/// <term>Line joins are round.</term>
/// </item>
/// </list>
/// </summary>
public uint elpPenStyle;
/// <summary>
/// <para>
/// The width of the pen. If the <c>elpPenStyle</c> member is PS_GEOMETRIC, this value is the width of the line in logical units.
/// Otherwise, the lines are cosmetic and this value is 1, which indicates a line with a width of one pixel.
/// </para>
/// </summary>
public uint elpWidth;
/// <summary>
/// <para>The brush style of the pen. The <c>elpBrushStyle</c> member value can be one of the following.</para>
/// <list type="table">
/// <listheader>
/// <term>Value</term>
/// <term>Meaning</term>
/// </listheader>
/// <item>
/// <term>BS_DIBPATTERN</term>
/// <term>
/// Specifies a pattern brush defined by a DIB specification. If elpBrushStyle is BS_DIBPATTERN, the elpHatch member contains a
/// handle to a packed DIB. For more information, see discussion in elpHatch
/// </term>
/// </item>
/// <item>
/// <term>BS_DIBPATTERNPT</term>
/// <term>
/// Specifies a pattern brush defined by a DIB specification. If elpBrushStyle is BS_DIBPATTERNPT, the elpHatch member contains a
/// pointer to a packed DIB. For more information, see discussion in elpHatch.
/// </term>
/// </item>
/// <item>
/// <term>BS_HATCHED</term>
/// <term>Specifies a hatched brush.</term>
/// </item>
/// <item>
/// <term>BS_HOLLOW</term>
/// <term>Specifies a hollow or NULL brush.</term>
/// </item>
/// <item>
/// <term>BS_PATTERN</term>
/// <term>Specifies a pattern brush defined by a memory bitmap.</term>
/// </item>
/// <item>
/// <term>BS_SOLID</term>
/// <term>Specifies a solid brush.</term>
/// </item>
/// </list>
/// </summary>
public BrushStyle elpBrushStyle;
/// <summary>
/// <para>
/// If <c>elpBrushStyle</c> is BS_SOLID or BS_HATCHED, <c>elpColor</c> specifies the color in which the pen is to be drawn. For
/// BS_HATCHED, the SetBkMode and SetBkColor functions determine the background color.
/// </para>
/// <para>If <c>elpBrushStyle</c> is BS_HOLLOW or BS_PATTERN, <c>elpColor</c> is ignored.</para>
/// <para>
/// If <c>elpBrushStyle</c> is BS_DIBPATTERN or BS_DIBPATTERNPT, the low-order word of <c>elpColor</c> specifies whether the
/// <c>bmiColors</c> member of the BITMAPINFO structure contain explicit RGB values or indices into the currently realized
/// logical palette. The <c>elpColor</c> value must be one of the following.
/// </para>
/// <list type="table">
/// <listheader>
/// <term>Value</term>
/// <term>Meaning</term>
/// </listheader>
/// <item>
/// <term>DIB_PAL_COLORS</term>
/// <term>The color table consists of an array of 16-bit indices into the currently realized logical palette.</term>
/// </item>
/// <item>
/// <term>DIB_RGB_COLORS</term>
/// <term>The color table contains literal RGB values.</term>
/// </item>
/// </list>
/// <para>The RGB macro is used to generate a COLORREF structure.</para>
/// </summary>
public COLORREF elpColor;
/// <summary>
/// <para>If <c>elpBrushStyle</c> is BS_PATTERN, <c>elpHatch</c> is a handle to the bitmap that defines the pattern.</para>
/// <para>If <c>elpBrushStyle</c> is BS_SOLID or BS_HOLLOW, <c>elpHatch</c> is ignored.</para>
/// <para>
/// If <c>elpBrushStyle</c> is BS_DIBPATTERN, the <c>elpHatch</c> member is a handle to a packed DIB. To obtain this handle, an
/// application calls the GlobalAlloc function with GMEM_MOVEABLE (or LocalAlloc with LMEM_MOVEABLE) to allocate a block of
/// memory and then fills the memory with the packed DIB. A packed DIB consists of a BITMAPINFO structure immediately followed by
/// the array of bytes that define the pixels of the bitmap.
/// </para>
/// <para>
/// If <c>elpBrushStyle</c> is BS_DIBPATTERNPT, the <c>elpHatch</c> member is a pointer to a packed DIB. The pointer derives from
/// the memory block created by LocalAlloc with LMEM_FIXED set or by GlobalAlloc with GMEM_FIXED set, or it is the pointer
/// returned by a call like LocalLock (handle_to_the_dib). A packed DIB consists of a BITMAPINFO structure immediately followed
/// by the array of bytes that define the pixels of the bitmap.
/// </para>
/// <para>
/// If <c>elpBrushStyle</c> is BS_HATCHED, the <c>elpHatch</c> member specifies the orientation of the lines used to create the
/// hatch. It can be one of the following values.
/// </para>
/// <list type="table">
/// <listheader>
/// <term>Value</term>
/// <term>Meaning</term>
/// </listheader>
/// <item>
/// <term>HS_BDIAGONAL</term>
/// <term>45-degree upward hatch (left to right)</term>
/// </item>
/// <item>
/// <term>HS_CROSS</term>
/// <term>Horizontal and vertical crosshatch</term>
/// </item>
/// <item>
/// <term>HS_DIAGCROSS</term>
/// <term>45-degree crosshatch</term>
/// </item>
/// <item>
/// <term>HS_FDIAGONAL</term>
/// <term>45-degree downward hatch (left to right)</term>
/// </item>
/// <item>
/// <term>HS_HORIZONTAL</term>
/// <term>Horizontal hatch</term>
/// </item>
/// <item>
/// <term>HS_VERTICAL</term>
/// <term>Vertical hatch</term>
/// </item>
/// </list>
/// </summary>
public IntPtr elpHatch;
/// <summary>
/// <para>
/// The number of entries in the style array in the <c>elpStyleEntry</c> member. This value is zero if <c>elpPenStyle</c> does
/// not specify PS_USERSTYLE.
/// </para>
/// </summary>
public uint elpNumEntries;
/// <summary>
/// <para>
/// A user-supplied style array. The array is specified with a finite length, but it is used as if it repeated indefinitely. The
/// first entry in the array specifies the length of the first dash. The second entry specifies the length of the first gap.
/// Thereafter, lengths of dashes and gaps alternate.
/// </para>
/// <para>
/// If <c>elpWidth</c> specifies geometric lines, the lengths are in logical units. Otherwise, the lines are cosmetic and lengths
/// are in device units.
/// </para>
/// </summary>
public IntPtr elpStyleEntry;
public PenStyle Style { get => (PenStyle)(elpPenStyle & 0xF); set => elpPenStyle = elpPenStyle & 0xFFFF0 | (uint)value; }
public PenEndCap EndCap { get => (PenEndCap)(elpPenStyle & 0xF00); set => elpPenStyle = elpPenStyle & 0xFF0FF | (uint)value; }
public PenJoin Join { get => (PenJoin)(elpPenStyle & 0xF000); set => elpPenStyle = elpPenStyle & 0xF0FFF | (uint)value; }
public PenType Type { get => (PenType)(elpPenStyle & 0xF0000); set => elpPenStyle = elpPenStyle & 0xFFFF | (uint)value; }
}
/// <summary>
/// <para>
/// The <c>LOGPEN</c> structure defines the style, width, and color of a pen. The CreatePenIndirect function uses the <c>LOGPEN</c> structure.
/// </para>
/// </summary>
/// <remarks>
/// <para>
/// If the width of the pen is greater than 1 and the pen style is PS_INSIDEFRAME, the line is drawn inside the frame of all GDI
/// objects except polygons and polylines. If the pen color does not match an available RGB value, the pen is drawn with a logical
/// (dithered) color. If the pen width is less than or equal to 1, the PS_INSIDEFRAME style is identical to the PS_SOLID style.
/// </para>
/// </remarks>
// https://docs.microsoft.com/en-us/windows/desktop/api/wingdi/ns-wingdi-taglogpen typedef struct tagLOGPEN { UINT lopnStyle; POINT
// lopnWidth; COLORREF lopnColor; } LOGPEN, *PLOGPEN, *NPLOGPEN, *LPLOGPEN;
[PInvokeData("wingdi.h", MSDNShortId = "0e098b5a-e249-43ad-a6d8-2509b6562453")]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
public struct LOGPEN
{
/// <summary>
/// <para>The pen style, which can be one of the following values.</para>
/// <list type="table">
/// <listheader>
/// <term>Value</term>
/// <term>Meaning</term>
/// </listheader>
/// <item>
/// <term>PS_SOLID</term>
/// <term>The pen is solid.</term>
/// </item>
/// <item>
/// <term>PS_DASH</term>
/// <term>The pen is dashed.</term>
/// </item>
/// <item>
/// <term>PS_DOT</term>
/// <term>The pen is dotted.</term>
/// </item>
/// <item>
/// <term>PS_DASHDOT</term>
/// <term>The pen has alternating dashes and dots.</term>
/// </item>
/// <item>
/// <term>PS_DASHDOTDOT</term>
/// <term>The pen has dashes and double dots.</term>
/// </item>
/// <item>
/// <term>PS_NULL</term>
/// <term>The pen is invisible.</term>
/// </item>
/// <item>
/// <term>PS_INSIDEFRAME</term>
/// <term>
/// The pen is solid. When this pen is used in any GDI drawing function that takes a bounding rectangle, the dimensions of the
/// figure are shrunk so that it fits entirely in the bounding rectangle, taking into account the width of the pen. This applies
/// only to geometric pens.
/// </term>
/// </item>
/// </list>
/// </summary>
public PenStyle lopnStyle;
/// <summary>
/// <para>
/// The POINT structure that contains the pen width, in logical units. If the <c>pointer</c> member is <c>NULL</c>, the pen is
/// one pixel wide on raster devices. The <c>y</c> member in the <c>POINT</c> structure for <c>lopnWidth</c> is not used.
/// </para>
/// </summary>
public System.Drawing.Point lopnWidth;
/// <summary>
/// <para>The pen color. To generate a COLORREF structure, use the RGB macro.</para>
/// </summary>
public COLORREF lopnColor;
}
}
}

View File

@ -10,18 +10,18 @@ namespace Vanara.PInvoke
/// <code language="cs" title="Using a pen and brush">
/// using (var screenDC = SafeHDC.ScreenCompatibleDCHandle)
/// {
/// var brush = CreateSolidBrush(Color.Red);
/// using (new GdiObjectContext(screenDC, brush))
/// {
/// // Do brush stuff
/// }
///
/// var pen = CreatePen(PS_SOLID, 1, Color.Black);
/// // Alternatively, call the SelectObject method on the SafeHDC object
/// using (screenDC.SelectObject(pen))
/// {
/// // Do pen stuff
/// }
/// var brush = CreateSolidBrush(Color.Red);
/// using (new GdiObjectContext(screenDC, brush))
/// {
/// // Do brush stuff
/// }
///
/// var pen = CreatePen(PS_SOLID, 1, Color.Black);
/// // Alternatively, call the SelectObject method on the SafeHDC object
/// using (screenDC.SelectObject(pen))
/// {
/// // Do pen stuff
/// }
/// }
/// </code>
/// </example>
@ -37,7 +37,7 @@ namespace Vanara.PInvoke
/// <exception cref="ArgumentNullException">hdc - Device context cannot be null.</exception>
public GdiObjectContext(HDC hdc, HGDIOBJ hObj)
{
if (hdc == null || hdc.IsInvalid) throw new ArgumentNullException(nameof(hdc), "Device context cannot be null.");
if (hdc.IsNull) throw new ArgumentNullException(nameof(hdc), "Device context cannot be null.");
hDC = hdc;
hOld = SelectObject(hdc, hObj);
}
@ -52,8 +52,64 @@ namespace Vanara.PInvoke
void IDisposable.Dispose() => SelectObject(hDC, hOld);
}
/// <summary>
/// Provides a <see cref="SafeHandle"/> to a graphics bitmap object that releases a created HBITMAP instance at disposal using DeleteObject.
/// </summary>
public class SafeHBITMAP : HANDLE
{
/// <summary>Initializes a new instance of the <see cref="SafeHBITMAP"/> class and assigns an existing handle.</summary>
/// <param name="preexistingHandle">An <see cref="IntPtr"/> object that represents the pre-existing handle to use.</param>
/// <param name="ownsHandle">
/// <see langword="true"/> to reliably release the handle during the finalization phase; otherwise, <see langword="false"/> (not recommended).
/// </param>
public SafeHBITMAP(IntPtr preexistingHandle, bool ownsHandle = true) : base(preexistingHandle, ownsHandle) { }
private SafeHBITMAP() : base() { }
/// <summary>Performs an implicit conversion from <see cref="SafeHBITMAP"/> to <see cref="HBITMAP"/>.</summary>
/// <param name="h">The safe handle instance.</param>
/// <returns>The result of the conversion.</returns>
public static implicit operator HBITMAP(SafeHBITMAP h) => h.handle;
/// <summary>Performs an implicit conversion from <see cref="SafeHBITMAP"/> to <see cref="HGDIOBJ"/>.</summary>
/// <param name="h">The safe handle instance.</param>
/// <returns>The result of the conversion.</returns>
public static implicit operator HGDIOBJ(SafeHBITMAP h) => h.handle;
/// <inheritdoc/>
protected override bool InternalReleaseHandle() => DeleteObject(this);
}
/// <summary>
/// Provides a <see cref="SafeHandle"/> to a graphics bitmap object that releases a created HBRUSH instance at disposal using DeleteObject.
/// </summary>
public class SafeHBRUSH : HANDLE
{
/// <summary>Initializes a new instance of the <see cref="SafeHBRUSH"/> class and assigns an existing handle.</summary>
/// <param name="preexistingHandle">An <see cref="IntPtr"/> object that represents the pre-existing handle to use.</param>
/// <param name="ownsHandle">
/// <see langword="true"/> to reliably release the handle during the finalization phase; otherwise, <see langword="false"/> (not recommended).
/// </param>
public SafeHBRUSH(IntPtr preexistingHandle, bool ownsHandle = true) : base(preexistingHandle, ownsHandle) { }
private SafeHBRUSH() : base() { }
/// <summary>Performs an implicit conversion from <see cref="SafeHBRUSH"/> to <see cref="HBRUSH"/>.</summary>
/// <param name="h">The safe handle instance.</param>
/// <returns>The result of the conversion.</returns>
public static implicit operator HBRUSH(SafeHBRUSH h) => h.handle;
/// <summary>Performs an implicit conversion from <see cref="SafeHBRUSH"/> to <see cref="HGDIOBJ"/>.</summary>
/// <param name="h">The safe handle instance.</param>
/// <returns>The result of the conversion.</returns>
public static implicit operator HGDIOBJ(SafeHBRUSH h) => h.handle;
/// <inheritdoc/>
protected override bool InternalReleaseHandle() => DeleteObject(this);
}
/// <summary>A SafeHandle to track DC handles.</summary>
public class SafeHDC : HDC
public class SafeHDC : HANDLE
{
private readonly IDeviceContext idc;
@ -73,15 +129,22 @@ namespace Vanara.PInvoke
SetHandle(dc.GetHdc());
}
private SafeHDC() : base() { }
/// <summary>Gets the screen compatible device context handle.</summary>
/// <value>The screen compatible device context handle.</value>
public static SafeHDC ScreenCompatibleDCHandle => CreateCompatibleDC(NULL);
public static SafeHDC ScreenCompatibleDCHandle => CreateCompatibleDC(HDC.NULL);
/// <summary>Performs an explicit conversion from <see cref="SafeHDC"/> to <see cref="Graphics"/>.</summary>
/// <param name="hdc">The HDC.</param>
/// <returns>The result of the conversion.</returns>
public static explicit operator Graphics(SafeHDC hdc) => Graphics.FromHdc(hdc.handle);
/// <summary>Performs an implicit conversion from <see cref="SafeHDC"/> to <see cref="HDC"/>.</summary>
/// <param name="h">The safe handle instance.</param>
/// <returns>The result of the conversion.</returns>
public static implicit operator HDC(SafeHDC h) => h.handle;
/// <summary>Performs an implicit conversion from <see cref="Graphics"/> to <see cref="SafeHDC"/>.</summary>
/// <param name="graphics">The <see cref="Graphics"/> instance.</param>
/// <returns>The result of the conversion.</returns>
@ -106,79 +169,10 @@ namespace Vanara.PInvoke
}
}
/// <summary>
/// Provides a <see cref="SafeHandle"/> to a graphics object that releases a created HGDIOBJ instance at disposal using DeleteObject.
/// </summary>
public abstract class SafeHGDIOBJ : HGDIOBJ
{
/// <summary>Initializes a new instance of the <see cref="SafeHGDIOBJ"/> class and assigns an existing handle.</summary>
/// <param name="preexistingHandle">An <see cref="IntPtr"/> object that represents the pre-existing handle to use.</param>
/// <param name="ownsHandle">
/// <see langword="true"/> to reliably release the handle during the finalization phase; otherwise, <see langword="false"/> (not recommended).
/// </param>
protected SafeHGDIOBJ(IntPtr preexistingHandle, bool ownsHandle = true) : base(preexistingHandle, ownsHandle) { }
/// <inheritdoc/>
protected override bool InternalReleaseHandle() => DeleteObject(this);
}
/// <summary>
/// Provides a <see cref="SafeHandle"/> to a graphics bitmap object that releases a created HBITMAP instance at disposal using DeleteObject.
/// </summary>
public class SafeHBITMAP : SafeHGDIOBJ
{
/// <summary>Initializes a new instance of the <see cref="SafeHBITMAP"/> class and assigns an existing handle.</summary>
/// <param name="preexistingHandle">An <see cref="IntPtr"/> object that represents the pre-existing handle to use.</param>
/// <param name="ownsHandle">
/// <see langword="true"/> to reliably release the handle during the finalization phase; otherwise, <see langword="false"/> (not recommended).
/// </param>
public SafeHBITMAP(IntPtr preexistingHandle, bool ownsHandle = true) : base(preexistingHandle, ownsHandle) { }
/// <summary>Returns an invalid handle by instantiating a <see cref="HGDIOBJ"/> object with <see cref="IntPtr.Zero"/>.</summary>
new public static SafeHBITMAP NULL => new SafeHBITMAP(IntPtr.Zero);
/// <summary>Creates a managed <see cref="System.Drawing.Bitmap"/> from this HBITMAP instance.</summary>
/// <returns>A managed bitmap instance.</returns>
public Bitmap ToBitmap() => IsInvalid ? null : (Bitmap)Image.FromHbitmap(handle).Clone();
}
/// <summary>
/// Provides a <see cref="SafeHandle"/> to a graphics bitmap object that releases a created HBRUSH instance at disposal using DeleteObject.
/// </summary>
public class SafeHBRUSH : SafeHGDIOBJ
{
/// <summary>Initializes a new instance of the <see cref="SafeHBRUSH"/> class and assigns an existing handle.</summary>
/// <param name="preexistingHandle">An <see cref="IntPtr"/> object that represents the pre-existing handle to use.</param>
/// <param name="ownsHandle">
/// <see langword="true"/> to reliably release the handle during the finalization phase; otherwise, <see langword="false"/> (not recommended).
/// </param>
public SafeHBRUSH(IntPtr preexistingHandle, bool ownsHandle = true) : base(preexistingHandle, ownsHandle) { }
/// <summary>Returns an invalid handle by instantiating a <see cref="HGDIOBJ"/> object with <see cref="IntPtr.Zero"/>.</summary>
new public static SafeHBRUSH NULL => new SafeHBRUSH(IntPtr.Zero);
/// <summary>Creates a managed <see cref="System.Drawing.Brush"/> from this HBRUSH instance.</summary>
/// <returns>A managed brush instance.</returns>
public Brush ToBrush() => IsInvalid ? null : new NativeBrush(this);
private class NativeBrush : Brush
{
public NativeBrush(SafeHBRUSH hBrush)
{
var lb = GetObject<LOGBRUSH>(hBrush);
var b2 = CreateBrushIndirect(ref lb);
SetNativeBrush(b2.DangerousGetHandle());
b2.SetHandleAsInvalid();
}
public override object Clone() => this;
}
}
/// <summary>
/// Provides a <see cref="SafeHandle"/> to a graphics bitmap object that releases a created HFONT instance at disposal using DeleteObject.
/// </summary>
public class SafeHFONT : SafeHGDIOBJ
public class SafeHFONT : HANDLE
{
/// <summary>Initializes a new instance of the <see cref="SafeHFONT"/> class and assigns an existing handle.</summary>
/// <param name="preexistingHandle">An <see cref="IntPtr"/> object that represents the pre-existing handle to use.</param>
@ -187,14 +181,55 @@ namespace Vanara.PInvoke
/// </param>
public SafeHFONT(IntPtr preexistingHandle, bool ownsHandle = true) : base(preexistingHandle, ownsHandle) { }
/// <summary>Returns an invalid handle by instantiating a <see cref="HGDIOBJ"/> object with <see cref="IntPtr.Zero"/>.</summary>
new public static SafeHFONT NULL => new SafeHFONT(IntPtr.Zero);
private SafeHFONT() : base() { }
/// <summary>Performs an implicit conversion from <see cref="SafeHFONT"/> to <see cref="HFONT"/>.</summary>
/// <param name="h">The safe handle instance.</param>
/// <returns>The result of the conversion.</returns>
public static implicit operator HFONT(SafeHFONT h) => h.handle;
/// <summary>Performs an implicit conversion from <see cref="SafeHFONT"/> to <see cref="HGDIOBJ"/>.</summary>
/// <param name="h">The safe handle instance.</param>
/// <returns>The result of the conversion.</returns>
public static implicit operator HGDIOBJ(SafeHFONT h) => h.handle;
/// <inheritdoc/>
protected override bool InternalReleaseHandle() => DeleteObject(this);
}
/// <summary>
/// Provides a <see cref="SafeHandle"/> to a graphics color palette object that releases a created HPALETTE instance at disposal
/// using DeleteObject.
/// </summary>
public class SafeHPALETTE : HANDLE
{
/// <summary>Initializes a new instance of the <see cref="SafeHPALETTE"/> class and assigns an existing handle.</summary>
/// <param name="preexistingHandle">An <see cref="IntPtr"/> object that represents the pre-existing handle to use.</param>
/// <param name="ownsHandle">
/// <see langword="true"/> to reliably release the handle during the finalization phase; otherwise, <see langword="false"/> (not recommended).
/// </param>
public SafeHPALETTE(IntPtr preexistingHandle, bool ownsHandle = true) : base(preexistingHandle, ownsHandle) { }
private SafeHPALETTE() : base() { }
/// <summary>Performs an implicit conversion from <see cref="SafeHPALETTE"/> to <see cref="HGDIOBJ"/>.</summary>
/// <param name="h">The safe handle instance.</param>
/// <returns>The result of the conversion.</returns>
public static implicit operator HGDIOBJ(SafeHPALETTE h) => h.handle;
/// <summary>Performs an implicit conversion from <see cref="SafeHPALETTE"/> to <see cref="HPALETTE"/>.</summary>
/// <param name="h">The safe handle instance.</param>
/// <returns>The result of the conversion.</returns>
public static implicit operator HPALETTE(SafeHPALETTE h) => h.handle;
/// <inheritdoc/>
protected override bool InternalReleaseHandle() => DeleteObject(this);
}
/// <summary>
/// Provides a <see cref="SafeHandle"/> to a graphics bitmap object that releases a created HPEN instance at disposal using DeleteObject.
/// </summary>
public class SafeHPEN : SafeHGDIOBJ
public class SafeHPEN : HANDLE
{
/// <summary>Initializes a new instance of the <see cref="SafeHPEN"/> class and assigns an existing handle.</summary>
/// <param name="preexistingHandle">An <see cref="IntPtr"/> object that represents the pre-existing handle to use.</param>
@ -203,14 +238,26 @@ namespace Vanara.PInvoke
/// </param>
public SafeHPEN(IntPtr preexistingHandle, bool ownsHandle = true) : base(preexistingHandle, ownsHandle) { }
/// <summary>Returns an invalid handle by instantiating a <see cref="HGDIOBJ"/> object with <see cref="IntPtr.Zero"/>.</summary>
new public static SafeHPEN NULL => new SafeHPEN(IntPtr.Zero);
private SafeHPEN() : base() { }
/// <summary>Performs an implicit conversion from <see cref="SafeHPEN"/> to <see cref="HGDIOBJ"/>.</summary>
/// <param name="h">The safe handle instance.</param>
/// <returns>The result of the conversion.</returns>
public static implicit operator HGDIOBJ(SafeHPEN h) => h.handle;
/// <summary>Performs an implicit conversion from <see cref="SafeHPEN"/> to <see cref="HPEN"/>.</summary>
/// <param name="h">The safe handle instance.</param>
/// <returns>The result of the conversion.</returns>
public static implicit operator HPEN(SafeHPEN h) => h.handle;
/// <inheritdoc/>
protected override bool InternalReleaseHandle() => DeleteObject(this);
}
/// <summary>
/// Provides a <see cref="SafeHandle"/> to a graphics bitmap object that releases a created HRGN instance at disposal using DeleteObject.
/// </summary>
public class SafeHRGN : SafeHGDIOBJ
public class SafeHRGN : HANDLE
{
/// <summary>Initializes a new instance of the <see cref="SafeHRGN"/> class and assigns an existing handle.</summary>
/// <param name="preexistingHandle">An <see cref="IntPtr"/> object that represents the pre-existing handle to use.</param>
@ -219,8 +266,20 @@ namespace Vanara.PInvoke
/// </param>
public SafeHRGN(IntPtr preexistingHandle, bool ownsHandle = true) : base(preexistingHandle, ownsHandle) { }
/// <summary>Returns an invalid handle by instantiating a <see cref="HGDIOBJ"/> object with <see cref="IntPtr.Zero"/>.</summary>
new public static SafeHRGN NULL => new SafeHRGN(IntPtr.Zero);
private SafeHRGN() : base() { }
/// <summary>Performs an implicit conversion from <see cref="SafeHRGN"/> to <see cref="HGDIOBJ"/>.</summary>
/// <param name="h">The safe handle instance.</param>
/// <returns>The result of the conversion.</returns>
public static implicit operator HGDIOBJ(SafeHRGN h) => h.handle;
/// <summary>Performs an implicit conversion from <see cref="SafeHRGN"/> to <see cref="HRGN"/>.</summary>
/// <param name="h">The safe handle instance.</param>
/// <returns>The result of the conversion.</returns>
public static implicit operator HRGN(SafeHRGN h) => h.handle;
/// <inheritdoc/>
protected override bool InternalReleaseHandle() => DeleteObject(this);
}
}
}

View File

@ -1,12 +1,11 @@
using System;
using System.Runtime.InteropServices;
// ReSharper disable InconsistentNaming
using System.Runtime.InteropServices;
namespace Vanara.PInvoke
{
public static partial class Gdi32
{
/// <summary>Defined character sets.</summary>
[PInvokeData("wingdi.h")]
public enum TMCHARSET : byte
{
/// <summary>The ANSI CHARSET</summary>
@ -70,28 +69,252 @@ namespace Vanara.PInvoke
BALTIC_CHARSET = 186,
}
/// <summary>
/// <para>
/// The <c>TEXTMETRIC</c> structure contains basic information about a physical font. All sizes are specified in logical units; that
/// is, they depend on the current mapping mode of the display context.
/// </para>
/// </summary>
// https://docs.microsoft.com/en-us/windows/desktop/api/wingdi/ns-wingdi-tagtextmetrica typedef struct tagTEXTMETRICA { LONG
// tmHeight; LONG tmAscent; LONG tmDescent; LONG tmInternalLeading; LONG tmExternalLeading; LONG tmAveCharWidth; LONG tmMaxCharWidth;
// LONG tmWeight; LONG tmOverhang; LONG tmDigitizedAspectX; LONG tmDigitizedAspectY; BYTE tmFirstChar; BYTE tmLastChar; BYTE
// tmDefaultChar; BYTE tmBreakChar; BYTE tmItalic; BYTE tmUnderlined; BYTE tmStruckOut; BYTE tmPitchAndFamily; BYTE tmCharSet; }
// TEXTMETRICA, *PTEXTMETRICA, *NPTEXTMETRICA, *LPTEXTMETRICA;
[PInvokeData("wingdi.h", MSDNShortId = "0a46da58-5d0f-4db4-bba6-9e1b6c1f892c")]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
public struct TEXTMETRIC
{
/// <summary>
/// <para>The height (ascent + descent) of characters.</para>
/// </summary>
public int tmHeight;
/// <summary>
/// <para>The ascent (units above the base line) of characters.</para>
/// </summary>
public int tmAscent;
/// <summary>
/// <para>The descent (units below the base line) of characters.</para>
/// </summary>
public int tmDescent;
/// <summary>
/// <para>
/// The amount of leading (space) inside the bounds set by the <c>tmHeight</c> member. Accent marks and other diacritical
/// characters may occur in this area. The designer may set this member to zero.
/// </para>
/// </summary>
public int tmInternalLeading;
/// <summary>
/// <para>
/// The amount of extra leading (space) that the application adds between rows. Since this area is outside the font, it contains
/// no marks and is not altered by text output calls in either OPAQUE or TRANSPARENT mode. The designer may set this member to zero.
/// </para>
/// </summary>
public int tmExternalLeading;
/// <summary>
/// <para>
/// The average width of characters in the font (generally defined as the width of the letter x ). This value does not include
/// the overhang required for bold or italic characters.
/// </para>
/// </summary>
public int tmAveCharWidth;
/// <summary>
/// <para>The width of the widest character in the font.</para>
/// </summary>
public int tmMaxCharWidth;
/// <summary>
/// <para>The weight of the font.</para>
/// </summary>
public int tmWeight;
/// <summary>
/// <para>
/// The extra width per string that may be added to some synthesized fonts. When synthesizing some attributes, such as bold or
/// italic, graphics device interface (GDI) or a device may have to add width to a string on both a per-character and per-string
/// basis. For example, GDI makes a string bold by expanding the spacing of each character and overstriking by an offset value;
/// it italicizes a font by shearing the string. In either case, there is an overhang past the basic string. For bold strings,
/// the overhang is the distance by which the overstrike is offset. For italic strings, the overhang is the amount the top of the
/// font is sheared past the bottom of the font.
/// </para>
/// <para>
/// The <c>tmOverhang</c> member enables the application to determine how much of the character width returned by a
/// GetTextExtentPoint32 function call on a single character is the actual character width and how much is the per-string extra
/// width. The actual width is the extent minus the overhang.
/// </para>
/// </summary>
public int tmOverhang;
/// <summary>
/// <para>The horizontal aspect of the device for which the font was designed.</para>
/// </summary>
public int tmDigitizedAspectX;
/// <summary>
/// <para>
/// The vertical aspect of the device for which the font was designed. The ratio of the <c>tmDigitizedAspectX</c> and
/// <c>tmDigitizedAspectY</c> members is the aspect ratio of the device for which the font was designed.
/// </para>
/// </summary>
public int tmDigitizedAspectY;
/// <summary>
/// <para>The value of the first character defined in the font.</para>
/// </summary>
public char tmFirstChar;
/// <summary>
/// <para>The value of the last character defined in the font.</para>
/// </summary>
public char tmLastChar;
/// <summary>
/// <para>The value of the character to be substituted for characters not in the font.</para>
/// </summary>
public char tmDefaultChar;
/// <summary>
/// <para>The value of the character that will be used to define word breaks for text justification.</para>
/// </summary>
public char tmBreakChar;
/// <summary>
/// <para>Specifies an italic font if it is nonzero.</para>
/// </summary>
public byte tmItalic;
/// <summary>
/// <para>Specifies an underlined font if it is nonzero.</para>
/// </summary>
public byte tmUnderlined;
/// <summary>
/// <para>A strikeout font if it is nonzero.</para>
/// </summary>
public byte tmStruckOut;
/// <summary>
/// <para>Specifies information about the pitch, the technology, and the family of a physical font.</para>
/// <para>
/// The four low-order bits of this member specify information about the pitch and the technology of the font. A constant is
/// defined for each of the four bits.
/// </para>
/// <list type="table">
/// <listheader>
/// <term>Constant</term>
/// <term>Meaning</term>
/// </listheader>
/// <item>
/// <term>TMPF_FIXED_PITCH</term>
/// <term>
/// If this bit is set the font is a variable pitch font. If this bit is clear the font is a fixed pitch font. Note very
/// carefully that those meanings are the opposite of what the constant name implies.
/// </term>
/// </item>
/// <item>
/// <term>TMPF_VECTOR</term>
/// <term>If this bit is set the font is a vector font.</term>
/// </item>
/// <item>
/// <term>TMPF_TRUETYPE</term>
/// <term>If this bit is set the font is a TrueType font.</term>
/// </item>
/// <item>
/// <term>TMPF_DEVICE</term>
/// <term>If this bit is set the font is a device font.</term>
/// </item>
/// </list>
/// <para>
/// An application should carefully test for qualities encoded in these low-order bits, making no arbitrary assumptions. For
/// example, besides having their own bits set, TrueType and PostScript fonts set the TMPF_VECTOR bit. A monospace bitmap font
/// has all of these low-order bits clear; a proportional bitmap font sets the TMPF_FIXED_PITCH bit. A Postscript printer device
/// font sets the TMPF_DEVICE, TMPF_VECTOR, and TMPF_FIXED_PITCH bits.
/// </para>
/// <para>
/// The four high-order bits of <c>tmPitchAndFamily</c> designate the font's font family. An application can use the value 0xF0
/// and the bitwise AND operator to mask out the four low-order bits of <c>tmPitchAndFamily</c>, thus obtaining a value that can
/// be directly compared with font family names to find an identical match. For information about font families, see the
/// description of the LOGFONT structure.
/// </para>
/// </summary>
public byte tmPitchAndFamily;
/// <summary>
/// <para>The character set of the font. The character set can be one of the following values.</para>
/// <list type="bullet">
/// <item>
/// <term>ANSI_CHARSET</term>
/// </item>
/// <item>
/// <term>BALTIC_CHARSET</term>
/// </item>
/// <item>
/// <term>CHINESEBIG5_CHARSET</term>
/// </item>
/// <item>
/// <term>DEFAULT_CHARSET</term>
/// </item>
/// <item>
/// <term>EASTEUROPE_CHARSET</term>
/// </item>
/// <item>
/// <term>GB2312_CHARSET</term>
/// </item>
/// <item>
/// <term>GREEK_CHARSET</term>
/// </item>
/// <item>
/// <term>HANGUL_CHARSET</term>
/// </item>
/// <item>
/// <term>MAC_CHARSET</term>
/// </item>
/// <item>
/// <term>OEM_CHARSET</term>
/// </item>
/// <item>
/// <term>RUSSIAN_CHARSET</term>
/// </item>
/// <item>
/// <term>SHIFTJIS_CHARSET</term>
/// </item>
/// <item>
/// <term>SYMBOL_CHARSET</term>
/// </item>
/// <item>
/// <term>TURKISH_CHARSET</term>
/// </item>
/// <item>
/// <term>VIETNAMESE_CHARSET</term>
/// </item>
/// </list>
/// <para>Korean language edition of Windows:</para>
/// <list type="bullet">
/// <item>
/// <term>JOHAB_CHARSET</term>
/// </item>
/// </list>
/// <para>Middle East language edition of Windows:</para>
/// <list type="bullet">
/// <item>
/// <term>ARABIC_CHARSET</term>
/// </item>
/// <item>
/// <term>HEBREW_CHARSET</term>
/// </item>
/// </list>
/// <para>Thai language edition of Windows:</para>
/// <list type="bullet">
/// <item>
/// <term>THAI_CHARSET</term>
/// </item>
/// </list>
/// </summary>
public TMCHARSET tmCharSet;
}
}

View File

@ -1,9 +1,8 @@
using System;
using System.Drawing;
using System.Runtime.InteropServices;
using Vanara.InteropServices;
// ReSharper disable InconsistentNaming
namespace Vanara.PInvoke
{
public static partial class Gdi32
@ -422,39 +421,6 @@ namespace Vanara.PInvoke
[PInvokeData("Wingdi.h", MSDNShortId = "dd183370")]
public static extern bool BitBlt(HDC hdc, int nXDest, int nYDest, int nWidth, int nHeight, HDC hdcSrc, int nXSrc, int nYSrc, RasterOperationMode dwRop);
/// <summary>
/// <para>The <c>CreateBrushIndirect</c> function creates a logical brush that has the specified style, color, and pattern.</para>
/// </summary>
/// <param name="plbrush">
/// <para>A pointer to a LOGBRUSH structure that contains information about the brush.</para>
/// </param>
/// <returns>
/// <para>If the function succeeds, the return value identifies a logical brush.</para>
/// <para>If the function fails, the return value is <c>NULL</c>.</para>
/// </returns>
/// <remarks>
/// <para>A brush is a bitmap that the system uses to paint the interiors of filled shapes.</para>
/// <para>
/// After an application creates a brush by calling <c>CreateBrushIndirect</c>, it can select it into any device context by calling
/// the SelectObject function.
/// </para>
/// <para>
/// A brush created by using a monochrome bitmap (one color plane, one bit per pixel) is drawn using the current text and background
/// colors. Pixels represented by a bit set to 0 are drawn with the current text color; pixels represented by a bit set to 1 are
/// drawn with the current background color.
/// </para>
/// <para>When you no longer need the brush, call the DeleteObject function to delete it.</para>
/// <para>
/// <c>ICM:</c> No color is done at brush creation. However, color management is performed when the brush is selected into an
/// ICM-enabled device context.
/// </para>
/// </remarks>
// https://docs.microsoft.com/en-us/windows/desktop/api/wingdi/nf-wingdi-createbrushindirect HBRUSH CreateBrushIndirect( CONST
// LOGBRUSH *plbrush );
[DllImport(Lib.Gdi32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("wingdi.h", MSDNShortId = "75f94ad1-ca25-4ad1-9e8c-ad1a4b8475a7")]
public static extern SafeHBRUSH CreateBrushIndirect(ref LOGBRUSH plbrush);
/// <summary>The CreateCompatibleDC function creates a memory device context (DC) compatible with the specified device.</summary>
/// <param name="hDC">
/// A handle to an existing DC. If this handle is NULL, the function creates a memory DC compatible with the application's current screen.
@ -609,16 +575,90 @@ namespace Vanara.PInvoke
[PInvokeData("Wingdi.h", MSDNShortId = "dd144904")]
public static T GetObject<T>(HGDIOBJ hgdiobj) where T : struct
{
var result = default(T);
using (var ptr = SafeHGlobalHandle.CreateFromStructure(result))
{
var ret = GetObject(hgdiobj, ptr.Size, (IntPtr)ptr);
if (ret == 0)
throw new System.ComponentModel.Win32Exception();
using (var ptr = GetObject(hgdiobj))
return ptr.ToStructure<T>();
}
}
/// <summary>The GetObject function retrieves information for the specified graphics object.</summary>
/// <param name="hgdiobj">
/// A handle to the graphics object of interest. This can be a handle to one of the following: a logical bitmap, a brush, a font, a
/// palette, a pen, or a device independent bitmap created by calling the CreateDIBSection function.
/// </param>
/// <returns>Allocated memory holding the information for the graphics object.</returns>
[PInvokeData("Wingdi.h", MSDNShortId = "dd144904")]
public static SafeHGlobalHandle GetObject(HGDIOBJ hgdiobj)
{
var sz = GetObject(hgdiobj, 0, IntPtr.Zero);
var ptr = new SafeHGlobalHandle(sz);
var ret = GetObject(hgdiobj, ptr.Size, (IntPtr)ptr);
if (ret == 0)
Win32Error.ThrowLastError();
return ptr;
}
/// <summary>Converts a height in logical units to pixels.</summary>
/// <param name="width">The height in logical units.</param>
/// <param name="hdc">The device context handle.</param>
/// <returns>The height in pixels.</returns>
public static int LogicalHeightToDeviceWidth(int height, HDC hdc = default)
{
var pts = new[] { new Point(0, height) };
LPtoDP(hdc.IsNull ? SafeHDC.ScreenCompatibleDCHandle : hdc, pts, 1);
return pts[0].Y;
}
/// <summary>Converts a width in logical units to pixels.</summary>
/// <param name="width">The width in logical units.</param>
/// <param name="hdc">The device context handle.</param>
/// <returns>The width in pixels.</returns>
public static int LogicalWidthToDeviceWidth(int width, HDC hdc = default)
{
var pts = new[] { new Point(width, 0) };
LPtoDP(hdc.IsNull ? SafeHDC.ScreenCompatibleDCHandle : hdc, pts, 1);
return pts[0].X;
}
/// <summary>
/// <para>
/// The <c>LPtoDP</c> function converts logical coordinates into device coordinates. The conversion depends on the mapping mode of
/// the device context, the settings of the origins and extents for the window and viewport, and the world transformation.
/// </para>
/// </summary>
/// <param name="hdc">
/// <para>A handle to the device context.</para>
/// </param>
/// <param name="lppt">
/// <para>
/// A pointer to an array of POINT structures. The x-coordinates and y-coordinates contained in each of the <c>POINT</c> structures
/// will be transformed.
/// </para>
/// </param>
/// <param name="c">
/// <para>The number of points in the array.</para>
/// </param>
/// <returns>
/// <para>If the function succeeds, the return value is nonzero.</para>
/// <para>If the function fails, the return value is zero.</para>
/// </returns>
/// <remarks>
/// <para>
/// The <c>LPtoDP</c> function fails if the logical coordinates exceed 32 bits, or if the converted device coordinates exceed 27
/// bits. In the case of such an overflow, the results for all the points are undefined.
/// </para>
/// <para>
/// <c>LPtoDP</c> calculates complex floating-point arithmetic, and it has a caching system for efficiency. Therefore, the conversion
/// result of an initial call to <c>LPtoDP</c> might not exactly match the conversion result of a later call to <c>LPtoDP</c>. We
/// recommend not to write code that relies on the exact match of the conversion results from multiple calls to <c>LPtoDP</c> even if
/// the parameters that are passed to each call are identical.
/// </para>
/// </remarks>
// https://docs.microsoft.com/en-us/windows/desktop/api/wingdi/nf-wingdi-lptodp
// BOOL LPtoDP( HDC hdc, LPPOINT lppt, int c );
[DllImport(Lib.Gdi32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("wingdi.h", MSDNShortId = "670a16fb-842e-4250-9ad7-dc08e849c2ba")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool LPtoDP(HDC hdc, [In, Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] Point[] lppt, int c);
/// <summary>
/// The SelectObject function selects an object into the specified device context (DC). The new object replaces the previous object
/// of the same type.
@ -702,223 +742,5 @@ namespace Vanara.PInvoke
[return: MarshalAs(UnmanagedType.Bool)]
[PInvokeData("Wingdi.h", MSDNShortId = "dd145141")]
public static extern bool TransparentBlt(HDC hdcDest, int xOriginDest, int yOriginDest, int wDest, int hDest, HDC hdcSrc, int xOriginSrc, int yOriginSrc, int wSrc, int hSrc, int crTransparent);
/// <summary>
/// <para>
/// The <c>LOGBRUSH</c> structure defines the style, color, and pattern of a physical brush. It is used by the CreateBrushIndirect
/// and ExtCreatePen functions.
/// </para>
/// </summary>
/// <remarks>
/// <para>
/// Although <c>lbColor</c> controls the foreground color of a hatch brush, the SetBkMode and SetBkColor functions control the
/// background color.
/// </para>
/// </remarks>
// https://docs.microsoft.com/en-us/windows/desktop/api/wingdi/ns-wingdi-taglogbrush typedef struct tagLOGBRUSH { UINT lbStyle;
// COLORREF lbColor; ULONG_PTR lbHatch; } LOGBRUSH, *PLOGBRUSH, *NPLOGBRUSH, *LPLOGBRUSH;
[PInvokeData("wingdi.h", MSDNShortId = "ded2c7a4-2248-4d01-95c6-ab4050719094")]
[StructLayout(LayoutKind.Explicit)]
public struct LOGBRUSH
{
/// <summary>
/// <para>The brush style. The <c>lbStyle</c> member must be one of the following styles.</para>
/// <list type="table">
/// <listheader>
/// <term>Value</term>
/// <term>Meaning</term>
/// </listheader>
/// <item>
/// <term>BS_DIBPATTERN</term>
/// <term>
/// A pattern brush defined by a device-independent bitmap (DIB) specification. If lbStyle is BS_DIBPATTERN, the lbHatch member
/// contains a handle to a packed DIB. For more information, see discussion in lbHatch.
/// </term>
/// </item>
/// <item>
/// <term>BS_DIBPATTERN8X8</term>
/// <term>See BS_DIBPATTERN.</term>
/// </item>
/// <item>
/// <term>BS_DIBPATTERNPT</term>
/// <term>
/// A pattern brush defined by a device-independent bitmap (DIB) specification. If lbStyle is BS_DIBPATTERNPT, the lbHatch member
/// contains a pointer to a packed DIB. For more information, see discussion in lbHatch.
/// </term>
/// </item>
/// <item>
/// <term>BS_HATCHED</term>
/// <term>Hatched brush.</term>
/// </item>
/// <item>
/// <term>BS_HOLLOW</term>
/// <term>Hollow brush.</term>
/// </item>
/// <item>
/// <term>BS_NULL</term>
/// <term>Same as BS_HOLLOW.</term>
/// </item>
/// <item>
/// <term>BS_PATTERN</term>
/// <term>Pattern brush defined by a memory bitmap.</term>
/// </item>
/// <item>
/// <term>BS_PATTERN8X8</term>
/// <term>See BS_PATTERN.</term>
/// </item>
/// <item>
/// <term>BS_SOLID</term>
/// <term>Solid brush.</term>
/// </item>
/// </list>
/// </summary>
[FieldOffset(0)]
public BrushStyle lbStyle;
/// <summary>
/// <para>
/// The color in which the brush is to be drawn. If <c>lbStyle</c> is the BS_HOLLOW or BS_PATTERN style, <c>lbColor</c> is ignored.
/// </para>
/// <para>
/// If <c>lbStyle</c> is BS_DIBPATTERN or BS_DIBPATTERNPT, the low-order word of <c>lbColor</c> specifies whether the
/// <c>bmiColors</c> members of the BITMAPINFO structure contain explicit red, green, blue (RGB) values or indexes into the
/// currently realized logical palette. The <c>lbColor</c> member must be one of the following values.
/// </para>
/// <list type="table">
/// <listheader>
/// <term>Value</term>
/// <term>Meaning</term>
/// </listheader>
/// <item>
/// <term>DIB_PAL_COLORS</term>
/// <term>The color table consists of an array of 16-bit indexes into the currently realized logical palette.</term>
/// </item>
/// <item>
/// <term>DIB_RGB_COLORS</term>
/// <term>The color table contains literal RGB values.</term>
/// </item>
/// </list>
/// <para>
/// If <c>lbStyle</c> is BS_HATCHED or BS_SOLID, <c>lbColor</c> is a COLORREF color value. To create a <c>COLORREF</c> color
/// value, use the RGB macro.
/// </para>
/// </summary>
[FieldOffset(4)]
public COLORREF lbColor;
/// <summary>
/// <para>A hatch style. The meaning depends on the brush style defined by <c>lbStyle</c>.</para>
/// <para>
/// If <c>lbStyle</c> is BS_DIBPATTERN, the <c>lbHatch</c> member contains a handle to a packed DIB. To obtain this handle, an
/// application calls the GlobalAlloc function with GMEM_MOVEABLE (or LocalAlloc with LMEM_MOVEABLE) to allocate a block of
/// memory and then fills the memory with the packed DIB. A packed DIB consists of a BITMAPINFO structure immediately followed by
/// the array of bytes that define the pixels of the bitmap.
/// </para>
/// <para>
/// If <c>lbStyle</c> is BS_DIBPATTERNPT, the <c>lbHatch</c> member contains a pointer to a packed DIB. The pointer derives from
/// the memory block created by LocalAlloc with LMEM_FIXED set or by GlobalAlloc with GMEM_FIXED set, or it is the pointer
/// returned by a call like LocalLock (handle_to_the_dib). A packed DIB consists of a BITMAPINFO structure immediately followed
/// by the array of bytes that define the pixels of the bitmap.
/// </para>
/// <para>
/// If <c>lbStyle</c> is BS_HATCHED, the <c>lbHatch</c> member specifies the orientation of the lines used to create the hatch.
/// It can be one of the following values.
/// </para>
/// <list type="table">
/// <listheader>
/// <term>Value</term>
/// <term>Meaning</term>
/// </listheader>
/// <item>
/// <term>HS_BDIAGONAL</term>
/// <term>A 45-degree upward, left-to-right hatch</term>
/// </item>
/// <item>
/// <term>HS_CROSS</term>
/// <term>Horizontal and vertical cross-hatch</term>
/// </item>
/// <item>
/// <term>HS_DIAGCROSS</term>
/// <term>45-degree crosshatch</term>
/// </item>
/// <item>
/// <term>HS_FDIAGONAL</term>
/// <term>A 45-degree downward, left-to-right hatch</term>
/// </item>
/// <item>
/// <term>HS_HORIZONTAL</term>
/// <term>Horizontal hatch</term>
/// </item>
/// <item>
/// <term>HS_VERTICAL</term>
/// <term>Vertical hatch</term>
/// </item>
/// </list>
/// <para>
/// If <c>lbStyle</c> is BS_PATTERN, <c>lbHatch</c> is a handle to the bitmap that defines the pattern. The bitmap cannot be a
/// DIB section bitmap, which is created by the CreateDIBSection function.
/// </para>
/// <para>If <c>lbStyle</c> is BS_SOLID or BS_HOLLOW, <c>lbHatch</c> is ignored.</para>
/// </summary>
[FieldOffset(8)]
public HatchStyle lbHatchStyle;
/// <summary>
/// <para>A hatch style. The meaning depends on the brush style defined by <c>lbStyle</c>.</para>
/// <para>
/// If <c>lbStyle</c> is BS_DIBPATTERN, the <c>lbHatch</c> member contains a handle to a packed DIB. To obtain this handle, an
/// application calls the GlobalAlloc function with GMEM_MOVEABLE (or LocalAlloc with LMEM_MOVEABLE) to allocate a block of
/// memory and then fills the memory with the packed DIB. A packed DIB consists of a BITMAPINFO structure immediately followed by
/// the array of bytes that define the pixels of the bitmap.
/// </para>
/// <para>
/// If <c>lbStyle</c> is BS_DIBPATTERNPT, the <c>lbHatch</c> member contains a pointer to a packed DIB. The pointer derives from
/// the memory block created by LocalAlloc with LMEM_FIXED set or by GlobalAlloc with GMEM_FIXED set, or it is the pointer
/// returned by a call like LocalLock (handle_to_the_dib). A packed DIB consists of a BITMAPINFO structure immediately followed
/// by the array of bytes that define the pixels of the bitmap.
/// </para>
/// <para>
/// If <c>lbStyle</c> is BS_HATCHED, the <c>lbHatch</c> member specifies the orientation of the lines used to create the hatch.
/// It can be one of the following values.
/// </para>
/// <list type="table">
/// <listheader>
/// <term>Value</term>
/// <term>Meaning</term>
/// </listheader>
/// <item>
/// <term>HS_BDIAGONAL</term>
/// <term>A 45-degree upward, left-to-right hatch</term>
/// </item>
/// <item>
/// <term>HS_CROSS</term>
/// <term>Horizontal and vertical cross-hatch</term>
/// </item>
/// <item>
/// <term>HS_DIAGCROSS</term>
/// <term>45-degree crosshatch</term>
/// </item>
/// <item>
/// <term>HS_FDIAGONAL</term>
/// <term>A 45-degree downward, left-to-right hatch</term>
/// </item>
/// <item>
/// <term>HS_HORIZONTAL</term>
/// <term>Horizontal hatch</term>
/// </item>
/// <item>
/// <term>HS_VERTICAL</term>
/// <term>Vertical hatch</term>
/// </item>
/// </list>
/// <para>
/// If <c>lbStyle</c> is BS_PATTERN, <c>lbHatch</c> is a handle to the bitmap that defines the pattern. The bitmap cannot be a
/// DIB section bitmap, which is created by the CreateDIBSection function.
/// </para>
/// <para>If <c>lbStyle</c> is BS_SOLID or BS_HOLLOW, <c>lbHatch</c> is ignored.</para>
/// </summary>
[FieldOffset(8)]
public IntPtr lbHatch;
}
}
}

View File

@ -1,5 +1,5 @@
## Correlation report for iphlpapi.dll
### Methods (56% complete)
### Methods (57% complete)
Native Method | Native DLL | Header | Managed Method
--- | --- | --- | ---
[AddIPAddress](http://msdn2.microsoft.com/en-us/library/669264cd-a43c-4681-9416-2704d4232685) | iphlpapi.dll | iphlpapi.h | Vanara.PInvoke.IpHlpApi.AddIPAddress
@ -76,6 +76,7 @@ Native Method | Native DLL | Header | Managed Method
[GetIpNetEntry2](http://msdn2.microsoft.com/en-us/library/c77e01da-2d5a-4c74-b581-62fa6ee52c9e) | iphlpapi.dll | netioapi.h | Vanara.PInvoke.IpHlpApi.GetIpNetEntry2
[GetIpNetTable](http://msdn2.microsoft.com/en-us/library/01bcf86e-5fcc-4ce9-bb89-02d393e75d1d) | iphlpapi.dll | iphlpapi.h | Vanara.PInvoke.IpHlpApi.GetIpNetTable
[GetIpNetTable2](http://msdn2.microsoft.com/en-us/library/6c45d735-9a07-41ca-8d8a-919f32c98a3c) | iphlpapi.dll | netioapi.h | Vanara.PInvoke.IpHlpApi.GetIpNetTable2
[GetIpNetworkConnectionBandwidthEstimates](http://msdn2.microsoft.com/en-us/library/FE60AF0D-15B0-4223-8AE1-3E65483A1C5F) | Iphlpapi.dll | netioapi.h | Vanara.PInvoke.IpHlpApi.GetIpNetworkConnectionBandwidthEstimates
[GetIpPathEntry](http://msdn2.microsoft.com/en-us/library/8ad43a1d-428a-41cc-bba8-5eec7f87c11f) | iphlpapi.dll | netioapi.h | Vanara.PInvoke.IpHlpApi.GetIpPathEntry
[GetIpPathTable](http://msdn2.microsoft.com/en-us/library/e03816a4-0b86-4e0b-a45e-8148c8ba5472) | iphlpapi.dll | netioapi.h | Vanara.PInvoke.IpHlpApi.GetIpPathTable
[GetIpStatistics](https://www.google.com/search?num=5&q=GetIpStatistics+site%3Amicrosoft.com) | iphlpapi.dll | |
@ -100,12 +101,14 @@ Native Method | Native DLL | Header | Managed Method
[GetTcp6Table2](https://www.google.com/search?num=5&q=GetTcp6Table2+site%3Amicrosoft.com) | iphlpapi.dll | |
[GetTcpStatistics](https://www.google.com/search?num=5&q=GetTcpStatistics+site%3Amicrosoft.com) | iphlpapi.dll | |
[GetTcpStatisticsEx](https://www.google.com/search?num=5&q=GetTcpStatisticsEx+site%3Amicrosoft.com) | iphlpapi.dll | |
[GetTcpStatisticsEx2](https://www.google.com/search?num=5&q=GetTcpStatisticsEx2+site%3Amicrosoft.com) | iphlpapi.dll | |
[GetTcpTable](https://www.google.com/search?num=5&q=GetTcpTable+site%3Amicrosoft.com) | iphlpapi.dll | |
[GetTcpTable2](https://www.google.com/search?num=5&q=GetTcpTable2+site%3Amicrosoft.com) | iphlpapi.dll | |
[GetTeredoPort](http://msdn2.microsoft.com/en-us/library/59d3764d-e560-4474-a73e-ab50bbddbf07) | iphlpapi.dll | netioapi.h | Vanara.PInvoke.IpHlpApi.GetTeredoPort
[GetUdp6Table](https://www.google.com/search?num=5&q=GetUdp6Table+site%3Amicrosoft.com) | iphlpapi.dll | |
[GetUdpStatistics](https://www.google.com/search?num=5&q=GetUdpStatistics+site%3Amicrosoft.com) | iphlpapi.dll | |
[GetUdpStatisticsEx](https://www.google.com/search?num=5&q=GetUdpStatisticsEx+site%3Amicrosoft.com) | iphlpapi.dll | |
[GetUdpStatisticsEx2](https://www.google.com/search?num=5&q=GetUdpStatisticsEx2+site%3Amicrosoft.com) | iphlpapi.dll | |
[GetUdpTable](https://www.google.com/search?num=5&q=GetUdpTable+site%3Amicrosoft.com) | iphlpapi.dll | |
[GetUnicastIpAddressEntry](http://msdn2.microsoft.com/en-us/library/d5475c09-05dd-41d7-80ff-63c52d78468c) | iphlpapi.dll | netioapi.h | Vanara.PInvoke.IpHlpApi.GetUnicastIpAddressEntry
[GetUnicastIpAddressTable](http://msdn2.microsoft.com/en-us/library/bdafc4a4-5f3c-4dd5-ba9b-4f6045a82652) | iphlpapi.dll | netioapi.h | Vanara.PInvoke.IpHlpApi.GetUnicastIpAddressTable
@ -141,6 +144,7 @@ Native Method | Native DLL | Header | Managed Method
[ResolveNeighbor](https://www.google.com/search?num=5&q=ResolveNeighbor+site%3Amicrosoft.com) | iphlpapi.dll | |
[RestoreMediaSense](https://www.google.com/search?num=5&q=RestoreMediaSense+site%3Amicrosoft.com) | iphlpapi.dll | |
[SendARP](http://msdn2.microsoft.com/en-us/library/5cbaf45a-a64e-49fd-a920-01759b5c4f81) | iphlpapi.dll | iphlpapi.h | Vanara.PInvoke.IpHlpApi.SendARP
[SetCurrentThreadCompartmentId](http://msdn2.microsoft.com/en-us/library/15c634b5-c621-430d-99d7-c55ad8b6864e) | Iphlpapi.dll | netioapi.h | Vanara.PInvoke.IpHlpApi.SetCurrentThreadCompartmentId
[SetIfEntry](https://www.google.com/search?num=5&q=SetIfEntry+site%3Amicrosoft.com) | iphlpapi.dll | |
[SetIpForwardEntry](https://www.google.com/search?num=5&q=SetIpForwardEntry+site%3Amicrosoft.com) | iphlpapi.dll | |
[SetIpForwardEntry2](http://msdn2.microsoft.com/en-us/library/e11aab0b-6d6c-4e90-a60a-f7d68c09751b) | iphlpapi.dll | netioapi.h | Vanara.PInvoke.IpHlpApi.SetIpForwardEntry2
@ -150,10 +154,12 @@ Native Method | Native DLL | Header | Managed Method
[SetIpStatistics](https://www.google.com/search?num=5&q=SetIpStatistics+site%3Amicrosoft.com) | iphlpapi.dll | |
[SetIpStatisticsEx](https://www.google.com/search?num=5&q=SetIpStatisticsEx+site%3Amicrosoft.com) | iphlpapi.dll | |
[SetIpTTL](https://www.google.com/search?num=5&q=SetIpTTL+site%3Amicrosoft.com) | iphlpapi.dll | |
[SetNetworkInformation](http://msdn2.microsoft.com/en-us/library/e196e978-2eb7-4b22-af3b-e14736c5ac94) | Iphlpapi.dll | netioapi.h | Vanara.PInvoke.IpHlpApi.SetNetworkInformation
[SetPerTcp6ConnectionEStats](https://www.google.com/search?num=5&q=SetPerTcp6ConnectionEStats+site%3Amicrosoft.com) | iphlpapi.dll | |
[SetPerTcp6ConnectionStats](https://www.google.com/search?num=5&q=SetPerTcp6ConnectionStats+site%3Amicrosoft.com) | iphlpapi.dll | |
[SetPerTcpConnectionEStats](https://www.google.com/search?num=5&q=SetPerTcpConnectionEStats+site%3Amicrosoft.com) | iphlpapi.dll | |
[SetPerTcpConnectionStats](https://www.google.com/search?num=5&q=SetPerTcpConnectionStats+site%3Amicrosoft.com) | iphlpapi.dll | |
[SetSessionCompartmentId](http://msdn2.microsoft.com/en-us/library/d8192a40-0122-44cd-87a8-3999204322b4) | Iphlpapi.dll | netioapi.h | Vanara.PInvoke.IpHlpApi.SetSessionCompartmentId
[SetTcpEntry](https://www.google.com/search?num=5&q=SetTcpEntry+site%3Amicrosoft.com) | iphlpapi.dll | |
[SetUnicastIpAddressEntry](http://msdn2.microsoft.com/en-us/library/906a3895-2e42-4bed-90a3-7c10487d76cb) | iphlpapi.dll | netioapi.h | Vanara.PInvoke.IpHlpApi.SetUnicastIpAddressEntry
[UnenableRouter](http://msdn2.microsoft.com/en-us/library/95f0387f-24e8-4382-b78e-e59bcec0f2ed) | iphlpapi.dll | iphlpapi.h | Vanara.PInvoke.IpHlpApi.UnenableRouter
@ -161,8 +167,6 @@ Native Method | Native DLL | Header | Managed Method
Native Structure | Header | Managed Structure
--- | --- | ---
[FIXED_INFO](http://msdn2.microsoft.com/en-us/library/6dcf33c6-33dc-4583-9b04-5231948d3d9a) | iptypes.h | Vanara.PInvoke.IpHlpApi+FIXED_INFO
[IN_ADDR](https://www.google.com/search?num=5&q=IN_ADDR+site%3Amicrosoft.com) | winsock2.h | Vanara.PInvoke.IpHlpApi+IN_ADDR
[IN6_ADDR](https://www.google.com/search?num=5&q=IN6_ADDR+site%3Amicrosoft.com) | winsock2.h | Vanara.PInvoke.IpHlpApi+IN6_ADDR
[IP_ADAPTER_ADDRESSES](http://msdn2.microsoft.com/en-us/library/a2df3749-6c75-40c0-8952-1656bbe639a6) | iptypes.h | Vanara.PInvoke.IpHlpApi+IP_ADAPTER_ADDRESSES
[IP_ADAPTER_ANYCAST_ADDRESS](http://msdn2.microsoft.com/en-us/library/2626fc86-e29b-4162-8625-207c709d67ed) | iptypes.h | Vanara.PInvoke.IpHlpApi+IP_ADAPTER_ANYCAST_ADDRESS
[IP_ADAPTER_DNS_SERVER_ADDRESS](http://msdn2.microsoft.com/en-us/library/96855386-9010-40df-8260-16b43ad6646f) | iptypes.h | Vanara.PInvoke.IpHlpApi+IP_ADAPTER_DNS_SERVER_ADDRESS
@ -179,7 +183,7 @@ Native Structure | Header | Managed Structure
[IP_PER_ADAPTER_INFO](http://msdn2.microsoft.com/en-us/library/10cfdded-4184-4d34-9ccd-85446c13d497) | iptypes.h | Vanara.PInvoke.IpHlpApi+IP_PER_ADAPTER_INFO
[MIB_ANYCASTIPADDRESS_ROW](http://msdn2.microsoft.com/en-us/library/bdbe43b8-88aa-48af-aa6b-c88c4e8e404e) | netioapi.h | Vanara.PInvoke.IpHlpApi+MIB_ANYCASTIPADDRESS_ROW
[MIB_IF_ROW2](http://msdn2.microsoft.com/en-us/library/e8bb79f9-e7e9-470b-8883-36d08061661b) | netioapi.h | Vanara.PInvoke.IpHlpApi+MIB_IF_ROW2
[MIB_IFROW](https://www.google.com/search?num=5&q=MIB_IFROW+site%3Amicrosoft.com) | IpHlpApi.h | Vanara.PInvoke.IpHlpApi+MIB_IFROW
[MIB_IFROW](http://msdn2.microsoft.com/en-us/library/b08631e9-6036-4377-b2f2-4ea899acb787) | ifmib.h | Vanara.PInvoke.IpHlpApi+MIB_IFROW
[MIB_IFSTACK_ROW](http://msdn2.microsoft.com/en-us/library/ff559207) | Netioapi.h | Vanara.PInvoke.IpHlpApi+MIB_IFSTACK_ROW
[MIB_INVERTEDIFSTACK_ROW](http://msdn2.microsoft.com/en-us/library/ff559234) | Netioapi.h | Vanara.PInvoke.IpHlpApi+MIB_INVERTEDIFSTACK_ROW
[MIB_IP_NETWORK_CONNECTION_BANDWIDTH_ESTIMATES](http://msdn2.microsoft.com/en-us/library/E3109F71-E103-4586-9274-B83C4DC22382) | netioapi.h | Vanara.PInvoke.IpHlpApi+MIB_IP_NETWORK_CONNECTION_BANDWIDTH_ESTIMATES
@ -211,8 +215,3 @@ Native Structure | Header | Managed Structure
[NL_BANDWIDTH_INFORMATION](http://msdn2.microsoft.com/en-us/library/F5D7238A-EAE0-4D60-A0A4-D839F738EF48) | nldef.h | Vanara.PInvoke.IpHlpApi+NL_BANDWIDTH_INFORMATION
[NL_INTERFACE_OFFLOAD_ROD](http://msdn2.microsoft.com/en-us/library/764c7f5a-00df-461d-99ee-07f9e1f77ec7) | nldef.h | Vanara.PInvoke.IpHlpApi+NL_INTERFACE_OFFLOAD_ROD
[SCOPE_ID](https://www.google.com/search?num=5&q=SCOPE_ID+site%3Amicrosoft.com) | ws2def.h | Vanara.PInvoke.IpHlpApi+SCOPE_ID
[SOCKADDR_IN](https://www.google.com/search?num=5&q=SOCKADDR_IN+site%3Amicrosoft.com) | winsock2.h | Vanara.PInvoke.IpHlpApi+SOCKADDR_IN
[SOCKADDR_IN6](https://www.google.com/search?num=5&q=SOCKADDR_IN6+site%3Amicrosoft.com) | winsock2.h | Vanara.PInvoke.IpHlpApi+SOCKADDR_IN6
[SOCKADDR_IN6_PAIR](http://msdn2.microsoft.com/en-us/library/0265f8e0-8b35-4d9d-bf22-e98e9ff36a17) | ws2ipdef.h | Vanara.PInvoke.IpHlpApi+SOCKADDR_IN6_PAIR
[SOCKADDR_INET](https://www.google.com/search?num=5&q=SOCKADDR_INET+site%3Amicrosoft.com) | winsock2.h | Vanara.PInvoke.IpHlpApi+SOCKADDR_INET
[SOCKET_ADDRESS](https://www.google.com/search?num=5&q=SOCKET_ADDRESS+site%3Amicrosoft.com) | winsock2.h | Vanara.PInvoke.IpHlpApi+SOCKET_ADDRESS

File diff suppressed because it is too large Load Diff

View File

@ -2,11 +2,77 @@
using System.Collections.Generic;
using System.Runtime.InteropServices;
using Vanara.Extensions;
using Vanara.InteropServices;
using static Vanara.PInvoke.Ws2_32;
namespace Vanara.PInvoke
{
public static partial class IpHlpApi
{
/// <summary>Flags for an IP address.</summary>
[PInvokeData("IpTypes.h")]
[Flags]
public enum IP_ADAPTER_CAST_FLAGS
{
/// <summary>The IP address is legal to appear in DNS.</summary>
IP_ADAPTER_ADDRESS_DNS_ELIGIBLE = 0x01,
/// <summary>The IP address is a cluster address and should not be used by most applications.</summary>
IP_ADAPTER_ADDRESS_TRANSIENT = 0x02
}
/// <summary>Flags for <see cref="IP_ADAPTER_ADDRESSES"/>.</summary>
[PInvokeData("IPTypes.h")]
[Flags]
public enum IP_ADAPTER_FLAGS : uint
{
/// <summary>Dynamic DNS is enabled on this adapter.</summary>
IP_ADAPTER_DDNS_ENABLED = 0x00000001,
/// <summary>Register the DNS suffix for this adapter.</summary>
IP_ADAPTER_REGISTER_ADAPTER_SUFFIX = 0x00000002,
/// <summary>Dynamic Host Configuration Protocol is enabled on this adapter.</summary>
IP_ADAPTER_DHCP_ENABLED = 0x00000004,
/// <summary>The adapter is a receive-only adapter.</summary>
IP_ADAPTER_RECEIVE_ONLY = 0x00000008,
/// <summary>The adapter is not a multicast recipient.</summary>
IP_ADAPTER_NO_MULTICAST = 0x00000010,
/// <summary>The adapter contains other IPv6-specific stateful configuration information.</summary>
IP_ADAPTER_IPV6_OTHER_STATEFUL_CONFIG = 0x00000020,
/// <summary>
/// The adapter is enabled for NetBIOS over TCP/IP. <note type="note">This flag is only supported on Windows Vista and later when
/// the application has been compiled for a target platform with an NTDDI version equal or greater than NTDDI_LONGHORN. This flag
/// is defined in the IP_ADAPTER_ADDRESSES_LH structure as the NetbiosOverTcpipEnabled bitfield.</note>
/// </summary>
IP_ADAPTER_NETBIOS_OVER_TCPIP_ENABLED = 0x00000040,
/// <summary>
/// The adapter is enabled for IPv4. <note type="note">This flag is only supported on Windows Vista and later when the
/// application has been compiled for a target platform with an NTDDI version equal or greater than NTDDI_LONGHORN. This flag is
/// defined in the IP_ADAPTER_ADDRESSES_LH structure as the Ipv4Enabled bitfield.</note>
/// </summary>
IP_ADAPTER_IPV4_ENABLED = 0x00000080,
/// <summary>
/// The adapter is enabled for IPv6. <note type="note">This flag is only supported on Windows Vista and later when the
/// application has been compiled for a target platform with an NTDDI version equal or greater than NTDDI_LONGHORN. This flag is
/// defined in the IP_ADAPTER_ADDRESSES_LH structure as the Ipv6Enabled bitfield.</note>
/// </summary>
IP_ADAPTER_IPV6_ENABLED = 0x00000100,
/// <summary>
/// The adapter is enabled for IPv6 managed address configuration. <note type="note">This flag is only supported on Windows Vista
/// and later when the application has been compiled for a target platform with an NTDDI version equal or greater than
/// NTDDI_LONGHORN. This flag is defined in the IP_ADAPTER_ADDRESSES_LH structure as the Ipv6ManagedAddressConfigurationSupported bitfield.</note>
/// </summary>
IP_ADAPTER_IPV6_MANAGE_ADDRESS_CONFIG = 0x00000200,
}
/// <summary>
/// <para>The <c>FIXED_INFO</c> structure contains information that is the same across all the interfaces on a computer.</para>
/// </summary>
@ -740,5 +806,844 @@ namespace Vanara.PInvoke
public IP_ADAPTER_ADDRESSES? GetNext() => Next.ToNullableStructure<IP_ADAPTER_ADDRESSES>();
}
/// <summary>
/// <para>
/// The <c>IP_ADAPTER_ANYCAST_ADDRESS</c> structure stores a single anycast IP address in a linked list of addresses for a particular adapter.
/// </para>
/// </summary>
/// <remarks>
/// <para>
/// The IP_ADAPTER_ADDRESSES structure is retrieved by the GetAdaptersAddresses function. The <c>FirstAnycastAddress</c> member of
/// the <c>IP_ADAPTER_ADDRESSES</c> structure is a pointer to a linked list of <c>IP_ADAPTER_ANYCAST_ADDRESS</c> structures.
/// </para>
/// <para>
/// The SOCKET_ADDRESS structure is used in the <c>IP_ADAPTER_ANYCAST_ADDRESS</c> structure. On the Microsoft Windows Software
/// Development Kit (SDK) released for Windows Vista and later, the organization of header files has changed and the
/// <c>SOCKET_ADDRESS</c> structure is defined in the Ws2def.h header file which is automatically included by the Winsock2.h header
/// file. On the Platform Software Development Kit (SDK) released for Windows Server 2003 and Windows XP, the <c>SOCKET_ADDRESS</c>
/// structure is declared in the Winsock2.h header file. In order to use the <c>IP_ADAPTER_ANYCAST_ADDRESS</c> structure, the
/// Winsock2.h header file must be included before the Iphlpapi.h header file.
/// </para>
/// </remarks>
// https://docs.microsoft.com/en-us/windows/desktop/api/iptypes/ns-iptypes-_ip_adapter_anycast_address_xp typedef struct
// _IP_ADAPTER_ANYCAST_ADDRESS_XP { union { ULONGLONG Alignment; struct { ULONG Length; DWORD Flags; }; }; struct
// _IP_ADAPTER_ANYCAST_ADDRESS_XP *Next; SOCKET_ADDRESS Address; } IP_ADAPTER_ANYCAST_ADDRESS_XP, *PIP_ADAPTER_ANYCAST_ADDRESS_XP;
[PInvokeData("iptypes.h", MSDNShortId = "2626fc86-e29b-4162-8625-207c709d67ed")]
[StructLayout(LayoutKind.Sequential)]
public struct IP_ADAPTER_ANYCAST_ADDRESS : ILinkedListElement<IP_ADAPTER_ANYCAST_ADDRESS>
{
/// <summary>Specifies the length of this structure.</summary>
public uint Length;
/// <summary>Specifies flags for this address.</summary>
public IP_ADAPTER_CAST_FLAGS Flags;
/// <summary>
/// <para>Type: <c>struct _IP_ADAPTER_ANYCAST_ADDRESS*</c></para>
/// <para>A pointer to the next anycast IP address structure in the list.</para>
/// </summary>
public IntPtr Next;
/// <summary>
/// <para>Type: <c>SOCKET_ADDRESS</c></para>
/// <para>The IP address for this anycast IP address entry. This member can be an IPv6 address or an IPv4 address.</para>
/// </summary>
public SOCKET_ADDRESS Address;
/// <summary>
/// <para>Gets a reference to the next <c>IP_ADAPTER_ANYCAST_ADDRESS</c> structure in the list.</para>
/// </summary>
public IP_ADAPTER_ANYCAST_ADDRESS? GetNext() => Next.ToNullableStructure<IP_ADAPTER_ANYCAST_ADDRESS>();
/// <inheritdoc/>
public override string ToString() => Address.ToString();
}
/// <summary>
/// <para>
/// The <c>IP_ADAPTER_DNS_SERVER_ADDRESS</c> structure stores a single DNS server address in a linked list of DNS server addresses
/// for a particular adapter.
/// </para>
/// </summary>
/// <remarks>
/// <para>
/// The IP_ADAPTER_ADDRESSES structure is retrieved by the GetAdaptersAddresses function. The <c>FirstDnsServerAddress</c> member of
/// the <c>IP_ADAPTER_ADDRESSES</c> structure is a pointer to a linked list of <c>IP_ADAPTER_DNS_SERVER_ADDRESS</c> structures.
/// </para>
/// <para>
/// The SOCKET_ADDRESS structure is used in the <c>IP_ADAPTER_DNS_SERVER_ADDRESS</c> structure. On the Microsoft Windows Software
/// Development Kit (SDK) released for Windows Vista and later, the organization of header files has changed and the
/// <c>SOCKET_ADDRESS</c> structure is defined in the Ws2def.h header file which is automatically included by the Winsock2.h header
/// file. On the Platform Software Development Kit (SDK) released for Windows Server 2003 and Windows XP, the <c>SOCKET_ADDRESS</c>
/// structure is declared in the Winsock2.h header file. In order to use the <c>IP_ADAPTER_DNS_SERVER_ADDRESS</c> structure, the
/// Winsock2.h header file must be included before the Iphlpapi.h header file.
/// </para>
/// </remarks>
// https://docs.microsoft.com/en-us/windows/desktop/api/iptypes/ns-iptypes-_ip_adapter_dns_server_address_xp typedef struct
// _IP_ADAPTER_DNS_SERVER_ADDRESS_XP { union { ULONGLONG Alignment; struct { ULONG Length; DWORD Reserved; }; }; struct
// _IP_ADAPTER_DNS_SERVER_ADDRESS_XP *Next; SOCKET_ADDRESS Address; } IP_ADAPTER_DNS_SERVER_ADDRESS_XP, *PIP_ADAPTER_DNS_SERVER_ADDRESS_XP;
[PInvokeData("iptypes.h", MSDNShortId = "96855386-9010-40df-8260-16b43ad6646f")]
[StructLayout(LayoutKind.Sequential)]
public struct IP_ADAPTER_DNS_SERVER_ADDRESS : ILinkedListElement<IP_ADAPTER_DNS_SERVER_ADDRESS>
{
/// <summary>Specifies the length of this structure.</summary>
public uint Length;
/// <summary>Reserved.</summary>
public uint Reserved;
/// <summary>
/// <para>A pointer to the next DNS server address structure in the list.</para>
/// </summary>
public IntPtr Next;
/// <summary>
/// <para>The IP address for this DNS server entry. This member can be an IPv6 address or an IPv4 address.</para>
/// </summary>
public SOCKET_ADDRESS Address;
/// <summary>
/// <para>Gets a reference to the next <c>IP_ADAPTER_DNS_SERVER_ADDRESS</c> structure in the list.</para>
/// </summary>
public IP_ADAPTER_DNS_SERVER_ADDRESS? GetNext() => Next.ToNullableStructure<IP_ADAPTER_DNS_SERVER_ADDRESS>();
/// <inheritdoc/>
public override string ToString() => Address.ToString();
}
/// <summary>
/// <para>The <c>IP_ADAPTER_DNS_SUFFIX</c> structure stores a DNS suffix in a linked list of DNS suffixes for a particular adapter.</para>
/// </summary>
/// <remarks>
/// <para>
/// The IP_ADAPTER_ADDRESSES structure is retrieved by the GetAdaptersAddresses function. The <c>FirstDnsSuffix</c> member of the
/// <c>IP_ADAPTER_ADDRESSES</c> structure is a pointer to a linked list of <c>IP_ADAPTER_DNS_SUFFIX</c> structures.
/// </para>
/// </remarks>
// https://docs.microsoft.com/en-us/windows/desktop/api/iptypes/ns-iptypes-_ip_adapter_dns_suffix typedef struct
// _IP_ADAPTER_DNS_SUFFIX { struct _IP_ADAPTER_DNS_SUFFIX *Next; WCHAR String[MAX_DNS_SUFFIX_STRING_LENGTH]; } IP_ADAPTER_DNS_SUFFIX, *PIP_ADAPTER_DNS_SUFFIX;
[PInvokeData("iptypes.h", MSDNShortId = "3730a406-2995-48f7-b70e-1cf8258ee4a6")]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct IP_ADAPTER_DNS_SUFFIX : ILinkedListElement<IP_ADAPTER_DNS_SUFFIX>
{
/// <summary>
/// <para>A pointer to the next DNS suffix in the linked list.</para>
/// </summary>
public IntPtr Next;
/// <summary>
/// <para>The DNS suffix for this DNS suffix entry.</para>
/// </summary>
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = MAX_DNS_SUFFIX_STRING_LENGTH)]
public string String;
/// <summary>
/// <para>Gets a reference to the next <c>IP_ADAPTER_DNS_SUFFIX</c> structure in the list.</para>
/// </summary>
public IP_ADAPTER_DNS_SUFFIX? GetNext() => Next.ToNullableStructure<IP_ADAPTER_DNS_SUFFIX>();
/// <inheritdoc/>
public override string ToString() => String;
}
/// <summary>
/// <para>
/// The <c>IP_ADAPTER_GATEWAY_ADDRESS</c> structure stores a single gateway address in a linked list of gateway addresses for a
/// particular adapter.
/// </para>
/// </summary>
/// <remarks>
/// <para>
/// The IP_ADAPTER_ADDRESSES structure is retrieved by the GetAdaptersAddresses function. The <c>FirstGatewayAddress</c> member of
/// the <c>IP_ADAPTER_ADDRESSES</c> structure is a pointer to a linked list of <c>IP_ADAPTER_GATEWAY_ADDRESS</c> structures.
/// </para>
/// <para>
/// The SOCKET_ADDRESS structure is used in the <c>IP_ADAPTER_GATEWAY_ADDRESS</c> structure. On the Microsoft Windows Software
/// Development Kit (SDK) released for Windows Vista and later, the organization of header files has changed and the
/// <c>SOCKET_ADDRESS</c> structure is defined in the Ws2def.h header file which is automatically included by the Winsock2.h header
/// file. On the Platform Software Development Kit (SDK) released for Windows Server 2003 and Windows XP, the <c>SOCKET_ADDRESS</c>
/// structure is declared in the Winsock2.h header file. In order to use the <c>IP_ADAPTER_GATEWAY_ADDRESS</c> structure, the
/// Winsock2.h header file must be included before the Iphlpapi.h header file.
/// </para>
/// </remarks>
// https://docs.microsoft.com/en-us/windows/desktop/api/iptypes/ns-iptypes-_ip_adapter_gateway_address_lh typedef struct
// _IP_ADAPTER_GATEWAY_ADDRESS_LH { union { ULONGLONG Alignment; struct { ULONG Length; DWORD Reserved; }; }; struct
// _IP_ADAPTER_GATEWAY_ADDRESS_LH *Next; SOCKET_ADDRESS Address; } IP_ADAPTER_GATEWAY_ADDRESS_LH, *PIP_ADAPTER_GATEWAY_ADDRESS_LH;
[PInvokeData("iptypes.h", MSDNShortId = "CA38504A-1CC9-4ABA-BD4E-1B2EAD6F588B")]
[StructLayout(LayoutKind.Sequential)]
public struct IP_ADAPTER_GATEWAY_ADDRESS : ILinkedListElement<IP_ADAPTER_GATEWAY_ADDRESS>
{
/// <summary>Specifies the length of this structure.</summary>
public uint Length;
/// <summary>Reserved.</summary>
public uint Reserved;
/// <summary>
/// <para>A pointer to the next gateway address structure in the list.</para>
/// </summary>
public IntPtr Next;
/// <summary>
/// <para>The IP address for this gateway entry. This member can be an IPv6 address or an IPv4 address.</para>
/// </summary>
public SOCKET_ADDRESS Address;
/// <summary>
/// <para>Gets a reference to the next <c>IP_ADAPTER_GATEWAY_ADDRESS</c> structure in the list.</para>
/// </summary>
public IP_ADAPTER_GATEWAY_ADDRESS? GetNext() => Next.ToNullableStructure<IP_ADAPTER_GATEWAY_ADDRESS>();
/// <inheritdoc/>
public override string ToString() => Address.ToString();
}
/// <summary>
/// <para>The <c>IP_ADAPTER_INFO</c> structure contains information about a particular network adapter on the local computer.</para>
/// </summary>
/// <remarks>
/// <para>
/// The <c>IP_ADAPTER_INFO</c> structure is limited to IPv4 information about a particular network adapter on the local computer. The
/// <c>IP_ADAPTER_INFO</c> structure is retrieved by calling the GetAdaptersInfofunction.
/// </para>
/// <para>
/// When using Visual Studio 2005 and later, the <c>time_t</c> datatype defaults to an 8-byte datatype, not the 4-byte datatype used
/// for the <c>LeaseObtained</c> and <c>LeaseExpires</c> members on a 32-bit platform. To properly use the <c>IP_ADAPTER_INFO</c>
/// structure on a 32-bit platform, define <c>_USE_32BIT_TIME_T</c> (use as an option, for example) when compiling the application to
/// force the <c>time_t</c> datatype to a 4-byte datatype.
/// </para>
/// <para>
/// For use on Windows XP and later, the IP_ADAPTER_ADDRESSES structure contains both IPv4 and IPv6 information. The
/// GetAdaptersAddresses function retrieves IPv4 and IPv6 adapter information.
/// </para>
/// <para>Examples</para>
/// <para>This example retrieves the adapter information and prints various properties of each adapter.</para>
/// </remarks>
// https://docs.microsoft.com/en-us/windows/desktop/api/iptypes/ns-iptypes-_ip_adapter_info typedef struct _IP_ADAPTER_INFO { struct
// _IP_ADAPTER_INFO *Next; DWORD ComboIndex; char AdapterName[MAX_ADAPTER_NAME_LENGTH + 4]; char
// Description[MAX_ADAPTER_DESCRIPTION_LENGTH + 4]; UINT AddressLength; BYTE Address[MAX_ADAPTER_ADDRESS_LENGTH]; DWORD Index; UINT
// Type; UINT DhcpEnabled; PIP_ADDR_STRING CurrentIpAddress; IP_ADDR_STRING IpAddressList; IP_ADDR_STRING GatewayList; IP_ADDR_STRING
// DhcpServer; BOOL HaveWins; IP_ADDR_STRING PrimaryWinsServer; IP_ADDR_STRING SecondaryWinsServer; time_t LeaseObtained; time_t
// LeaseExpires; } IP_ADAPTER_INFO, *PIP_ADAPTER_INFO;
[PInvokeData("iptypes.h", MSDNShortId = "f8035801-ca0c-4d86-bfc5-8e2d746af1b4")]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
public struct IP_ADAPTER_INFO : ILinkedListElement<IP_ADAPTER_INFO>
{
/// <summary>
/// <para>Type: <c>struct _IP_ADAPTER_INFO*</c></para>
/// <para>A pointer to the next adapter in the list of adapters.</para>
/// </summary>
public IntPtr Next;
/// <summary>
/// <para>Type: <c>DWORD</c></para>
/// <para>Reserved.</para>
/// </summary>
public uint ComboIndex;
/// <summary>
/// <para>Type: <c>char[MAX_ADAPTER_NAME_LENGTH + 4]</c></para>
/// <para>An ANSI character string of the name of the adapter.</para>
/// </summary>
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = MAX_ADAPTER_NAME_LENGTH + 4)]
public string AdapterName;
/// <summary>
/// <para>Type: <c>char[MAX_ADAPTER_DESCRIPTION_LENGTH + 4]</c></para>
/// <para>An ANSI character string that contains the description of the adapter.</para>
/// </summary>
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = MAX_ADAPTER_DESCRIPTION_LENGTH + 4)]
public string AdapterDescription;
/// <summary>
/// <para>Type: <c>UINT</c></para>
/// <para>The length, in bytes, of the hardware address for the adapter.</para>
/// </summary>
public uint AddressLength;
/// <summary>
/// <para>Type: <c>BYTE[MAX_ADAPTER_ADDRESS_LENGTH]</c></para>
/// <para>The hardware address for the adapter represented as a <c>BYTE</c> array.</para>
/// </summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = MAX_ADAPTER_ADDRESS_LENGTH)]
public byte[] Address;
/// <summary>
/// <para>Type: <c>DWORD</c></para>
/// <para>The adapter index.</para>
/// <para>
/// The adapter index may change when an adapter is disabled and then enabled, or under other circumstances, and should not be
/// considered persistent.
/// </para>
/// </summary>
public uint Index;
/// <summary>
/// <para>Type: <c>UINT</c></para>
/// <para>The adapter type. Possible values for the adapter type are listed in the Ipifcons.h header file.</para>
/// <para>The table below lists common values for the adapter type although other values are possible on Windows Vista and later.</para>
/// <list type="table">
/// <listheader>
/// <term>Value</term>
/// <term>Meaning</term>
/// </listheader>
/// <item>
/// <term>MIB_IF_TYPE_OTHER 1</term>
/// <term>Some other type of network interface.</term>
/// </item>
/// <item>
/// <term>MIB_IF_TYPE_ETHERNET 6</term>
/// <term>An Ethernet network interface.</term>
/// </item>
/// <item>
/// <term>IF_TYPE_ISO88025_TOKENRING 9</term>
/// <term>MIB_IF_TYPE_TOKENRING</term>
/// </item>
/// <item>
/// <term>MIB_IF_TYPE_PPP 23</term>
/// <term>A PPP network interface.</term>
/// </item>
/// <item>
/// <term>MIB_IF_TYPE_LOOPBACK 24</term>
/// <term>A software loopback network interface.</term>
/// </item>
/// <item>
/// <term>MIB_IF_TYPE_SLIP 28</term>
/// <term>An ATM network interface.</term>
/// </item>
/// <item>
/// <term>IF_TYPE_IEEE80211 71</term>
/// <term>An IEEE 802.11 wireless network interface.</term>
/// </item>
/// </list>
/// </summary>
public IFTYPE Type;
/// <summary>
/// <para>Type: <c>UINT</c></para>
/// <para>An option value that specifies whether the dynamic host configuration protocol (DHCP) is enabled for this adapter.</para>
/// </summary>
[MarshalAs(UnmanagedType.Bool)]
public bool DhcpEnabled;
/// <summary>
/// <para>Type: <c>PIP_ADDR_STRING</c></para>
/// <para>Reserved.</para>
/// </summary>
public IntPtr CurrentIpAddress;
/// <summary>
/// <para>Type: <c>IP_ADDR_STRING</c></para>
/// <para>
/// The list of IPv4 addresses associated with this adapter represented as a linked list of <c>IP_ADDR_STRING</c> structures. An
/// adapter can have multiple IPv4 addresses assigned to it.
/// </para>
/// </summary>
public IP_ADDR_STRING IpAddressList;
/// <summary>
/// <para>Type: <c>IP_ADDR_STRING</c></para>
/// <para>
/// The IPv4 address of the gateway for this adapter represented as a linked list of <c>IP_ADDR_STRING</c> structures. An adapter
/// can have multiple IPv4 gateway addresses assigned to it. This list usually contains a single entry for IPv4 address of the
/// default gateway for this adapter.
/// </para>
/// </summary>
public IP_ADDR_STRING GatewayList;
/// <summary>
/// <para>Type: <c>IP_ADDR_STRING</c></para>
/// <para>
/// The IPv4 address of the DHCP server for this adapter represented as a linked list of <c>IP_ADDR_STRING</c> structures. This
/// list contains a single entry for the IPv4 address of the DHCP server for this adapter. A value of 255.255.255.255 indicates
/// the DHCP server could not be reached, or is in the process of being reached.
/// </para>
/// <para>This member is only valid when the <c>DhcpEnabled</c> member is nonzero.</para>
/// </summary>
public IP_ADDR_STRING DhcpServer;
/// <summary>
/// <para>Type: <c>BOOL</c></para>
/// <para>An option value that specifies whether this adapter uses the Windows Internet Name Service (WINS).</para>
/// </summary>
[MarshalAs(UnmanagedType.Bool)]
public bool HaveWins;
/// <summary>
/// <para>Type: <c>IP_ADDR_STRING</c></para>
/// <para>
/// The IPv4 address of the primary WINS server represented as a linked list of <c>IP_ADDR_STRING</c> structures. This list
/// contains a single entry for the IPv4 address of the primary WINS server for this adapter.
/// </para>
/// <para>This member is only valid when the <c>HaveWins</c> member is <c>TRUE</c>.</para>
/// </summary>
public IP_ADDR_STRING PrimaryWinsServer;
/// <summary>
/// <para>Type: <c>IP_ADDR_STRING</c></para>
/// <para>
/// The IPv4 address of the secondary WINS server represented as a linked list of <c>IP_ADDR_STRING</c> structures. An adapter
/// can have multiple secondary WINS server addresses assigned to it.
/// </para>
/// <para>This member is only valid when the <c>HaveWins</c> member is <c>TRUE</c>.</para>
/// </summary>
public IP_ADDR_STRING SecondaryWinsServer;
/// <summary>
/// <para>Type: <c>time_t</c></para>
/// <para>The time when the current DHCP lease was obtained.</para>
/// <para>This member is only valid when the <c>DhcpEnabled</c> member is nonzero.</para>
/// </summary>
public uint LeaseObtained;
/// <summary>
/// <para>Type: <c>time_t</c></para>
/// <para>The time when the current DHCP lease expires.</para>
/// <para>This member is only valid when the <c>DhcpEnabled</c> member is nonzero.</para>
/// </summary>
public uint LeaseExpires;
public IEnumerable<IP_ADDR_STRING> IpAddresses => IpAddressList.GetLinkedList(s => s.IpAddress != null);
public IEnumerable<IP_ADDR_STRING> Gateways => GatewayList.GetLinkedList(s => s.IpAddress != null);
public IEnumerable<IP_ADDR_STRING> SecondaryWinsServers => SecondaryWinsServer.GetLinkedList(s => s.IpAddress != null);
/// <summary>
/// <para>Gets a reference to the next <c>IP_ADAPTER_INFO</c> structure in the list.</para>
/// </summary>
public IP_ADAPTER_INFO? GetNext() => Next.ToNullableStructure<IP_ADAPTER_INFO>();
}
/// <summary>
/// <para>
/// The <c>IP_ADAPTER_MULTICAST_ADDRESS</c> structure stores a single multicast address in a linked-list of addresses for a
/// particular adapter.
/// </para>
/// </summary>
/// <remarks>
/// <para>
/// The IP_ADAPTER_ADDRESSES structure is retrieved by the GetAdaptersAddresses function. The <c>FirstMulticastAddress</c> member of
/// the <c>IP_ADAPTER_ADDRESSES</c> structure is a pointer to a linked list of <c>IP_ADAPTER_MULTICAST_ADDRESS</c> structures.
/// </para>
/// <para>
/// The SOCKET_ADDRESS structure is used in the <c>IP_ADAPTER_MULTICAST_ADDRESS</c> structure. On the Microsoft Windows Software
/// Development Kit (SDK) released for Windows Vista and later, the organization of header files has changed and the
/// <c>SOCKET_ADDRESS</c> structure is defined in the Ws2def.h header file which is automatically included by the Winsock2.h header
/// file. On the Platform Software Development Kit (SDK) released for Windows Server 2003 and Windows XP, the <c>SOCKET_ADDRESS</c>
/// structure is declared in the Winsock2.h header file. In order to use the <c>IP_ADAPTER_MULTICAST_ADDRESS</c> structure, the
/// Winsock2.h header file must be included before the Iphlpapi.h header file.
/// </para>
/// </remarks>
// https://docs.microsoft.com/en-us/windows/desktop/api/iptypes/ns-iptypes-_ip_adapter_multicast_address_xp typedef struct
// _IP_ADAPTER_MULTICAST_ADDRESS_XP { union { ULONGLONG Alignment; struct { ULONG Length; DWORD Flags; }; }; struct
// _IP_ADAPTER_MULTICAST_ADDRESS_XP *Next; SOCKET_ADDRESS Address; } IP_ADAPTER_MULTICAST_ADDRESS_XP, *PIP_ADAPTER_MULTICAST_ADDRESS_XP;
[PInvokeData("iptypes.h", MSDNShortId = "b85a6e0a-df2c-4608-b07a-191b34440a43")]
[StructLayout(LayoutKind.Sequential)]
public struct IP_ADAPTER_MULTICAST_ADDRESS : ILinkedListElement<IP_ADAPTER_MULTICAST_ADDRESS>
{
/// <summary>Specifies the length of this structure.</summary>
public uint Length;
/// <summary>Specifies flags for this address.</summary>
public IP_ADAPTER_CAST_FLAGS Flags;
/// <summary>
/// <para>Type: <c>struct _IP_ADAPTER_MULTICAST_ADDRESS*</c></para>
/// <para>A pointer to the next multicast IP address structure in the list.</para>
/// </summary>
public IntPtr Next;
/// <summary>
/// <para>Type: <c>SOCKET_ADDRESS</c></para>
/// <para>The IP address for this multicast IP address entry. This member can be an IPv6 address or an IPv4 address.</para>
/// </summary>
public SOCKET_ADDRESS Address;
/// <summary>
/// <para>Gets a reference to the next <c>IP_ADAPTER_MULTICAST_ADDRESS</c> structure in the list.</para>
/// </summary>
public IP_ADAPTER_MULTICAST_ADDRESS? GetNext() => Next.ToNullableStructure<IP_ADAPTER_MULTICAST_ADDRESS>();
/// <inheritdoc/>
public override string ToString() => Address.ToString();
}
/// <summary>
/// <para>The <c>IP_ADAPTER_PREFIX</c> structure stores an IP address prefix.</para>
/// </summary>
/// <remarks>
/// <para>
/// The IP_ADAPTER_ADDRESSES structure is retrieved by the GetAdaptersAddresses function. On Windows XP with Service Pack 1 (SP1) and
/// later, the <c>FirstPrefix</c> member of the <c>IP_ADAPTER_ADDRESSES</c> structure is a pointer to a linked list of
/// <c>IP_ADAPTER_PREFIX</c> structures.
/// </para>
/// <para>
/// The SOCKET_ADDRESS structure is used in the <c>IP_ADAPTER_PREFIX</c> structure. On the Microsoft Windows Software Development Kit
/// (SDK) released for Windows Vista and later, the organization of header files has changed and the <c>SOCKET_ADDRESS</c> structure
/// is defined in the Ws2def.h header file which is automatically included by the Winsock2.h header file. On the Platform Software
/// Development Kit (SDK) released for Windows Server 2003 and Windows XP, the <c>SOCKET_ADDRESS</c> structure is declared in the
/// Winsock2.h header file. In order to use the <c>IP_ADAPTER_PREFIX</c> structure, the Winsock2.h header file must be included
/// before the Iphlpapi.h header file.
/// </para>
/// </remarks>
// https://docs.microsoft.com/en-us/windows/desktop/api/iptypes/ns-iptypes-_ip_adapter_prefix_xp typedef struct _IP_ADAPTER_PREFIX_XP
// { union { ULONGLONG Alignment; struct { ULONG Length; DWORD Flags; }; }; struct _IP_ADAPTER_PREFIX_XP *Next; SOCKET_ADDRESS
// Address; ULONG PrefixLength; } IP_ADAPTER_PREFIX_XP, *PIP_ADAPTER_PREFIX_XP;
[PInvokeData("iptypes.h", MSDNShortId = "680b412d-2352-421d-ae58-dcf34ee6cf31")]
[StructLayout(LayoutKind.Sequential)]
public struct IP_ADAPTER_PREFIX : ILinkedListElement<IP_ADAPTER_PREFIX>
{
/// <summary>Specifies the length of this structure.</summary>
public uint Length;
/// <summary>This member is reserved and should be set to zero.</summary>
public uint Flags;
/// <summary>
/// <para>A pointer to the next adapter prefix structure in the list.</para>
/// </summary>
public IntPtr Next;
/// <summary>
/// <para>The address prefix, in the form of a SOCKET_ADDRESS structure.</para>
/// </summary>
public SOCKET_ADDRESS Address;
/// <summary>
/// <para>The length of the prefix, in bits.</para>
/// </summary>
public uint PrefixLength;
/// <summary>
/// <para>Gets a reference to the next <c>IP_ADAPTER_PREFIX</c> structure in the list.</para>
/// </summary>
public IP_ADAPTER_PREFIX? GetNext() => Next.ToNullableStructure<IP_ADAPTER_PREFIX>();
/// <inheritdoc/>
public override string ToString() => Address.ToString();
}
/// <summary>
/// <para>
/// The <c>IP_ADAPTER_UNICAST_ADDRESS</c> structure stores a single unicast IP address in a linked list of IP addresses for a
/// particular adapter.
/// </para>
/// </summary>
/// <remarks>
/// <para>
/// The IP_ADAPTER_ADDRESSES structure is retrieved by the GetAdaptersAddresses function. The <c>FirstUnicastAddress</c> member of
/// the <c>IP_ADAPTER_ADDRESSES</c> structure is a pointer to a linked list of <c>IP_ADAPTER_UNICAST_ADDRESS</c> structures.
/// </para>
/// <para>
/// The size of the <c>IP_ADAPTER_UNICAST_ADDRESS</c> structure changed on Windows Vista and later. The <c>Length</c> member should
/// be used to determine which version of the <c>IP_ADAPTER_UNICAST_ADDRESS</c> structure is being used.
/// </para>
/// <para>
/// The version of the <c>IP_ADAPTER_UNICAST_ADDRESS</c> structure on Windows Vista and later has the following new member added: <c>OnLinkPrefixLength</c>.
/// </para>
/// <para>
/// When this structure is used with the GetAdaptersAddresses function and similar management functions, all configured addresses are
/// shown, including duplicate addresses. Such duplicate address entries can occur when addresses are configured statically. Such
/// reporting facilitates administrator troubleshooting. The <c>DadState</c> member is effective in identifying and troubleshooting
/// such situations.
/// </para>
/// <para>
/// In the Windows SDK, the version of the structure for use on Windows Vista and later is defined as
/// <c>IP_ADAPTER_UNICAST_ADDRESS_LH</c>. In the Windows SDK, the version of this structure to be used on earlier systems including
/// Windows XP with Service Pack 1 (SP1) and later is defined as <c>IP_ADAPTER_UNICAST_ADDRESS_XP</c>. When compiling an application
/// if the target platform is Windows Vista and later (, , or ), the <c>IP_ADAPTER_UNICAST_ADDRESS_LH</c> structure is typedefed to
/// the <c>IP_ADAPTER_UNICAST_ADDRESS</c> structure. When compiling an application if the target platform is not Windows Vista and
/// later, the <c>IP_ADAPTER_UNICAST_ADDRESS_XP</c> structure is typedefed to the <c>IP_ADAPTER_UNICAST_ADDRESS</c> structure.
/// </para>
/// <para>
/// The SOCKET_ADDRESS structure is used in the <c>IP_ADAPTER_UNICAST_ADDRESS</c> structure. On the Microsoft Windows Software
/// Development Kit (SDK) released for Windows Vista and later, the organization of header files has changed and the
/// <c>SOCKET_ADDRESS</c> structure is defined in the Ws2def.h header file which is automatically included by the Winsock2.h header
/// file. On the Platform Software Development Kit (SDK) released for Windows Server 2003 and Windows XP, the <c>SOCKET_ADDRESS</c>
/// structure is declared in the Winsock2.h header file. In order to use the <c>IP_ADAPTER_UNICAST_ADDRESS</c> structure, the
/// Winsock2.h header file must be included before the Iphlpapi.h header file.
/// </para>
/// </remarks>
// https://docs.microsoft.com/en-us/windows/desktop/api/iptypes/ns-iptypes-_ip_adapter_unicast_address_lh typedef struct
// _IP_ADAPTER_UNICAST_ADDRESS_LH { union { ULONGLONG Alignment; struct { ULONG Length; DWORD Flags; }; }; struct
// _IP_ADAPTER_UNICAST_ADDRESS_LH *Next; SOCKET_ADDRESS Address; IP_PREFIX_ORIGIN PrefixOrigin; IP_SUFFIX_ORIGIN SuffixOrigin;
// IP_DAD_STATE DadState; ULONG ValidLifetime; ULONG PreferredLifetime; ULONG LeaseLifetime; UINT8 OnLinkPrefixLength; }
// IP_ADAPTER_UNICAST_ADDRESS_LH, *PIP_ADAPTER_UNICAST_ADDRESS_LH;
[PInvokeData("iptypes.h", MSDNShortId = "65c3648c-89bd-417b-8a9b-feefa6149c4a")]
[StructLayout(LayoutKind.Sequential)]
public struct IP_ADAPTER_UNICAST_ADDRESS : ILinkedListElement<IP_ADAPTER_UNICAST_ADDRESS>
{
/// <summary>Specifies the length of this structure.</summary>
public uint Length;
/// <summary>This member is reserved and should be set to zero.</summary>
public uint Flags;
/// <summary>
/// <para>Type: <c>struct _IP_ADAPTER_UNICAST_ADDRESS*</c></para>
/// <para>A pointer to the next IP adapter address structure in the list.</para>
/// </summary>
public IntPtr Next;
/// <summary>
/// <para>Type: <c>SOCKET_ADDRESS</c></para>
/// <para>The IP address for this unicast IP address entry. This member can be an IPv6 address or an IPv4 address.</para>
/// </summary>
public SOCKET_ADDRESS Address;
/// <summary>
/// <para>Type: <c>IP_PREFIX_ORIGIN</c></para>
/// <para>
/// The prefix or network part of IP the address. This member can be one of the values from the IP_PREFIX_ORIGIN enumeration type
/// defined in the Iptypes.h header file.
/// </para>
/// </summary>
public IP_PREFIX_ORIGIN PrefixOrigin;
/// <summary>
/// <para>Type: <c>IP_SUFFIX_ORIGIN</c></para>
/// <para>
/// The suffix or host part of the IP address. This member can be one of the values from the IP_SUFFIX_ORIGIN enumeration type
/// defined in the Iptypes.h header file.
/// </para>
/// </summary>
public IP_SUFFIX_ORIGIN SuffixOrigin;
/// <summary>
/// <para>Type: <c>IP_DAD_STATE</c></para>
/// <para>
/// The duplicate address detection (DAD) state. This member can be one of the values from the IP_DAD_STATE enumeration type
/// defined in the Iptypes.h header file. Duplicate address detection is available for both IPv4 and IPv6 addresses.
/// </para>
/// </summary>
public IP_DAD_STATE DadState;
/// <summary>
/// <para>Type: <c>ULONG</c></para>
/// <para>The maximum lifetime, in seconds, that the IP address is valid. A value of 0xffffffff is considered to be infinite.</para>
/// </summary>
public uint ValidLifetime;
/// <summary>
/// <para>Type: <c>ULONG</c></para>
/// <para>The preferred lifetime, in seconds, that the IP address is valid. A value of 0xffffffff is considered to be infinite.</para>
/// </summary>
public uint PreferredLifetime;
/// <summary>
/// <para>Type: <c>ULONG</c></para>
/// <para>The lease lifetime, in seconds, that the IP address is valid.</para>
/// </summary>
public uint LeaseLifetime;
/// <summary>
/// <para>Type: <c>UINT8</c></para>
/// <para>
/// The length, in bits, of the prefix or network part of the IP address. For a unicast IPv4 address, any value greater than 32
/// is an illegal value. For a unicast IPv6 address, any value greater than 128 is an illegal value. A value of 255 is commonly
/// used to represent an illegal value.
/// </para>
/// <para><c>Note</c> This structure member is only available on Windows Vista and later.</para>
/// </summary>
public byte OnLinkPrefixLength;
/// <summary>
/// <para>Gets a reference to the next <c>IP_ADAPTER_UNICAST_ADDRESS</c> structure in the list.</para>
/// </summary>
public IP_ADAPTER_UNICAST_ADDRESS? GetNext() => Next.ToNullableStructure<IP_ADAPTER_UNICAST_ADDRESS>();
/// <inheritdoc/>
public override string ToString() => Address.ToString();
}
/// <summary>
/// <para>
/// The <c>IP_ADAPTER_WINS_SERVER_ADDRESS</c> structure stores a single Windows Internet Name Service (WINS) server address in a
/// linked list of WINS server addresses for a particular adapter.
/// </para>
/// </summary>
/// <remarks>
/// <para>
/// The IP_ADAPTER_ADDRESSES structure is retrieved by the GetAdaptersAddresses function. The <c>FirstWinsServerAddress</c> member of
/// the <c>IP_ADAPTER_ADDRESSES</c> structure is a pointer to a linked list of <c>IP_ADAPTER_WINS_SERVER_ADDRESS</c> structures.
/// </para>
/// <para>
/// The SOCKET_ADDRESS structure is used in the IP_ADAPTER_GATEWAY_ADDRESS structure. On the Microsoft Windows Software Development
/// Kit (SDK) released for Windows Vista and later, the organization of header files has changed and the <c>SOCKET_ADDRESS</c>
/// structure is defined in the Ws2def.h header file which is automatically included by the Winsock2.h header file. On the Platform
/// Software Development Kit (SDK) released for Windows Server 2003 and Windows XP, the <c>SOCKET_ADDRESS</c> structure is declared
/// in the Winsock2.h header file. In order to use the <c>IP_ADAPTER_GATEWAY_ADDRESS</c> structure, the Winsock2.h header file must
/// be included before the Iphlpapi.h header file.
/// </para>
/// </remarks>
// https://docs.microsoft.com/en-us/windows/desktop/api/iptypes/ns-iptypes-_ip_adapter_wins_server_address_lh typedef struct
// _IP_ADAPTER_WINS_SERVER_ADDRESS_LH { union { ULONGLONG Alignment; struct { ULONG Length; DWORD Reserved; }; }; struct
// _IP_ADAPTER_WINS_SERVER_ADDRESS_LH *Next; SOCKET_ADDRESS Address; } IP_ADAPTER_WINS_SERVER_ADDRESS_LH, *PIP_ADAPTER_WINS_SERVER_ADDRESS_LH;
[PInvokeData("iptypes.h", MSDNShortId = "AF9A40C4-63DB-4830-A689-1DFE4DC2CAB7")]
[StructLayout(LayoutKind.Sequential)]
public struct IP_ADAPTER_WINS_SERVER_ADDRESS : ILinkedListElement<IP_ADAPTER_WINS_SERVER_ADDRESS>
{
/// <summary>Specifies the length of this structure.</summary>
public uint Length;
/// <summary>This member is reserved and should be set to zero.</summary>
public uint Reserved;
/// <summary>
/// <para>A pointer to the next WINS server address structure in the list.</para>
/// </summary>
public IntPtr Next;
/// <summary>
/// <para>The IP address for this WINS server entry. This member can be an IPv6 address or an IPv4 address.</para>
/// </summary>
public SOCKET_ADDRESS Address;
/// <summary>
/// <para>Gets a reference to the next <c>IP_ADAPTER_WINS_SERVER_ADDRESS</c> structure in the list.</para>
/// </summary>
public IP_ADAPTER_WINS_SERVER_ADDRESS? GetNext() => Next.ToNullableStructure<IP_ADAPTER_WINS_SERVER_ADDRESS>();
/// <inheritdoc/>
public override string ToString() => Address.ToString();
}
/// <summary>
/// <para>The <c>IP_ADDR_STRING</c> structure represents a node in a linked-list of IPv4 addresses.</para>
/// </summary>
// https://docs.microsoft.com/en-us/windows/desktop/api/iptypes/ns-iptypes-_ip_addr_string typedef struct _IP_ADDR_STRING { struct
// _IP_ADDR_STRING *Next; IP_ADDRESS_STRING IpAddress; IP_MASK_STRING IpMask; DWORD Context; } IP_ADDR_STRING, *PIP_ADDR_STRING;
[PInvokeData("iptypes.h", MSDNShortId = "783c383d-7fd3-45bc-90f6-2e8ce01db3c3")]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
public struct IP_ADDR_STRING : ILinkedListElement<IP_ADDR_STRING>
{
/// <summary>
/// <para>A pointer to the next <c>IP_ADDR_STRING</c> structure in the list.</para>
/// </summary>
public IntPtr Next;
/// <summary>
/// <para>
/// A value that specifies a structure type with a single member, <c>String</c>. The <c>String</c> member is a <c>char</c> array
/// of size 16. This array holds an IPv4 address in dotted decimal notation.
/// </para>
/// </summary>
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 16)]
public string IpAddress;
/// <summary>
/// <para>
/// A value that specifies a structure type with a single member, <c>String</c>. The <c>String</c> member is a <c>char</c> array
/// of size 16. This array holds the IPv4 subnet mask in dotted decimal notation.
/// </para>
/// </summary>
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 16)]
public string IpMask;
/// <summary>
/// <para>
/// A network table entry (NTE). This value corresponds to the NTEContext parameters in the AddIPAddress and DeleteIPAddress functions.
/// </para>
/// </summary>
public uint Context;
/// <summary>
/// <para>Gets a reference to the next <c>IP_ADDR_STRING</c> structure in the list.</para>
/// </summary>
public IP_ADDR_STRING? GetNext() => Next.ToNullableStructure<IP_ADDR_STRING>();
}
/// <summary>
/// <para>The <c>IP_PER_ADAPTER_INFO</c> structure contains information specific to a particular adapter.</para>
/// </summary>
/// <remarks>
/// <para>
/// APIPA enables automatic IP address configuration on networks without DHCP servers, using the IANA-reserved Class B network
/// 169.254.0.0, with a subnet mask of 255.255.0.0. Clients send ARP messages to ensure the selected address is not currently in use.
/// Clients auto-configured in this fashion continue to poll for a valid DHCP server every five minutes, and if found, the DHCP
/// server configuration overrides all auto-configuration settings.
/// </para>
/// </remarks>
// https://docs.microsoft.com/en-us/windows/desktop/api/iptypes/ns-iptypes-_ip_per_adapter_info_w2ksp1 typedef struct
// _IP_PER_ADAPTER_INFO_W2KSP1 { UINT AutoconfigEnabled; UINT AutoconfigActive; PIP_ADDR_STRING CurrentDnsServer; IP_ADDR_STRING
// DnsServerList; } IP_PER_ADAPTER_INFO_W2KSP1, *PIP_PER_ADAPTER_INFO_W2KSP1;
[PInvokeData("iptypes.h", MSDNShortId = "10cfdded-4184-4d34-9ccd-85446c13d497")]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
public struct IP_PER_ADAPTER_INFO
{
/// <summary>
/// <para>Specifies whether IP address auto-configuration (APIPA) is enabled on this adapter. See Remarks.</para>
/// </summary>
[MarshalAs(UnmanagedType.Bool)]
public bool AutoconfigEnabled;
/// <summary>
/// <para>Specifies whether this adapter's IP address is currently auto-configured by APIPA.</para>
/// </summary>
[MarshalAs(UnmanagedType.Bool)]
public bool AutoconfigActive;
/// <summary>
/// <para>Reserved. Use the <c>DnsServerList</c> member to obtain the DNS servers for the local computer.</para>
/// </summary>
public IntPtr CurrentDnsServer; /* IpAddressList* */
/// <summary>
/// <para>A linked list of IP_ADDR_STRING structures that specify the set of DNS servers used by the local computer.</para>
/// </summary>
public IP_ADDR_STRING DnsServerList;
/// <summary>
/// <para>
/// A list of IP_ADDR_STRING structures pulled from <see cref="DnsServerList"/> that specify the set of DNS servers used by the
/// local computer.
/// </para>
/// </summary>
public IEnumerable<IP_ADDR_STRING> DnsServers => DnsServerList.GetLinkedList(s => s.IpAddress != null);
}
/// <summary>
/// <para>The <c>IP_PER_ADAPTER_INFO</c> structure contains information specific to a particular adapter.</para>
/// </summary>
/// <remarks>
/// <para>
/// APIPA enables automatic IP address configuration on networks without DHCP servers, using the IANA-reserved Class B network
/// 169.254.0.0, with a subnet mask of 255.255.0.0. Clients send ARP messages to ensure the selected address is not currently in use.
/// Clients auto-configured in this fashion continue to poll for a valid DHCP server every five minutes, and if found, the DHCP
/// server configuration overrides all auto-configuration settings.
/// </para>
/// </remarks>
// https://docs.microsoft.com/en-us/windows/desktop/api/iptypes/ns-iptypes-_ip_per_adapter_info_w2ksp1 typedef struct
// _IP_PER_ADAPTER_INFO_W2KSP1 { UINT AutoconfigEnabled; UINT AutoconfigActive; PIP_ADDR_STRING CurrentDnsServer; IP_ADDR_STRING
// DnsServerList; } IP_PER_ADAPTER_INFO_W2KSP1, *PIP_PER_ADAPTER_INFO_W2KSP1;
[PInvokeData("iptypes.h", MSDNShortId = "10cfdded-4184-4d34-9ccd-85446c13d497")]
public class PIP_PER_ADAPTER_INFO : SafeMemoryHandle<CoTaskMemoryMethods>
{
/// <summary>Initializes a new instance of the <see cref="PIP_PER_ADAPTER_INFO"/> class.</summary>
/// <param name="byteSize">Amount of space, in bytes, to reserve.</param>
public PIP_PER_ADAPTER_INFO(uint byteSize) : base((int)byteSize)
{
}
/// <summary>
/// <para>Specifies whether this adapter's IP address is currently auto-configured by APIPA.</para>
/// </summary>
public bool AutoconfigActive => !IsInvalid && handle.ToStructure<IP_PER_ADAPTER_INFO>().AutoconfigActive;
/// <summary>
/// <para>Specifies whether IP address auto-configuration (APIPA) is enabled on this adapter. See Remarks.</para>
/// </summary>
public bool AutoconfigEnabled => !IsInvalid && handle.ToStructure<IP_PER_ADAPTER_INFO>().AutoconfigEnabled;
/// <summary>
/// <para>A linked list of IP_ADDR_STRING structures that specify the set of DNS servers used by the local computer.</para>
/// </summary>
public IEnumerable<IP_ADDR_STRING> DnsServerList => IsInvalid ? new IP_ADDR_STRING[0] : handle.ToStructure<IP_PER_ADAPTER_INFO>().DnsServers;
/// <summary>Performs an implicit conversion from <see cref="PIP_PER_ADAPTER_INFO"/> to <see cref="IntPtr"/>.</summary>
/// <param name="info">The PIP_PER_ADAPTER_INFO instance.</param>
/// <returns>The result of the conversion.</returns>
public static implicit operator IntPtr(PIP_PER_ADAPTER_INFO info) => info.DangerousGetHandle();
}
}
}

View File

@ -6,6 +6,7 @@ using System.Runtime.InteropServices;
using System.Text;
using Vanara.Extensions;
using Vanara.InteropServices;
using static Vanara.PInvoke.Ws2_32;
namespace Vanara.PInvoke
{
@ -438,7 +439,7 @@ namespace Vanara.PInvoke
// NETIOAPI_API ConvertInterfaceGuidToLuid( CONST GUID *InterfaceGuid, PNET_LUID InterfaceLuid );
[DllImport(Lib.IpHlpApi, SetLastError = false, ExactSpelling = true)]
[PInvokeData("netioapi.h", MSDNShortId = "cae669dc-899b-4485-b70a-5f58207a07df")]
public static extern Win32Error ConvertInterfaceGuidToLuid([MarshalAs(UnmanagedType.LPStruct)] Guid InterfaceGuid, out NET_LUID InterfaceLuid);
public static extern Win32Error ConvertInterfaceGuidToLuid(in Guid InterfaceGuid, out NET_LUID InterfaceLuid);
/// <summary>
/// <para>
@ -554,7 +555,7 @@ namespace Vanara.PInvoke
// NETIOAPI_API ConvertInterfaceLuidToAlias( CONST NET_LUID *InterfaceLuid, PWSTR InterfaceAlias, SIZE_T Length );
[DllImport(Lib.IpHlpApi, SetLastError = false, ExactSpelling = true)]
[PInvokeData("netioapi.h", MSDNShortId = "86a821c1-e04b-4bc3-846d-767c55008aed")]
public static extern Win32Error ConvertInterfaceLuidToAlias([MarshalAs(UnmanagedType.LPStruct)] NET_LUID InterfaceLuid, [MarshalAs(UnmanagedType.LPWStr)] StringBuilder InterfaceAlias, SizeT Length);
public static extern Win32Error ConvertInterfaceLuidToAlias(in NET_LUID InterfaceLuid, [MarshalAs(UnmanagedType.LPWStr)] StringBuilder InterfaceAlias, SizeT Length);
/// <summary>
/// <para>
@ -598,7 +599,7 @@ namespace Vanara.PInvoke
// NETIOAPI_API ConvertInterfaceLuidToGuid( CONST NET_LUID *InterfaceLuid, GUID *InterfaceGuid );
[DllImport(Lib.IpHlpApi, SetLastError = false, ExactSpelling = true)]
[PInvokeData("netioapi.h", MSDNShortId = "9d5bd1e9-0bf1-405a-8726-8e2c9ba4e022")]
public static extern Win32Error ConvertInterfaceLuidToGuid([MarshalAs(UnmanagedType.LPStruct)] NET_LUID InterfaceLuid, out Guid InterfaceGuid);
public static extern Win32Error ConvertInterfaceLuidToGuid(in NET_LUID InterfaceLuid, out Guid InterfaceGuid);
/// <summary>
/// The <c>ConvertInterfaceLuidToIndex</c> function converts a locally unique identifier (LUID) for a network interface to the local
@ -630,7 +631,7 @@ namespace Vanara.PInvoke
// NETIO_STATUS WINAPI ConvertInterfaceLuidToIndex( _In_ const NET_LUID *InterfaceLuid, _Out_ PNET_IFINDEX InterfaceIndex); https://msdn.microsoft.com/en-us/library/windows/desktop/aa365835(v=vs.85).aspx
[DllImport(Lib.IpHlpApi, SetLastError = false, ExactSpelling = true)]
[PInvokeData("Netioapi.h", MSDNShortId = "aa365835")]
public static extern Win32Error ConvertInterfaceLuidToIndex([In, MarshalAs(UnmanagedType.LPStruct)] NET_LUID InterfaceLuid, out uint InterfaceIndex);
public static extern Win32Error ConvertInterfaceLuidToIndex(in NET_LUID InterfaceLuid, out uint InterfaceIndex);
/// <summary>
/// <para>
@ -695,7 +696,7 @@ namespace Vanara.PInvoke
// NETIOAPI_API ConvertInterfaceLuidToNameA( CONST NET_LUID *InterfaceLuid, PSTR InterfaceName, SIZE_T Length );
[DllImport(Lib.IpHlpApi, SetLastError = false, CharSet = CharSet.Auto)]
[PInvokeData("netioapi.h", MSDNShortId = "c65f7b3c-55f4-40f8-9a7a-19d1066deca4")]
public static extern Win32Error ConvertInterfaceLuidToName([In, MarshalAs(UnmanagedType.LPStruct)] NET_LUID InterfaceLuid, StringBuilder InterfaceName, SizeT Length);
public static extern Win32Error ConvertInterfaceLuidToName(in NET_LUID InterfaceLuid, StringBuilder InterfaceName, SizeT Length);
/// <summary>
/// <para>
@ -820,9 +821,96 @@ namespace Vanara.PInvoke
[PInvokeData("netioapi.h", MSDNShortId = "5d986301-368e-4984-9f90-e2af1f87cbea")]
public static extern Win32Error ConvertLengthToIpv4Mask(uint MaskLength, out uint Mask);
/// <summary><para>The <c>CreateAnycastIpAddressEntry</c> function adds a new anycast IP address entry on the local computer.</para></summary><param name="Row"><para>A pointer to a MIB_ANYCASTIPADDRESS_ROW structure entry for an anycast IP address entry.</para></param><returns><para>If the function succeeds, the return value is NO_ERROR.</para><para>If the function fails, the return value is one of the following error codes.</para><list type="table"><listheader><term>Return code</term><term>Description</term></listheader><item><term> ERROR_ACCESS_DENIED </term><term>Access is denied. This error is returned under several conditions that include the following: the user lacks the required administrative privileges on the local computer or the application is not running in an enhanced shell as the built-in Administrator (RunAs administrator).</term></item><item><term> ERROR_INVALID_PARAMETER </term><term> An invalid parameter was passed to the function. This error is returned if a NULL pointer is passed in the Row parameter, the Address member of the MIB_ANYCASTIPADDRESS_ROW pointed to by the Row parameter was not set to a valid unicast IPv4 or IPv6 address, or both the InterfaceLuid or InterfaceIndex members of the MIB_ANYCASTIPADDRESS_ROW pointed to by the Row parameter were unspecified. </term></item><item><term> ERROR_NOT_FOUND </term><term> The specified interface could not be found. This error is returned if the network interface specified by the InterfaceLuid or InterfaceIndex member of the MIB_ANYCASTIPADDRESS_ROW pointed to by the Row parameter could not be found. </term></item><item><term> ERROR_NOT_SUPPORTED </term><term> The request is not supported. This error is returned if no IPv4 stack is on the local computer and an IPv4 address was specified in the Address member of the MIB_ANYCASTIPADDRESS_ROW pointed to by the Row parameter. This error is also returned if no IPv6 stack is on the local computer and an IPv6 address was specified in the Address member. </term></item><item><term> ERROR_OBJECT_ALREADY_EXISTS </term><term> The object already exists. This error is returned if the Address member of the MIB_ANYCASTIPADDRESS_ROW pointed to by the Row parameter is a duplicate of an existing anycast IP address on the interface specified by the InterfaceLuid or InterfaceIndex member of the MIB_ANYCASTIPADDRESS_ROW. </term></item><item><term> Other </term><term> Use FormatMessage to obtain the message string for the returned error. </term></item></list></returns><remarks><para>The <c>CreateAnycastIpAddressEntry</c> function is defined on Windows Vista and later.</para><para>The <c>CreateAnycastIpAddressEntry</c> function is used to add a new anycast IP address entry on a local computer.</para><para>The <c>Address</c> member in the MIB_ANYCASTIPADDRESS_ROW structure pointed to by the Row parameter must be initialized to a valid unicast IPv4 or IPv6 address and family. In addition, at least one of the following members in the <c>MIB_ANYCASTIPADDRESS_ROW</c> structure pointed to the Row parameter must be initialized to the interface: the <c>InterfaceLuid</c> or <c>InterfaceIndex</c>.</para><para>The <c>ScopeId</c> member of the MIB_ANYCASTIPADDRESS_ROW structure pointed to by the Row is ignored when the <c>CreateAnycastIpAddressEntry</c> function is called. The <c>ScopeId</c> member is automatically determined by the interface on which the address is added.</para><para>The <c>CreateAnycastIpAddressEntry</c> function will fail if the anycast IP address passed in the <c>Address</c> member of the MIB_ANYCASTIPADDRESS_ROW pointed to by the Row parameter is a duplicate of an existing anycast IP address on the interface.</para><para>The <c>CreateAnycastIpAddressEntry</c> function can only be called by a user logged on as a member of the Administrators group. If <c>CreateAnycastIpAddressEntry</c> is called by a user that is not a member of the Administrators group, the function call will fail and <c>ERROR_ACCESS_DENIED</c> is returned. This function can also fail because of user account control (UAC) on Windows Vista and later. If an application that contains this function is executed by a user logged on as a member of the Administrators group other than the built-in Administrator, this call will fail unless the application has been marked in the manifest file with a <c>requestedExecutionLevel</c> set to requireAdministrator. If the application lacks this manifest file, a user logged on as a member of the Administrators group other than the built-in Administrator must then be executing the application in an enhanced shell as the built-in Administrator (RunAs administrator) for this function to succeed.</para></remarks>
// https://docs.microsoft.com/en-us/windows/desktop/api/netioapi/nf-netioapi-createanycastipaddressentry
// _NETIOAPI_SUCCESS_ NETIOAPI_API CreateAnycastIpAddressEntry( CONST MIB_ANYCASTIPADDRESS_ROW *Row );
/// <summary>
/// <para>The <c>CreateAnycastIpAddressEntry</c> function adds a new anycast IP address entry on the local computer.</para>
/// </summary>
/// <param name="Row">
/// <para>A pointer to a MIB_ANYCASTIPADDRESS_ROW structure entry for an anycast IP address entry.</para>
/// </param>
/// <returns>
/// <para>If the function succeeds, the return value is NO_ERROR.</para>
/// <para>If the function fails, the return value is one of the following error codes.</para>
/// <list type="table">
/// <listheader>
/// <term>Return code</term>
/// <term>Description</term>
/// </listheader>
/// <item>
/// <term>ERROR_ACCESS_DENIED</term>
/// <term>
/// Access is denied. This error is returned under several conditions that include the following: the user lacks the required
/// administrative privileges on the local computer or the application is not running in an enhanced shell as the built-in
/// Administrator (RunAs administrator).
/// </term>
/// </item>
/// <item>
/// <term>ERROR_INVALID_PARAMETER</term>
/// <term>
/// An invalid parameter was passed to the function. This error is returned if a NULL pointer is passed in the Row parameter, the
/// Address member of the MIB_ANYCASTIPADDRESS_ROW pointed to by the Row parameter was not set to a valid unicast IPv4 or IPv6
/// address, or both the InterfaceLuid or InterfaceIndex members of the MIB_ANYCASTIPADDRESS_ROW pointed to by the Row parameter were unspecified.
/// </term>
/// </item>
/// <item>
/// <term>ERROR_NOT_FOUND</term>
/// <term>
/// The specified interface could not be found. This error is returned if the network interface specified by the InterfaceLuid or
/// InterfaceIndex member of the MIB_ANYCASTIPADDRESS_ROW pointed to by the Row parameter could not be found.
/// </term>
/// </item>
/// <item>
/// <term>ERROR_NOT_SUPPORTED</term>
/// <term>
/// The request is not supported. This error is returned if no IPv4 stack is on the local computer and an IPv4 address was specified
/// in the Address member of the MIB_ANYCASTIPADDRESS_ROW pointed to by the Row parameter. This error is also returned if no IPv6
/// stack is on the local computer and an IPv6 address was specified in the Address member.
/// </term>
/// </item>
/// <item>
/// <term>ERROR_OBJECT_ALREADY_EXISTS</term>
/// <term>
/// The object already exists. This error is returned if the Address member of the MIB_ANYCASTIPADDRESS_ROW pointed to by the Row
/// parameter is a duplicate of an existing anycast IP address on the interface specified by the InterfaceLuid or InterfaceIndex
/// member of the MIB_ANYCASTIPADDRESS_ROW.
/// </term>
/// </item>
/// <item>
/// <term>Other</term>
/// <term>Use FormatMessage to obtain the message string for the returned error.</term>
/// </item>
/// </list>
/// </returns>
/// <remarks>
/// <para>The <c>CreateAnycastIpAddressEntry</c> function is defined on Windows Vista and later.</para>
/// <para>The <c>CreateAnycastIpAddressEntry</c> function is used to add a new anycast IP address entry on a local computer.</para>
/// <para>
/// The <c>Address</c> member in the MIB_ANYCASTIPADDRESS_ROW structure pointed to by the Row parameter must be initialized to a
/// valid unicast IPv4 or IPv6 address and family. In addition, at least one of the following members in the
/// <c>MIB_ANYCASTIPADDRESS_ROW</c> structure pointed to the Row parameter must be initialized to the interface: the
/// <c>InterfaceLuid</c> or <c>InterfaceIndex</c>.
/// </para>
/// <para>
/// The <c>ScopeId</c> member of the MIB_ANYCASTIPADDRESS_ROW structure pointed to by the Row is ignored when the
/// <c>CreateAnycastIpAddressEntry</c> function is called. The <c>ScopeId</c> member is automatically determined by the interface on
/// which the address is added.
/// </para>
/// <para>
/// The <c>CreateAnycastIpAddressEntry</c> function will fail if the anycast IP address passed in the <c>Address</c> member of the
/// MIB_ANYCASTIPADDRESS_ROW pointed to by the Row parameter is a duplicate of an existing anycast IP address on the interface.
/// </para>
/// <para>
/// The <c>CreateAnycastIpAddressEntry</c> function can only be called by a user logged on as a member of the Administrators group.
/// If <c>CreateAnycastIpAddressEntry</c> is called by a user that is not a member of the Administrators group, the function call
/// will fail and <c>ERROR_ACCESS_DENIED</c> is returned. This function can also fail because of user account control (UAC) on
/// Windows Vista and later. If an application that contains this function is executed by a user logged on as a member of the
/// Administrators group other than the built-in Administrator, this call will fail unless the application has been marked in the
/// manifest file with a <c>requestedExecutionLevel</c> set to requireAdministrator. If the application lacks this manifest file, a
/// user logged on as a member of the Administrators group other than the built-in Administrator must then be executing the
/// application in an enhanced shell as the built-in Administrator (RunAs administrator) for this function to succeed.
/// </para>
/// </remarks>
// https://docs.microsoft.com/en-us/windows/desktop/api/netioapi/nf-netioapi-createanycastipaddressentry _NETIOAPI_SUCCESS_
// NETIOAPI_API CreateAnycastIpAddressEntry( CONST MIB_ANYCASTIPADDRESS_ROW *Row );
[DllImport(Lib.IpHlpApi, SetLastError = false, ExactSpelling = true)]
[PInvokeData("netioapi.h", MSDNShortId = "30393132-0fad-4687-b9e3-7b5cf47fbb96")]
public static extern Win32Error CreateAnycastIpAddressEntry(ref MIB_ANYCASTIPADDRESS_ROW Row);
@ -1140,7 +1228,7 @@ namespace Vanara.PInvoke
/// <returns>An array of SOCKADDR_IN6_PAIR structures that contain the sorted address pairs.</returns>
public static SOCKADDR_IN6_PAIR[] CreateSortedAddressPairs(SOCKADDR_IN6[] DestinationAddressList)
{
CreateSortedAddressPairs(IntPtr.Zero, 0, DestinationAddressList, (uint)DestinationAddressList.Length, 0, out SafeMibTableHandle pairs, out uint cnt).ThrowIfFailed();
CreateSortedAddressPairs(IntPtr.Zero, 0, DestinationAddressList, (uint)DestinationAddressList.Length, 0, out var pairs, out var cnt).ThrowIfFailed();
return pairs.ToArray<SOCKADDR_IN6_PAIR>((int)cnt);
}
@ -5396,7 +5484,7 @@ namespace Vanara.PInvoke
// SetIpForwardEntry2( CONST MIB_IPFORWARD_ROW2 *Route );
[DllImport(Lib.IpHlpApi, SetLastError = false, ExactSpelling = true)]
[PInvokeData("netioapi.h", MSDNShortId = "e11aab0b-6d6c-4e90-a60a-f7d68c09751b")]
public static extern Win32Error SetIpForwardEntry2([In] ref MIB_IPFORWARD_ROW2 Route);
public static extern Win32Error SetIpForwardEntry2(in MIB_IPFORWARD_ROW2 Route);
/// <summary>
/// <para>The <c>SetIpInterfaceEntry</c> function sets the properties of an IP interface on the local computer.</para>
@ -5526,7 +5614,7 @@ namespace Vanara.PInvoke
// SetIpInterfaceEntry( PMIB_IPINTERFACE_ROW Row );
[DllImport(Lib.IpHlpApi, SetLastError = false, ExactSpelling = true)]
[PInvokeData("netioapi.h", MSDNShortId = "8e6d2c14-29c3-47a7-9eb8-0989df9da68c")]
public static extern Win32Error SetIpInterfaceEntry([In] ref MIB_IPINTERFACE_ROW Row);
public static extern Win32Error SetIpInterfaceEntry(in MIB_IPINTERFACE_ROW Row);
/// <summary>
/// <para>The <c>SetIpNetEntry2</c> function sets the physical address of an existing neighbor IP address entry on the local computer.</para>
@ -5636,7 +5724,7 @@ namespace Vanara.PInvoke
// SetNetworkInformation( CONST NET_IF_NETWORK_GUID *NetworkGuid, NET_IF_COMPARTMENT_ID CompartmentId, CONST WCHAR *NetworkName );
[DllImport(Lib.IpHlpApi, SetLastError = false, ExactSpelling = true)]
[PInvokeData("netioapi.h", MSDNShortId = "e196e978-2eb7-4b22-af3b-e14736c5ac94")]
public static extern Win32Error SetNetworkInformation([MarshalAs(UnmanagedType.LPStruct)] Guid NetworkGuid, uint CompartmentId, [MarshalAs(UnmanagedType.LPWStr)] string NetworkName);
public static extern Win32Error SetNetworkInformation(in Guid NetworkGuid, uint CompartmentId, [MarshalAs(UnmanagedType.LPWStr)] string NetworkName);
/// <summary>
/// <para>Reserved for future use. Do not use this function.</para>
@ -5764,7 +5852,7 @@ namespace Vanara.PInvoke
// SetUnicastIpAddressEntry( CONST MIB_UNICASTIPADDRESS_ROW *Row );
[DllImport(Lib.IpHlpApi, SetLastError = false, ExactSpelling = true)]
[PInvokeData("netioapi.h", MSDNShortId = "906a3895-2e42-4bed-90a3-7c10487d76cb")]
public static extern Win32Error SetUnicastIpAddressEntry([In] ref MIB_UNICASTIPADDRESS_ROW Row);
public static extern Win32Error SetUnicastIpAddressEntry(in MIB_UNICASTIPADDRESS_ROW Row);
/// <summary>
/// <para>The <c>IP_ADDRESS_PREFIX</c> structure stores an IP address prefix.</para>
@ -6087,17 +6175,11 @@ namespace Vanara.PInvoke
/// <summary>Initializes a new instance of the <see cref="MIB_IF_ROW2"/> struct.</summary>
/// <param name="interfaceIndex">Index of the interface.</param>
public MIB_IF_ROW2(uint interfaceIndex) : this()
{
InterfaceIndex = interfaceIndex;
}
public MIB_IF_ROW2(uint interfaceIndex) : this() => InterfaceIndex = interfaceIndex;
/// <summary>Initializes a new instance of the <see cref="MIB_IF_ROW2"/> struct.</summary>
/// <param name="interfaceLuid">The interface luid.</param>
public MIB_IF_ROW2(NET_LUID interfaceLuid) : this()
{
InterfaceLuid = interfaceLuid;
}
public MIB_IF_ROW2(NET_LUID interfaceLuid) : this() => InterfaceLuid = interfaceLuid;
}
/// <summary>The MIB_IFSTACK_ROW structure represents the relationship between two network interfaces.</summary>
@ -6831,10 +6913,7 @@ namespace Vanara.PInvoke
/// <param name="ipV4">The neighbor IP address.</param>
/// <param name="ifLuid">The locally unique identifier (LUID) for the network interface associated with this IP address.</param>
/// <param name="macAddr">The physical hardware address of the adapter for the network interface associated with this IP address.</param>
public MIB_IPNET_ROW2(SOCKADDR_IN ipV4, NET_LUID ifLuid, byte[] macAddr = null) : this(ipV4, macAddr)
{
InterfaceLuid = ifLuid;
}
public MIB_IPNET_ROW2(SOCKADDR_IN ipV4, NET_LUID ifLuid, byte[] macAddr = null) : this(ipV4, macAddr) => InterfaceLuid = ifLuid;
/// <summary>Initializes a new instance of the <see cref="MIB_IPNET_ROW2"/> struct.</summary>
/// <param name="ipV4">The neighbor IP address.</param>
@ -6843,19 +6922,13 @@ namespace Vanara.PInvoke
/// adapter is disabled and then enabled, or under other circumstances, and should not be considered persistent.
/// </param>
/// <param name="macAddr">The physical hardware address of the adapter for the network interface associated with this IP address.</param>
public MIB_IPNET_ROW2(SOCKADDR_IN ipV4, uint ifIdx, byte[] macAddr = null) : this(ipV4, macAddr)
{
InterfaceIndex = ifIdx;
}
public MIB_IPNET_ROW2(SOCKADDR_IN ipV4, uint ifIdx, byte[] macAddr = null) : this(ipV4, macAddr) => InterfaceIndex = ifIdx;
/// <summary>Initializes a new instance of the <see cref="MIB_IPNET_ROW2"/> struct.</summary>
/// <param name="ipV6">The neighbor IP address.</param>
/// <param name="ifLuid">The locally unique identifier (LUID) for the network interface associated with this IP address.</param>
/// <param name="macAddr">The physical hardware address of the adapter for the network interface associated with this IP address.</param>
public MIB_IPNET_ROW2(SOCKADDR_IN6 ipV6, NET_LUID ifLuid, byte[] macAddr = null) : this(ipV6, macAddr)
{
InterfaceLuid = ifLuid;
}
public MIB_IPNET_ROW2(SOCKADDR_IN6 ipV6, NET_LUID ifLuid, byte[] macAddr = null) : this(ipV6, macAddr) => InterfaceLuid = ifLuid;
/// <summary>Initializes a new instance of the <see cref="MIB_IPNET_ROW2"/> struct.</summary>
/// <param name="ipV6">The neighbor IP address.</param>
@ -6864,10 +6937,7 @@ namespace Vanara.PInvoke
/// adapter is disabled and then enabled, or under other circumstances, and should not be considered persistent.
/// </param>
/// <param name="macAddr">The physical hardware address of the adapter for the network interface associated with this IP address.</param>
public MIB_IPNET_ROW2(SOCKADDR_IN6 ipV6, uint ifIdx, byte[] macAddr = null) : this(ipV6, macAddr)
{
InterfaceIndex = ifIdx;
}
public MIB_IPNET_ROW2(SOCKADDR_IN6 ipV6, uint ifIdx, byte[] macAddr = null) : this(ipV6, macAddr) => InterfaceIndex = ifIdx;
private MIB_IPNET_ROW2(SOCKADDR_IN ipV4, byte[] macAddr) : this()
{
@ -6894,10 +6964,7 @@ namespace Vanara.PInvoke
}
/// <inheritdoc/>
public override string ToString()
{
return $"{Address}; MAC:{PhysicalAddressToString(PhysicalAddress)}; If:{(InterfaceIndex != 0 ? InterfaceIndex.ToString() : InterfaceLuid.ToString())}";
}
public override string ToString() => $"{Address}; MAC:{PhysicalAddressToString(PhysicalAddress)}; If:{(InterfaceIndex != 0 ? InterfaceIndex.ToString() : InterfaceLuid.ToString())}";
}
/// <summary>

View File

@ -28,10 +28,10 @@ Functions
AddIPAddress, CancelIPChangeNotify, CancelMibChangeNotify2, ConvertInterfaceAliasToLuid, ConvertInterfaceGuidToLuid, ConvertInterfaceIndexToLuid, ConvertInterfaceLuidToAlias, ConvertInterfaceLuidToGuid, ConvertInterfaceLuidToIndex, ConvertInterfaceLuidToNameA, ConvertInterfaceLuidToNameW, ConvertInterfaceNameToLuidA, ConvertInterfaceNameToLuidW, ConvertIpv4MaskToLength, ConvertLengthToIpv4Mask, CreateAnycastIpAddressEntry, CreateIpForwardEntry2, CreateIpNetEntry, CreateIpNetEntry2, CreateSortedAddressPairs, CreateUnicastIpAddressEntry, DeleteAnycastIpAddressEntry, DeleteIPAddress, DeleteIpForwardEntry2, DeleteIpNetEntry, DeleteIpNetEntry2, DeleteUnicastIpAddressEntry, EnableRouter, FlushIpNetTable2, FlushIpPathTable, FreeMibTable, GetAdapterIndex, GetAdaptersAddresses, GetAdaptersInfo, GetAnycastIpAddressEntry, GetAnycastIpAddressTable, GetBestInterface, GetBestInterfaceEx, GetBestRoute, GetBestRoute2, GetExtendedTcpTable, GetExtendedUdpTable, GetIfEntry2, GetIfEntry2Ex, GetIfStackTable, GetIfTable, GetIfTable2, GetIfTable2Ex, GetInterfaceInfo, GetInvertedIfStackTable, GetIpAddrTable, GetIpForwardEntry2, GetIpForwardTable2, GetIpInterfaceEntry, GetIpInterfaceTable, GetIpNetEntry2, GetIpNetTable, GetIpNetTable2, GetIpNetworkConnectionBandwidthEstimates, GetIpPathEntry, GetIpPathTable, GetMulticastIpAddressEntry, GetMulticastIpAddressTable, GetNetworkParams, GetPerAdapterInfo, GetTeredoPort, GetUnicastIpAddressEntry, GetUnicastIpAddressTable, GetUniDirectionalAdapterInfo, if_indextoname, if_nametoindex, InitializeIpForwardEntry, InitializeIpInterfaceEntry, InitializeUnicastIpAddressEntry, IpReleaseAddress, IpRenewAddress, NotifyAddrChange, NotifyIpInterfaceChange, NotifyRouteChange, NotifyRouteChange2, NotifyStableUnicastIpAddressTable, NotifyTeredoPortChange, NotifyUnicastIpAddressChange, ResolveIpNetEntry2, SendARP, SetCurrentThreadCompartmentId, SetIpForwardEntry2, SetIpInterfaceEntry, SetIpNetEntry, SetIpNetEntry2, SetNetworkInformation, SetSessionCompartmentId, SetUnicastIpAddressEntry, UnenableRouter
Structures
IP_ADAPTER_ANYCAST_ADDRESS, IP_ADAPTER_DNS_SERVER_ADDRESS, IP_ADAPTER_DNS_SUFFIX, IP_ADAPTER_GATEWAY_ADDRESS, IP_ADAPTER_INDEX_MAP, IP_ADAPTER_INFO, IP_ADAPTER_MULTICAST_ADDRESS, IP_ADAPTER_PREFIX, IP_ADAPTER_UNICAST_ADDRESS, IP_ADAPTER_WINS_SERVER_ADDRESS, IP_ADDR_STRING, IP_PER_ADAPTER_INFO, MIB_IFROW, MIB_IPADDRROW, MIB_IPFORWARDROW, MIB_IPNETROW, MIB_TCP6ROW, MIB_TCP6ROW_OWNER_MODULE, MIB_TCP6ROW_OWNER_PID, MIB_TCPROW, MIB_TCPROW_OWNER_MODULE, MIB_TCPROW_OWNER_PID, MIB_TCPROW2, MIB_TCPSTATS, MIB_TCPSTATS2, MIB_UDP6ROW, MIB_UDP6ROW_OWNER_MODULE, MIB_UDP6ROW_OWNER_PID, MIB_UDPROW, MIB_UDPROW_OWNER_MODULE, MIB_UDPROW_OWNER_PID, NET_LUID, FIXED_INFO, IP_ADAPTER_ADDRESSES, IP_ADDRESS_PREFIX, MIB_ANYCASTIPADDRESS_ROW, MIB_IF_ROW2, MIB_IFSTACK_ROW, MIB_INVERTEDIFSTACK_ROW, MIB_IP_NETWORK_CONNECTION_BANDWIDTH_ESTIMATES, MIB_IPFORWARD_ROW2, MIB_IPINTERFACE_ROW, MIB_IPNET_ROW2, MIB_IPPATH_ROW, MIB_MULTICASTIPADDRESS_ROW, MIB_UNICASTIPADDRESS_ROW, NL_BANDWIDTH_INFORMATION, NL_INTERFACE_OFFLOAD_ROD, SCOPE_ID, IN_ADDR, IN6_ADDR, SOCKADDR_IN, SOCKADDR_IN6, SOCKADDR_IN6_PAIR, SOCKADDR_INET, SOCKET_ADDRESS
IP_ADAPTER_INDEX_MAP, NET_LUID, FIXED_INFO, IP_ADAPTER_ADDRESSES, IP_ADAPTER_ANYCAST_ADDRESS, IP_ADAPTER_DNS_SERVER_ADDRESS, IP_ADAPTER_DNS_SUFFIX, IP_ADAPTER_GATEWAY_ADDRESS, IP_ADAPTER_INFO, IP_ADAPTER_MULTICAST_ADDRESS, IP_ADAPTER_PREFIX, IP_ADAPTER_UNICAST_ADDRESS, IP_ADAPTER_WINS_SERVER_ADDRESS, IP_ADDR_STRING, IP_PER_ADAPTER_INFO, MIB_IFROW, MIB_IPADDRROW, MIB_IPFORWARDROW, MIB_IPNETROW, MIB_TCP6ROW, MIB_TCP6ROW_OWNER_MODULE, MIB_TCP6ROW_OWNER_PID, MIB_TCPROW, MIB_TCPROW_OWNER_MODULE, MIB_TCPROW_OWNER_PID, MIB_TCPROW2, MIB_TCPSTATS, MIB_TCPSTATS2, MIB_UDP6ROW, MIB_UDP6ROW_OWNER_MODULE, MIB_UDP6ROW_OWNER_PID, MIB_UDPROW, MIB_UDPROW_OWNER_MODULE, MIB_UDPROW_OWNER_PID, IP_ADDRESS_PREFIX, MIB_ANYCASTIPADDRESS_ROW, MIB_IF_ROW2, MIB_IFSTACK_ROW, MIB_INVERTEDIFSTACK_ROW, MIB_IP_NETWORK_CONNECTION_BANDWIDTH_ESTIMATES, MIB_IPFORWARD_ROW2, MIB_IPINTERFACE_ROW, MIB_IPNET_ROW2, MIB_IPPATH_ROW, MIB_MULTICASTIPADDRESS_ROW, MIB_UNICASTIPADDRESS_ROW, NL_BANDWIDTH_INFORMATION, NL_INTERFACE_OFFLOAD_ROD, SCOPE_ID
</PackageReleaseNotes>
<LangVersion>latest</LangVersion>
<LangVersion>latest</LangVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)'=='Release'">
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
@ -52,5 +52,6 @@ IP_ADAPTER_ANYCAST_ADDRESS, IP_ADAPTER_DNS_SERVER_ADDRESS, IP_ADAPTER_DNS_SUFFIX
<ItemGroup>
<ProjectReference Include="..\..\Core\Vanara.Core.csproj" />
<ProjectReference Include="..\Shared\Vanara.PInvoke.Shared.csproj" />
<ProjectReference Include="..\Ws2_32\Vanara.PInvoke.Ws2_32.csproj" />
</ItemGroup>
</Project>

3534
PInvoke/IpHlpApi/mib.cs Normal file

File diff suppressed because it is too large Load Diff

View File

@ -224,7 +224,7 @@ namespace Vanara.PInvoke
// LONG WINAPI AppPolicyGetCreateFileAccess( _In_ HANDLE processToken, _Out_ AppPolicyCreateFileAccess *policy); https://msdn.microsoft.com/en-us/library/windows/desktop/mt829655(v=vs.85).aspx
[DllImport(Lib.Kernel32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("AppModel.h", MSDNShortId = "mt829655")]
public static extern Win32Error AppPolicyGetCreateFileAccess(IntPtr processToken, out AppPolicyCreateFileAccess policy);
public static extern Win32Error AppPolicyGetCreateFileAccess(HTOKEN processToken, out AppPolicyCreateFileAccess policy);
/// <summary>Retrieves the method used to end a process.</summary>
/// <param name="processToken">A handle that identifies the access token for a process.</param>
@ -243,7 +243,7 @@ namespace Vanara.PInvoke
// LONG WINAPI AppPolicyGetProcessTerminationMethod( _In_ HANDLE processToken, _Out_ AppPolicyProcessTerminationMethod *policy); https://msdn.microsoft.com/en-us/library/windows/desktop/mt829656(v=vs.85).aspx
[DllImport(Lib.Kernel32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("AppModel.h", MSDNShortId = "mt829656")]
public static extern Win32Error AppPolicyGetProcessTerminationMethod(IntPtr processToken, out AppPolicyProcessTerminationMethod policy);
public static extern Win32Error AppPolicyGetProcessTerminationMethod(HTOKEN processToken, out AppPolicyProcessTerminationMethod policy);
/// <summary>Retrieves the method used for a process to surface developer information, such as asserts, to the user.</summary>
/// <param name="processToken">A handle that identifies the access token for a process.</param>
@ -263,7 +263,7 @@ namespace Vanara.PInvoke
// LONG WINAPI AppPolicyGetShowDeveloperDiagnostic( _In_ HANDLE processToken, _Out_ AppPolicyShowDeveloperDiagnostic *policy); https://msdn.microsoft.com/en-us/library/windows/desktop/mt829657(v=vs.85).aspx
[DllImport(Lib.Kernel32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("AppModel.h", MSDNShortId = "mt829657")]
public static extern Win32Error AppPolicyGetShowDeveloperDiagnostic(IntPtr processToken, out AppPolicyShowDeveloperDiagnostic policy);
public static extern Win32Error AppPolicyGetShowDeveloperDiagnostic(HTOKEN processToken, out AppPolicyShowDeveloperDiagnostic policy);
/// <summary>
/// Retrieves the kind of initialization that should be automatically performed for a process when beginthread[ex] creates a thread.
@ -285,7 +285,7 @@ namespace Vanara.PInvoke
// LONG WINAPI AppPolicyGetThreadInitializationType( _In_ HANDLE processToken, _Out_ AppPolicyThreadInitializationType *policy); https://msdn.microsoft.com/en-us/library/windows/desktop/mt829658(v=vs.85).aspx
[DllImport(Lib.Kernel32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("AppModel.h", MSDNShortId = "mt829658")]
public static extern Win32Error AppPolicyGetThreadInitializationType(IntPtr processToken, out AppPolicyThreadInitializationType policy);
public static extern Win32Error AppPolicyGetThreadInitializationType(HTOKEN processToken, out AppPolicyThreadInitializationType policy);
/// <summary>
/// <para>Closes a reference to the specified package information.</para>
@ -472,7 +472,7 @@ namespace Vanara.PInvoke
// GetApplicationUserModelId( HANDLE hProcess, UINT32 *applicationUserModelIdLength, PWSTR applicationUserModelId );
[DllImport(Lib.Kernel32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("appmodel.h", MSDNShortId = "FE4E0818-F548-494B-B3BD-FB51DC748451")]
public static extern Win32Error GetApplicationUserModelId(IntPtr hProcess, ref uint applicationUserModelIdLength, [MarshalAs(UnmanagedType.LPWStr)] StringBuilder applicationUserModelId);
public static extern Win32Error GetApplicationUserModelId(HPROCESS hProcess, ref uint applicationUserModelIdLength, [MarshalAs(UnmanagedType.LPWStr)] StringBuilder applicationUserModelId);
/// <summary>
/// <para>Gets the application user model ID for the specified token.</para>
@ -520,7 +520,7 @@ namespace Vanara.PInvoke
// GetApplicationUserModelIdFromToken( HANDLE token, UINT32 *applicationUserModelIdLength, PWSTR applicationUserModelId );
[DllImport(Lib.Kernel32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("appmodel.h", MSDNShortId = "80036518-927E-4CD0-B499-8EA472AB7E5A")]
public static extern Win32Error GetApplicationUserModelIdFromToken(IntPtr token, ref uint applicationUserModelIdLength, [MarshalAs(UnmanagedType.LPWStr)] StringBuilder applicationUserModelId);
public static extern Win32Error GetApplicationUserModelIdFromToken(HTOKEN token, ref uint applicationUserModelIdLength, [MarshalAs(UnmanagedType.LPWStr)] StringBuilder applicationUserModelId);
/// <summary>
/// <para>Gets the application user model ID for the current process.</para>
@ -875,7 +875,7 @@ namespace Vanara.PInvoke
// hProcess, UINT32 *packageFamilyNameLength, PWSTR packageFamilyName );
[DllImport(Lib.Kernel32, SetLastError = true, ExactSpelling = true, CharSet = CharSet.Unicode)]
[PInvokeData("appmodel.h", MSDNShortId = "AC239898-9924-4193-9072-7A7EEC2D03E9")]
public static extern Win32Error GetPackageFamilyName(IntPtr hProcess, ref uint packageFamilyNameLength, StringBuilder packageFamilyName);
public static extern Win32Error GetPackageFamilyName(HPROCESS hProcess, ref uint packageFamilyNameLength, StringBuilder packageFamilyName);
/// <summary>
/// <para>Gets the package family name for the specified token.</para>
@ -924,7 +924,7 @@ namespace Vanara.PInvoke
// GetPackageFamilyNameFromToken( HANDLE token, UINT32 *packageFamilyNameLength, PWSTR packageFamilyName );
[DllImport(Lib.Kernel32, SetLastError = true, ExactSpelling = true, CharSet = CharSet.Unicode)]
[PInvokeData("appmodel.h", MSDNShortId = "C4FAF5DE-DF1F-4AFA-813B-5D80C786031B")]
public static extern Win32Error GetPackageFamilyNameFromToken(IntPtr token, ref uint packageFamilyNameLength, StringBuilder packageFamilyName);
public static extern Win32Error GetPackageFamilyNameFromToken(HTOKEN token, ref uint packageFamilyNameLength, StringBuilder packageFamilyName);
/// <summary>
/// <para>Gets the package full name for the specified token.</para>
@ -969,7 +969,7 @@ namespace Vanara.PInvoke
// GetPackageFullNameFromToken( HANDLE token, UINT32 *packageFullNameLength, PWSTR packageFullName );
[DllImport(Lib.Kernel32, SetLastError = true, ExactSpelling = true, CharSet = CharSet.Unicode)]
[PInvokeData("appmodel.h", MSDNShortId = "7B0D574E-A2F5-4D08-AEFB-9E040BBC729F")]
public static extern Win32Error GetPackageFullNameFromToken(IntPtr token, ref uint packageFullNameLength, StringBuilder packageFullName);
public static extern Win32Error GetPackageFullNameFromToken(HTOKEN token, ref uint packageFullNameLength, StringBuilder packageFullName);
/// <summary>
/// <para>Gets the package information for the specified package.</para>

View File

@ -9,7 +9,7 @@ Native Method | Native DLL | Header | Managed Method
[AddConsoleAlias](https://www.google.com/search?num=5&q=AddConsoleAliasA+site%3Amicrosoft.com) | kernel32.dll | Wincon.h | Vanara.PInvoke.Kernel32.AddConsoleAlias
[AddDllDirectory](http://msdn2.microsoft.com/en-us/library/hh310513) | kernel32.dll | LibLoaderAPI.h | Vanara.PInvoke.Kernel32.AddDllDirectory
[AddIntegrityLabelToBoundaryDescriptor](http://msdn2.microsoft.com/en-us/library/6b56e664-7795-4e30-8bca-1e4df2764606) | kernel32.dll | winbase.h | Vanara.PInvoke.Kernel32.AddIntegrityLabelToBoundaryDescriptor
[AddLocalAlternateComputerName](http://msdn2.microsoft.com/en-us/library/e4d8355b-0492-4b6f-988f-3887e63a2bba) | kernel32.dll | | Vanara.PInvoke.Kernel32.AddLocalAlternateComputerName
[AddLocalAlternateComputerName](http://msdn2.microsoft.com/en-us/library/e4d8355b-0492-4b6f-988f-3887e63a2bba) | kernel32.dll | winbase.h | Vanara.PInvoke.Kernel32.AddLocalAlternateComputerName
[AddRefActCtx](http://msdn2.microsoft.com/en-us/library/aa374171) | kernel32.dll | Winbase.h | Vanara.PInvoke.Kernel32.AddRefActCtx
[AddSecureMemoryCacheCallback](http://msdn2.microsoft.com/en-us/library/6c89d6f3-182e-4b10-931c-8d55d603c9dc) | kernel32.dll | winbase.h | Vanara.PInvoke.Kernel32.AddSecureMemoryCacheCallback
[AddSIDToBoundaryDescriptor](http://msdn2.microsoft.com/en-us/library/ms681937) | kernel32.dll | WinBase.h | Vanara.PInvoke.Kernel32.AddSIDToBoundaryDescriptor
@ -38,6 +38,7 @@ Native Method | Native DLL | Header | Managed Method
[BuildCommDCB](http://msdn2.microsoft.com/en-us/library/aa363143) | kernel32.dll | Winbase.h | Vanara.PInvoke.Kernel32.BuildCommDCB
[BuildCommDCBAndTimeouts](http://msdn2.microsoft.com/en-us/library/aa363145) | kernel32.dll | Winbase.h | Vanara.PInvoke.Kernel32.BuildCommDCBAndTimeouts
[CallbackMayRunLong](http://msdn2.microsoft.com/en-us/library/ms681981) | kernel32.dll | WinBase.h | Vanara.PInvoke.Kernel32.CallbackMayRunLong
[CallEnclave](http://msdn2.microsoft.com/en-us/library/mt844231) | kernelbase.dll | Enclaveapi.h | Vanara.PInvoke.Kernel32.CallEnclave
[CallNamedPipe](http://msdn2.microsoft.com/en-us/library/aa365144) | kernel32.dll | Winbase.h | Vanara.PInvoke.Kernel32.CallNamedPipe
[CancelIo](http://msdn2.microsoft.com/en-us/library/aa363791) | kernel32.dll | IoAPI.h | Vanara.PInvoke.Kernel32.CancelIo
[CancelIoEx](http://msdn2.microsoft.com/en-us/library/aa363792) | kernel32.dll | IoAPI.h | Vanara.PInvoke.Kernel32.CancelIoEx
@ -101,7 +102,7 @@ Native Method | Native DLL | Header | Managed Method
[CreateHardLink](http://msdn2.microsoft.com/en-us/library/aa363860) | kernel32.dll | WinBase.h | Vanara.PInvoke.Kernel32.CreateHardLink
[CreateHardLinkTransacted](http://msdn2.microsoft.com/en-us/library/27dd5b0a-08ef-4757-8f51-03d9918028c8) | kernel32.dll | winbase.h | Vanara.PInvoke.Kernel32.CreateHardLinkTransacted
[CreateIoCompletionPort](http://msdn2.microsoft.com/en-us/library/aa363862) | kernel32.dll | IoAPI.h | Vanara.PInvoke.Kernel32.CreateIoCompletionPort
[CreateJobObject](http://msdn2.microsoft.com/en-us/library/ms682409) | kernel32.dll | WinBase.h | Vanara.PInvoke.Kernel32.CreateJobObject
[CreateJobObject](http://msdn2.microsoft.com/en-us/library/ca6a044f-67ed-4a9c-9aeb-69dd77652854) | kernel32.dll | winbase.h | Vanara.PInvoke.Kernel32.CreateJobObject
[CreateMailslot](http://msdn2.microsoft.com/en-us/library/aa365147) | kernel32.dll | Winbase.h | Vanara.PInvoke.Kernel32.CreateMailslot
[CreateMemoryResourceNotification](http://msdn2.microsoft.com/en-us/library/aa366541) | kernel32.dll | WinBase.h | Vanara.PInvoke.Kernel32.CreateMemoryResourceNotification
[CreateMutex](http://msdn2.microsoft.com/en-us/library/ms682411) | kernel32.dll | WinBase.h | Vanara.PInvoke.Kernel32.CreateMutex
@ -125,7 +126,7 @@ Native Method | Native DLL | Header | Managed Method
[CreateThreadpoolWait](http://msdn2.microsoft.com/en-us/library/ms682474) | kernel32.dll | WinBase.h | Vanara.PInvoke.Kernel32.CreateThreadpoolWait
[CreateThreadpoolWork](http://msdn2.microsoft.com/en-us/library/ms682478) | kernel32.dll | WinBase.h | Vanara.PInvoke.Kernel32.CreateThreadpoolWork
[CreateTimerQueue](http://msdn2.microsoft.com/en-us/library/ms682483) | kernel32.dll | WinBase.h | Vanara.PInvoke.Kernel32.CreateTimerQueue
[CreateTimerQueueTimer](http://msdn2.microsoft.com/en-us/library/ms682485) | kernel32.dll | WinBase.h | Vanara.PInvoke.Kernel32.CreateTimerQueueTimer
[CreateTimerQueueTimer](https://www.google.com/search?num=5&q=CreateTimerQueueTimer+site%3Amicrosoft.com) | kernel32.dll | | Vanara.PInvoke.Kernel32._CreateTimerQueueTimer
[CreateToolhelp32Snapshot](http://msdn2.microsoft.com/en-us/library/df643c25-7558-424c-b187-b3f86ba51358) | kernel32.dll | tlhelp32.h | Vanara.PInvoke.Kernel32.CreateToolhelp32Snapshot
[CreateUmsCompletionList](http://msdn2.microsoft.com/en-us/library/6e77b793-a82e-4e23-8c8b-7aff79d69346) | kernel32.dll | winbase.h | Vanara.PInvoke.Kernel32.CreateUmsCompletionList
[CreateUmsThreadContext](http://msdn2.microsoft.com/en-us/library/b27ce81a-8463-46af-8acf-2de091f625df) | kernel32.dll | winbase.h | Vanara.PInvoke.Kernel32.CreateUmsThreadContext
@ -144,6 +145,7 @@ Native Method | Native DLL | Header | Managed Method
[DeleteAtom](http://msdn2.microsoft.com/en-us/library/ms649057) | kernel32.dll | Winbase.h | Vanara.PInvoke.Kernel32.DeleteAtom
[DeleteBoundaryDescriptor](http://msdn2.microsoft.com/en-us/library/ms682549) | kernel32.dll | WinBase.h | Vanara.PInvoke.Kernel32.DeleteBoundaryDescriptor
[DeleteCriticalSection](http://msdn2.microsoft.com/en-us/library/ms682552) | kernel32.dll | WinBase.h | Vanara.PInvoke.Kernel32.DeleteCriticalSection
[DeleteEnclave](http://msdn2.microsoft.com/en-us/library/mt844232) | kernelbase.dll | Enclaveapi.h | Vanara.PInvoke.Kernel32.DeleteEnclave
[DeleteFiber](http://msdn2.microsoft.com/en-us/library/ms682556) | kernel32.dll | WinBase.h | Vanara.PInvoke.Kernel32.DeleteFiber
[DeleteFile](http://msdn2.microsoft.com/en-us/library/aa363915) | kernel32.dll | FileAPI.h | Vanara.PInvoke.Kernel32.DeleteFile
[DeleteFileTransacted](http://msdn2.microsoft.com/en-us/library/e0a6230b-2da1-4746-95fe-80f7b6bae41f) | kernel32.dll | winbase.h | Vanara.PInvoke.Kernel32.DeleteFileTransacted
@ -182,9 +184,12 @@ Native Method | Native DLL | Header | Managed Method
[EnumDateFormatsEx](http://msdn2.microsoft.com/en-us/library/dd317811) | kernel32.dll | Winnls.h | Vanara.PInvoke.Kernel32.EnumDateFormatsEx
[EnumDateFormatsExEx](http://msdn2.microsoft.com/en-us/library/dd317812) | kernel32.dll | Winnls.h | Vanara.PInvoke.Kernel32.EnumDateFormatsExEx
[EnumDeviceDrivers](http://msdn2.microsoft.com/en-us/library/55925741-da23-44b1-93e8-0e9468434a61) | kernelbase.dll | psapi.h | Vanara.PInvoke.Kernel32.EnumDeviceDrivers
[EnumDynamicTimeZoneInformation](http://msdn2.microsoft.com/en-us/library/hh706893) | kernelbase.dll | Winbase.h | Vanara.PInvoke.Kernel32.EnumDynamicTimeZoneInformation
[EnumDynamicTimeZoneInformation](http://msdn2.microsoft.com/en-us/library/EBB2366A-86FE-4764-B7F9-5D305993CE0A) | kernelbase.dll | timezoneapi.h | Vanara.PInvoke.Kernel32.EnumDynamicTimeZoneInformation
[EnumLanguageGroupLocales](http://msdn2.microsoft.com/en-us/library/dd317819) | kernel32.dll | Winnls.h | Vanara.PInvoke.Kernel32.EnumLanguageGroupLocales
[EnumProcesses](http://msdn2.microsoft.com/en-us/library/0c0445cb-27d2-4857-a4a5-7a4c180b068b) | kernelbase.dll | psapi.h | Vanara.PInvoke.Kernel32.EnumProcesses
[EnumPageFilesA](http://msdn2.microsoft.com/en-us/library/9289fe3c-a7d9-4acb-aeb6-a50de65db0a2) | kernel32.dll | psapi.h | Vanara.PInvoke.Kernel32.EnumPageFiles
[EnumPageFilesW](http://msdn2.microsoft.com/en-us/library/9289fe3c-a7d9-4acb-aeb6-a50de65db0a2) | kernel32.dll | psapi.h | Vanara.PInvoke.Kernel32.EnumPageFiles
[EnumProcessesA](http://msdn2.microsoft.com/en-us/library/0c0445cb-27d2-4857-a4a5-7a4c180b068b) | kernel32.dll | psapi.h | Vanara.PInvoke.Kernel32.EnumProcesses
[EnumProcessesW](http://msdn2.microsoft.com/en-us/library/0c0445cb-27d2-4857-a4a5-7a4c180b068b) | kernel32.dll | psapi.h | Vanara.PInvoke.Kernel32.EnumProcesses
[EnumProcessModules](http://msdn2.microsoft.com/en-us/library/b4088506-2f69-4cf0-9bab-3e6a7185f5b2) | kernelbase.dll | psapi.h | Vanara.PInvoke.Kernel32.EnumProcessModules
[EnumProcessModulesEx](http://msdn2.microsoft.com/en-us/library/0f982f32-31f4-47b6-85d2-d6e17aa4eeb9) | kernelbase.dll | psapi.h | Vanara.PInvoke.Kernel32.EnumProcessModulesEx
[EnumResourceLanguagesEx](https://www.google.com/search?num=5&q=EnumResourceLanguagesExA+site%3Amicrosoft.com) | kernelbase.dll | Winbase.h | Vanara.PInvoke.Kernel32.EnumResourceLanguagesEx
@ -196,6 +201,7 @@ Native Method | Native DLL | Header | Managed Method
[EnumSystemCodePages](http://msdn2.microsoft.com/en-us/library/dd317825) | kernel32.dll | Winnls.h | Vanara.PInvoke.Kernel32.EnumSystemCodePages
[EnumSystemFirmwareTables](http://msdn2.microsoft.com/en-us/library/ms724259) | kernel32.dll | Winbase.h | Vanara.PInvoke.Kernel32.EnumSystemFirmwareTables
[EnumSystemGeoID](http://msdn2.microsoft.com/en-us/library/dd317826) | kernel32.dll | Winnls.h | Vanara.PInvoke.Kernel32.EnumSystemGeoID
[EnumSystemGeoNames](http://msdn2.microsoft.com/en-us/library/mt826465) | kernel32.dll | Winnls.h | Vanara.PInvoke.Kernel32.EnumSystemGeoNames
[EnumSystemLanguageGroups](http://msdn2.microsoft.com/en-us/library/dd317827) | kernel32.dll | Winnls.h | Vanara.PInvoke.Kernel32.EnumSystemLanguageGroups
[EnumSystemLocales](http://msdn2.microsoft.com/en-us/library/dd317828) | kernel32.dll | Winnls.h | Vanara.PInvoke.Kernel32.EnumSystemLocales
[EnumSystemLocalesEx](http://msdn2.microsoft.com/en-us/library/dd317829) | kernel32.dll | Winnls.h | Vanara.PInvoke.Kernel32.EnumSystemLocalesEx
@ -368,7 +374,9 @@ Native Method | Native DLL | Header | Managed Method
[GetFirmwareEnvironmentVariableEx](http://msdn2.microsoft.com/en-us/library/B093BA68-C68B-4ED6-9902-058650A191FD) | kernel32.dll | winbase.h | Vanara.PInvoke.Kernel32.GetFirmwareEnvironmentVariableEx
[GetFullPathName](http://msdn2.microsoft.com/en-us/library/aa364963) | kernel32.dll | FileAPI.h | Vanara.PInvoke.Kernel32.GetFullPathName
[GetFullPathNameTransacted](http://msdn2.microsoft.com/en-us/library/63cbcec6-e9f0-4db3-bf2f-03a987000af1) | kernel32.dll | winbase.h | Vanara.PInvoke.Kernel32.GetFullPathNameTransacted
[GetGamingDeviceModelInformation](http://msdn2.microsoft.com/en-us/library/78101CBA-63B5-4B3F-9CEC-A215F32D9EB8) | kernelbase.dll | gamingdeviceinformation.h | Vanara.PInvoke.Kernel32.GetGamingDeviceModelInformation
[GetGeoInfo](http://msdn2.microsoft.com/en-us/library/dd318099) | kernel32.dll | Winnls.h | Vanara.PInvoke.Kernel32.GetGeoInfo
[GetGeoInfoEx](http://msdn2.microsoft.com/en-us/library/mt826489) | kernel32.dll | Winnls.h | Vanara.PInvoke.Kernel32.GetGeoInfoEx
[GetHandleInformation](http://msdn2.microsoft.com/en-us/library/ms724329) | kernel32.dll | Winbase.h | Vanara.PInvoke.Kernel32.GetHandleInformation
[GetIntegratedDisplaySize](http://msdn2.microsoft.com/en-us/library/dn904185) | kernelbase.dll | Winbase.h | Vanara.PInvoke.Kernel32.GetIntegratedDisplaySize
[GetLargePageMinimum](http://msdn2.microsoft.com/en-us/library/aa366568) | kernel32.dll | WinBase.h | Vanara.PInvoke.Kernel32.GetLargePageMinimum
@ -451,6 +459,8 @@ Native Method | Native DLL | Header | Managed Method
[GetProcessImageFileName](http://msdn2.microsoft.com/en-us/library/819fc2f4-0801-417b-9cbb-d7fd2894634e) | kernelbase.dll | psapi.h | Vanara.PInvoke.Kernel32.GetProcessImageFileName
[GetProcessInformation](http://msdn2.microsoft.com/en-us/library/hh448381) | kernel32.dll | WinBase.h | Vanara.PInvoke.Kernel32.GetProcessInformation
[GetProcessIoCounters](http://msdn2.microsoft.com/en-us/library/ms683218) | kernel32.dll | WinBase.h | Vanara.PInvoke.Kernel32.GetProcessIoCounters
[GetProcessMemoryInfoA](http://msdn2.microsoft.com/en-us/library/12990e8d-6097-4502-824e-db6c3f76c715) | kernel32.dll | psapi.h | Vanara.PInvoke.Kernel32.GetProcessMemoryInfo
[GetProcessMemoryInfoW](http://msdn2.microsoft.com/en-us/library/12990e8d-6097-4502-824e-db6c3f76c715) | kernel32.dll | psapi.h | Vanara.PInvoke.Kernel32.GetProcessMemoryInfo
[GetProcessMitigationPolicy](http://msdn2.microsoft.com/en-us/library/hh769085) | kernel32.dll | Processthreadsapi.h | Vanara.PInvoke.Kernel32.GetProcessMitigationPolicy
[GetProcessorSystemCycleTime](http://msdn2.microsoft.com/en-us/library/dd405497) | kernel32.dll | WinBase.h | Vanara.PInvoke.Kernel32.GetProcessorSystemCycleTime
[GetProcessPreferredUILanguages](http://msdn2.microsoft.com/en-us/library/dd318115) | kernel32.dll | Winnls.h | Vanara.PInvoke.Kernel32.GetProcessPreferredUILanguages
@ -525,6 +535,7 @@ Native Method | Native DLL | Header | Managed Method
[GetUILanguageInfo](http://msdn2.microsoft.com/en-us/library/dd318133) | kernel32.dll | Winnls.h | Vanara.PInvoke.Kernel32.GetUILanguageInfo
[GetUmsCompletionListEvent](http://msdn2.microsoft.com/en-us/library/393f6e0a-fbea-4aa0-9c18-f96da18e61e9) | kernel32.dll | winbase.h | Vanara.PInvoke.Kernel32.GetUmsCompletionListEvent
[GetUmsSystemThreadInformation](http://msdn2.microsoft.com/en-us/library/7c8347b6-6546-4ea9-9b2a-11794782f482) | kernel32.dll | winbase.h | Vanara.PInvoke.Kernel32.GetUmsSystemThreadInformation
[GetUserDefaultGeoName](http://msdn2.microsoft.com/en-us/library/mt826490) | kernel32.dll | Winnls.h | Vanara.PInvoke.Kernel32.GetUserDefaultGeoName
[GetUserDefaultLangID](http://msdn2.microsoft.com/en-us/library/dd318134) | kernel32.dll | Winnls.h | Vanara.PInvoke.Kernel32.GetUserDefaultLangID
[GetUserDefaultLCID](http://msdn2.microsoft.com/en-us/library/dd318135) | kernel32.dll | Winnls.h | Vanara.PInvoke.Kernel32.GetUserDefaultLCID
[GetUserDefaultLocaleName](http://msdn2.microsoft.com/en-us/library/dd318136) | kernel32.dll | Winnls.h | Vanara.PInvoke.Kernel32.GetUserDefaultLocaleName
@ -541,6 +552,8 @@ Native Method | Native DLL | Header | Managed Method
[GetWindowsDirectory](http://msdn2.microsoft.com/en-us/library/ms724454) | kernel32.dll | Winbase.h | Vanara.PInvoke.Kernel32.GetWindowsDirectory
[GetWriteWatch](http://msdn2.microsoft.com/en-us/library/aa366573) | kernel32.dll | WinBase.h | Vanara.PInvoke.Kernel32.GetWriteWatch
[GetWsChanges](http://msdn2.microsoft.com/en-us/library/ace5106c-9c7b-4d5f-a69a-c3a8bff0bb2d) | kernelbase.dll | psapi.h | Vanara.PInvoke.Kernel32.GetWsChanges
[GetWsChangesExA](http://msdn2.microsoft.com/en-us/library/8572db5c-2ffc-424f-8cec-b6a6902fed62) | kernel32.dll | psapi.h | Vanara.PInvoke.Kernel32.GetWsChangesEx
[GetWsChangesExW](http://msdn2.microsoft.com/en-us/library/8572db5c-2ffc-424f-8cec-b6a6902fed62) | kernel32.dll | psapi.h | Vanara.PInvoke.Kernel32.GetWsChangesEx
[GetXStateFeaturesMask](http://msdn2.microsoft.com/en-us/library/D9A8D0B6-21E3-46B7-AB88-CE2FF4025A17) | kernel32.dll | winbase.h | Vanara.PInvoke.Kernel32.GetXStateFeaturesMask
[GlobalAddAtom](http://msdn2.microsoft.com/en-us/library/ms649060) | kernel32.dll | Winbase.h | Vanara.PInvoke.Kernel32.GlobalAddAtom
[GlobalAddAtomEx](http://msdn2.microsoft.com/en-us/library/dn764994) | kernel32.dll | Winbase.h | Vanara.PInvoke.Kernel32.GlobalAddAtomEx
@ -551,12 +564,12 @@ Native Method | Native DLL | Header | Managed Method
[GlobalFree](http://msdn2.microsoft.com/en-us/library/aa366579) | kernel32.dll | WinBase.h | Vanara.PInvoke.Kernel32.GlobalFree
[GlobalGetAtomName](http://msdn2.microsoft.com/en-us/library/ms649063) | kernel32.dll | Winbase.h | Vanara.PInvoke.Kernel32.GlobalGetAtomName
[GlobalHandle](http://msdn2.microsoft.com/en-us/library/aa366582) | kernel32.dll | WinBase.h | Vanara.PInvoke.Kernel32.GlobalHandle
[GlobalLock](http://msdn2.microsoft.com/en-us/library/aa366584) | kernel32.dll | WinBase.h | Vanara.PInvoke.Kernel32.GlobalLock
[GlobalLock](http://msdn2.microsoft.com/en-us/library/0d7deac2-c9c4-4adc-8a0a-edfc512a4d6c) | kernel32.dll | winbase.h | Vanara.PInvoke.Kernel32.GlobalLock
[GlobalMemoryStatus](http://msdn2.microsoft.com/en-us/library/aa366586) | kernel32.dll | WinBase.h | Vanara.PInvoke.Kernel32.GlobalMemoryStatus
[GlobalMemoryStatusEx](http://msdn2.microsoft.com/en-us/library/aa366589) | kernel32.dll | WinBase.h | Vanara.PInvoke.Kernel32.GlobalMemoryStatusEx
[GlobalReAlloc](http://msdn2.microsoft.com/en-us/library/aa366590) | kernel32.dll | WinBase.h | Vanara.PInvoke.Kernel32.GlobalReAlloc
[GlobalSize](http://msdn2.microsoft.com/en-us/library/aa366593) | kernel32.dll | WinBase.h | Vanara.PInvoke.Kernel32.GlobalSize
[GlobalUnlock](http://msdn2.microsoft.com/en-us/library/aa366595) | kernel32.dll | WinBase.h | Vanara.PInvoke.Kernel32.GlobalUnlock
[GlobalUnlock](http://msdn2.microsoft.com/en-us/library/580a2873-7f06-47a1-acf5-c2b3c96e15e7) | kernel32.dll | winbase.h | Vanara.PInvoke.Kernel32.GlobalUnlock
[Heap32First](http://msdn2.microsoft.com/en-us/library/79d01e3a-b11b-46b5-99d0-b445000288a7) | kernel32.dll | tlhelp32.h | Vanara.PInvoke.Kernel32.Heap32First
[Heap32ListFirst](http://msdn2.microsoft.com/en-us/library/b9a2992b-0dc1-41c3-aa23-796def674831) | kernel32.dll | tlhelp32.h | Vanara.PInvoke.Kernel32.Heap32ListFirst
[Heap32ListNext](http://msdn2.microsoft.com/en-us/library/bb4d573c-a82f-48ac-be22-440d6a1d0c9c) | kernel32.dll | tlhelp32.h | Vanara.PInvoke.Kernel32.Heap32ListNext
@ -585,6 +598,8 @@ Native Method | Native DLL | Header | Managed Method
[InitializeCriticalSectionAndSpinCount](http://msdn2.microsoft.com/en-us/library/ms683476) | kernel32.dll | WinBase.h | Vanara.PInvoke.Kernel32.InitializeCriticalSectionAndSpinCount
[InitializeCriticalSectionEx](http://msdn2.microsoft.com/en-us/library/ms683477) | kernel32.dll | WinBase.h | Vanara.PInvoke.Kernel32.InitializeCriticalSectionEx
[InitializeEnclave](http://msdn2.microsoft.com/en-us/library/mt592869) | kernel32.dll | Enclaveapi.h | Vanara.PInvoke.Kernel32.InitializeEnclave
[InitializeProcessForWsWatchA](http://msdn2.microsoft.com/en-us/library/c928656c-a59d-41b5-9434-911329b0278e) | kernel32.dll | psapi.h | Vanara.PInvoke.Kernel32.InitializeProcessForWsWatch
[InitializeProcessForWsWatchW](http://msdn2.microsoft.com/en-us/library/c928656c-a59d-41b5-9434-911329b0278e) | kernel32.dll | psapi.h | Vanara.PInvoke.Kernel32.InitializeProcessForWsWatch
[InitializeProcThreadAttributeList](http://msdn2.microsoft.com/en-us/library/ms683481) | kernel32.dll | WinBase.h | Vanara.PInvoke.Kernel32.InitializeProcThreadAttributeList
[InitializeSListHead](http://msdn2.microsoft.com/en-us/library/4e34f947-1687-4ea9-aaa1-8d8dc11dad70) | kernel32.dll | interlockedapi.h | Vanara.PInvoke.Kernel32.InitializeSListHead
[InitializeSRWLock](http://msdn2.microsoft.com/en-us/library/ms683483) | kernel32.dll | WinBase.h | Vanara.PInvoke.Kernel32.InitializeSRWLock
@ -594,7 +609,12 @@ Native Method | Native DLL | Header | Managed Method
[InitOnceExecuteOnce](http://msdn2.microsoft.com/en-us/library/ms683493) | kernel32.dll | WinBase.h | Vanara.PInvoke.Kernel32.InitOnceExecuteOnce
[InitOnceInitialize](http://msdn2.microsoft.com/en-us/library/ms683495) | kernel32.dll | WinBase.h | Vanara.PInvoke.Kernel32.InitOnceInitialize
[InstallELAMCertificateInfo](http://msdn2.microsoft.com/en-us/library/dn369255) | kernel32.dll | Windows.h | Vanara.PInvoke.Kernel32.InstallELAMCertificateInfo
[InterlockedCompareExchange](http://msdn2.microsoft.com/en-us/library/ms683560) | kernel32.dll | WinBase.h | Vanara.PInvoke.Kernel32.InterlockedCompareExchange
[InterlockedDecrement](http://msdn2.microsoft.com/en-us/library/ms683580) | kernel32.dll | WinBase.h | Vanara.PInvoke.Kernel32.InterlockedDecrement
[InterlockedExchange](http://msdn2.microsoft.com/en-us/library/ms683590) | kernel32.dll | WinBase.h | Vanara.PInvoke.Kernel32.InterlockedExchange
[InterlockedExchangeAdd](http://msdn2.microsoft.com/en-us/library/ms683597) | kernel32.dll | WinBase.h | Vanara.PInvoke.Kernel32.InterlockedExchangeAdd
[InterlockedFlushSList](http://msdn2.microsoft.com/en-us/library/3fde3377-8a98-4976-a350-2c173b209e8c) | kernel32.dll | interlockedapi.h | Vanara.PInvoke.Kernel32.InterlockedFlushSList
[InterlockedIncrement](http://msdn2.microsoft.com/en-us/library/ms683614) | kernel32.dll | WinBase.h | Vanara.PInvoke.Kernel32.InterlockedIncrement
[InterlockedPopEntrySList](http://msdn2.microsoft.com/en-us/library/10760fd4-5973-4ab0-991c-7a5951c798a4) | kernel32.dll | interlockedapi.h | Vanara.PInvoke.Kernel32.InterlockedPopEntrySList
[InterlockedPushEntrySList](http://msdn2.microsoft.com/en-us/library/60e3b6f7-f556-4699-be90-db7330cfb8ca) | kernel32.dll | interlockedapi.h | Vanara.PInvoke.Kernel32.InterlockedPushEntrySList
[InterlockedPushListSList](http://msdn2.microsoft.com/en-us/library/hh448545) | kernel32.dll | WinBase.h | Vanara.PInvoke.Kernel32.InterlockedPushListSList
@ -621,29 +641,31 @@ Native Method | Native DLL | Header | Managed Method
[IsValidLocale](http://msdn2.microsoft.com/en-us/library/dd318679) | kernel32.dll | Winnls.h | Vanara.PInvoke.Kernel32.IsValidLocale
[IsValidLocaleName](http://msdn2.microsoft.com/en-us/library/dd318681) | kernel32.dll | Winnls.h | Vanara.PInvoke.Kernel32.IsValidLocaleName
[IsValidNLSVersion](http://msdn2.microsoft.com/en-us/library/hh706739) | kernel32.dll | Winnls.h | Vanara.PInvoke.Kernel32.IsValidNLSVersion
[IsWow64GuestMachineSupported](http://msdn2.microsoft.com/en-us/library/mt804321) | kernel32.dll | Wow64apiset.h | Vanara.PInvoke.Kernel32.IsWow64GuestMachineSupported
[IsWow64Process](http://msdn2.microsoft.com/en-us/library/ms684139) | kernel32.dll | WinBase.h | Vanara.PInvoke.Kernel32.IsWow64Process
[IsWow64Process2](http://msdn2.microsoft.com/en-us/library/mt804318) | kernelbase.dll | Wow64apiset.h | Vanara.PInvoke.Kernel32.IsWow64Process2
[IsWow64Process2](http://msdn2.microsoft.com/en-us/library/mt804318) | kernel32.dll | Wow64apiset.h | Vanara.PInvoke.Kernel32.IsWow64Process2
[LCIDToLocaleName](http://msdn2.microsoft.com/en-us/library/dd318698) | kernel32.dll | Winnls.h | Vanara.PInvoke.Kernel32.LCIDToLocaleName
[LCMapString](http://msdn2.microsoft.com/en-us/library/dd318700) | kernel32.dll | Winnls.h | Vanara.PInvoke.Kernel32.LCMapString
[LCMapStringEx](http://msdn2.microsoft.com/en-us/library/dd318702) | kernel32.dll | Winnls.h | Vanara.PInvoke.Kernel32.LCMapStringEx
[LeaveCriticalSection](http://msdn2.microsoft.com/en-us/library/ms684169) | kernel32.dll | WinBase.h | Vanara.PInvoke.Kernel32.LeaveCriticalSection
[LeaveCriticalSectionWhenCallbackReturns](http://msdn2.microsoft.com/en-us/library/ms684171) | kernel32.dll | WinBase.h | Vanara.PInvoke.Kernel32.LeaveCriticalSectionWhenCallbackReturns
[LoadEnclaveData](http://msdn2.microsoft.com/en-us/library/mt592871) | kernel32.dll | Enclaveapi.h | Vanara.PInvoke.Kernel32.LoadEnclaveData
[LoadEnclaveImage](http://msdn2.microsoft.com/en-us/library/mt844248) | kernelbase.dll | Enclaveapi.h | Vanara.PInvoke.Kernel32.LoadEnclaveImage
[LoadLibrary](http://msdn2.microsoft.com/en-us/library/ms684175) | kernel32.dll | Winbase.h | Vanara.PInvoke.Kernel32.LoadLibrary
[LoadLibraryEx](http://msdn2.microsoft.com/en-us/library/ms684179) | kernel32.dll | LibLoaderAPI.h | Vanara.PInvoke.Kernel32.LoadLibraryEx
[LoadModule](http://msdn2.microsoft.com/en-us/library/ms684183) | kernel32.dll | Winbase.h | Vanara.PInvoke.Kernel32.LoadModule
[LoadPackagedLibrary](http://msdn2.microsoft.com/en-us/library/4a103753-a2c9-487f-b797-01d5f5d489f3) | kernel32.dll | winbase.h | Vanara.PInvoke.Kernel32.LoadPackagedLibrary
[LoadResource](http://msdn2.microsoft.com/en-us/library/ms648046) | kernel32.dll | Winbase.h | Vanara.PInvoke.Kernel32.LoadResource
[LoadStringByReference](http://msdn2.microsoft.com/en-us/library/4E0470ED-512F-4B76-A3E4-31C8B269CD5C) | kernelbase.dll | winnls.h | Vanara.PInvoke.Kernel32.LoadStringByReference
[LocalAlloc](http://msdn2.microsoft.com/en-us/library/aa366723) | kernel32.dll | WinBase.h | Vanara.PInvoke.Kernel32.LocalAlloc
[LocalAlloc](http://msdn2.microsoft.com/en-us/library/da8cd2be-ff4c-4da5-813c-8759a58228c9) | kernel32.dll | winbase.h | Vanara.PInvoke.Kernel32.LocalAlloc
[LocaleNameToLCID](http://msdn2.microsoft.com/en-us/library/dd318711) | kernel32.dll | Winnls.h | Vanara.PInvoke.Kernel32.LocaleNameToLCID
[LocalFileTimeToFileTime](http://msdn2.microsoft.com/en-us/library/ms724490) | kernel32.dll | FileAPI.h | Vanara.PInvoke.Kernel32.LocalFileTimeToFileTime
[LocalFlags](http://msdn2.microsoft.com/en-us/library/aa366728) | kernel32.dll | WinBase.h | Vanara.PInvoke.Kernel32.LocalFlags
[LocalFree](http://msdn2.microsoft.com/en-us/library/aa366730) | kernel32.dll | WinBase.h | Vanara.PInvoke.Kernel32.LocalFree
[LocalFree](http://msdn2.microsoft.com/en-us/library/a0393983-cb43-4dfa-91a6-d82a5fb8de12) | kernel32.dll | winbase.h | Vanara.PInvoke.Kernel32.LocalFree
[LocalHandle](http://msdn2.microsoft.com/en-us/library/aa366733) | kernel32.dll | WinBase.h | Vanara.PInvoke.Kernel32.LocalHandle
[LocalLock](http://msdn2.microsoft.com/en-us/library/aa366737) | kernel32.dll | WinBase.h | Vanara.PInvoke.Kernel32.LocalLock
[LocalReAlloc](http://msdn2.microsoft.com/en-us/library/aa366742) | kernel32.dll | WinBase.h | Vanara.PInvoke.Kernel32.LocalReAlloc
[LocalSize](http://msdn2.microsoft.com/en-us/library/aa366745) | kernel32.dll | WinBase.h | Vanara.PInvoke.Kernel32.LocalSize
[LocalReAlloc](http://msdn2.microsoft.com/en-us/library/88527ddd-e0c2-4a41-825e-d3a6df77fd2a) | kernel32.dll | winbase.h | Vanara.PInvoke.Kernel32.LocalReAlloc
[LocalSize](http://msdn2.microsoft.com/en-us/library/d1337845-d89c-4cd5-a584-36fe0c682c1a) | kernel32.dll | winbase.h | Vanara.PInvoke.Kernel32.LocalSize
[LocalUnlock](http://msdn2.microsoft.com/en-us/library/aa366747) | kernel32.dll | WinBase.h | Vanara.PInvoke.Kernel32.LocalUnlock
[LocateXStateFeature](http://msdn2.microsoft.com/en-us/library/7AAEA13B-E4A4-4410-BFC7-09B81B92FF26) | kernel32.dll | winbase.h | Vanara.PInvoke.Kernel32.LocateXStateFeature
[LockFile](http://msdn2.microsoft.com/en-us/library/aa365202) | kernel32.dll | FileAPI.h | Vanara.PInvoke.Kernel32.LockFile
@ -662,6 +684,7 @@ Native Method | Native DLL | Header | Managed Method
[MapViewOfFileNuma2](http://msdn2.microsoft.com/en-us/library/mt492558) | kernelbase.dll | WinBase.h | Vanara.PInvoke.Kernel32.MapViewOfFileNuma2
[Module32First](http://msdn2.microsoft.com/en-us/library/bb41cab9-13a1-469d-bf76-68c172e982f6) | kernel32.dll | tlhelp32.h | Vanara.PInvoke.Kernel32.Module32First
[Module32Next](https://www.google.com/search?num=5&q=Module32Next+site%3Amicrosoft.com) | kernel32.dll | tlhelp32.h | Vanara.PInvoke.Kernel32.Module32Next
[Module32NextA](http://msdn2.microsoft.com/en-us/library/88ec1af4-bae7-4cd7-b830-97a98fb337f4) | kernel32.dll | tlhelp32.h | Vanara.PInvoke.Kernel32.Module32Next
[MoveFile](http://msdn2.microsoft.com/en-us/library/aa365239) | kernel32.dll | WinBase.h | Vanara.PInvoke.Kernel32.MoveFile
[MoveFileEx](http://msdn2.microsoft.com/en-us/library/aa365240) | kernel32.dll | WinBase.h | Vanara.PInvoke.Kernel32.MoveFileEx
[MoveFileTransacted](http://msdn2.microsoft.com/en-us/library/466d733b-30d2-4297-a0e6-77038f1a21d5) | kernel32.dll | winbase.h | Vanara.PInvoke.Kernel32.MoveFileTransacted
@ -671,6 +694,7 @@ Native Method | Native DLL | Header | Managed Method
[NeedCurrentDirectoryForExePath](http://msdn2.microsoft.com/en-us/library/ms684269) | kernel32.dll | WinBase.h | Vanara.PInvoke.Kernel32.NeedCurrentDirectoryForExePath
[NormalizeString](http://msdn2.microsoft.com/en-us/library/dd319093) | kernel32.dll | Winnls.h | Vanara.PInvoke.Kernel32.NormalizeString
[OfferVirtualMemory](http://msdn2.microsoft.com/en-us/library/dn781436) | kernel32.dll | WinBase.h | Vanara.PInvoke.Kernel32.OfferVirtualMemory
[OpenCommPort](http://msdn2.microsoft.com/en-us/library/D96D3F6D-2158-4E6A-84A8-DC3BAE9624FA) | kernelbase.dll | winbase.h | Vanara.PInvoke.Kernel32.OpenCommPort
[OpenEvent](http://msdn2.microsoft.com/en-us/library/ms684305) | kernel32.dll | WinBase.h | Vanara.PInvoke.Kernel32.OpenEvent
[OpenFile](http://msdn2.microsoft.com/en-us/library/aa365430) | kernel32.dll | WinBase.h | Vanara.PInvoke.Kernel32.OpenFile
[OpenFileById](http://msdn2.microsoft.com/en-us/library/caa757a2-fc3f-4883-8d3e-b98d28f92517) | kernel32.dll | winbase.h | Vanara.PInvoke.Kernel32.OpenFileById
@ -722,7 +746,9 @@ Native Method | Native DLL | Header | Managed Method
[PrefetchVirtualMemory](http://msdn2.microsoft.com/en-us/library/hh780543) | kernel32.dll | WinBase.h | Vanara.PInvoke.Kernel32.PrefetchVirtualMemory
[PrepareTape](http://msdn2.microsoft.com/en-us/library/aa362532) | kernel32.dll | Winbase.h | Vanara.PInvoke.Kernel32.PrepareTape
[Process32First](https://www.google.com/search?num=5&q=Process32First+site%3Amicrosoft.com) | kernel32.dll | tlhelp32.h | Vanara.PInvoke.Kernel32.Process32First
[Process32FirstA](http://msdn2.microsoft.com/en-us/library/097790e8-30c2-4b00-9256-fa26e2ceb893) | kernel32.dll | tlhelp32.h | Vanara.PInvoke.Kernel32.Process32First
[Process32Next](https://www.google.com/search?num=5&q=Process32Next+site%3Amicrosoft.com) | kernel32.dll | tlhelp32.h | Vanara.PInvoke.Kernel32.Process32Next
[Process32NextA](http://msdn2.microsoft.com/en-us/library/843a95fd-27ae-4215-83d0-82fc402b82b6) | kernel32.dll | tlhelp32.h | Vanara.PInvoke.Kernel32.Process32Next
[ProcessIdToSessionId](http://msdn2.microsoft.com/en-us/library/aa382990) | kernel32.dll | Winbase.h | Vanara.PInvoke.Kernel32.ProcessIdToSessionId
[PssCaptureSnapshot](http://msdn2.microsoft.com/en-us/library/44F2CB48-A9F6-4131-B21C-9F27A27CECD5) | kernel32.dll | processsnapshot.h | Vanara.PInvoke.Kernel32.PssCaptureSnapshot
[PssDuplicateSnapshot](http://msdn2.microsoft.com/en-us/library/5D2751F3-E7E1-4917-8060-E2BC8A7A3DEA) | kernel32.dll | processsnapshot.h | Vanara.PInvoke.Kernel32.PssDuplicateSnapshot
@ -773,6 +799,7 @@ Native Method | Native DLL | Header | Managed Method
[ReadConsoleOutput](https://www.google.com/search?num=5&q=ReadConsoleOutputA+site%3Amicrosoft.com) | kernel32.dll | Wincon.h | Vanara.PInvoke.Kernel32.ReadConsoleOutput
[ReadConsoleOutputAttribute](https://www.google.com/search?num=5&q=ReadConsoleOutputAttribute+site%3Amicrosoft.com) | kernel32.dll | Wincon.h | Vanara.PInvoke.Kernel32.ReadConsoleOutputAttribute
[ReadConsoleOutputCharacter](https://www.google.com/search?num=5&q=ReadConsoleOutputCharacterA+site%3Amicrosoft.com) | kernel32.dll | Wincon.h | Vanara.PInvoke.Kernel32.ReadConsoleOutputCharacter
[ReadDirectoryChangesExW](http://msdn2.microsoft.com/en-us/library/90C2F258-094C-4A0E-80E7-3FA241D288EA) | kernel32.dll | winbase.h | Vanara.PInvoke.Kernel32.ReadDirectoryChangesExW
[ReadDirectoryChangesW](http://msdn2.microsoft.com/en-us/library/aa365465) | kernel32.dll | WinBase.h | Vanara.PInvoke.Kernel32.ReadDirectoryChanges
[ReadFile](http://msdn2.microsoft.com/en-us/library/aa365467) | kernel32.dll | FileAPI.h | Vanara.PInvoke.Kernel32.ReadFile
[ReadFileEx](http://msdn2.microsoft.com/en-us/library/aa365468) | kernel32.dll | FileAPI.h | Vanara.PInvoke.Kernel32.ReadFileEx
@ -783,7 +810,7 @@ Native Method | Native DLL | Header | Managed Method
[RegisterApplicationRecoveryCallback](http://msdn2.microsoft.com/en-us/library/aa373345) | kernel32.dll | Winbase.h | Vanara.PInvoke.Kernel32.RegisterApplicationRecoveryCallback
[RegisterApplicationRestart](http://msdn2.microsoft.com/en-us/library/aa373347) | kernel32.dll | Winbase.h | Vanara.PInvoke.Kernel32.RegisterApplicationRestart
[RegisterBadMemoryNotification](http://msdn2.microsoft.com/en-us/library/hh691013) | kernel32.dll | WinBase.h | Vanara.PInvoke.Kernel32.RegisterBadMemoryNotification
[RegisterWaitForSingleObject](http://msdn2.microsoft.com/en-us/library/ms685061) | kernel32.dll | WinBase.h | Vanara.PInvoke.Kernel32.RegisterWaitForSingleObject
[RegisterWaitForSingleObject](https://www.google.com/search?num=5&q=RegisterWaitForSingleObject+site%3Amicrosoft.com) | kernel32.dll | | Vanara.PInvoke.Kernel32.RegisterWaitForSingleObject
[ReleaseActCtx](http://msdn2.microsoft.com/en-us/library/aa375713) | kernel32.dll | Winbase.h | Vanara.PInvoke.Kernel32.ReleaseActCtx
[ReleaseMutex](http://msdn2.microsoft.com/en-us/library/ms685066) | kernel32.dll | WinBase.h | Vanara.PInvoke.Kernel32.ReleaseMutex
[ReleaseMutexWhenCallbackReturns](http://msdn2.microsoft.com/en-us/library/ms685070) | kernel32.dll | WinBase.h | Vanara.PInvoke.Kernel32.ReleaseMutexWhenCallbackReturns
@ -928,12 +955,13 @@ Native Method | Native DLL | Header | Managed Method
[SetUnhandledExceptionFilter](http://msdn2.microsoft.com/en-us/library/ms680634) | kernel32.dll | WinBase.h | Vanara.PInvoke.Kernel32.SetUnhandledExceptionFilter
[SetupComm](http://msdn2.microsoft.com/en-us/library/aa363439) | kernel32.dll | Winbase.h | Vanara.PInvoke.Kernel32.SetupComm
[SetUserGeoID](http://msdn2.microsoft.com/en-us/library/dd374055) | kernel32.dll | Winnls.h | Vanara.PInvoke.Kernel32.SetUserGeoID
[SetUserGeoName](http://msdn2.microsoft.com/en-us/library/mt812045) | kernel32.dll | Winnls.h | Vanara.PInvoke.Kernel32.SetUserGeoName
[SetVolumeLabel](http://msdn2.microsoft.com/en-us/library/aa365560) | kernel32.dll | WinBase.h | Vanara.PInvoke.Kernel32.SetVolumeLabel
[SetVolumeMountPoint](http://msdn2.microsoft.com/en-us/library/aa365561) | kernel32.dll | WinBase.h | Vanara.PInvoke.Kernel32.SetVolumeMountPoint
[SetWaitableTimer](http://msdn2.microsoft.com/en-us/library/ms686289) | kernel32.dll | WinBase.h | Vanara.PInvoke.Kernel32.SetWaitableTimer
[SetWaitableTimerEx](http://msdn2.microsoft.com/en-us/library/dd405521) | kernel32.dll | WinBase.h | Vanara.PInvoke.Kernel32.SetWaitableTimerEx
[SetXStateFeaturesMask](http://msdn2.microsoft.com/en-us/library/64ADEA8A-DE78-437E-AE68-A68E7214C5FD) | kernel32.dll | winbase.h | Vanara.PInvoke.Kernel32.SetXStateFeaturesMask
[SignalObjectAndWait](http://msdn2.microsoft.com/en-us/library/ms686293) | kernel32.dll | WinBase.h | Vanara.PInvoke.Kernel32.SignalObjectAndWait
[SignalObjectAndWait](https://www.google.com/search?num=5&q=SignalObjectAndWait+site%3Amicrosoft.com) | kernel32.dll | | Vanara.PInvoke.Kernel32.SignalObjectAndWait
[SizeofResource](http://msdn2.microsoft.com/en-us/library/ms648048) | kernel32.dll | Winbase.h | Vanara.PInvoke.Kernel32.SizeofResource
[Sleep](http://msdn2.microsoft.com/en-us/library/ms686298) | kernel32.dll | WinBase.h | Vanara.PInvoke.Kernel32.Sleep
[SleepConditionVariableCS](http://msdn2.microsoft.com/en-us/library/ms686301) | kernel32.dll | WinBase.h | Vanara.PInvoke.Kernel32.SleepConditionVariableCS
@ -947,6 +975,7 @@ Native Method | Native DLL | Header | Managed Method
[SystemTimeToFileTime](http://msdn2.microsoft.com/en-us/library/ms724948) | kernel32.dll | Winbase.h | Vanara.PInvoke.Kernel32.SystemTimeToFileTime
[SystemTimeToTzSpecificLocalTime](http://msdn2.microsoft.com/en-us/library/ms724949) | kernel32.dll | Winbase.h | Vanara.PInvoke.Kernel32.SystemTimeToTzSpecificLocalTime
[SystemTimeToTzSpecificLocalTimeEx](http://msdn2.microsoft.com/en-us/library/jj206642) | kernel32.dll | Winbase.h | Vanara.PInvoke.Kernel32.SystemTimeToTzSpecificLocalTimeEx
[TerminateEnclave](http://msdn2.microsoft.com/en-us/library/mt844249) | kernelbase.dll | Enclaveapi.h | Vanara.PInvoke.Kernel32.TerminateEnclave
[TerminateJobObject](http://msdn2.microsoft.com/en-us/library/ms686709) | kernel32.dll | WinBase.h | Vanara.PInvoke.Kernel32.TerminateJobObject
[TerminateProcess](http://msdn2.microsoft.com/en-us/library/ms686714) | kernel32.dll | WinBase.h | Vanara.PInvoke.Kernel32.TerminateProcess
[TerminateProcessOnMemoryExhaustion](https://www.google.com/search?num=5&q=TerminateProcessOnMemoryExhaustion+site%3Amicrosoft.com) | kernelbase.dll | WinBase.h | Vanara.PInvoke.Kernel32.TerminateProcessOnMemoryExhaustion
@ -982,6 +1011,7 @@ Native Method | Native DLL | Header | Managed Method
[UpdateCalendarDayOfWeek](http://msdn2.microsoft.com/en-us/library/b9ae250a-73bb-4ec2-bb0d-e1f8b25c173c) | kernel32.dll | | Vanara.PInvoke.Kernel32.UpdateCalendarDayOfWeek
[UpdateProcThreadAttribute](http://msdn2.microsoft.com/en-us/library/ms686880) | kernel32.dll | WinBase.h | Vanara.PInvoke.Kernel32.UpdateProcThreadAttribute
[UpdateResource](http://msdn2.microsoft.com/en-us/library/ms648049) | kernel32.dll | Winbase.h | Vanara.PInvoke.Kernel32.UpdateResource
[UserHandleGrantAccess](http://msdn2.microsoft.com/en-us/library/6e7a6cfc-f881-43cc-a5af-b97e0bf14bf4) | user32.dll | winuser.h | Vanara.PInvoke.Kernel32.UserHandleGrantAccess
[VerifyScripts](http://msdn2.microsoft.com/en-us/library/dd374129) | kernel32.dll | Winnls.h | Vanara.PInvoke.Kernel32.VerifyScripts
[VerifyVersionInfo](http://msdn2.microsoft.com/en-us/library/ms725492) | kernel32.dll | Winbase.h | Vanara.PInvoke.Kernel32.VerifyVersionInfo
[VerSetConditionMask](http://msdn2.microsoft.com/en-us/library/ms725493) | kernel32.dll | Winnt.h | Vanara.PInvoke.Kernel32.VerSetConditionMask
@ -1001,10 +1031,10 @@ Native Method | Native DLL | Header | Managed Method
[WaitCommEvent](http://msdn2.microsoft.com/en-us/library/aa363479) | kernel32.dll | Winbase.h | Vanara.PInvoke.Kernel32.WaitCommEvent
[WaitForDebugEvent](http://msdn2.microsoft.com/en-us/library/ms681423) | kernel32.dll | WinBase.h | Vanara.PInvoke.Kernel32.WaitForDebugEvent
[WaitForDebugEventEx](http://msdn2.microsoft.com/en-us/library/mt171594) | kernel32.dll | WinBase.h | Vanara.PInvoke.Kernel32.WaitForDebugEventEx
[WaitForMultipleObjects](http://msdn2.microsoft.com/en-us/library/ms687025) | kernel32.dll | WinBase.h | Vanara.PInvoke.Kernel32.WaitForMultipleObjects
[WaitForMultipleObjectsEx](http://msdn2.microsoft.com/en-us/library/ms687028) | kernel32.dll | WinBase.h | Vanara.PInvoke.Kernel32.WaitForMultipleObjectsEx
[WaitForSingleObject](http://msdn2.microsoft.com/en-us/library/ms687032) | kernel32.dll | WinBase.h | Vanara.PInvoke.Kernel32.WaitForSingleObject
[WaitForSingleObjectEx](http://msdn2.microsoft.com/en-us/library/ms687036) | kernel32.dll | WinBase.h | Vanara.PInvoke.Kernel32.WaitForSingleObjectEx
[WaitForMultipleObjects](https://www.google.com/search?num=5&q=WaitForMultipleObjects+site%3Amicrosoft.com) | kernel32.dll | | Vanara.PInvoke.Kernel32.WaitForMultipleObjects
[WaitForMultipleObjectsEx](https://www.google.com/search?num=5&q=WaitForMultipleObjectsEx+site%3Amicrosoft.com) | kernel32.dll | | Vanara.PInvoke.Kernel32.WaitForMultipleObjectsEx
[WaitForSingleObject](https://www.google.com/search?num=5&q=WaitForSingleObject+site%3Amicrosoft.com) | kernel32.dll | | Vanara.PInvoke.Kernel32.WaitForSingleObject
[WaitForSingleObjectEx](https://www.google.com/search?num=5&q=WaitForSingleObjectEx+site%3Amicrosoft.com) | kernel32.dll | | Vanara.PInvoke.Kernel32.WaitForSingleObjectEx
[WaitForThreadpoolIoCallbacks](http://msdn2.microsoft.com/en-us/library/ms687038) | kernel32.dll | WinBase.h | Vanara.PInvoke.Kernel32.WaitForThreadpoolIoCallbacks
[WaitForThreadpoolTimerCallbacks](http://msdn2.microsoft.com/en-us/library/ms687042) | kernel32.dll | WinBase.h | Vanara.PInvoke.Kernel32.WaitForThreadpoolTimerCallbacks
[WaitForThreadpoolWaitCallbacks](http://msdn2.microsoft.com/en-us/library/ms687047) | kernel32.dll | WinBase.h | Vanara.PInvoke.Kernel32.WaitForThreadpoolWaitCallbacks
@ -1017,6 +1047,7 @@ Native Method | Native DLL | Header | Managed Method
[WakeConditionVariable](http://msdn2.microsoft.com/en-us/library/ms687080) | kernel32.dll | WinBase.h | Vanara.PInvoke.Kernel32.WakeConditionVariable
[WerGetFlags](http://msdn2.microsoft.com/en-us/library/8c5f08c0-e2d1-448c-9a57-ef19897f64c6) | kernel32.dll | werapi.h | Vanara.PInvoke.Kernel32.WerGetFlags
[WerRegisterAdditionalProcess](http://msdn2.microsoft.com/en-us/library/mt492585) | kernel32.dll | Werapi.h | Vanara.PInvoke.Kernel32.WerRegisterAdditionalProcess
[WerRegisterAppLocalDump](http://msdn2.microsoft.com/en-us/library/C57F5758-2BF7-444E-A22C-62C925B899A1) | kernel32.dll | werapi.h | Vanara.PInvoke.Kernel32.WerRegisterAppLocalDump
[WerRegisterCustomMetadata](http://msdn2.microsoft.com/en-us/library/55FB3110-314A-4327-AA8F-3AF77B7006DD) | kernel32.dll | werapi.h | Vanara.PInvoke.Kernel32.WerRegisterCustomMetadata
[WerRegisterExcludedMemoryBlock](http://msdn2.microsoft.com/en-us/library/6CDA8EDD-C8A5-471D-9716-3AB29E571133) | kernel32.dll | werapi.h | Vanara.PInvoke.Kernel32.WerRegisterExcludedMemoryBlock
[WerRegisterFile](http://msdn2.microsoft.com/en-us/library/4b4bb1bb-6782-447a-901f-75702256d907) | kernel32.dll | werapi.h | Vanara.PInvoke.Kernel32.WerRegisterFile
@ -1024,6 +1055,7 @@ Native Method | Native DLL | Header | Managed Method
[WerRegisterRuntimeExceptionModule](http://msdn2.microsoft.com/en-us/library/b0fb2c0d-cc98-43cc-a508-e80545377b7f) | kernel32.dll | werapi.h | Vanara.PInvoke.Kernel32.WerRegisterRuntimeExceptionModule
[WerSetFlags](http://msdn2.microsoft.com/en-us/library/2a71203f-3a08-461f-a230-e3fee00d9d99) | kernel32.dll | werapi.h | Vanara.PInvoke.Kernel32.WerSetFlags
[WerUnregisterAdditionalProcess](http://msdn2.microsoft.com/en-us/library/CE840EE8-5EB6-4F0F-935E-5DA9097E950F) | kernel32.dll | werapi.h | Vanara.PInvoke.Kernel32.WerUnregisterAdditionalProcess
[WerUnregisterAppLocalDump](http://msdn2.microsoft.com/en-us/library/A3AD976A-9C44-494C-ABF0-90D151001E30) | kernel32.dll | werapi.h | Vanara.PInvoke.Kernel32.WerUnregisterAppLocalDump
[WerUnregisterCustomMetadata](http://msdn2.microsoft.com/en-us/library/29DB2CE5-2A96-450B-96C8-082B786613F9) | kernel32.dll | werapi.h | Vanara.PInvoke.Kernel32.WerUnregisterCustomMetadata
[WerUnregisterExcludedMemoryBlock](http://msdn2.microsoft.com/en-us/library/99FF746E-8EFC-47DB-AEE6-EC46F7BC7F0B) | kernel32.dll | werapi.h | Vanara.PInvoke.Kernel32.WerUnregisterExcludedMemoryBlock
[WerUnregisterFile](http://msdn2.microsoft.com/en-us/library/bb513630) | kernel32.dll | Werapi.h | Vanara.PInvoke.Kernel32.WerUnregisterFile
@ -1059,12 +1091,12 @@ Native Method | Native DLL | Header | Managed Method
### Structures
Native Structure | Header | Managed Structure
--- | --- | ---
[ACTCTX](http://msdn2.microsoft.com/en-us/library/aa374149) | Winbase.h | Vanara.PInvoke.Kernel32+ACTCTX
[ACTCTX_SECTION_KEYED_DATA](http://msdn2.microsoft.com/en-us/library/aa374148) | Winbase.h | Vanara.PInvoke.Kernel32+ACTCTX_SECTION_KEYED_DATA
[APP_MEMORY_INFORMATION](http://msdn2.microsoft.com/en-us/library/mt767995) | WinBase.h | Vanara.PInvoke.Kernel32+APP_MEMORY_INFORMATION
[BLOCK_DATA](https://www.google.com/search?num=5&q=BLOCK_DATA+site%3Amicrosoft.com) | | Vanara.PInvoke.Kernel32+PROCESS_HEAP_ENTRY+BLOCK_REGION_UNION+BLOCK_DATA
[BY_HANDLE_FILE_INFORMATION](http://msdn2.microsoft.com/en-us/library/aa363788) | FileAPI.h | Vanara.PInvoke.Kernel32+BY_HANDLE_FILE_INFORMATION
[CACHE_DESCRIPTOR](http://msdn2.microsoft.com/en-us/library/ms681979) | WinNT.h | Vanara.PInvoke.Kernel32+CACHE_DESCRIPTOR
[CACHE_RELATIONSHIP](http://msdn2.microsoft.com/en-us/library/f8fe521b-02d6-4c58-8ef8-653280add111) | winnt.h | Vanara.PInvoke.Kernel32+CACHE_RELATIONSHIP
[CALDATETIME](http://msdn2.microsoft.com/en-us/library/a714ff32-2b1f-4256-931e-324d64daf2ac) | | Vanara.PInvoke.Kernel32+CALDATETIME
[CFG_CALL_TARGET_INFO](http://msdn2.microsoft.com/en-us/library/mt219054) | Ntmmapi.h | Vanara.PInvoke.Kernel32+CFG_CALL_TARGET_INFO
[CHAR_INFO](https://www.google.com/search?num=5&q=CHAR_INFO+site%3Amicrosoft.com) | Wincon.h | Vanara.PInvoke.Kernel32+CHAR_INFO
@ -1090,13 +1122,10 @@ Native Structure | Header | Managed Structure
[CPINFO](http://msdn2.microsoft.com/en-us/library/dd317780) | Winnls.h | Vanara.PInvoke.Kernel32+CPINFO
[CPINFOEX](http://msdn2.microsoft.com/en-us/library/dd317781) | Winnls.h | Vanara.PInvoke.Kernel32+CPINFOEX
[CPU_RATE_CONTROL_UNION](https://www.google.com/search?num=5&q=CPU_RATE_CONTROL_UNION+site%3Amicrosoft.com) | | Vanara.PInvoke.Kernel32+JOBOBJECT_CPU_RATE_CONTROL_INFORMATION+CPU_RATE_CONTROL_UNION
[CREATE_PROCESS_DEBUG_INFO](http://msdn2.microsoft.com/en-us/library/ms679286) | WinBase.h | Vanara.PInvoke.Kernel32+DEBUG_EVENT+EXCEPTION_INFO+CREATE_PROCESS_DEBUG_INFO
[CREATE_THREAD_DEBUG_INFO](http://msdn2.microsoft.com/en-us/library/ms679287) | WinBase.h | Vanara.PInvoke.Kernel32+DEBUG_EVENT+EXCEPTION_INFO+CREATE_THREAD_DEBUG_INFO
[CREATEFILE2_EXTENDED_PARAMETERS](http://msdn2.microsoft.com/en-us/library/hh449426) | FileAPI.h | Vanara.PInvoke.Kernel32+CREATEFILE2_EXTENDED_PARAMETERS
[CRITICAL_SECTION](https://www.google.com/search?num=5&q=CRITICAL_SECTION+site%3Amicrosoft.com) | | Vanara.PInvoke.Kernel32+CRITICAL_SECTION
[CURRENCYFMT](http://msdn2.microsoft.com/en-us/library/dd317784) | Winnls.h | Vanara.PInvoke.Kernel32+CURRENCYFMT
[DCB](http://msdn2.microsoft.com/en-us/library/aa363214) | Winbase.h | Vanara.PInvoke.Kernel32+DCB
[DETAIL](https://www.google.com/search?num=5&q=DETAIL+site%3Amicrosoft.com) | | Vanara.PInvoke.Kernel32+REASON_CONTEXT+REASON+DETAIL
[DETAIL](https://www.google.com/search?num=5&q=DETAIL+site%3Amicrosoft.com) | | Vanara.PInvoke.Kernel32+REASON_CONTEXT+DETAIL
[DUMMYSTRUCTNAME](https://www.google.com/search?num=5&q=DUMMYSTRUCTNAME+site%3Amicrosoft.com) | | Vanara.PInvoke.Kernel32+PACKAGE_VERSION+DUMMYSTRUCTNAME
[DYNAMIC_TIME_ZONE_INFORMATION](http://msdn2.microsoft.com/en-us/library/ms724253) | WinBase.h | Vanara.PInvoke.Kernel32+DYNAMIC_TIME_ZONE_INFORMATION
[ENCLAVE_CREATE_INFO_SGX](http://msdn2.microsoft.com/en-us/library/mt592867) | Winnt.h | Vanara.PInvoke.Kernel32+ENCLAVE_CREATE_INFO_SGX
@ -1112,15 +1141,37 @@ Native Structure | Header | Managed Structure
[EXCEPTION_RECORD](http://msdn2.microsoft.com/en-us/library/aa363082) | WinNT.h | Vanara.PInvoke.Kernel32+EXCEPTION_RECORD
[EXIT_PROCESS_DEBUG_INFO](http://msdn2.microsoft.com/en-us/library/ms679334) | WinBase.h | Vanara.PInvoke.Kernel32+DEBUG_EVENT+EXCEPTION_INFO+EXIT_PROCESS_DEBUG_INFO
[EXIT_THREAD_DEBUG_INFO](http://msdn2.microsoft.com/en-us/library/ms679335) | WinBase.h | Vanara.PInvoke.Kernel32+DEBUG_EVENT+EXCEPTION_INFO+EXIT_THREAD_DEBUG_INFO
[FILE_ALIGNMENT_INFO](http://msdn2.microsoft.com/en-us/library/a6d3cba0-d59b-45c2-a763-ecdde5b36348) | winbase.h | Vanara.PInvoke.Kernel32+FILE_ALIGNMENT_INFO
[FILE_ALLOCATION_INFO](http://msdn2.microsoft.com/en-us/library/909f1747-0099-407e-89a7-bec6331887da) | winbase.h | Vanara.PInvoke.Kernel32+FILE_ALLOCATION_INFO
[FILE_ATTRIBUTE_TAG_INFO](http://msdn2.microsoft.com/en-us/library/4a2467a2-c22a-4ee6-a40e-5603ea381adc) | winbase.h | Vanara.PInvoke.Kernel32+FILE_ATTRIBUTE_TAG_INFO
[FILE_BASIC_INFO](http://msdn2.microsoft.com/en-us/library/7765e430-cf6b-4ccf-b5e7-9fb6e15ca6d6) | winbase.h | Vanara.PInvoke.Kernel32+FILE_BASIC_INFO
[FILE_COMPRESSION_INFO](http://msdn2.microsoft.com/en-us/library/2f64e7cc-e23c-4e3d-8e17-0e8e38f1ea24) | winbase.h | Vanara.PInvoke.Kernel32+FILE_COMPRESSION_INFO
[FILE_DISPOSITION_INFO](http://msdn2.microsoft.com/en-us/library/07095f62-323a-463a-a33e-7e4ca9adcb69) | winbase.h | Vanara.PInvoke.Kernel32+FILE_DISPOSITION_INFO
[FILE_END_OF_FILE_INFO](http://msdn2.microsoft.com/en-us/library/77500ae7-654a-4b34-aaee-5c3844303271) | winbase.h | Vanara.PInvoke.Kernel32+FILE_END_OF_FILE_INFO
[FILE_FULL_DIR_INFO](http://msdn2.microsoft.com/en-us/library/606726e7-fd6b-4419-bd37-7282283007f8) | winbase.h | Vanara.PInvoke.Kernel32+FILE_FULL_DIR_INFO
[FILE_ID_128](http://msdn2.microsoft.com/en-us/library/254ea6a9-e1dd-4b97-91f7-2693065c4bb8) | winnt.h | Vanara.PInvoke.Kernel32+FILE_ID_128
[FILE_ID_BOTH_DIR_INFO](http://msdn2.microsoft.com/en-us/library/d7011ea4-e70a-4c03-a715-6144ce0c7029) | winbase.h | Vanara.PInvoke.Kernel32+FILE_ID_BOTH_DIR_INFO
[FILE_ID_EXTD_DIR_INFO](http://msdn2.microsoft.com/en-us/library/68f222c4-beb6-4be1-a31a-c5fbebbf76f7) | winbase.h | Vanara.PInvoke.Kernel32+FILE_ID_EXTD_DIR_INFO
[FILE_ID_INFO](http://msdn2.microsoft.com/en-us/library/e2774e29-1a90-44d6-9001-f73a98be6624) | winbase.h | Vanara.PInvoke.Kernel32+FILE_ID_INFO
[FILE_IO_PRIORITY_HINT_INFO](http://msdn2.microsoft.com/en-us/library/a142b8fd-b71c-4449-a8c6-fb23715d1576) | winbase.h | Vanara.PInvoke.Kernel32+FILE_IO_PRIORITY_HINT_INFO
[FILE_NAME_INFO](http://msdn2.microsoft.com/en-us/library/7ab98f41-b99e-4731-b803-921064a961c4) | winbase.h | Vanara.PInvoke.Kernel32+FILE_NAME_INFO
[FILE_STANDARD_INFO](http://msdn2.microsoft.com/en-us/library/da3187de-7de2-4307-a083-ae5fff6d8096) | winbase.h | Vanara.PInvoke.Kernel32+FILE_STANDARD_INFO
[FILE_STORAGE_INFO](http://msdn2.microsoft.com/en-us/library/1aa9585d-9001-4d94-babe-a39c8dde2332) | winbase.h | Vanara.PInvoke.Kernel32+FILE_STORAGE_INFO
[FILE_STREAM_INFO](http://msdn2.microsoft.com/en-us/library/36d1b0b3-bd6b-41e7-937a-4e8deef6f9da) | winbase.h | Vanara.PInvoke.Kernel32+FILE_STREAM_INFO
[FILEMUIINFO](http://msdn2.microsoft.com/en-us/library/dd318039) | Winnls.h | Vanara.PInvoke.Kernel32+FILEMUIINFO
[FLOATING_SAVE_AREA](http://msdn2.microsoft.com/en-us/library/ms681671) | WinNT.h | Vanara.PInvoke.Kernel32+CONTEXT+FLOATING_SAVE_AREA
[FOCUS_EVENT_RECORD](https://www.google.com/search?num=5&q=FOCUS_EVENT_RECORD+site%3Amicrosoft.com) | Wincon.h | Vanara.PInvoke.Kernel32+FOCUS_EVENT_RECORD
[GAMING_DEVICE_MODEL_INFORMATION](http://msdn2.microsoft.com/en-us/library/0D5A6358-0F82-4414-BD17-BDE22EDBBB15) | gamingdeviceinformation.h | Vanara.PInvoke.Kernel32+GAMING_DEVICE_MODEL_INFORMATION
[GenericReserved_](https://www.google.com/search?num=5&q=GenericReserved_+site%3Amicrosoft.com) | | Vanara.PInvoke.Kernel32+FILE_REMOTE_PROTOCOL_INFO+GenericReserved_
[GROUP_AFFINITY](http://msdn2.microsoft.com/en-us/library/dd405500) | WinNT.h | Vanara.PInvoke.Kernel32+GROUP_AFFINITY
[GROUP_RELATIONSHIP](http://msdn2.microsoft.com/en-us/library/3529ddef-04c5-4573-877d-c225da684e38) | winnt.h | Vanara.PInvoke.Kernel32+GROUP_RELATIONSHIP
[HACTCTX](https://www.google.com/search?num=5&q=HACTCTX+site%3Amicrosoft.com) | | Vanara.PInvoke.Kernel32+HACTCTX
[HARDWARE_COUNTER_DATA](http://msdn2.microsoft.com/en-us/library/dd796394) | Winnt.h | Vanara.PInvoke.Kernel32+HARDWARE_COUNTER_DATA
[HEAP_OPTIMIZE_RESOURCES_INFORMATION](https://www.google.com/search?num=5&q=HEAP_OPTIMIZE_RESOURCES_INFORMATION+site%3Amicrosoft.com) | | Vanara.PInvoke.Kernel32+HEAP_OPTIMIZE_RESOURCES_INFORMATION
[HEAP_SUMMARY](https://www.google.com/search?num=5&q=HEAP_SUMMARY+site%3Amicrosoft.com) | | Vanara.PInvoke.Kernel32+HEAP_SUMMARY
[HEAPENTRY32](http://msdn2.microsoft.com/en-us/library/c5f1dc66-d44f-4491-b0b7-961b163d0f1f) | tlhelp32.h | Vanara.PInvoke.Kernel32+HEAPENTRY32
[HEAPLIST32](http://msdn2.microsoft.com/en-us/library/61e01d23-9f15-44c5-9f6d-45df4809ccad) | tlhelp32.h | Vanara.PInvoke.Kernel32+HEAPLIST32
[HJOB](https://www.google.com/search?num=5&q=HJOB+site%3Amicrosoft.com) | | Vanara.PInvoke.Kernel32+HJOB
[INIT_ONCE](https://www.google.com/search?num=5&q=INIT_ONCE+site%3Amicrosoft.com) | | Vanara.PInvoke.Kernel32+INIT_ONCE
[INPUT_RECORD](https://www.google.com/search?num=5&q=INPUT_RECORD+site%3Amicrosoft.com) | Wincon.h | Vanara.PInvoke.Kernel32+INPUT_RECORD
[INPUT_RECORD_EVENT](https://www.google.com/search?num=5&q=INPUT_RECORD_EVENT+site%3Amicrosoft.com) | | Vanara.PInvoke.Kernel32+INPUT_RECORD+INPUT_RECORD_EVENT
@ -1149,19 +1200,19 @@ Native Structure | Header | Managed Structure
[JOBOBJECT_SECURITY_LIMIT_INFORMATION](http://msdn2.microsoft.com/en-us/library/ms684159) | WinNT.h | Vanara.PInvoke.Kernel32+JOBOBJECT_SECURITY_LIMIT_INFORMATION
[KEY_EVENT_RECORD](https://www.google.com/search?num=5&q=KEY_EVENT_RECORD+site%3Amicrosoft.com) | Wincon.h | Vanara.PInvoke.Kernel32+KEY_EVENT_RECORD
[LDT_ENTRY](http://msdn2.microsoft.com/en-us/library/ms680348) | WinNT.h | Vanara.PInvoke.Kernel32+LDT_ENTRY
[LOAD_DLL_DEBUG_INFO](http://msdn2.microsoft.com/en-us/library/ms680351) | WinBase.h | Vanara.PInvoke.Kernel32+DEBUG_EVENT+EXCEPTION_INFO+LOAD_DLL_DEBUG_INFO
[M128A](https://www.google.com/search?num=5&q=M128A+site%3Amicrosoft.com) | | Vanara.PInvoke.Kernel32+CONTEXT64+M128A
[MEMORY_BASIC_INFORMATION](http://msdn2.microsoft.com/en-us/library/dc3fa48e-0986-49cc-88a9-ff8179fbe5f0) | winnt.h | Vanara.PInvoke.Kernel32+MEMORY_BASIC_INFORMATION
[MEMORY_PRIORITY_INFORMATION](http://msdn2.microsoft.com/en-us/library/hh448387) | WinBase.h | Vanara.PInvoke.Kernel32+MEMORY_PRIORITY_INFORMATION
[MEMORYSTATUS](http://msdn2.microsoft.com/en-us/library/aa366772) | WinBase.h | Vanara.PInvoke.Kernel32+MEMORYSTATUS
[MEMORYSTATUSEX](http://msdn2.microsoft.com/en-us/library/aa366770) | WinBase.h | Vanara.PInvoke.Kernel32+MEMORYSTATUSEX
[MENU_EVENT_RECORD](https://www.google.com/search?num=5&q=MENU_EVENT_RECORD+site%3Amicrosoft.com) | Wincon.h | Vanara.PInvoke.Kernel32+MENU_EVENT_RECORD
[MODULEENTRY32](http://msdn2.microsoft.com/en-us/library/305fab35-625c-42e3-a434-e2513e4c8870) | tlhelp32.h | Vanara.PInvoke.Kernel32+MODULEENTRY32
[MODULEINFO](http://msdn2.microsoft.com/en-us/library/583caafe-7fa3-4041-b5bc-4e8899b3a08a) | psapi.h | Vanara.PInvoke.Kernel32+MODULEINFO
[MOUSE_EVENT_RECORD](https://www.google.com/search?num=5&q=MOUSE_EVENT_RECORD+site%3Amicrosoft.com) | Wincon.h | Vanara.PInvoke.Kernel32+MOUSE_EVENT_RECORD
[Mutant](https://www.google.com/search?num=5&q=Mutant+site%3Amicrosoft.com) | | Vanara.PInvoke.Kernel32+PSS_HANDLE_ENTRY+Mutant
[NamespaceHandle](https://www.google.com/search?num=5&q=NamespaceHandle+site%3Amicrosoft.com) | | Vanara.PInvoke.Kernel32+NamespaceHandle
[NLSVERSIONINFO](http://msdn2.microsoft.com/en-us/library/dd319086) | Winnls.h | Vanara.PInvoke.Kernel32+NLSVERSIONINFO
[NLSVERSIONINFOEX](http://msdn2.microsoft.com/en-us/library/dd319087) | Winnls.h | Vanara.PInvoke.Kernel32+NLSVERSIONINFOEX
[NUMA_NODE_RELATIONSHIP](http://msdn2.microsoft.com/en-us/library/a4e4c994-c4af-4b4f-8684-6037bcba35a9) | winnt.h | Vanara.PInvoke.Kernel32+NUMA_NODE_RELATIONSHIP
[NUMBERFMT](http://msdn2.microsoft.com/en-us/library/dd319095) | Winnls.h | Vanara.PInvoke.Kernel32+NUMBERFMT
[OFSTRUCT](http://msdn2.microsoft.com/en-us/library/aa365282) | WinBase.h | Vanara.PInvoke.Kernel32+OFSTRUCT
[OSVERSIONINFOEX](http://msdn2.microsoft.com/en-us/library/ms724833) | Winnt.h | Vanara.PInvoke.Kernel32+OSVERSIONINFOEX
@ -1171,9 +1222,9 @@ Native Structure | Header | Managed Structure
[PACKAGE_VERSION](http://msdn2.microsoft.com/en-us/library/8543DF84-A908-4DF5-AEE6-169FECB2AA97) | appmodel.h | Vanara.PInvoke.Kernel32+PACKAGE_VERSION
[PERFORMANCE_DATA](http://msdn2.microsoft.com/en-us/library/dd796401) | Winnt.h | Vanara.PInvoke.Kernel32+PERFORMANCE_DATA
[PERFORMANCE_INFORMATION](http://msdn2.microsoft.com/en-us/library/efc47f6e-1a60-4e77-9e5d-c725f9042ab8) | psapi.h | Vanara.PInvoke.Kernel32+PERFORMANCE_INFORMATION
[PerformanceDataHandle](https://www.google.com/search?num=5&q=PerformanceDataHandle+site%3Amicrosoft.com) | | Vanara.PInvoke.Kernel32+PerformanceDataHandle
[PollContinue](https://www.google.com/search?num=5&q=PollContinue+site%3Amicrosoft.com) | | Vanara.PInvoke.Kernel32+COPYFILE2_MESSAGE+PollContinue
[Process](https://www.google.com/search?num=5&q=Process+site%3Amicrosoft.com) | | Vanara.PInvoke.Kernel32+PSS_HANDLE_ENTRY+Process
[PROCESS_INFORMATION](http://msdn2.microsoft.com/en-us/library/ms684873) | WinBase.h | Vanara.PInvoke.Kernel32+PROCESS_INFORMATION
[PROCESS_MEMORY_COUNTERS](http://msdn2.microsoft.com/en-us/library/288b5865-28a3-478b-ad32-c710fe4f3a81) | psapi.h | Vanara.PInvoke.Kernel32+PROCESS_MEMORY_COUNTERS
[PROCESS_MEMORY_EXHAUSTION_INFO](http://msdn2.microsoft.com/en-us/library/mt767997) | WinBase.h | Vanara.PInvoke.Kernel32+PROCESS_MEMORY_EXHAUSTION_INFO
[PROCESS_MITIGATION_ASLR_POLICY](http://msdn2.microsoft.com/en-us/library/hh769086) | WinNT.h | Vanara.PInvoke.Kernel32+PROCESS_MITIGATION_ASLR_POLICY
@ -1192,7 +1243,12 @@ Native Structure | Header | Managed Structure
[PROCESS_POWER_THROTTLING_STATE](http://msdn2.microsoft.com/en-us/library/mt804324) | Processthreadsapi.h | Vanara.PInvoke.Kernel32+PROCESS_POWER_THROTTLING_STATE
[PROCESS_PROTECTION_LEVEL_INFORMATION](http://msdn2.microsoft.com/en-us/library/mt823702) | Processthreadsapi.h | Vanara.PInvoke.Kernel32+PROCESS_PROTECTION_LEVEL_INFORMATION
[PROCESSENTRY32](http://msdn2.microsoft.com/en-us/library/9e2f7345-52bf-4bfc-9761-90b0b374c727) | tlhelp32.h | Vanara.PInvoke.Kernel32+PROCESSENTRY32
[PROCESSOR_GROUP_INFO](http://msdn2.microsoft.com/en-us/library/6ff9cc3c-34e7-4dc4-94cd-6ed278dfaa03) | winnt.h | Vanara.PInvoke.Kernel32+PROCESSOR_GROUP_INFO
[PROCESSOR_NUMBER](http://msdn2.microsoft.com/en-us/library/dd405505) | WinNT.h | Vanara.PInvoke.Kernel32+PROCESSOR_NUMBER
[PROCESSOR_RELATIONSHIP](http://msdn2.microsoft.com/en-us/library/1efda80d-cf5b-4312-801a-ea3585b152ac) | winnt.h | Vanara.PInvoke.Kernel32+PROCESSOR_RELATIONSHIP
[ProcessorRelationUnion](https://www.google.com/search?num=5&q=ProcessorRelationUnion+site%3Amicrosoft.com) | | Vanara.PInvoke.Kernel32+SYSTEM_LOGICAL_PROCESSOR_INFORMATION+ProcessorRelationUnion
[ProcessorRelationUnion](https://www.google.com/search?num=5&q=ProcessorRelationUnion+site%3Amicrosoft.com) | | Vanara.PInvoke.Kernel32+SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX+ProcessorRelationUnion
[ProtocolSpecificReserved_](https://www.google.com/search?num=5&q=ProtocolSpecificReserved_+site%3Amicrosoft.com) | | Vanara.PInvoke.Kernel32+FILE_REMOTE_PROTOCOL_INFO+ProtocolSpecificReserved_
[PSAPI_WS_WATCH_INFORMATION](http://msdn2.microsoft.com/en-us/library/61083366-2a55-431c-807a-3eb85ba0b347) | psapi.h | Vanara.PInvoke.Kernel32+PSAPI_WS_WATCH_INFORMATION
[PSAPI_WS_WATCH_INFORMATION_EX](http://msdn2.microsoft.com/en-us/library/fb0429b1-ec93-401c-aeb1-f7e9d9acfa47) | psapi.h | Vanara.PInvoke.Kernel32+PSAPI_WS_WATCH_INFORMATION_EX
[PSS_ALLOCATOR](http://msdn2.microsoft.com/en-us/library/54225F76-9A2E-4CB3-A3B5-9F9DB5551D53) | processsnapshot.h | Vanara.PInvoke.Kernel32+PSS_ALLOCATOR
@ -1208,17 +1264,25 @@ Native Structure | Header | Managed Structure
[PSS_VA_CLONE_INFORMATION](http://msdn2.microsoft.com/en-us/library/F93D61B0-EDB2-4560-A69F-CF839EC98B53) | processsnapshot.h | Vanara.PInvoke.Kernel32+PSS_VA_CLONE_INFORMATION
[PSS_VA_SPACE_ENTRY](http://msdn2.microsoft.com/en-us/library/69B8F6A3-76DF-421B-B89B-73BA3254F897) | processsnapshot.h | Vanara.PInvoke.Kernel32+PSS_VA_SPACE_ENTRY
[PSS_VA_SPACE_INFORMATION](http://msdn2.microsoft.com/en-us/library/F38FF7EB-DDC5-4692-8F57-8D633193D891) | processsnapshot.h | Vanara.PInvoke.Kernel32+PSS_VA_SPACE_INFORMATION
[PTP_CALLBACK_ENVIRON](https://www.google.com/search?num=5&q=PTP_CALLBACK_ENVIRON+site%3Amicrosoft.com) | threadpoolapiset.h | Vanara.PInvoke.Kernel32+PTP_CALLBACK_ENVIRON
[REASON](https://www.google.com/search?num=5&q=REASON+site%3Amicrosoft.com) | | Vanara.PInvoke.Kernel32+REASON_CONTEXT+REASON
[PTP_CALLBACK_INSTANCE](https://www.google.com/search?num=5&q=PTP_CALLBACK_INSTANCE+site%3Amicrosoft.com) | | Vanara.PInvoke.Kernel32+PTP_CALLBACK_INSTANCE
[PTP_CLEANUP_GROUP](https://www.google.com/search?num=5&q=PTP_CLEANUP_GROUP+site%3Amicrosoft.com) | | Vanara.PInvoke.Kernel32+PTP_CLEANUP_GROUP
[PTP_IO](https://www.google.com/search?num=5&q=PTP_IO+site%3Amicrosoft.com) | | Vanara.PInvoke.Kernel32+PTP_IO
[PTP_POOL](https://www.google.com/search?num=5&q=PTP_POOL+site%3Amicrosoft.com) | | Vanara.PInvoke.Kernel32+PTP_POOL
[PTP_TIMER](https://www.google.com/search?num=5&q=PTP_TIMER+site%3Amicrosoft.com) | | Vanara.PInvoke.Kernel32+PTP_TIMER
[PTP_WAIT](https://www.google.com/search?num=5&q=PTP_WAIT+site%3Amicrosoft.com) | | Vanara.PInvoke.Kernel32+PTP_WAIT
[PTP_WORK](https://www.google.com/search?num=5&q=PTP_WORK+site%3Amicrosoft.com) | | Vanara.PInvoke.Kernel32+PTP_WORK
[REASON_CONTEXT](http://msdn2.microsoft.com/en-us/library/dd405536) | MinWinBase.h | Vanara.PInvoke.Kernel32+REASON_CONTEXT
[REGION_DATA](https://www.google.com/search?num=5&q=REGION_DATA+site%3Amicrosoft.com) | | Vanara.PInvoke.Kernel32+PROCESS_HEAP_ENTRY+BLOCK_REGION_UNION+REGION_DATA
[RIP_INFO](http://msdn2.microsoft.com/en-us/library/ms680587) | WinBase.h | Vanara.PInvoke.Kernel32+DEBUG_EVENT+EXCEPTION_INFO+RIP_INFO
[Section](https://www.google.com/search?num=5&q=Section+site%3Amicrosoft.com) | | Vanara.PInvoke.Kernel32+PSS_HANDLE_ENTRY+Section
[Semaphore](https://www.google.com/search?num=5&q=Semaphore+site%3Amicrosoft.com) | | Vanara.PInvoke.Kernel32+PSS_HANDLE_ENTRY+Semaphore
[Server](https://www.google.com/search?num=5&q=Server+site%3Amicrosoft.com) | | Vanara.PInvoke.Kernel32+FILE_REMOTE_PROTOCOL_INFO+Server
[Share](https://www.google.com/search?num=5&q=Share+site%3Amicrosoft.com) | | Vanara.PInvoke.Kernel32+FILE_REMOTE_PROTOCOL_INFO+Share
[SLIST_ENTRY](http://msdn2.microsoft.com/en-us/library/ff563805) | Wdm.h | Vanara.PInvoke.Kernel32+SLIST_ENTRY
[SMALL_RECT](https://www.google.com/search?num=5&q=SMALL_RECT+site%3Amicrosoft.com) | Wincon.h | Vanara.PInvoke.Kernel32+SMALL_RECT
[SRWLOCK](https://www.google.com/search?num=5&q=SRWLOCK+site%3Amicrosoft.com) | | Vanara.PInvoke.Kernel32+SRWLOCK
[STARTUPINFO](http://msdn2.microsoft.com/en-us/library/ms686331) | WinBase.h | Vanara.PInvoke.Kernel32+STARTUPINFO
[STARTUPINFOEX](http://msdn2.microsoft.com/en-us/library/61203f57-292d-4ea1-88f4-a3b05012d7a3) | winbase.h | Vanara.PInvoke.Kernel32+STARTUPINFOEX
[StreamFinished](https://www.google.com/search?num=5&q=StreamFinished+site%3Amicrosoft.com) | | Vanara.PInvoke.Kernel32+COPYFILE2_MESSAGE+StreamFinished
[StreamStarted](https://www.google.com/search?num=5&q=StreamStarted+site%3Amicrosoft.com) | | Vanara.PInvoke.Kernel32+COPYFILE2_MESSAGE+StreamStarted
[SYNCHRONIZATION_BARRIER](https://www.google.com/search?num=5&q=SYNCHRONIZATION_BARRIER+site%3Amicrosoft.com) | | Vanara.PInvoke.Kernel32+SYNCHRONIZATION_BARRIER
@ -1226,6 +1290,8 @@ Native Structure | Header | Managed Structure
[SYSTEM_CPU_SET_INFORMATION1](https://www.google.com/search?num=5&q=SYSTEM_CPU_SET_INFORMATION1+site%3Amicrosoft.com) | | Vanara.PInvoke.Kernel32+SYSTEM_CPU_SET_INFORMATION1
[SYSTEM_CPU_UNION](https://www.google.com/search?num=5&q=SYSTEM_CPU_UNION+site%3Amicrosoft.com) | | Vanara.PInvoke.Kernel32+SYSTEM_CPU_SET_INFORMATION+SYSTEM_CPU_UNION
[SYSTEM_INFO](http://msdn2.microsoft.com/en-us/library/ms724958) | Winbase.h | Vanara.PInvoke.Kernel32+SYSTEM_INFO
[SYSTEM_LOGICAL_PROCESSOR_INFORMATION](http://msdn2.microsoft.com/en-us/library/ms686694) | WinNT.h | Vanara.PInvoke.Kernel32+SYSTEM_LOGICAL_PROCESSOR_INFORMATION
[SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX](http://msdn2.microsoft.com/en-us/library/6ff16cda-c1dc-4d5c-ac60-756653cd6b07) | winnt.h | Vanara.PInvoke.Kernel32+SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX
[SYSTEM_POWER_STATUS](http://msdn2.microsoft.com/en-us/library/aa373232) | Winbase.h | Vanara.PInvoke.Kernel32+SYSTEM_POWER_STATUS
[SYSTEM_PROCESSOR_CYCLE_TIME_INFORMATION](https://www.google.com/search?num=5&q=SYSTEM_PROCESSOR_CYCLE_TIME_INFORMATION+site%3Amicrosoft.com) | WinNT.h | Vanara.PInvoke.Kernel32+SYSTEM_PROCESSOR_CYCLE_TIME_INFORMATION
[TAPE_GET_DRIVE_PARAMETERS](http://msdn2.microsoft.com/en-us/library/aa362562) | Winnt.h | Vanara.PInvoke.Kernel32+TAPE_GET_DRIVE_PARAMETERS

View File

@ -12,76 +12,86 @@ namespace Vanara.PInvoke
{
/// <summary>Do not use minutes or seconds.</summary>
TIME_NOMINUTESORSECONDS = 1,
/// <summary>Do not use seconds.</summary>
TIME_NOSECONDS = 2,
/// <summary>Do not use a time marker.</summary>
TIME_NOTIMEMARKER = 4,
/// <summary>Always use a 24-hour time format.</summary>
TIME_FORCE24HOURFORMAT = 8,
/// <summary>
/// Windows Me/98, Windows 2000: System default Windows ANSI code page (ACP) instead of the locale code page used for string translation. See Code
/// Page Identifiers for a list of ANSI and other code pages.
/// Windows Me/98, Windows 2000: System default Windows ANSI code page (ACP) instead of the locale code page used for string
/// translation. See Code Page Identifiers for a list of ANSI and other code pages.
/// </summary>
LOCAL_USE_CP_ACP = 0x40000000,
/// <summary>
/// No user override. In several functions, for example, GetLocaleInfo and GetLocaleInfoEx, this constant causes the function to bypass any user
/// override and use the system default value for any other constant specified in the function call. The information is retrieved from the locale
/// database, even if the identifier indicates the current locale and the user has changed some of the values using the Control Panel, or if an
/// application has changed these values by using SetLocaleInfo. If this constant is not specified, any values that the user has configured from the
/// Control Panel or that an application has configured using SetLocaleInfo take precedence over the database settings for the current system default locale.
/// No user override. In several functions, for example, GetLocaleInfo and GetLocaleInfoEx, this constant causes the function to
/// bypass any user override and use the system default value for any other constant specified in the function call. The
/// information is retrieved from the locale database, even if the identifier indicates the current locale and the user has
/// changed some of the values using the Control Panel, or if an application has changed these values by using SetLocaleInfo. If
/// this constant is not specified, any values that the user has configured from the Control Panel or that an application has
/// configured using SetLocaleInfo take precedence over the database settings for the current system default locale.
/// </summary>
LOCALE_NOUSEROVERRIDE = 0x80000000
}
/// <summary>
/// Formats a date as a date string for a locale specified by the locale identifier. The function formats either a specified date or the local system date.
/// Formats a date as a date string for a locale specified by the locale identifier. The function formats either a specified date or
/// the local system date.
/// </summary>
/// <param name="Locale">
/// Locale identifier that specifies the locale this function formats the date string for. You can use the <c>MAKELCID</c> macro to create a locale
/// identifier or use one of the following predefined values.
/// Locale identifier that specifies the locale this function formats the date string for. You can use the <c>MAKELCID</c> macro to
/// create a locale identifier or use one of the following predefined values.
/// </param>
/// <param name="dwFlags">Flags specifying date format options. For detailed definitions, see the dwFlags parameter of <c>GetDateFormatEx</c>.</param>
/// <param name="lpDate">
/// Pointer to a <c>SYSTEMTIME</c> structure that contains the date information to format. The application sets this parameter to <c>NULL</c> if the
/// function is to use the current local system date.
/// Pointer to a <c>SYSTEMTIME</c> structure that contains the date information to format. The application sets this parameter to
/// <c>NULL</c> if the function is to use the current local system date.
/// </param>
/// <param name="lpFormat">
/// <para>
/// Pointer to a format picture string that is used to form the date. Possible values for the format picture string are defined in Day, Month, Year, and
/// Era Format Pictures.
/// Pointer to a format picture string that is used to form the date. Possible values for the format picture string are defined in
/// Day, Month, Year, and Era Format Pictures.
/// </para>
/// <para>
/// The function uses the specified locale only for information not specified in the format picture string, for example, the day and month names for the
/// locale. The application can set this parameter to <c>NULL</c> to format the string according to the date format for the specified locale.
/// The function uses the specified locale only for information not specified in the format picture string, for example, the day and
/// month names for the locale. The application can set this parameter to <c>NULL</c> to format the string according to the date
/// format for the specified locale.
/// </para>
/// </param>
/// <param name="lpDateStr">Pointer to a buffer in which this function retrieves the formatted date string.</param>
/// <param name="cchDate">
/// Size, in characters, of the lpDateStr buffer. The application can set this parameter to 0 to return the buffer size required to hold the formatted
/// date string. In this case, the buffer indicated by lpDateStr is not used.
/// Size, in characters, of the lpDateStr buffer. The application can set this parameter to 0 to return the buffer size required to
/// hold the formatted date string. In this case, the buffer indicated by lpDateStr is not used.
/// </param>
/// <returns>
/// <para>
/// Returns the number of characters written to the lpDateStr buffer if successful. If the cchDate parameter is set to 0, the function returns the number
/// of characters required to hold the formatted date string, including the terminating null character.
/// Returns the number of characters written to the lpDateStr buffer if successful. If the cchDate parameter is set to 0, the
/// function returns the number of characters required to hold the formatted date string, including the terminating null character.
/// </para>
/// <para>
/// The function returns 0 if it does not succeed. To get extended error information, the application can call <c>GetLastError</c>, which can return one
/// of the following error codes:
/// The function returns 0 if it does not succeed. To get extended error information, the application can call <c>GetLastError</c>,
/// which can return one of the following error codes:
/// </para>
/// </returns>
// int GetDateFormat( _In_ LCID Locale, _In_ DWORD dwFlags, _In_opt_ const SYSTEMTIME *lpDate, _In_opt_ LPCTSTR lpFormat, _Out_opt_ LPTSTR lpDateStr,
// _In_ int cchDate); https://msdn.microsoft.com/en-us/library/windows/desktop/dd318086(v=vs.85).aspx
// int GetDateFormat( _In_ LCID Locale, _In_ DWORD dwFlags, _In_opt_ const SYSTEMTIME *lpDate, _In_opt_ LPCTSTR lpFormat, _Out_opt_
// LPTSTR lpDateStr, _In_ int cchDate); https://msdn.microsoft.com/en-us/library/windows/desktop/dd318086(v=vs.85).aspx
[DllImport(Lib.Kernel32, SetLastError = true, CharSet = CharSet.Auto)]
[PInvokeData("Datetimeapi.h", MSDNShortId = "dd318086")]
public static extern int GetDateFormat(uint Locale, DATE_FORMAT dwFlags, [In] ref SYSTEMTIME lpDate, [In] string lpFormat, [Out] StringBuilder lpDateStr, int cchDate);
public static extern int GetDateFormat(uint Locale, DATE_FORMAT dwFlags, in SYSTEMTIME lpDate, string lpFormat, StringBuilder lpDateStr, int cchDate);
/// <summary>Formats a date as a date string for a locale specified by name. The function formats either a specified date or the local system date.</summary>
/// <summary>
/// Formats a date as a date string for a locale specified by name. The function formats either a specified date or the local system date.
/// </summary>
/// <param name="lpLocaleName">Pointer to a locale name, or one of the following predefined values.</param>
/// <param name="dwFlags">
/// <para>
/// Flags specifying various function options that can be set if lpFormat is set to <c>NULL</c>. The application can specify a combination of the
/// following values and LOCALE_USE_CP_ACP or LOCALE_NOUSEROVERRIDE.
/// Flags specifying various function options that can be set if lpFormat is set to <c>NULL</c>. The application can specify a
/// combination of the following values and LOCALE_USE_CP_ACP or LOCALE_NOUSEROVERRIDE.
/// </para>
/// <para>
/// <list type="table">
@ -92,9 +102,9 @@ namespace Vanara.PInvoke
/// <item>
/// <term>DATE_AUTOLAYOUT</term>
/// <term>
/// Windows 7 and later: Detect the need for right-to-left and left-to-right reading layout using the locale and calendar information, and add marks
/// accordingly. This value cannot be used with DATE_LTRREADING or DATE_RTLREADING. DATE_AUTOLAYOUT is preferred over DATE_LTRREADING and DATE_RTLREADING
/// because it uses the locales and calendars to determine the correct addition of marks.
/// Windows 7 and later: Detect the need for right-to-left and left-to-right reading layout using the locale and calendar
/// information, and add marks accordingly. This value cannot be used with DATE_LTRREADING or DATE_RTLREADING. DATE_AUTOLAYOUT is
/// preferred over DATE_LTRREADING and DATE_RTLREADING because it uses the locales and calendars to determine the correct addition of marks.
/// </term>
/// </item>
/// <item>
@ -116,9 +126,9 @@ namespace Vanara.PInvoke
/// <item>
/// <term>DATE_USE_ALT_CALENDAR</term>
/// <term>
/// Use the alternate calendar, if one exists, to format the date string. If this flag is set, the function uses the default format for that alternate
/// calendar, rather than using any user overrides. The user overrides will be used only in the event that there is no default format for the specified
/// alternate calendar.
/// Use the alternate calendar, if one exists, to format the date string. If this flag is set, the function uses the default format
/// for that alternate calendar, rather than using any user overrides. The user overrides will be used only in the event that there
/// is no default format for the specified alternate calendar.
/// </term>
/// </item>
/// <item>
@ -128,97 +138,103 @@ namespace Vanara.PInvoke
/// <item>
/// <term>DATE_MONTHDAY</term>
/// <term>
/// Windows 10: Use the combination of month and day formats appropriate for the specified locale. This value cannot be used with DATE_YEARMONTH,
/// DATE_SHORTDATE, or DATE_LONGDATE.
/// Windows 10: Use the combination of month and day formats appropriate for the specified locale. This value cannot be used with
/// DATE_YEARMONTH, DATE_SHORTDATE, or DATE_LONGDATE.
/// </term>
/// </item>
/// </list>
/// </para>
/// <para>
/// If the application does not specify DATE_YEARMONTH, DATE_MONTHDAY, DATE_SHORTDATE, or DATE_LONGDATE, and lpFormat is set to <c>NULL</c>,
/// DATE_SHORTDATE is the default.
/// If the application does not specify DATE_YEARMONTH, DATE_MONTHDAY, DATE_SHORTDATE, or DATE_LONGDATE, and lpFormat is set to
/// <c>NULL</c>, DATE_SHORTDATE is the default.
/// </para>
/// </param>
/// <param name="lpDate">
/// Pointer to a <c>SYSTEMTIME</c> structure that contains the date information to format. The application can set this parameter to <c>NULL</c> if the
/// function is to use the current local system date.
/// Pointer to a <c>SYSTEMTIME</c> structure that contains the date information to format. The application can set this parameter to
/// <c>NULL</c> if the function is to use the current local system date.
/// </param>
/// <param name="lpFormat">
/// <para>
/// Pointer to a format picture string that is used to form the date. Possible values for the format picture string are defined in Day, Month, Year, and
/// Era Format Pictures.
/// Pointer to a format picture string that is used to form the date. Possible values for the format picture string are defined in
/// Day, Month, Year, and Era Format Pictures.
/// </para>
/// <para>For example, to get the date string "Wed, Aug 31 94", the application uses the picture string "ddd',' MMM dd yy".</para>
/// <para>
/// The function uses the specified locale only for information not specified in the format picture string, for example, the day and month names for the
/// locale. The application can set this parameter to <c>NULL</c> to format the string according to the date format for the specified locale.
/// The function uses the specified locale only for information not specified in the format picture string, for example, the day and
/// month names for the locale. The application can set this parameter to <c>NULL</c> to format the string according to the date
/// format for the specified locale.
/// </para>
/// </param>
/// <param name="lpDateStr">Pointer to a buffer in which this function retrieves the formatted date string.</param>
/// <param name="cchDate">
/// Size, in characters, of the lpDateStr buffer. The application can set this parameter to 0 to return the buffer size required to hold the formatted
/// date string. In this case, the buffer indicated by lpDateStr is not used.
/// Size, in characters, of the lpDateStr buffer. The application can set this parameter to 0 to return the buffer size required to
/// hold the formatted date string. In this case, the buffer indicated by lpDateStr is not used.
/// </param>
/// <param name="lpCalendar">Reserved; must set to <c>NULL</c>.</param>
/// <returns>
/// <para>
/// Returns the number of characters written to the lpDateStr buffer if successful. If the cchDate parameter is set to 0, the function returns the number
/// of characters required to hold the formatted date string, including the terminating null character.
/// Returns the number of characters written to the lpDateStr buffer if successful. If the cchDate parameter is set to 0, the
/// function returns the number of characters required to hold the formatted date string, including the terminating null character.
/// </para>
/// <para>
/// This function returns 0 if it does not succeed. To get extended error information, the application can call <c>GetLastError</c>, which can return one
/// of the following error codes:
/// This function returns 0 if it does not succeed. To get extended error information, the application can call <c>GetLastError</c>,
/// which can return one of the following error codes:
/// </para>
/// </returns>
// int GetDateFormatEx( _In_opt_ LPCWSTR lpLocaleName, _In_ DWORD dwFlags, _In_opt_ const SYSTEMTIME *lpDate, _In_opt_ LPCWSTR lpFormat, _Out_opt_ LPWSTR
// lpDateStr, _In_ int cchDate, _In_opt_ LPCWSTR lpCalendar); https://msdn.microsoft.com/en-us/library/windows/desktop/dd318088(v=vs.85).aspx
// int GetDateFormatEx( _In_opt_ LPCWSTR lpLocaleName, _In_ DWORD dwFlags, _In_opt_ const SYSTEMTIME *lpDate, _In_opt_ LPCWSTR
// lpFormat, _Out_opt_ LPWSTR lpDateStr, _In_ int cchDate, _In_opt_ LPCWSTR lpCalendar); https://msdn.microsoft.com/en-us/library/windows/desktop/dd318088(v=vs.85).aspx
[DllImport(Lib.Kernel32, SetLastError = true, ExactSpelling = true, CharSet = CharSet.Unicode)]
[PInvokeData("Datetimeapi.h", MSDNShortId = "dd318088")]
public static extern int GetDateFormatEx(string lpLocaleName, DATE_FORMAT dwFlags, [In] ref SYSTEMTIME lpDate, [In] string lpFormat, [Out] StringBuilder lpDateStr, int cchDate);
public static extern int GetDateFormatEx(string lpLocaleName, DATE_FORMAT dwFlags, in SYSTEMTIME lpDate, string lpFormat, StringBuilder lpDateStr, int cchDate);
/// <summary>
/// Formats time as a time string for a locale specified by identifier. The function formats either a specified time or the local system time.
/// Formats time as a time string for a locale specified by identifier. The function formats either a specified time or the local
/// system time.
/// </summary>
/// <param name="Locale">
/// Locale identifier that specifies the locale. You can use the <c>MAKELCID</c> macro to create a locale identifier or use one of the following
/// predefined values.
/// Locale identifier that specifies the locale. You can use the <c>MAKELCID</c> macro to create a locale identifier or use one of
/// the following predefined values.
/// </param>
/// <param name="dwFlags">Flags specifying time format options. For detailed definitions see the dwFlags parameter of <c>GetTimeFormatEx</c>.</param>
/// <param name="lpTime">
/// Pointer to a <c>SYSTEMTIME</c> structure that contains the time information to format. The application can set this parameter to <c>NULL</c> if the
/// function is to use the current local system time.
/// Pointer to a <c>SYSTEMTIME</c> structure that contains the time information to format. The application can set this parameter to
/// <c>NULL</c> if the function is to use the current local system time.
/// </param>
/// <param name="lpFormat">
/// Pointer to a format picture to use to format the time string. If the application sets this parameter to <c>NULL</c>, the function formats the string
/// according to the time format of the specified locale. If the application does not set the parameter to <c>NULL</c>, the function uses the locale only
/// for information not specified in the format picture string, for example, the locale-specific time markers. For information about the format picture
/// string, see the Remarks section.
/// Pointer to a format picture to use to format the time string. If the application sets this parameter to <c>NULL</c>, the function
/// formats the string according to the time format of the specified locale. If the application does not set the parameter to
/// <c>NULL</c>, the function uses the locale only for information not specified in the format picture string, for example, the
/// locale-specific time markers. For information about the format picture string, see the Remarks section.
/// </param>
/// <param name="lpTimeStr">Pointer to a buffer in which this function retrieves the formatted time string.</param>
/// <param name="cchTime">
/// Size, in TCHAR values, for the time string buffer indicated by lpTimeStr. Alternatively, the application can set this parameter to 0. In this case,
/// the function returns the required size for the time string buffer, and does not use the lpTimeStr parameter.
/// Size, in TCHAR values, for the time string buffer indicated by lpTimeStr. Alternatively, the application can set this parameter
/// to 0. In this case, the function returns the required size for the time string buffer, and does not use the lpTimeStr parameter.
/// </param>
/// <returns>
/// <para>
/// Returns the number of TCHAR values retrieved in the buffer indicated by lpTimeStr. If the cchTime parameter is set to 0, the function returns the
/// size of the buffer required to hold the formatted time string, including a terminating null character.
/// Returns the number of TCHAR values retrieved in the buffer indicated by lpTimeStr. If the cchTime parameter is set to 0, the
/// function returns the size of the buffer required to hold the formatted time string, including a terminating null character.
/// </para>
/// <para>
/// This function returns 0 if it does not succeed. To get extended error information, the application can call <c>GetLastError</c>, which can return one
/// of the following error codes:
/// This function returns 0 if it does not succeed. To get extended error information, the application can call <c>GetLastError</c>,
/// which can return one of the following error codes:
/// </para>
/// </returns>
// int GetTimeFormat( _In_ LCID Locale, _In_ DWORD dwFlags, _In_opt_ const SYSTEMTIME *lpTime, _In_opt_ LPCTSTR lpFormat, _Out_opt_ LPTSTR lpTimeStr,
// _In_ int cchTime); https://msdn.microsoft.com/en-us/library/windows/desktop/dd318130(v=vs.85).aspx
// int GetTimeFormat( _In_ LCID Locale, _In_ DWORD dwFlags, _In_opt_ const SYSTEMTIME *lpTime, _In_opt_ LPCTSTR lpFormat, _Out_opt_
// LPTSTR lpTimeStr, _In_ int cchTime); https://msdn.microsoft.com/en-us/library/windows/desktop/dd318130(v=vs.85).aspx
[DllImport(Lib.Kernel32, SetLastError = true, CharSet = CharSet.Auto)]
[PInvokeData("Datetimeapi.h", MSDNShortId = "dd318130")]
public static extern int GetTimeFormat(uint Locale, TIME_FORMAT dwFlags, [In] ref SYSTEMTIME lpTime, [In] string lpFormat, [Out] StringBuilder lpTimeStr, int cchTime);
public static extern int GetTimeFormat(uint Locale, TIME_FORMAT dwFlags, in SYSTEMTIME lpTime, string lpFormat, StringBuilder lpTimeStr, int cchTime);
/// <summary>Formats time as a time string for a locale specified by name. The function formats either a specified time or the local system time.</summary>
/// <summary>
/// Formats time as a time string for a locale specified by name. The function formats either a specified time or the local system time.
/// </summary>
/// <param name="lpLocaleName">Pointer to a locale name, or one of the following predefined values.</param>
/// <param name="dwFlags">
/// <para>Flags specifying time format options. The application can specify a combination of the following values and LOCALE_USE_CP_ACP or LOCALE_NOUSEROVERRIDE.</para>
/// <para>
/// Flags specifying time format options. The application can specify a combination of the following values and LOCALE_USE_CP_ACP or LOCALE_NOUSEROVERRIDE.
/// </para>
/// <para>
/// <list type="table">
/// <listheader>
@ -245,34 +261,34 @@ namespace Vanara.PInvoke
/// </para>
/// </param>
/// <param name="lpTime">
/// Pointer to a <c>SYSTEMTIME</c> structure that contains the time information to format. The application can set this parameter to <c>NULL</c> if the
/// function is to use the current local system time.
/// Pointer to a <c>SYSTEMTIME</c> structure that contains the time information to format. The application can set this parameter to
/// <c>NULL</c> if the function is to use the current local system time.
/// </param>
/// <param name="lpFormat">
/// Pointer to a format picture to use to format the time string. If the application sets this parameter to <c>NULL</c>, the function formats the string
/// according to the time format of the specified locale. If the application does not set the parameter to <c>NULL</c>, the function uses the locale only
/// for information not specified in the format picture string, for example, the locale-specific time markers. For information about the format picture
/// string, see the Remarks section.
/// Pointer to a format picture to use to format the time string. If the application sets this parameter to <c>NULL</c>, the function
/// formats the string according to the time format of the specified locale. If the application does not set the parameter to
/// <c>NULL</c>, the function uses the locale only for information not specified in the format picture string, for example, the
/// locale-specific time markers. For information about the format picture string, see the Remarks section.
/// </param>
/// <param name="lpTimeStr">Pointer to a buffer in which this function retrieves the formatted time string.</param>
/// <param name="cchTime">
/// Size, in characters, for the time string buffer indicated by lpTimeStr. Alternatively, the application can set this parameter to 0. In this case, the
/// function returns the required size for the time string buffer, and does not use the lpTimeStr parameter.
/// Size, in characters, for the time string buffer indicated by lpTimeStr. Alternatively, the application can set this parameter to
/// 0. In this case, the function returns the required size for the time string buffer, and does not use the lpTimeStr parameter.
/// </param>
/// <returns>
/// <para>
/// Returns the number of characters retrieved in the buffer indicated by lpTimeStr. If the cchTime parameter is set to 0, the function returns the size
/// of the buffer required to hold the formatted time string, including a terminating null character.
/// Returns the number of characters retrieved in the buffer indicated by lpTimeStr. If the cchTime parameter is set to 0, the
/// function returns the size of the buffer required to hold the formatted time string, including a terminating null character.
/// </para>
/// <para>
/// This function returns 0 if it does not succeed. To get extended error information, the application can call <c>GetLastError</c>, which can return one
/// of the following error codes:
/// This function returns 0 if it does not succeed. To get extended error information, the application can call <c>GetLastError</c>,
/// which can return one of the following error codes:
/// </para>
/// </returns>
// int GetTimeFormatEx( _In_opt_ LPCWSTR lpLocaleName, _In_ DWORD dwFlags, _In_opt_ const SYSTEMTIME *lpTime, _In_opt_ LPCWSTR lpFormat, _Out_opt_ LPWSTR
// lpTimeStr, _In_ int cchTime); https://msdn.microsoft.com/en-us/library/windows/desktop/dd318131(v=vs.85).aspx
// int GetTimeFormatEx( _In_opt_ LPCWSTR lpLocaleName, _In_ DWORD dwFlags, _In_opt_ const SYSTEMTIME *lpTime, _In_opt_ LPCWSTR
// lpFormat, _Out_opt_ LPWSTR lpTimeStr, _In_ int cchTime); https://msdn.microsoft.com/en-us/library/windows/desktop/dd318131(v=vs.85).aspx
[DllImport(Lib.Kernel32, SetLastError = true, ExactSpelling = true, CharSet = CharSet.Unicode)]
[PInvokeData("Datetimeapi.h", MSDNShortId = "dd318131")]
public static extern int GetTimeFormatEx(string lpLocaleName, TIME_FORMAT dwFlags, [In] ref SYSTEMTIME lpTime, [In] string lpFormat, [Out] StringBuilder lpTimeStr, int cchTime);
public static extern int GetTimeFormatEx(string lpLocaleName, TIME_FORMAT dwFlags, in SYSTEMTIME lpTime, string lpFormat, StringBuilder lpTimeStr, int cchTime);
}
}

View File

@ -16,20 +16,23 @@ namespace Vanara.PInvoke
public enum DEBUG_CONTINUE : uint
{
/// <summary>
/// If the thread specified by the dwThreadId parameter previously reported an EXCEPTION_DEBUG_EVENT debugging event, the function stops all
/// exception processing and continues the thread and the exception is marked as handled. For any other debugging event, this flag simply continues
/// the thread.
/// If the thread specified by the dwThreadId parameter previously reported an EXCEPTION_DEBUG_EVENT debugging event, the
/// function stops all exception processing and continues the thread and the exception is marked as handled. For any other
/// debugging event, this flag simply continues the thread.
/// </summary>
DBG_CONTINUE = 0x00010002,
/// <summary>
/// If the thread specified by dwThreadId previously reported an EXCEPTION_DEBUG_EVENT debugging event, the function continues exception processing.
/// If this is a first-chance exception event, the search and dispatch logic of the structured exception handler is used; otherwise, the process is
/// terminated. For any other debugging event, this flag simply continues the thread.
/// If the thread specified by dwThreadId previously reported an EXCEPTION_DEBUG_EVENT debugging event, the function continues
/// exception processing. If this is a first-chance exception event, the search and dispatch logic of the structured exception
/// handler is used; otherwise, the process is terminated. For any other debugging event, this flag simply continues the thread.
/// </summary>
DBG_EXCEPTION_NOT_HANDLED = 0x80010001,
/// <summary>
/// Supported in Windows 10, version 1507 or above, this flag causes dwThreadId to replay the existing breaking event after the target continues. By
/// calling the SuspendThread API against dwThreadId, a debugger can resume other threads in the process and later return to the breaking.
/// Supported in Windows 10, version 1507 or above, this flag causes dwThreadId to replay the existing breaking event after the
/// target continues. By calling the SuspendThread API against dwThreadId, a debugger can resume other threads in the process and
/// later return to the breaking.
/// </summary>
DBG_REPLY_LATER = 0x40010001,
}
@ -37,7 +40,9 @@ namespace Vanara.PInvoke
/// <summary>The code that identifies the type of debugging event.</summary>
public enum DEBUG_EVENT_CODE : uint
{
/// <summary>Reports a create-process debugging event. The value of u.CreateProcessInfo specifies a CREATE_PROCESS_DEBUG_INFO structure.</summary>
/// <summary>
/// Reports a create-process debugging event. The value of u.CreateProcessInfo specifies a CREATE_PROCESS_DEBUG_INFO structure.
/// </summary>
CREATE_PROCESS_DEBUG_EVENT = 3,
/// <summary>Reports a create-thread debugging event. The value of u.CreateThread specifies a CREATE_THREAD_DEBUG_INFO structure.</summary>
@ -52,10 +57,14 @@ namespace Vanara.PInvoke
/// <summary>Reports an exit-thread debugging event. The value of u.ExitThread specifies an EXIT_THREAD_DEBUG_INFO structure.</summary>
EXIT_THREAD_DEBUG_EVENT = 4,
/// <summary>Reports a load-dynamic-link-library (DLL) debugging event. The value of u.LoadDll specifies a LOAD_DLL_DEBUG_INFO structure.</summary>
/// <summary>
/// Reports a load-dynamic-link-library (DLL) debugging event. The value of u.LoadDll specifies a LOAD_DLL_DEBUG_INFO structure.
/// </summary>
LOAD_DLL_DEBUG_EVENT = 6,
/// <summary>Reports an output-debugging-string debugging event. The value of u.DebugString specifies an OUTPUT_DEBUG_STRING_INFO structure.</summary>
/// <summary>
/// Reports an output-debugging-string debugging event. The value of u.DebugString specifies an OUTPUT_DEBUG_STRING_INFO structure.
/// </summary>
OUTPUT_DEBUG_STRING_EVENT = 8,
/// <summary>Reports a RIP-debugging event (system debugging error). The value of u.RipInfo specifies a RIP_INFO structure.</summary>
@ -78,13 +87,13 @@ namespace Vanara.PInvoke
[DllImport(Lib.Kernel32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("WinBase.h", MSDNShortId = "ms679280")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool CheckRemoteDebuggerPresent([In] IntPtr hProcess, [MarshalAs(UnmanagedType.Bool)] ref bool pbDebuggerPresent);
public static extern bool CheckRemoteDebuggerPresent([In] HPROCESS hProcess, [MarshalAs(UnmanagedType.Bool)] out bool pbDebuggerPresent);
/// <summary>Enables a debugger to continue a thread that previously reported a debugging event.</summary>
/// <param name="dwProcessId">The process identifier of the process to continue.</param>
/// <param name="dwThreadId">
/// The thread identifier of the thread to continue. The combination of process identifier and thread identifier must identify a thread that has
/// previously reported a debugging event.
/// The thread identifier of the thread to continue. The combination of process identifier and thread identifier must identify a
/// thread that has previously reported a debugging event.
/// </param>
/// <param name="dwContinueStatus">
/// <para>The options to continue the thread that reported the debugging event.</para>
@ -97,23 +106,25 @@ namespace Vanara.PInvoke
/// <item>
/// <term>DBG_CONTINUE0x00010002L</term>
/// <term>
/// If the thread specified by the dwThreadId parameter previously reported an EXCEPTION_DEBUG_EVENT debugging event, the function stops all exception
/// processing and continues the thread and the exception is marked as handled. For any other debugging event, this flag simply continues the thread.
/// If the thread specified by the dwThreadId parameter previously reported an EXCEPTION_DEBUG_EVENT debugging event, the function
/// stops all exception processing and continues the thread and the exception is marked as handled. For any other debugging event,
/// this flag simply continues the thread.
/// </term>
/// </item>
/// <item>
/// <term>DBG_EXCEPTION_NOT_HANDLED0x80010001L</term>
/// <term>
/// If the thread specified by dwThreadId previously reported an EXCEPTION_DEBUG_EVENT debugging event, the function continues exception processing. If
/// this is a first-chance exception event, the search and dispatch logic of the structured exception handler is used; otherwise, the process is
/// terminated. For any other debugging event, this flag simply continues the thread.
/// If the thread specified by dwThreadId previously reported an EXCEPTION_DEBUG_EVENT debugging event, the function continues
/// exception processing. If this is a first-chance exception event, the search and dispatch logic of the structured exception
/// handler is used; otherwise, the process is terminated. For any other debugging event, this flag simply continues the thread.
/// </term>
/// </item>
/// <item>
/// <term>DBG_REPLY_LATER0x40010001L</term>
/// <term>
/// Supported in Windows 10, version 1507 or above, this flag causes dwThreadId to replay the existing breaking event after the target continues. By
/// calling the SuspendThread API against dwThreadId, a debugger can resume other threads in the process and later return to the breaking.
/// Supported in Windows 10, version 1507 or above, this flag causes dwThreadId to replay the existing breaking event after the
/// target continues. By calling the SuspendThread API against dwThreadId, a debugger can resume other threads in the process and
/// later return to the breaking.
/// </term>
/// </item>
/// </list>
@ -131,8 +142,8 @@ namespace Vanara.PInvoke
/// <summary>Enables a debugger to attach to an active process and debug it.</summary>
/// <param name="dwProcessId">
/// The identifier for the process to be debugged. The debugger is granted debugging access to the process as if it created the process with the
/// <c>DEBUG_ONLY_THIS_PROCESS</c> flag. For more information, see the Remarks section of this topic.
/// The identifier for the process to be debugged. The debugger is granted debugging access to the process as if it created the
/// process with the <c>DEBUG_ONLY_THIS_PROCESS</c> flag. For more information, see the Remarks section of this topic.
/// </param>
/// <returns>
/// <para>If the function succeeds, the return value is nonzero.</para>
@ -157,7 +168,10 @@ namespace Vanara.PInvoke
public static extern bool DebugActiveProcessStop(uint dwProcessId);
/// <summary>
/// <para>Causes a breakpoint exception to occur in the current process. This allows the calling thread to signal the debugger to handle the exception.</para>
/// <para>
/// Causes a breakpoint exception to occur in the current process. This allows the calling thread to signal the debugger to handle
/// the exception.
/// </para>
/// <para>To cause a breakpoint exception in another process, use the <c>DebugBreakProcess</c> function.</para>
/// </summary>
/// <returns>This function does not return a value.</returns>
@ -183,13 +197,13 @@ namespace Vanara.PInvoke
// void WINAPI OutputDebugString( _In_opt_ LPCTSTR lpOutputString); https://msdn.microsoft.com/en-us/library/windows/desktop/aa363362(v=vs.85).aspx
[DllImport(Lib.Kernel32, SetLastError = false, CharSet = CharSet.Auto)]
[PInvokeData("WinBase.h", MSDNShortId = "aa363362")]
public static extern void OutputDebugString([In] string lpOutputString);
public static extern void OutputDebugString(string lpOutputString);
/// <summary>Waits for a debugging event to occur in a process being debugged.</summary>
/// <param name="lpDebugEvent">A pointer to a <c>DEBUG_EVENT</c> structure that receives information about the debugging event.</param>
/// <param name="dwMilliseconds">
/// The number of milliseconds to wait for a debugging event. If this parameter is zero, the function tests for a debugging event and returns
/// immediately. If the parameter is INFINITE, the function does not return until a debugging event has occurred.
/// The number of milliseconds to wait for a debugging event. If this parameter is zero, the function tests for a debugging event and
/// returns immediately. If the parameter is INFINITE, the function does not return until a debugging event has occurred.
/// </param>
/// <returns>
/// <para>If the function succeeds, the return value is nonzero.</para>
@ -203,15 +217,15 @@ namespace Vanara.PInvoke
/// <summary>
/// <para>
/// [Some information relates to pre-released product which may be substantially modified before it's commercially released. Microsoft makes no
/// warranties, express or implied, with respect to the information provided here.]
/// [Some information relates to pre-released product which may be substantially modified before it's commercially released.
/// Microsoft makes no warranties, express or implied, with respect to the information provided here.]
/// </para>
/// <para>Waits for a debugging event to occur in a process being debugged.</para>
/// </summary>
/// <param name="lpDebugEvent">A pointer to a <c>DEBUG_EVENT</c> structure that receives information about the debugging event.</param>
/// <param name="dwMilliseconds">
/// The number of milliseconds to wait for a debugging event. If this parameter is zero, the function tests for a debugging event and returns
/// immediately. If the parameter is INFINITE, the function does not return until a debugging event has occurred.
/// The number of milliseconds to wait for a debugging event. If this parameter is zero, the function tests for a debugging event and
/// returns immediately. If the parameter is INFINITE, the function does not return until a debugging event has occurred.
/// </param>
/// <returns>
/// <para>If the function succeeds, the return value is nonzero.</para>
@ -225,8 +239,9 @@ namespace Vanara.PInvoke
/// <summary>Describes a debugging event.</summary>
// typedef struct _DEBUG_EVENT { DWORD dwDebugEventCode; DWORD dwProcessId; DWORD dwThreadId; union { EXCEPTION_DEBUG_INFO Exception;
// CREATE_THREAD_DEBUG_INFO CreateThread; CREATE_PROCESS_DEBUG_INFO CreateProcessInfo; EXIT_THREAD_DEBUG_INFO ExitThread; EXIT_PROCESS_DEBUG_INFO
// ExitProcess; LOAD_DLL_DEBUG_INFO LoadDll; UNLOAD_DLL_DEBUG_INFO UnloadDll; OUTPUT_DEBUG_STRING_INFO DebugString; RIP_INFO RipInfo; } u;} DEBUG_EVENT,
// CREATE_THREAD_DEBUG_INFO CreateThread; CREATE_PROCESS_DEBUG_INFO CreateProcessInfo; EXIT_THREAD_DEBUG_INFO ExitThread;
// EXIT_PROCESS_DEBUG_INFO ExitProcess; LOAD_DLL_DEBUG_INFO LoadDll; UNLOAD_DLL_DEBUG_INFO UnloadDll; OUTPUT_DEBUG_STRING_INFO
// DebugString; RIP_INFO RipInfo; } u;} DEBUG_EVENT,
// *LPDEBUG_EVENT;// https://msdn.microsoft.com/en-us/library/windows/desktop/ms679308(v=vs.85).aspx
[PInvokeData("WinBase.h", MSDNShortId = "ms679308")]
[StructLayout(LayoutKind.Sequential)]
@ -263,11 +278,15 @@ namespace Vanara.PInvoke
/// </item>
/// <item>
/// <term>LOAD_DLL_DEBUG_EVENT6</term>
/// <term>Reports a load-dynamic-link-library (DLL) debugging event. The value of u.LoadDll specifies a LOAD_DLL_DEBUG_INFO structure.</term>
/// <term>
/// Reports a load-dynamic-link-library (DLL) debugging event. The value of u.LoadDll specifies a LOAD_DLL_DEBUG_INFO structure.
/// </term>
/// </item>
/// <item>
/// <term>OUTPUT_DEBUG_STRING_EVENT8</term>
/// <term>Reports an output-debugging-string debugging event. The value of u.DebugString specifies an OUTPUT_DEBUG_STRING_INFO structure.</term>
/// <term>
/// Reports an output-debugging-string debugging event. The value of u.DebugString specifies an OUTPUT_DEBUG_STRING_INFO structure.
/// </term>
/// </item>
/// <item>
/// <term>RIP_EVENT9</term>
@ -281,29 +300,35 @@ namespace Vanara.PInvoke
/// </para>
/// </summary>
public DEBUG_EVENT_CODE dwDebugEventCode;
/// <summary>
/// <para>Type: <c>DWORD</c></para>
/// <para>
/// The identifier of the process in which the debugging event occurred. A debugger uses this value to locate the debugger's per-process structure.
/// These values are not necessarily small integers that can be used as table indices.
/// The identifier of the process in which the debugging event occurred. A debugger uses this value to locate the debugger's
/// per-process structure. These values are not necessarily small integers that can be used as table indices.
/// </para>
/// </summary>
public uint dwProcessId;
/// <summary>
/// <para>Type: <c>DWORD</c></para>
/// <para>
/// The identifier of the thread in which the debugging event occurred. A debugger uses this value to locate the debugger's per-thread structure.
/// These values are not necessarily small integers that can be used as table indices.
/// The identifier of the thread in which the debugging event occurred. A debugger uses this value to locate the debugger's
/// per-thread structure. These values are not necessarily small integers that can be used as table indices.
/// </para>
/// </summary>
public uint dwThreadId;
/// <summary>
/// Any additional information relating to the debugging event. This union takes on the type and value appropriate to the type of debugging event, as
/// described in the <c>dwDebugEventCode</c> member.
/// Any additional information relating to the debugging event. This union takes on the type and value appropriate to the type of
/// debugging event, as described in the <c>dwDebugEventCode</c> member.
/// </summary>
public EXCEPTION_INFO u;
/// <summary>This union takes on the type and value appropriate to the type of debugging event, as described in the <c>dwDebugEventCode</c> member.</summary>
/// <summary>
/// This union takes on the type and value appropriate to the type of debugging event, as described in the
/// <c>dwDebugEventCode</c> member.
/// </summary>
[PInvokeData("WinBase.h", MSDNShortId = "ms679308")]
[StructLayout(LayoutKind.Explicit)]
public struct EXCEPTION_INFO
@ -311,138 +336,178 @@ namespace Vanara.PInvoke
/// <summary>If the dwDebugEventCode is EXCEPTION_DEBUG_EVENT (1), u.Exception specifies an EXCEPTION_DEBUG_INFO structure.</summary>
[FieldOffset(0)]
public EXCEPTION_DEBUG_INFO Exception;
/// <summary>If the dwDebugEventCode is CREATE_THREAD_DEBUG_EVENT (2), u.CreateThread specifies an CREATE_THREAD_DEBUG_INFO structure.</summary>
/// <summary>
/// If the dwDebugEventCode is CREATE_THREAD_DEBUG_EVENT (2), u.CreateThread specifies an CREATE_THREAD_DEBUG_INFO structure.
/// </summary>
[FieldOffset(0)]
public CREATE_THREAD_DEBUG_INFO CreateThread;
/// <summary>If the dwDebugEventCode is CREATE_PROCESS_DEBUG_EVENT (3), u.CreateProcessInfo specifies an CREATE_PROCESS_DEBUG_INFO structure.</summary>
/// <summary>
/// If the dwDebugEventCode is CREATE_PROCESS_DEBUG_EVENT (3), u.CreateProcessInfo specifies an CREATE_PROCESS_DEBUG_INFO structure.
/// </summary>
[FieldOffset(0)]
public CREATE_PROCESS_DEBUG_INFO CreateProcessInfo;
/// <summary>If the dwDebugEventCode is EXIT_THREAD_DEBUG_EVENT (4), u.ExitThread specifies an EXIT_THREAD_DEBUG_INFO structure.</summary>
/// <summary>
/// If the dwDebugEventCode is EXIT_THREAD_DEBUG_EVENT (4), u.ExitThread specifies an EXIT_THREAD_DEBUG_INFO structure.
/// </summary>
[FieldOffset(0)]
public EXIT_THREAD_DEBUG_INFO ExitThread;
/// <summary>If the dwDebugEventCode is EXIT_PROCESS_DEBUG_EVENT (5), u.ExitProcess specifies an EXIT_PROCESS_DEBUG_INFO structure.</summary>
/// <summary>
/// If the dwDebugEventCode is EXIT_PROCESS_DEBUG_EVENT (5), u.ExitProcess specifies an EXIT_PROCESS_DEBUG_INFO structure.
/// </summary>
[FieldOffset(0)]
public EXIT_PROCESS_DEBUG_INFO ExitProcess;
/// <summary>If the dwDebugEventCode is LOAD_DLL_DEBUG_EVENT (6), u.LoadDll specifies an LOAD_DLL_DEBUG_INFO structure.</summary>
[FieldOffset(0)]
public LOAD_DLL_DEBUG_INFO LoadDll;
/// <summary>If the dwDebugEventCode is UNLOAD_DLL_DEBUG_EVENT (7), u.UnloadDll specifies an UNLOAD_DLL_DEBUG_INFO structure.</summary>
[FieldOffset(0)]
public UNLOAD_DLL_DEBUG_INFO UnloadDll;
/// <summary>If the dwDebugEventCode is OUTPUT_DEBUG_STRING_EVENT (8), u.DebugString specifies an OUTPUT_DEBUG_STRING_INFO structure.</summary>
/// <summary>
/// If the dwDebugEventCode is OUTPUT_DEBUG_STRING_EVENT (8), u.DebugString specifies an OUTPUT_DEBUG_STRING_INFO structure.
/// </summary>
[FieldOffset(0)]
public OUTPUT_DEBUG_STRING_INFO DebugString;
/// <summary>If the dwDebugEventCode is RIP_EVENT (9), u.RipInfo specifies an RIP_INFO structure.</summary>
[FieldOffset(0)]
public RIP_INFO RipInfo;
/// <summary>Contains exception information that can be used by a debugger.</summary>
// typedef struct _EXCEPTION_DEBUG_INFO { EXCEPTION_RECORD ExceptionRecord; DWORD dwFirstChance;} EXCEPTION_DEBUG_INFO, *LPEXCEPTION_DEBUG_INFO; https://msdn.microsoft.com/en-us/library/windows/desktop/ms679326(v=vs.85).aspx
// typedef struct _EXCEPTION_DEBUG_INFO { EXCEPTION_RECORD ExceptionRecord; DWORD dwFirstChance;} EXCEPTION_DEBUG_INFO,
// *LPEXCEPTION_DEBUG_INFO; https://msdn.microsoft.com/en-us/library/windows/desktop/ms679326(v=vs.85).aspx
[PInvokeData("WinBase.h", MSDNShortId = "ms679326")]
[StructLayout(LayoutKind.Sequential)]
public struct EXCEPTION_DEBUG_INFO
{
/// <summary>
/// An <c>EXCEPTION_RECORD</c> structure with information specific to the exception. This includes the exception code, flags, address, a
/// pointer to a related exception, extra parameters, and so on.
/// An <c>EXCEPTION_RECORD</c> structure with information specific to the exception. This includes the exception code,
/// flags, address, a pointer to a related exception, extra parameters, and so on.
/// </summary>
public EXCEPTION_RECORD ExceptionRecord;
/// <summary>
/// A value that indicates whether the debugger has previously encountered the exception specified by the <c>ExceptionRecord</c> member. If
/// the <c>dwFirstChance</c> member is nonzero, this is the first time the debugger has encountered the exception. Debuggers typically handle
/// breakpoint and single-step exceptions when they are first encountered. If this member is zero, the debugger has previously encountered
/// the exception. This occurs only if, during the search for structured exception handlers, either no handler was found or the exception was continued.
/// A value that indicates whether the debugger has previously encountered the exception specified by the
/// <c>ExceptionRecord</c> member. If the <c>dwFirstChance</c> member is nonzero, this is the first time the debugger has
/// encountered the exception. Debuggers typically handle breakpoint and single-step exceptions when they are first
/// encountered. If this member is zero, the debugger has previously encountered the exception. This occurs only if,
/// during the search for structured exception handlers, either no handler was found or the exception was continued.
/// </summary>
public uint dwFirstChance;
}
/// <summary>Contains thread-creation information that can be used by a debugger.</summary>
// typedef struct _CREATE_THREAD_DEBUG_INFO { HANDLE hThread; LPVOID lpThreadLocalBase; LPTHREAD_START_ROUTINE lpStartAddress;} CREATE_THREAD_DEBUG_INFO,
// typedef struct _CREATE_THREAD_DEBUG_INFO { HANDLE hThread; LPVOID lpThreadLocalBase; LPTHREAD_START_ROUTINE
// lpStartAddress;} CREATE_THREAD_DEBUG_INFO,
// *LPCREATE_THREAD_DEBUG_INFO; https://msdn.microsoft.com/en-us/library/windows/desktop/ms679287(v=vs.85).aspx
[PInvokeData("WinBase.h", MSDNShortId = "ms679287")]
[StructLayout(LayoutKind.Sequential)]
public struct CREATE_THREAD_DEBUG_INFO
{
/// <summary>
/// A handle to the thread whose creation caused the debugging event. If this member is <c>NULL</c>, the handle is not valid. Otherwise, the
/// debugger has THREAD_GET_CONTEXT, THREAD_SET_CONTEXT, and THREAD_SUSPEND_RESUME access to the thread, allowing the debugger to read from
/// and write to the registers of the thread and control execution of the thread.
/// A handle to the thread whose creation caused the debugging event. If this member is <c>NULL</c>, the handle is not
/// valid. Otherwise, the debugger has THREAD_GET_CONTEXT, THREAD_SET_CONTEXT, and THREAD_SUSPEND_RESUME access to the
/// thread, allowing the debugger to read from and write to the registers of the thread and control execution of the thread.
/// </summary>
public IntPtr hThread;
public HTHREAD hThread;
/// <summary>
/// A pointer to a block of data. At offset 0x2C into this block is another pointer, called ThreadLocalStoragePointer, that points to an
/// array of per-module thread local storage blocks. This gives a debugger access to per-thread data in the threads of the process being
/// debugged using the same algorithms that a compiler would use.
/// A pointer to a block of data. At offset 0x2C into this block is another pointer, called ThreadLocalStoragePointer,
/// that points to an array of per-module thread local storage blocks. This gives a debugger access to per-thread data in
/// the threads of the process being debugged using the same algorithms that a compiler would use.
/// </summary>
public IntPtr lpThreadLocalBase;
/// <summary>
/// A pointer to the starting address of the thread. This value may only be an approximation of the thread's starting address, because any
/// application with appropriate access to the thread can change the thread's context by using the <c>SetThreadContext</c> function.
/// A pointer to the starting address of the thread. This value may only be an approximation of the thread's starting
/// address, because any application with appropriate access to the thread can change the thread's context by using the
/// <c>SetThreadContext</c> function.
/// </summary>
public PTHREAD_START_ROUTINE lpStartAddress;
}
/// <summary>Contains process creation information that can be used by a debugger.</summary>
// typedef struct _CREATE_PROCESS_DEBUG_INFO { HANDLE hFile; HANDLE hProcess; HANDLE hThread; LPVOID lpBaseOfImage; DWORD dwDebugInfoFileOffset;
// DWORD nDebugInfoSize; LPVOID lpThreadLocalBase; LPTHREAD_START_ROUTINE lpStartAddress; LPVOID lpImageName; WORD fUnicode;}
// CREATE_PROCESS_DEBUG_INFO, *LPCREATE_PROCESS_DEBUG_INFO;
// typedef struct _CREATE_PROCESS_DEBUG_INFO { HANDLE hFile; HANDLE hProcess; HANDLE hThread; LPVOID lpBaseOfImage; DWORD
// dwDebugInfoFileOffset; DWORD nDebugInfoSize; LPVOID lpThreadLocalBase; LPTHREAD_START_ROUTINE lpStartAddress; LPVOID
// lpImageName; WORD fUnicode;} CREATE_PROCESS_DEBUG_INFO, *LPCREATE_PROCESS_DEBUG_INFO;
[PInvokeData("WinBase.h", MSDNShortId = "ms679286")]
[StructLayout(LayoutKind.Sequential)]
public struct CREATE_PROCESS_DEBUG_INFO
{
/// <summary>
/// <para>
/// A handle to the process's image file. If this member is <c>NULL</c>, the handle is not valid. Otherwise, the debugger can use the member
/// to read from and write to the image file.
/// A handle to the process's image file. If this member is <c>NULL</c>, the handle is not valid. Otherwise, the debugger
/// can use the member to read from and write to the image file.
/// </para>
/// <para>When the debugger is finished with this file, it should close the handle using the <c>CloseHandle</c> function.</para>
/// </summary>
public IntPtr hFile;
public HFILE hFile;
/// <summary>
/// A handle to the process. If this member is <c>NULL</c>, the handle is not valid. Otherwise, the debugger can use the member to read from
/// and write to the process's memory.
/// A handle to the process. If this member is <c>NULL</c>, the handle is not valid. Otherwise, the debugger can use the
/// member to read from and write to the process's memory.
/// </summary>
public IntPtr hProcess;
public HPROCESS hProcess;
/// <summary>
/// A handle to the initial thread of the process identified by the <c>hProcess</c> member. If <c>hThread</c> param is <c>NULL</c>, the
/// handle is not valid. Otherwise, the debugger has <c>THREAD_GET_CONTEXT</c>, <c>THREAD_SET_CONTEXT</c>, and <c>THREAD_SUSPEND_RESUME</c>
/// access to the thread, allowing the debugger to read from and write to the registers of the thread and to control execution of the thread.
/// A handle to the initial thread of the process identified by the <c>hProcess</c> member. If <c>hThread</c> param is
/// <c>NULL</c>, the handle is not valid. Otherwise, the debugger has <c>THREAD_GET_CONTEXT</c>,
/// <c>THREAD_SET_CONTEXT</c>, and <c>THREAD_SUSPEND_RESUME</c> access to the thread, allowing the debugger to read from
/// and write to the registers of the thread and to control execution of the thread.
/// </summary>
public IntPtr hThread;
public HTHREAD hThread;
/// <summary>The base address of the executable image that the process is running.</summary>
public IntPtr lpBaseOfImage;
/// <summary>The offset to the debugging information in the file identified by the <c>hFile</c> member.</summary>
public uint dwDebugInfoFileOffset;
/// <summary>The size of the debugging information in the file, in bytes. If this value is zero, there is no debugging information.</summary>
public uint nDebugInfoSize;
/// <summary>
/// A pointer to a block of data. At offset 0x2C into this block is another pointer, called , that points to an array of per-module thread
/// local storage blocks. This gives a debugger access to per-thread data in the threads of the process being debugged using the same
/// algorithms that a compiler would use.
/// The size of the debugging information in the file, in bytes. If this value is zero, there is no debugging information.
/// </summary>
public uint nDebugInfoSize;
/// <summary>
/// A pointer to a block of data. At offset 0x2C into this block is another pointer, called , that points to an array of
/// per-module thread local storage blocks. This gives a debugger access to per-thread data in the threads of the process
/// being debugged using the same algorithms that a compiler would use.
/// </summary>
public IntPtr lpThreadLocalBase;
/// <summary>
/// A pointer to the starting address of the thread. This value may only be an approximation of the thread's starting address, because any
/// application with appropriate access to the thread can change the thread's context by using the <c>SetThreadContext</c> function.
/// A pointer to the starting address of the thread. This value may only be an approximation of the thread's starting
/// address, because any application with appropriate access to the thread can change the thread's context by using the
/// <c>SetThreadContext</c> function.
/// </summary>
public PTHREAD_START_ROUTINE lpStartAddress;
/// <summary>
/// <para>
/// A pointer to the file name associated with the <c>hFile</c> member. This parameter may be <c>NULL</c>, or it may contain the address of a
/// string pointer in the address space of the process being debugged. That address may, in turn, either be <c>NULL</c> or point to the
/// actual filename. If <c>fUnicode</c> is a nonzero value, the name string is Unicode; otherwise, it is ANSI.
/// A pointer to the file name associated with the <c>hFile</c> member. This parameter may be <c>NULL</c>, or it may
/// contain the address of a string pointer in the address space of the process being debugged. That address may, in
/// turn, either be <c>NULL</c> or point to the actual filename. If <c>fUnicode</c> is a nonzero value, the name string
/// is Unicode; otherwise, it is ANSI.
/// </para>
/// <para>
/// This member is strictly optional. Debuggers must be prepared to handle the case where <c>lpImageName</c> is <c>NULL</c> or *
/// <c>lpImageName</c> (in the address space of the process being debugged) is <c>NULL</c>. Specifically, the system does not provide an
/// image name for a create process event, and will not likely pass an image name for the first DLL event. The system also does not provide
/// this information in the case of debug events that originate from a call to the <c>DebugActiveProcess</c> function.
/// This member is strictly optional. Debuggers must be prepared to handle the case where <c>lpImageName</c> is
/// <c>NULL</c> or * <c>lpImageName</c> (in the address space of the process being debugged) is <c>NULL</c>.
/// Specifically, the system does not provide an image name for a create process event, and will not likely pass an image
/// name for the first DLL event. The system also does not provide this information in the case of debug events that
/// originate from a call to the <c>DebugActiveProcess</c> function.
/// </para>
/// </summary>
public IntPtr lpImageName;
/// <summary>
/// A value that indicates whether a file name specified by the <c>lpImageName</c> member is Unicode or ANSI. A nonzero value indicates
/// Unicode; zero indicates ANSI.
/// A value that indicates whether a file name specified by the <c>lpImageName</c> member is Unicode or ANSI. A nonzero
/// value indicates Unicode; zero indicates ANSI.
/// </summary>
public ushort fUnicode;
}
@ -468,46 +533,56 @@ namespace Vanara.PInvoke
}
/// <summary>Contains information about a dynamic-link library (DLL) that has just been loaded.</summary>
// typedef struct _LOAD_DLL_DEBUG_INFO { HANDLE hFile; LPVOID lpBaseOfDll; DWORD dwDebugInfoFileOffset; DWORD nDebugInfoSize; LPVOID lpImageName;
// WORD fUnicode;} LOAD_DLL_DEBUG_INFO, *LPLOAD_DLL_DEBUG_INFO; https://msdn.microsoft.com/en-us/library/windows/desktop/ms680351(v=vs.85).aspx
// typedef struct _LOAD_DLL_DEBUG_INFO { HANDLE hFile; LPVOID lpBaseOfDll; DWORD dwDebugInfoFileOffset; DWORD nDebugInfoSize;
// LPVOID lpImageName; WORD fUnicode;} LOAD_DLL_DEBUG_INFO, *LPLOAD_DLL_DEBUG_INFO; https://msdn.microsoft.com/en-us/library/windows/desktop/ms680351(v=vs.85).aspx
[PInvokeData("WinBase.h", MSDNShortId = "ms680351")]
[StructLayout(LayoutKind.Sequential)]
public struct LOAD_DLL_DEBUG_INFO
{
/// <summary>
/// <para>
/// A handle to the loaded DLL. If this member is <c>NULL</c>, the handle is not valid. Otherwise, the member is opened for reading and
/// read-sharing in the context of the debugger.
/// A handle to the loaded DLL. If this member is <c>NULL</c>, the handle is not valid. Otherwise, the member is opened
/// for reading and read-sharing in the context of the debugger.
/// </para>
/// <para>When the debugger is finished with this file, it should close the handle using the <c>CloseHandle</c> function.</para>
/// </summary>
public IntPtr hFile;
public HFILE hFile;
/// <summary>A pointer to the base address of the DLL in the address space of the process loading the DLL.</summary>
public IntPtr lpBaseOfDll;
/// <summary>
/// The offset to the debugging information in the file identified by the <c>hFile</c> member, in bytes. The system expects the debugging
/// information to be in CodeView 4.0 format. This format is currently a derivative of Common Object File Format (COFF).
/// The offset to the debugging information in the file identified by the <c>hFile</c> member, in bytes. The system
/// expects the debugging information to be in CodeView 4.0 format. This format is currently a derivative of Common
/// Object File Format (COFF).
/// </summary>
public uint dwDebugInfoFileOffset;
/// <summary>The size of the debugging information in the file, in bytes. If this member is zero, there is no debugging information.</summary>
/// <summary>
/// The size of the debugging information in the file, in bytes. If this member is zero, there is no debugging information.
/// </summary>
public uint nDebugInfoSize;
/// <summary>
/// <para>
/// A pointer to the file name associated with <c>hFile</c>. This member may be <c>NULL</c>, or it may contain the address of a string
/// pointer in the address space of the process being debugged. That address may, in turn, either be <c>NULL</c> or point to the actual
/// filename. If <c>fUnicode</c> is a nonzero value, the name string is Unicode; otherwise, it is ANSI.
/// A pointer to the file name associated with <c>hFile</c>. This member may be <c>NULL</c>, or it may contain the
/// address of a string pointer in the address space of the process being debugged. That address may, in turn, either be
/// <c>NULL</c> or point to the actual filename. If <c>fUnicode</c> is a nonzero value, the name string is Unicode;
/// otherwise, it is ANSI.
/// </para>
/// <para>
/// This member is strictly optional. Debuggers must be prepared to handle the case where <c>lpImageName</c> is <c>NULL</c> or *
/// <c>lpImageName</c> (in the address space of the process being debugged) is <c>NULL</c>. Specifically, the system will never provide an
/// image name for a create process event, and it will not likely pass an image name for the first DLL event. The system will also never
/// provide this information in the case of debugging events that originate from a call to the <c>DebugActiveProcess</c> function.
/// This member is strictly optional. Debuggers must be prepared to handle the case where <c>lpImageName</c> is
/// <c>NULL</c> or * <c>lpImageName</c> (in the address space of the process being debugged) is <c>NULL</c>.
/// Specifically, the system will never provide an image name for a create process event, and it will not likely pass an
/// image name for the first DLL event. The system will also never provide this information in the case of debugging
/// events that originate from a call to the <c>DebugActiveProcess</c> function.
/// </para>
/// </summary>
public IntPtr lpImageName;
/// <summary>
/// A value that indicates whether a filename specified by <c>lpImageName</c> is Unicode or ANSI. A nonzero value for this member indicates
/// Unicode; zero indicates ANSI.
/// A value that indicates whether a filename specified by <c>lpImageName</c> is Unicode or ANSI. A nonzero value for
/// this member indicates Unicode; zero indicates ANSI.
/// </summary>
public ushort fUnicode;
}
@ -530,14 +605,17 @@ namespace Vanara.PInvoke
public struct OUTPUT_DEBUG_STRING_INFO
{
/// <summary>
/// The debugging string in the calling process's address space. The debugger can use the <c>ReadProcessMemory</c> function to retrieve the
/// value of the string.
/// The debugging string in the calling process's address space. The debugger can use the <c>ReadProcessMemory</c>
/// function to retrieve the value of the string.
/// </summary>
public string lpDebugStringData;
/// <summary>
/// The format of the debugging string. If this member is zero, the debugging string is ANSI; if it is nonzero, the string is Unicode.
/// The format of the debugging string. If this member is zero, the debugging string is ANSI; if it is nonzero, the
/// string is Unicode.
/// </summary>
public ushort fUnicode;
/// <summary>The size of the debugging string, in characters. The length includes the string's terminating null character.</summary>
public ushort nDebugStringLength;
}
@ -550,8 +628,12 @@ namespace Vanara.PInvoke
{
/// <summary>The error that caused the RIP debug event. For more information, see Error Handling.</summary>
public uint dwError;
/// <summary>
/// <para>Any additional information about the type of error that caused the RIP debug event. This member can be one of the following values.</para>
/// <para>
/// Any additional information about the type of error that caused the RIP debug event. This member can be one of the
/// following values.
/// </para>
/// <para>
/// <list type="table">
/// <listheader>
@ -564,7 +646,9 @@ namespace Vanara.PInvoke
/// </item>
/// <item>
/// <term>SLE_MINORERROR = 0x00000002</term>
/// <term>Indicates that invalid data was passed to the function, but the error probably will not cause the application to fail.</term>
/// <term>
/// Indicates that invalid data was passed to the function, but the error probably will not cause the application to fail.
/// </term>
/// </item>
/// <item>
/// <term>SLE_WARNING = 0x00000003</term>

View File

@ -17,6 +17,7 @@ namespace Vanara.PInvoke
{
/// <summary>The enclave does not permit debugging.</summary>
ENCLAVE_VBS_FLAG_NODEBUG = 0x00000000,
/// <summary>The enclave permits debugging.</summary>
ENCLAVE_VBS_FLAG_DEBUG = 0x00000001,
}
@ -27,40 +28,50 @@ namespace Vanara.PInvoke
{
/// <summary>An enclave for the Intel Software Guard Extensions (SGX) architecture extension.</summary>
ENCLAVE_TYPE_SGX = 0x00000001,
/// <summary>A VBS enclave.</summary>
ENCLAVE_TYPE_VBS = 0x00000010,
}
/// <summary>Calls a function within an enclave. <c>CallEnclave</c> can also be called within an enclave to call a function outside of the enclave.</summary>
/// <summary>
/// Calls a function within an enclave. <c>CallEnclave</c> can also be called within an enclave to call a function outside of the enclave.
/// </summary>
/// <param name="lpRoutine">The address of the function that you want to call.</param>
/// <param name="lpParameter">The parameter than you want to pass to the function.</param>
/// <param name="fWaitForThread">
/// <para>
/// <c>TRUE</c> if the call to the specified function should block execution until an idle enclave thread becomes available when no idle enclave thread
/// is available. <c>FALSE</c> if the call to the specified function should fail when no idle enclave thread is available.
/// <c>TRUE</c> if the call to the specified function should block execution until an idle enclave thread becomes available when no
/// idle enclave thread is available. <c>FALSE</c> if the call to the specified function should fail when no idle enclave thread is available.
/// </para>
/// <para>This parameter is ignored when you use <c>CallEnclave</c> within an enclave to call a function that is not in any enclave.</para>
/// </param>
/// <param name="lpReturnValue">The return value of the function, if it is called successfully.</param>
/// <returns><c>TRUE</c> if the specified function was called successfully; otherwise <c>FALSE</c>. To get extended error information, call <c>GetLastError</c>.</returns>
// BOOL WINAPI CallEnclave( _In_ LPENCLAVE_ROUTINE lpRoutine, _In_ LPVOID lpParameter, _In_ BOOL fWaitForThread, _Out_ LPVOID *lpReturnValue); https://msdn.microsoft.com/en-us/library/windows/desktop/mt844231(v=vs.85).aspx
/// <returns>
/// <c>TRUE</c> if the specified function was called successfully; otherwise <c>FALSE</c>. To get extended error information, call <c>GetLastError</c>.
/// </returns>
// BOOL WINAPI CallEnclave( _In_ LPENCLAVE_ROUTINE lpRoutine, _In_ LPVOID lpParameter, _In_ BOOL fWaitForThread, _Out_ LPVOID
// *lpReturnValue); https://msdn.microsoft.com/en-us/library/windows/desktop/mt844231(v=vs.85).aspx
[DllImport(Lib.VertDll, SetLastError = true, ExactSpelling = true)]
[PInvokeData("Enclaveapi.h", MSDNShortId = "mt844231")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool CallEnclave(PENCLAVE_ROUTINE lpRoutine, IntPtr lpParameter, [MarshalAs(UnmanagedType.Bool)] bool fWaitForThread, out IntPtr lpReturnValue);
/// <summary>
/// Creates a new uninitialized enclave. An enclave is an isolated region of code and data within the address space for an application. Only code that
/// runs within the enclave can access data within the same enclave.
/// Creates a new uninitialized enclave. An enclave is an isolated region of code and data within the address space for an
/// application. Only code that runs within the enclave can access data within the same enclave.
/// </summary>
/// <param name="hProcess">A handle to the process for which you want to create an enclave.</param>
/// <param name="lpAddress">The preferred base address of the enclave. Specify <c>NULL</c> to have the operating system assign the base address.</param>
/// <param name="dwSize">The size of the enclave that you want to create, including the size of the code that you will load into the enclave, in bytes.</param>
/// <param name="lpAddress">
/// The preferred base address of the enclave. Specify <c>NULL</c> to have the operating system assign the base address.
/// </param>
/// <param name="dwSize">
/// The size of the enclave that you want to create, including the size of the code that you will load into the enclave, in bytes.
/// </param>
/// <param name="dwInitialCommittment">
/// <para>The amount of memory to commit for the enclave, in bytes.</para>
/// <para>
/// If the amount of enclave memory available is not sufficient to commit this number of bytes, enclave creation fails. Any memory that remains unused
/// when you initialize the enclave by calling <c>InitializeEnclave</c> is returned to the list of free pages.
/// If the amount of enclave memory available is not sufficient to commit this number of bytes, enclave creation fails. Any memory
/// that remains unused when you initialize the enclave by calling <c>InitializeEnclave</c> is returned to the list of free pages.
/// </para>
/// <para>The value of the dwInitialCommittment parameter must not exceed the value of the dwSize parameter.</para>
/// <para>This parameter is not used for virtualization-based security (VBS) enclaves.</para>
@ -90,12 +101,12 @@ namespace Vanara.PInvoke
/// <para>For the <c>ENCLAVE_TYPE_VBS</c> enclave type, you must specify a pointer to an <c>ENCLAVE_CREATE_INFO_VBS</c> structure.</para>
/// </param>
/// <param name="dwInfoLength">
/// The length of the structure that the lpEnclaveInformation parameter points to, in bytes. For the <c>ENCLAVE_TYPE_SGX</c> enclave type, this value
/// must be 4096. For the <c>ENCLAVE_TYPE_VBS</c> enclave type, this value must be , which is 36 bytes.
/// The length of the structure that the lpEnclaveInformation parameter points to, in bytes. For the <c>ENCLAVE_TYPE_SGX</c> enclave
/// type, this value must be 4096. For the <c>ENCLAVE_TYPE_VBS</c> enclave type, this value must be , which is 36 bytes.
/// </param>
/// <param name="lpEnclaveError">
/// An optional pointer to a variable that receives an enclave error code that is architecture-specific. For the <c>ENCLAVE_TYPE_SGX</c> and
/// <c>ENCLAVE_TYPE_VBS</c> enclave types, the lpEnclaveError parameter is not used.
/// An optional pointer to a variable that receives an enclave error code that is architecture-specific. For the
/// <c>ENCLAVE_TYPE_SGX</c> and <c>ENCLAVE_TYPE_VBS</c> enclave types, the lpEnclaveError parameter is not used.
/// </param>
/// <returns>
/// <para>If the function succeeds, the return value is the base address of the created enclave.</para>
@ -113,16 +124,19 @@ namespace Vanara.PInvoke
/// </item>
/// <item>
/// <term>ERROR_BAD_LENGTH</term>
/// <term>The value of the dwInfoLength parameter did not match the value expected based on the value specified for the lpEnclaveInformation parameter.</term>
/// <term>
/// The value of the dwInfoLength parameter did not match the value expected based on the value specified for the
/// lpEnclaveInformation parameter.
/// </term>
/// </item>
/// </list>
/// </para>
/// </returns>
// PVOID WINAPI CreateEnclave( _In_ HANDLE hProcess, _In_opt_ LPVOID lpAddress, _In_ SIZE_T dwSize, _In_ SIZE_T dwInitialCommittment, _In_ DWORD
// flEnclaveType, _In_ LPCVOID lpEnclaveInformation, _In_ DWORD dwInfoLength, _Out_opt_ LPDWORD lpEnclaveError); https://msdn.microsoft.com/en-us/library/windows/desktop/mt592866(v=vs.85).aspx
// PVOID WINAPI CreateEnclave( _In_ HANDLE hProcess, _In_opt_ LPVOID lpAddress, _In_ SIZE_T dwSize, _In_ SIZE_T dwInitialCommittment,
// _In_ DWORD flEnclaveType, _In_ LPCVOID lpEnclaveInformation, _In_ DWORD dwInfoLength, _Out_opt_ LPDWORD lpEnclaveError); https://msdn.microsoft.com/en-us/library/windows/desktop/mt592866(v=vs.85).aspx
[DllImport(Lib.Kernel32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("Enclaveapi.h", MSDNShortId = "mt592866")]
public static extern void CreateEnclave(IntPtr hProcess, IntPtr lpAddress, SizeT dwSize, SizeT dwInitialCommittment, EnclaveType flEnclaveType, IntPtr lpEnclaveInformation, uint dwInfoLength, out uint lpEnclaveError);
public static extern void CreateEnclave(HPROCESS hProcess, IntPtr lpAddress, SizeT dwSize, SizeT dwInitialCommittment, EnclaveType flEnclaveType, IntPtr lpEnclaveInformation, uint dwInfoLength, out uint lpEnclaveError);
/// <summary>Deletes the specified enclave.</summary>
/// <param name="lpAddress">The base address of the enclave that you want to delete.</param>
@ -138,8 +152,8 @@ namespace Vanara.PInvoke
/// <item>
/// <term>ERROR_ENCLAVE_NOT_TERMINATED</term>
/// <term>
/// The execution of threads running with the enclave was not ended, because either TerminateEnclave was not called, or the execution of the threads has
/// not yet ended in response to an earlier call to TerminateEnclave.
/// The execution of threads running with the enclave was not ended, because either TerminateEnclave was not called, or the execution
/// of the threads has not yet ended in response to an earlier call to TerminateEnclave.
/// </term>
/// </item>
/// </list>
@ -160,20 +174,21 @@ namespace Vanara.PInvoke
/// <para>For the <c>ENCLAVE_TYPE_VBS</c> enclave type, specify a pointer to an <c>ENCLAVE_INIT_INFO_VBS</c> structure.</para>
/// </param>
/// <param name="dwInfoLength">
/// The length of the structure that the lpEnclaveInformation parameter points to, in bytes. For the <c>ENCLAVE_TYPE_SGX</c> enclave type, this value
/// must be 4096. For the <c>ENCLAVE_TYPE_VBS</c> enclave type, this value must be , which is 8 bytes.
/// The length of the structure that the lpEnclaveInformation parameter points to, in bytes. For the <c>ENCLAVE_TYPE_SGX</c> enclave
/// type, this value must be 4096. For the <c>ENCLAVE_TYPE_VBS</c> enclave type, this value must be , which is 8 bytes.
/// </param>
/// <param name="lpEnclaveError">
/// <para>An optional pointer to a variable that receives an enclave error code that is architecture-specific.</para>
/// <para>
/// For the <c>ENCLAVE_TYPE_SGX</c> enclave type, the lpEnclaveError parameter contains the error that the EINIT instruction generated if the function
/// fails and . <c>GetLastError</c> returns <c>ERROR_ENCLAVE_FAILURE</c>.
/// For the <c>ENCLAVE_TYPE_SGX</c> enclave type, the lpEnclaveError parameter contains the error that the EINIT instruction
/// generated if the function fails and . <c>GetLastError</c> returns <c>ERROR_ENCLAVE_FAILURE</c>.
/// </para>
/// <para>For the <c>ENCLAVE_TYPE_VBS</c> enclave type, the lpEnclaveError parameter is not used.</para>
/// </param>
/// <returns>
/// <para>
/// If the function succeeds, the return value is nonzero. If the function fails, the return value is zero. To get extended error information, call <c>GetLastError</c>.
/// If the function succeeds, the return value is nonzero. If the function fails, the return value is zero. To get extended error
/// information, call <c>GetLastError</c>.
/// </para>
/// <para>For a list of common error codes, see System Error Codes. The following error codes also apply for this function.</para>
/// <para>
@ -185,14 +200,17 @@ namespace Vanara.PInvoke
/// <item>
/// <term>ERROR_ENCLAVE_FAILURE</term>
/// <term>
/// An failure specific to the underlying enclave architecture occurred. The value for the lpEnclaveError parameter contains the architecture-specific
/// error. For the ENCLAVE_TYPE_SGX enclave type, the EINIT instruction that the ENCLAVE_INIT_INFO_SGX structure specified generated an error. The value
/// of the lpEnclaveError parameter contains the error that the instruction generated.
/// An failure specific to the underlying enclave architecture occurred. The value for the lpEnclaveError parameter contains the
/// architecture-specific error. For the ENCLAVE_TYPE_SGX enclave type, the EINIT instruction that the ENCLAVE_INIT_INFO_SGX
/// structure specified generated an error. The value of the lpEnclaveError parameter contains the error that the instruction generated.
/// </term>
/// </item>
/// <item>
/// <term>ERROR_BAD_LENGTH</term>
/// <term>The value of the dwInfoLength parameter did not match the value expected based on the value specified for the lpEnclaveInformation parameter.</term>
/// <term>
/// The value of the dwInfoLength parameter did not match the value expected based on the value specified for the
/// lpEnclaveInformation parameter.
/// </term>
/// </item>
/// <item>
/// <term>ERROR_RETRY</term>
@ -201,12 +219,12 @@ namespace Vanara.PInvoke
/// </list>
/// </para>
/// </returns>
// BOOL WINAPI InitializeEnclave( _In_ HANDLE hProcess, _In_ LPVOID lpAddress, _In_ LPVOID lpEnclaveInformation, _In_ DWORD dwInfoLength, _In_ LPDWORD
// lpEnclaveError); https://msdn.microsoft.com/en-us/library/windows/desktop/mt592869(v=vs.85).aspx
// BOOL WINAPI InitializeEnclave( _In_ HANDLE hProcess, _In_ LPVOID lpAddress, _In_ LPVOID lpEnclaveInformation, _In_ DWORD
// dwInfoLength, _In_ LPDWORD lpEnclaveError); https://msdn.microsoft.com/en-us/library/windows/desktop/mt592869(v=vs.85).aspx
[DllImport(Lib.Kernel32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("Enclaveapi.h", MSDNShortId = "mt592869")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool InitializeEnclave(IntPtr hProcess, IntPtr lpAddress, IntPtr lpEnclaveInformation, uint dwInfoLength, ref uint lpEnclaveError);
public static extern bool InitializeEnclave(HPROCESS hProcess, IntPtr lpAddress, IntPtr lpEnclaveInformation, uint dwInfoLength, ref uint lpEnclaveError);
/// <summary>Retrieves whether the specified type of enclave is supported.</summary>
/// <param name="flEnclaveType">
@ -230,7 +248,8 @@ namespace Vanara.PInvoke
/// </param>
/// <returns>
/// <para>
/// If the function succeeds, the return value is nonzero. If the function fails, the return value is zero. To get extended error information, call <c>GetLastError</c>.
/// If the function succeeds, the return value is nonzero. If the function fails, the return value is zero. To get extended error
/// information, call <c>GetLastError</c>.
/// </para>
/// <para>For a list of common error codes, see System Error Codes. The following error codes also apply for this function.</para>
/// <para>
@ -261,8 +280,8 @@ namespace Vanara.PInvoke
/// </param>
/// <param name="flProtect">
/// <para>
/// The memory protection to use for the pages that you want to add to the enclave. For a list of memory protection values, see memory protection
/// constants. This value must not include the following constants:
/// The memory protection to use for the pages that you want to add to the enclave. For a list of memory protection values, see
/// memory protection constants. This value must not include the following constants:
/// </para>
/// <para>This value can include the enclave specific constants that the following table describes.</para>
/// <para>
@ -278,7 +297,8 @@ namespace Vanara.PInvoke
/// <item>
/// <term>PAGE_ENCLAVE_UNVALIDATED</term>
/// <term>
/// The page contents that you supply are excluded from measurement with the EEXTEND instruction of the Intel Software Guard Extensions programming model.
/// The page contents that you supply are excluded from measurement with the EEXTEND instruction of the Intel Software Guard
/// Extensions programming model.
/// </term>
/// </item>
/// </list>
@ -287,15 +307,20 @@ namespace Vanara.PInvoke
/// <param name="lpPageInformation">
/// A pointer to information that describes the pages that you want to add to the enclave. The lpPageInformation parameter is not used.
/// </param>
/// <param name="dwInfoLength">The length of the structure that the lpPageInformation parameter points to, in bytes. This value must be 0.</param>
/// <param name="lpNumberOfBytesWritten">A pointer to a variable that receives the number of bytes that <c>LoadEnclaveData</c> copied into the enclave.</param>
/// <param name="dwInfoLength">
/// The length of the structure that the lpPageInformation parameter points to, in bytes. This value must be 0.
/// </param>
/// <param name="lpNumberOfBytesWritten">
/// A pointer to a variable that receives the number of bytes that <c>LoadEnclaveData</c> copied into the enclave.
/// </param>
/// <param name="lpEnclaveError">
/// An optional pointer to a variable that receives an enclave error code that is architecture-specific. The lpEnclaveError parameter is not used.
/// An optional pointer to a variable that receives an enclave error code that is architecture-specific. The lpEnclaveError parameter
/// is not used.
/// </param>
/// <returns>
/// <para>
/// If all of the data is loaded into the enclave successfully, the return value is nonzero. Otherwise, the return value is zero. To get extended error
/// information, call <c>GetLastError</c>.
/// If all of the data is loaded into the enclave successfully, the return value is nonzero. Otherwise, the return value is zero. To
/// get extended error information, call <c>GetLastError</c>.
/// </para>
/// <para>For a list of common error codes, see System Error Codes. The following error codes also apply for this function.</para>
/// <para>
@ -306,17 +331,20 @@ namespace Vanara.PInvoke
/// </listheader>
/// <item>
/// <term>ERROR_BAD_LENGTH</term>
/// <term>The value of the dwInfoLength parameter did not match the value expected based on the value specified for the lpPageInformation parameter.</term>
/// <term>
/// The value of the dwInfoLength parameter did not match the value expected based on the value specified for the lpPageInformation parameter.
/// </term>
/// </item>
/// </list>
/// </para>
/// </returns>
// BOOL WINAPI LoadEnclaveData( _In_ HANDLE hProcess, _In_ LPVOID lpAddress, _In_ LPCVOID lpBuffer, _In_ SIZE_T nSize, _In_ DWORD flProtect, _In_ LPCVOID
// lpPageInformation, _In_ DWORD dwInfoLength, _Out_ PSIZE_T lpNumberOfBytesWritten, _Out_opt_ LPDWORD lpEnclaveError); https://msdn.microsoft.com/en-us/library/windows/desktop/mt592871(v=vs.85).aspx
// BOOL WINAPI LoadEnclaveData( _In_ HANDLE hProcess, _In_ LPVOID lpAddress, _In_ LPCVOID lpBuffer, _In_ SIZE_T nSize, _In_ DWORD
// flProtect, _In_ LPCVOID lpPageInformation, _In_ DWORD dwInfoLength, _Out_ PSIZE_T lpNumberOfBytesWritten, _Out_opt_ LPDWORD
// lpEnclaveError); https://msdn.microsoft.com/en-us/library/windows/desktop/mt592871(v=vs.85).aspx
[DllImport(Lib.Kernel32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("Enclaveapi.h", MSDNShortId = "mt592871")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool LoadEnclaveData(IntPtr hProcess, IntPtr lpAddress, IntPtr lpBuffer, SizeT nSize, MEM_PROTECTION flProtect, IntPtr lpPageInformation, uint dwInfoLength, out SizeT lpNumberOfBytesWritten, out uint lpEnclaveError);
public static extern bool LoadEnclaveData(HPROCESS hProcess, IntPtr lpAddress, IntPtr lpBuffer, SizeT nSize, MEM_PROTECTION flProtect, IntPtr lpPageInformation, uint dwInfoLength, out SizeT lpNumberOfBytesWritten, out uint lpEnclaveError);
/// <summary>Loads an image and all of its imports into an enclave.</summary>
/// <param name="lpEnclaveAddress">The base address of the image into which to load the image.</param>
@ -342,8 +370,8 @@ namespace Vanara.PInvoke
public static extern bool TerminateEnclave(IntPtr lpAddress, [MarshalAs(UnmanagedType.Bool)] bool fWait);
/// <summary>
/// Contains architecture-specific information to use to create an enclave when the enclave type is <c>ENCLAVE_TYPE_SGX</c>, which specifies an enclave
/// for the Intel Software Guard Extensions (SGX) architecture extension.
/// Contains architecture-specific information to use to create an enclave when the enclave type is <c>ENCLAVE_TYPE_SGX</c>, which
/// specifies an enclave for the Intel Software Guard Extensions (SGX) architecture extension.
/// </summary>
// typedef struct _ENCLAVE_CREATE_INFO_SGX { UCHAR Secs[4096];} ENCLAVE_CREATE_INFO_SGX, *PENCLAVE_CREATE_INFO_SGX; https://msdn.microsoft.com/en-us/library/windows/desktop/mt592867(v=vs.85).aspx
[PInvokeData("Winnt.h", MSDNShortId = "mt592867")]
@ -356,8 +384,8 @@ namespace Vanara.PInvoke
}
/// <summary>
/// Contains architecture-specific information to use to create an enclave when the enclave type is <c>ENCLAVE_TYPE_VBS</c>, which specifies a
/// virtualization-based security (VBS) enclave.
/// Contains architecture-specific information to use to create an enclave when the enclave type is <c>ENCLAVE_TYPE_VBS</c>, which
/// specifies a virtualization-based security (VBS) enclave.
/// </summary>
// typedef struct _ENCLAVE_CREATE_INFO_VBS { ULONG Flags; UCHAR OwnerID[32]; } ENCLAVE_CREATE_INFO_VBS, *PENCLAVE_CREATE_INFO_VBS; https://msdn.microsoft.com/en-us/library/windows/desktop/mt844238(v=vs.85).aspx
[PInvokeData("Winnt.h", MSDNShortId = "mt844238")]
@ -384,14 +412,15 @@ namespace Vanara.PInvoke
/// </para>
/// </summary>
public ENCLAVE_VBS_FLAG Flags;
/// <summary>The identifier of the owner of the enclave.</summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)]
public byte[] OwnerID;
}
/// <summary>
/// Contains architecture-specific information to use to initialize an enclave when the enclave type is <c>ENCLAVE_TYPE_SGX</c>, which specifies an
/// enclave for the Intel Software Guard Extensions (SGX) architecture extension.
/// Contains architecture-specific information to use to initialize an enclave when the enclave type is <c>ENCLAVE_TYPE_SGX</c>,
/// which specifies an enclave for the Intel Software Guard Extensions (SGX) architecture extension.
/// </summary>
// typedef struct _ENCLAVE_INIT_INFO_SGX { UCHAR SigStruct[1808]; UCHAR Reserved1[240]; UCHAR EInitToken[304]; UCHAR Reserved2[744];}
// ENCLAVE_INIT_INFO_SGX, *PENCLAVE_INIT_INFO_SGX; https://msdn.microsoft.com/en-us/library/windows/desktop/mt592868(v=vs.85).aspx
@ -400,28 +429,31 @@ namespace Vanara.PInvoke
public struct ENCLAVE_INIT_INFO_SGX
{
/// <summary>
/// The enclave signature structure ( <c>SIGSTRUCT</c>) to use to initialize the enclave. This structure specifies information about the enclave from
/// the enclave signer.
/// The enclave signature structure ( <c>SIGSTRUCT</c>) to use to initialize the enclave. This structure specifies information
/// about the enclave from the enclave signer.
/// </summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 1808)]
public byte[] SigStruct;
/// <summary>Not used.</summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 240)]
public byte[] Reserved1;
/// <summary>
/// The EINIT token structure ( <c>EINITTOKEN</c>) to use to initialize the enclave. The initialization operation uses this structure to verify that
/// the enclave has permission to start.
/// The EINIT token structure ( <c>EINITTOKEN</c>) to use to initialize the enclave. The initialization operation uses this
/// structure to verify that the enclave has permission to start.
/// </summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 304)]
public byte[] EInitToken;
/// <summary>Not used.</summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 1744)]
public byte[] Reserved2;
}
/// <summary>
/// Contains architecture-specific information to use to initialize an enclave when the enclave type is <c>ENCLAVE_TYPE_VBS</c>, which specifies a
/// virtualization-based security (VBS) enclave.
/// Contains architecture-specific information to use to initialize an enclave when the enclave type is <c>ENCLAVE_TYPE_VBS</c>,
/// which specifies a virtualization-based security (VBS) enclave.
/// </summary>
// typedef struct ENCLAVE_INIT_INFO_VBS { ULONG Length; ULONG ThreadCount; }; https://msdn.microsoft.com/en-us/library/windows/desktop/mt844241(v=vs.85).aspx
[PInvokeData("Winnt.h", MSDNShortId = "mt844241")]
@ -430,9 +462,10 @@ namespace Vanara.PInvoke
{
/// <summary>The total length of the <c>ENCLAVE_INIT_INFO_VBS</c> structure, in bytes.</summary>
public uint Length;
/// <summary>
/// Upon entry to the <c>InitializeEnclave</c> function, specifies the number of threads to create in the enclave. Upon successful return from
/// <c>InitializeEnclave</c>, contains the number of threads the function actually created.
/// Upon entry to the <c>InitializeEnclave</c> function, specifies the number of threads to create in the enclave. Upon
/// successful return from <c>InitializeEnclave</c>, contains the number of threads the function actually created.
/// </summary>
public uint ThreadCount;
}

File diff suppressed because it is too large Load Diff

View File

@ -9,26 +9,26 @@ namespace Vanara.PInvoke
public const uint FLS_OUT_OF_INDEXES = 0xFFFFFFFF;
/// <summary>
/// An application-defined function. If the FLS slot is in use, FlsCallback is called on fiber deletion, thread exit, and when an FLS index is freed.
/// Specify this function when calling the FlsAlloc function. The PFLS_CALLBACK_FUNCTION type defines a pointer to this callback function. FlsCallback is
/// a placeholder for the application-defined function name.
/// An application-defined function. If the FLS slot is in use, FlsCallback is called on fiber deletion, thread exit, and when an FLS
/// index is freed. Specify this function when calling the FlsAlloc function. The PFLS_CALLBACK_FUNCTION type defines a pointer to
/// this callback function. FlsCallback is a placeholder for the application-defined function name.
/// </summary>
/// <param name="lpFlsData">The value stored in the FLS slot for the calling fiber.</param>
public delegate void PFLS_CALLBACK_FUNCTION(IntPtr lpFlsData);
/// <summary>
/// Allocates a fiber local storage (FLS) index. Any fiber in the process can subsequently use this index to store and retrieve values that are local to
/// the fiber.
/// Allocates a fiber local storage (FLS) index. Any fiber in the process can subsequently use this index to store and retrieve
/// values that are local to the fiber.
/// </summary>
/// <param name="lpCallback">
/// A pointer to the application-defined callback function of type <c>PFLS_CALLBACK_FUNCTION</c>. This parameter is optional. For more information, see <c>FlsCallback</c>.
/// A pointer to the application-defined callback function of type <c>PFLS_CALLBACK_FUNCTION</c>. This parameter is optional. For
/// more information, see <c>FlsCallback</c>.
/// </param>
/// <returns>
/// <para>If the function succeeds, the return value is an FLS index initialized to zero.</para>
/// <para>If the function fails, the return value is FLS_OUT_OF_INDEXES. To get extended error information, call <c>GetLastError</c>.</para>
/// </returns>
// DWORD WINAPI FlsAlloc( _In_ PFLS_CALLBACK_FUNCTION lpCallback);
// https://msdn.microsoft.com/en-us/library/windows/desktop/ms682664(v=vs.85).aspx
// DWORD WINAPI FlsAlloc( _In_ PFLS_CALLBACK_FUNCTION lpCallback); https://msdn.microsoft.com/en-us/library/windows/desktop/ms682664(v=vs.85).aspx
[DllImport(Lib.Kernel32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("WinBase.h", MSDNShortId = "ms682664")]
public static extern uint FlsAlloc(PFLS_CALLBACK_FUNCTION lpCallback);
@ -39,36 +39,39 @@ namespace Vanara.PInvoke
/// <para>If the function succeeds, the return value is nonzero.</para>
/// <para>If the function fails, the return value is zero. To get extended error information, call <c>GetLastError</c>.</para>
/// </returns>
// BOOL WINAPI FlsFree( _In_ DWORD dwFlsIndex);
// https://msdn.microsoft.com/en-us/library/windows/desktop/ms682667(v=vs.85).aspx
// BOOL WINAPI FlsFree( _In_ DWORD dwFlsIndex); https://msdn.microsoft.com/en-us/library/windows/desktop/ms682667(v=vs.85).aspx
[DllImport(Lib.Kernel32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("WinBase.h", MSDNShortId = "ms682667")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool FlsFree(uint dwFlsIndex);
/// <summary>
/// Retrieves the value in the calling fiber's fiber local storage (FLS) slot for the specified FLS index. Each fiber has its own slot for each FLS index.
/// Retrieves the value in the calling fiber's fiber local storage (FLS) slot for the specified FLS index. Each fiber has its own
/// slot for each FLS index.
/// </summary>
/// <param name="dwFlsIndex">The FLS index that was allocated by the <c>FlsAlloc</c> function.</param>
/// <returns>
/// <para>If the function succeeds, the return value is the value stored in the calling fiber's FLS slot associated with the specified index.</para>
/// <para>
/// If the function succeeds, the return value is the value stored in the calling fiber's FLS slot associated with the specified index.
/// </para>
/// <para>If the function fails, the return value is NULL. To get extended error information, call <c>GetLastError</c>.</para>
/// </returns>
// PVOID WINAPI FlsGetValue( _In_ DWORD dwFlsIndex);
// https://msdn.microsoft.com/en-us/library/windows/desktop/ms683141(v=vs.85).aspx
// PVOID WINAPI FlsGetValue( _In_ DWORD dwFlsIndex); https://msdn.microsoft.com/en-us/library/windows/desktop/ms683141(v=vs.85).aspx
[DllImport(Lib.Kernel32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("WinBase.h", MSDNShortId = "ms683141")]
public static extern IntPtr FlsGetValue(uint dwFlsIndex);
/// <summary>
/// Stores a value in the calling fiber's fiber local storage (FLS) slot for the specified FLS index. Each fiber has its own slot for each FLS index.
/// Stores a value in the calling fiber's fiber local storage (FLS) slot for the specified FLS index. Each fiber has its own slot for
/// each FLS index.
/// </summary>
/// <param name="dwFlsIndex">The FLS index that was allocated by the <c>FlsAlloc</c> function.</param>
/// <param name="lpFlsData">The value to be stored in the FLS slot for the calling fiber.</param>
/// <returns>
/// <para>If the function succeeds, the return value is nonzero.</para>
/// <para>
/// If the function fails, the return value is zero. To get extended error information, call <c>GetLastError</c>. The following errors can be returned.
/// If the function fails, the return value is zero. To get extended error information, call <c>GetLastError</c>. The following
/// errors can be returned.
/// </para>
/// <para>
/// <list type="table">
@ -87,8 +90,7 @@ namespace Vanara.PInvoke
/// </list>
/// </para>
/// </returns>
// BOOL WINAPI FlsSetValue( _In_ DWORD dwFlsIndex, _In_opt_ PVOID lpFlsData);
// https://msdn.microsoft.com/en-us/library/windows/desktop/ms683146(v=vs.85).aspx
// BOOL WINAPI FlsSetValue( _In_ DWORD dwFlsIndex, _In_opt_ PVOID lpFlsData); https://msdn.microsoft.com/en-us/library/windows/desktop/ms683146(v=vs.85).aspx
[DllImport(Lib.Kernel32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("WinBase.h", MSDNShortId = "ms683146")]
[return: MarshalAs(UnmanagedType.Bool)]
@ -96,8 +98,7 @@ namespace Vanara.PInvoke
/// <summary>Determines whether the current thread is a fiber.</summary>
/// <returns>The function returns <c>TRUE</c> if the thread is a fiber and <c>FALSE</c> otherwise.</returns>
// BOOL WINAPI IsThreadAFiber(void);
// https://msdn.microsoft.com/en-us/library/windows/desktop/ms684131(v=vs.85).aspx
// BOOL WINAPI IsThreadAFiber(void); https://msdn.microsoft.com/en-us/library/windows/desktop/ms684131(v=vs.85).aspx
[DllImport(Lib.Kernel32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("WinBase.h", MSDNShortId = "ms684131")]
[return: MarshalAs(UnmanagedType.Bool)]

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,114 @@
using System.Runtime.InteropServices;
namespace Vanara.PInvoke
{
public static partial class Kernel32
{
/// <summary>
/// <para>Indicates the type of device that the game is running on.</para>
/// </summary>
/// <remarks>
/// <para>
/// This is a Win32 API that's supported in both Win32 and UWP apps. While it works on any device family, it's only really of value
/// on Xbox devices.
/// </para>
/// </remarks>
// https://docs.microsoft.com/en-us/windows/desktop/api/gamingdeviceinformation/ne-gamingdeviceinformation-gaming_device_device_id
// typedef enum GAMING_DEVICE_DEVICE_ID { GAMING_DEVICE_DEVICE_ID_NONE , GAMING_DEVICE_DEVICE_ID_XBOX_ONE ,
// GAMING_DEVICE_DEVICE_ID_XBOX_ONE_S , GAMING_DEVICE_DEVICE_ID_XBOX_ONE_X , GAMING_DEVICE_DEVICE_ID_XBOX_ONE_X_DEVKIT } ;
[PInvokeData("gamingdeviceinformation.h", MSDNShortId = "DA196767-940E-47CF-8444-4A2C37E3718B")]
public enum GAMING_DEVICE_DEVICE_ID
{
/// <summary>The device is not in the Xbox family.</summary>
GAMING_DEVICE_DEVICE_ID_NONE,
/// <summary>The device is an Xbox One (original).</summary>
GAMING_DEVICE_DEVICE_ID_XBOX_ONE,
/// <summary>The device is an Xbox One S.</summary>
GAMING_DEVICE_DEVICE_ID_XBOX_ONE_S,
/// <summary>The device is an Xbox One X.</summary>
GAMING_DEVICE_DEVICE_ID_XBOX_ONE_X,
/// <summary>The device is an Xbox One X dev kit.</summary>
GAMING_DEVICE_DEVICE_ID_XBOX_ONE_X_DEVKIT,
}
/// <summary>
/// <para>Indicates the vendor of the console that the game is running on.</para>
/// </summary>
/// <remarks>
/// <para>
/// This is a Win32 API that's supported in both Win32 and UWP apps. While it works on any device family, it's only really of value
/// on Xbox devices.
/// </para>
/// </remarks>
// https://docs.microsoft.com/en-us/windows/desktop/api/gamingdeviceinformation/ne-gamingdeviceinformation-gaming_device_vendor_id
// typedef enum GAMING_DEVICE_VENDOR_ID { GAMING_DEVICE_VENDOR_ID_NONE , GAMING_DEVICE_VENDOR_ID_MICROSOFT } ;
[PInvokeData("gamingdeviceinformation.h", MSDNShortId = "0A74E610-9853-4299-A278-41C3B7F47D9C")]
public enum GAMING_DEVICE_VENDOR_ID
{
/// <summary>The vendor of the device is not known.</summary>
GAMING_DEVICE_VENDOR_ID_NONE,
/// <summary>The vendor of the device is Microsoft.</summary>
GAMING_DEVICE_VENDOR_ID_MICROSOFT,
}
/// <summary>
/// <para>Gets information about the device that the game is running on.</para>
/// </summary>
/// <param name="information">
/// <para>A structure containing information about the device that the game is running on.</para>
/// </param>
/// <returns>
/// <para>This function does not return a value.</para>
/// </returns>
/// <remarks>
/// <para>
/// This is a Win32 API that's supported in both Win32 and UWP apps. While it works on any device family, it's only really of value
/// on Xbox devices.
/// </para>
/// <para>
/// This function gets information about the console that the game is running on, including the type of console (Xbox One, Xbox One
/// S, etc.) and the vendor. On non-Xbox devices, it returns <c>GAMING_DEVICE_DEVICE_ID_NONE</c> and <c>GAMING_DEVICE_VENDOR_ID_NONE</c>.
/// </para>
/// <para>
/// If the game is running in an emulation mode, the type of device being emulated is returned. For example, if the game is running
/// on an Xbox One X dev kit in Xbox One emulation mode, <c>GAMING_DEVICE_DEVICE_ID_XBOX_ONE</c> is returned.
/// </para>
/// </remarks>
// https://docs.microsoft.com/en-us/windows/desktop/api/gamingdeviceinformation/nf-gamingdeviceinformation-getgamingdevicemodelinformation
// HRESULT GetGamingDeviceModelInformation( GAMING_DEVICE_MODEL_INFORMATION *information );
[DllImport(Lib.KernelBase, SetLastError = false, ExactSpelling = true)]
[PInvokeData("gamingdeviceinformation.h", MSDNShortId = "78101CBA-63B5-4B3F-9CEC-A215F32D9EB8")]
public static extern HRESULT GetGamingDeviceModelInformation(out GAMING_DEVICE_MODEL_INFORMATION information);
/// <summary>
/// <para>Contains information about the device that the game is running on.</para>
/// </summary>
/// <remarks>
/// <para>
/// This is a Win32 API that's supported in both Win32 and UWP apps. While it works on any device family, it's only really of value
/// on Xbox devices.
/// </para>
/// </remarks>
// https://docs.microsoft.com/en-us/windows/desktop/api/gamingdeviceinformation/ns-gamingdeviceinformation-gaming_device_model_information
// typedef struct GAMING_DEVICE_MODEL_INFORMATION { GAMING_DEVICE_VENDOR_ID vendorId; GAMING_DEVICE_DEVICE_ID deviceId; };
[PInvokeData("gamingdeviceinformation.h", MSDNShortId = "0D5A6358-0F82-4414-BD17-BDE22EDBBB15")]
[StructLayout(LayoutKind.Sequential)]
public struct GAMING_DEVICE_MODEL_INFORMATION
{
/// <summary>
/// <para>The vendor of the device.</para>
/// </summary>
public GAMING_DEVICE_VENDOR_ID vendorId;
/// <summary>
/// <para>The type of device.</para>
/// </summary>
public GAMING_DEVICE_DEVICE_ID deviceId;
}
}
}

View File

@ -56,7 +56,7 @@ namespace Vanara.PInvoke
[DllImport(Lib.KernelBase, SetLastError = false, ExactSpelling = true)]
[PInvokeData("Handleapi.h", MSDNShortId = "mt438733")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool CompareObjectHandles(HANDLE hFirstObjectHandle, HANDLE hSecondObjectHandle);
public static extern bool CompareObjectHandles(IntPtr hFirstObjectHandle, IntPtr hSecondObjectHandle);
/// <summary>Duplicates an object handle.</summary>
/// <param name="hSourceProcessHandle">
@ -122,7 +122,7 @@ namespace Vanara.PInvoke
[PInvokeData("Winbase.h", MSDNShortId = "ms724251")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool DuplicateHandle(
[In] IntPtr hSourceProcessHandle, [In] HANDLE hSourceHandle, [In] IntPtr hTargetProcessHandle, out HANDLE lpTargetHandle, uint dwDesiredAccess,
[In] HPROCESS hSourceProcessHandle, [In] IntPtr hSourceHandle, [In] HPROCESS hTargetProcessHandle, out HANDLE lpTargetHandle, uint dwDesiredAccess,
[MarshalAs(UnmanagedType.Bool)] bool bInheritHandle, DUPLICATE_HANDLE_OPTIONS dwOptions);
/// <summary>Retrieves certain properties of an object handle.</summary>
@ -160,7 +160,7 @@ namespace Vanara.PInvoke
[DllImport(Lib.Kernel32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("Winbase.h", MSDNShortId = "ms724329")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool GetHandleInformation([In] HANDLE hObject, out HANDLE_FLAG lpdwFlags);
public static extern bool GetHandleInformation([In] IntPtr hObject, out HANDLE_FLAG lpdwFlags);
/// <summary>Sets certain properties of an object handle.</summary>
/// <param name="hObject">
@ -198,6 +198,36 @@ namespace Vanara.PInvoke
[DllImport(Lib.Kernel32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("Winbase.h", MSDNShortId = "ms724935")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SetHandleInformation([In] HANDLE hObject, HANDLE_FLAG dwMask, HANDLE_FLAG dwFlags);
public static extern bool SetHandleInformation([In] IntPtr hObject, HANDLE_FLAG dwMask, HANDLE_FLAG dwFlags);
/// <summary>Provides a <see cref="SafeHandle"/> to a handle that releases a created HANDLE instance at disposal using CloseHandle.</summary>
public abstract class SafeKernelHandle : HANDLE, IKernelHandle
{
/// <summary>Initializes a new instance of the <see cref="SafeSyncHandle"/> class.</summary>
protected SafeKernelHandle() : base() { }
/// <summary>Initializes a new instance of the <see cref="HANDLE"/> class and assigns an existing handle.</summary>
/// <param name="preexistingHandle">An <see cref="IntPtr"/> object that represents the pre-existing handle to use.</param>
/// <param name="ownsHandle"><see langword="true"/> to reliably release the handle during the finalization phase; otherwise, <see langword="false"/> (not recommended).</param>
protected SafeKernelHandle(IntPtr preexistingHandle, bool ownsHandle = true) : base(preexistingHandle, ownsHandle) { }
/// <inheritdoc/>
protected override bool InternalReleaseHandle() => CloseHandle(this);
}
/// <summary>Provides a <see cref="SafeHandle"/> to a synchronization object that is automatically disposed using CloseHandle.</summary>
/// <remarks></remarks>
public abstract class SafeSyncHandle : SafeKernelHandle, ISyncHandle
{
/// <summary>Initializes a new instance of the <see cref="SafeSyncHandle"/> class.</summary>
protected SafeSyncHandle() : base() { }
/// <summary>Initializes a new instance of the <see cref="SafeSyncHandle"/> class and assigns an existing handle.</summary>
/// <param name="preexistingHandle">An <see cref="IntPtr"/> object that represents the pre-existing handle to use.</param>
/// <param name="ownsHandle">
/// <see langword="true"/> to reliably release the handle during the finalization phase; otherwise, <see langword="false"/> (not recommended).
/// </param>
protected SafeSyncHandle(IntPtr preexistingHandle, bool ownsHandle = true) : base(preexistingHandle, ownsHandle) { }
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -28,10 +28,7 @@ namespace Vanara.InteropServices
/// <summary>Performs necessary cleanup of the unmanaged data when it is no longer needed.</summary>
/// <param name="pNativeData">A pointer to the unmanaged data to be destroyed.</param>
public void CleanUpNativeData(IntPtr pNativeData)
{
mm.FreeMem(pNativeData);
}
public void CleanUpNativeData(IntPtr pNativeData) => mm.FreeMem(pNativeData);
/// <summary>Returns the size of the native data to be marshaled.</summary>
/// <returns>The size in bytes of the native data.</returns>
@ -47,4 +44,4 @@ namespace Vanara.InteropServices
/// <returns>Returns the managed view of the COM data.</returns>
public object MarshalNativeToManaged(IntPtr pNativeData) => StringHelper.GetString(pNativeData, charSet);
}
}
}

View File

@ -14,56 +14,31 @@ namespace Vanara.InteropServices
public sealed class LocalMemoryMethods : IMemoryMethods
{
/// <summary>Gets the allocation method.</summary>
public Func<int, IntPtr> AllocMem => i => { var o = LocalAlloc(LMEM.LPTR, (UIntPtr)i); return o != IntPtr.Zero ? o : throw Win32Error.GetLastError().GetException(); };
/// <summary>Gets the reallocation method.</summary>
public Func<IntPtr, int, IntPtr> ReAllocMem => (p, i) => { var o = LocalReAlloc(p, (UIntPtr)i, LMEM.LMEM_MOVEABLE); return o != IntPtr.Zero ? o : throw Win32Error.GetLastError().GetException(); };
public Func<int, IntPtr> AllocMem => i => { var o = LocalAlloc(LMEM.LPTR, i); return !o.IsNull ? (IntPtr)o : throw Win32Error.GetLastError().GetException(); };
/// <summary>Gets the Ansi <see cref="SecureString"/> allocation method.</summary>
public Func<SecureString, IntPtr> AllocSecureStringAnsi => s => StringHelper.AllocSecureString(s, CharSet.Ansi, AllocMem);
/// <summary>Gets the Unicode <see cref="SecureString"/> allocation method.</summary>
public Func<SecureString, IntPtr> AllocSecureStringUni => s => StringHelper.AllocSecureString(s, CharSet.Unicode, AllocMem);
/// <summary>Gets the Ansi string allocation method.</summary>
public Func<string, IntPtr> AllocStringAnsi => s => StringHelper.AllocString(s, CharSet.Ansi, AllocMem);
/// <summary>Gets the Unicode string allocation method.</summary>
public Func<string, IntPtr> AllocStringUni => s => StringHelper.AllocString(s, CharSet.Unicode, AllocMem);
/// <summary>Gets the free method.</summary>
public Action<IntPtr> FreeMem => p => LocalFree(p);
/// <summary>Gets the Unicode string allocation method.</summary>
public Func<string, IntPtr> AllocStringUni => s => MakeString(s, CharSet.Unicode);
/// <summary>Gets the Ansi string allocation method.</summary>
public Func<string, IntPtr> AllocStringAnsi => s => MakeString(s, CharSet.Ansi);
/// <summary>Gets the Unicode <see cref="SecureString"/> allocation method.</summary>
public Func<SecureString, IntPtr> AllocSecureStringUni => s => MakeSecString(s, CharSet.Unicode);
/// <summary>Gets the Ansi <see cref="SecureString"/> allocation method.</summary>
public Func<SecureString, IntPtr> AllocSecureStringAnsi => s => MakeSecString(s, CharSet.Ansi);
/// <summary>Gets the Unicode <see cref="SecureString"/> free method.</summary>
public Action<IntPtr> FreeSecureStringUni => FreeSecureString;
/// <summary>Gets the Ansi <see cref="SecureString"/> free method.</summary>
public Action<IntPtr> FreeSecureStringAnsi => FreeSecureString;
public Action<IntPtr> FreeSecureStringAnsi => p => StringHelper.FreeSecureString(p, LocalSize(p), FreeMem);
private void FreeSecureString(IntPtr p)
{
if (p == IntPtr.Zero) return;
var i = LocalSize(p);
var b = new byte[i];
Marshal.Copy(b, 0, p, b.Length);
FreeMem(p);
}
/// <summary>Gets the Unicode <see cref="SecureString"/> free method.</summary>
public Action<IntPtr> FreeSecureStringUni => p => StringHelper.FreeSecureString(p, LocalSize(p), FreeMem);
private IntPtr MakeSecString(SecureString s, CharSet charSet)
{
if (s == null) return IntPtr.Zero;
var chSz = StringHelper.GetCharSize(charSet);
var encoding = chSz == 2 ? System.Text.Encoding.Unicode : System.Text.Encoding.ASCII;
var hMem = StringHelper.AllocSecureString(s, charSet);
var str = chSz == 2 ? Marshal.PtrToStringUni(hMem) : Marshal.PtrToStringAnsi(hMem);
Marshal.FreeCoTaskMem(hMem);
if (str == null) return IntPtr.Zero;
var b = encoding.GetBytes(str);
var p = AllocMem(b.Length);
Marshal.Copy(b, 0, p, b.Length);
return p;
}
private IntPtr MakeString(string s, CharSet charSet)
{
if (s == null) return IntPtr.Zero;
var b = s.GetBytes(true, charSet);
var p = AllocMem(b.Length);
Marshal.Copy(b, 0, p, b.Length);
return p;
}
/// <summary>Gets the reallocation method.</summary>
public Func<IntPtr, int, IntPtr> ReAllocMem => (p, i) => { var o = LocalReAlloc(p, i, LMEM.LMEM_MOVEABLE); return !o.IsNull ? (IntPtr)o : throw Win32Error.GetLastError().GetException(); };
}
/// <summary>A <see cref="SafeHandle"/> for memory allocated via LocalAlloc.</summary>
@ -74,19 +49,25 @@ namespace Vanara.InteropServices
/// <param name="handle">The handle.</param>
/// <param name="size">The size of memory allocated to the handle, in bytes.</param>
/// <param name="ownsHandle">if set to <c>true</c> if this class is responsible for freeing the memory on disposal.</param>
public SafeLocalHandle(IntPtr handle, int size, bool ownsHandle = true) : base(handle, size, ownsHandle) { }
public SafeLocalHandle(HLOCAL handle, int size, bool ownsHandle = true) : base((IntPtr)handle, size, ownsHandle) { }
/// <summary>Initializes a new instance of the <see cref="SafeLocalHandle"/> class.</summary>
/// <param name="size">The size of memory to allocate, in bytes.</param>
/// <exception cref="System.ArgumentOutOfRangeException">size - The value of this argument must be non-negative</exception>
public SafeLocalHandle(int size) : base(size) { }
/// <summary>Allocates from unmanaged memory to represent an array of pointers and marshals the unmanaged pointers (IntPtr) to the native array equivalent.</summary>
/// <summary>
/// Allocates from unmanaged memory to represent an array of pointers and marshals the unmanaged pointers (IntPtr) to the native
/// array equivalent.
/// </summary>
/// <param name="bytes">Array of unmanaged pointers</param>
/// <returns>SafeLocalHandle object to an native (unmanaged) array of pointers</returns>
public SafeLocalHandle(byte[] bytes) : base(bytes) { }
/// <summary>Allocates from unmanaged memory to represent an array of pointers and marshals the unmanaged pointers (IntPtr) to the native array equivalent.</summary>
/// <summary>
/// Allocates from unmanaged memory to represent an array of pointers and marshals the unmanaged pointers (IntPtr) to the native
/// array equivalent.
/// </summary>
/// <param name="values">Array of unmanaged pointers</param>
/// <returns>SafeLocalHandle object to an native (unmanaged) array of pointers</returns>
public SafeLocalHandle(IntPtr[] values) : base(values) { }
@ -103,35 +84,38 @@ namespace Vanara.InteropServices
/// <summary>Represents a NULL memory pointer.</summary>
public static SafeLocalHandle Null { get; } = new SafeLocalHandle(IntPtr.Zero, 0, false);
/// <summary>Converts an <see cref="IntPtr"/> to a <see cref="SafeLocalHandle"/> where it owns the reference.</summary>
/// <param name="ptr">The <see cref="IntPtr"/>.</param>
/// <returns>The result of the conversion.</returns>
public static implicit operator SafeLocalHandle(IntPtr ptr) => new SafeLocalHandle(ptr, 0, true);
/// <summary>Allocates from unmanaged memory sufficient memory to hold an object of type T.</summary>
/// <typeparam name="T">Native type</typeparam>
/// <param name="value">The value.</param>
/// <returns><see cref="SafeLocalHandle"/> object to an native (unmanaged) memory block the size of T.</returns>
public static SafeLocalHandle CreateFromStructure<T>(T value = default(T)) => new SafeLocalHandle(InteropExtensions.StructureToPtr(value, mm.AllocMem, out int s), s);
/// <summary>
/// Allocates from unmanaged memory to represent a structure with a variable length array at the end and marshal these structure elements. It is the
/// callers responsibility to marshal what precedes the trailing array into the unmanaged memory. ONLY structures with attribute StructLayout of
/// LayoutKind.Sequential are supported.
/// Allocates from unmanaged memory to represent a structure with a variable length array at the end and marshal these structure
/// elements. It is the callers responsibility to marshal what precedes the trailing array into the unmanaged memory. ONLY structures
/// with attribute StructLayout of LayoutKind.Sequential are supported.
/// </summary>
/// <typeparam name="T">Type of the trailing array of structures</typeparam>
/// <param name="values">Collection of structure objects</param>
/// <param name="count">Number of items in <paramref name="values"/>.</param>
/// <param name="prefixBytes">Number of bytes preceding the trailing array of structures</param>
/// <returns><see cref="SafeLocalHandle"/> object to an native (unmanaged) structure with a trail array of structures</returns>
public static SafeLocalHandle CreateFromList<T>(IEnumerable<T> values, int count = -1, int prefixBytes = 0) => new SafeLocalHandle(InteropExtensions.MarshalToPtr(values, mm.AllocMem, out int s, prefixBytes), s);
public static SafeLocalHandle CreateFromList<T>(IEnumerable<T> values, int count = -1, int prefixBytes = 0) => new SafeLocalHandle(InteropExtensions.MarshalToPtr(values, new LocalMemoryMethods().AllocMem, out var s, prefixBytes), s);
/// <summary>Allocates from unmanaged memory sufficient memory to hold an array of strings.</summary>
/// <param name="values">The list of strings.</param>
/// <param name="packing">The packing type for the strings.</param>
/// <param name="charSet">The character set to use for the strings.</param>
/// <param name="prefixBytes">Number of bytes preceding the trailing strings.</param>
/// <returns><see cref="SafeLocalHandle"/> object to an native (unmanaged) array of strings stored using the <paramref name="packing"/> model and the character set defined by <paramref name="charSet"/>.</returns>
public static SafeLocalHandle CreateFromStringList(IEnumerable<string> values, StringListPackMethod packing = StringListPackMethod.Concatenated, CharSet charSet = CharSet.Auto, int prefixBytes = 0) => new SafeLocalHandle(InteropExtensions.MarshalToPtr(values, packing, mm.AllocMem, out int s, charSet, prefixBytes), s);
/// <returns>
/// <see cref="SafeLocalHandle"/> object to an native (unmanaged) array of strings stored using the <paramref name="packing"/> model
/// and the character set defined by <paramref name="charSet"/>.
/// </returns>
public static SafeLocalHandle CreateFromStringList(IEnumerable<string> values, StringListPackMethod packing = StringListPackMethod.Concatenated, CharSet charSet = CharSet.Auto, int prefixBytes = 0) => new SafeLocalHandle(InteropExtensions.MarshalToPtr(values, packing, new LocalMemoryMethods().AllocMem, out var s, charSet, prefixBytes), s);
/// <summary>Allocates from unmanaged memory sufficient memory to hold an object of type T.</summary>
/// <typeparam name="T">Native type</typeparam>
/// <param name="value">The value.</param>
/// <returns><see cref="SafeLocalHandle"/> object to an native (unmanaged) memory block the size of T.</returns>
public static SafeLocalHandle CreateFromStructure<T>(T value = default(T)) => new SafeLocalHandle(InteropExtensions.StructureToPtr(value, new LocalMemoryMethods().AllocMem, out var s), s);
/// <summary>Converts an <see cref="IntPtr"/> to a <see cref="SafeLocalHandle"/> where it owns the reference.</summary>
/// <param name="ptr">The <see cref="IntPtr"/>.</param>
/// <returns>The result of the conversion.</returns>
public static implicit operator SafeLocalHandle(IntPtr ptr) => new SafeLocalHandle(ptr, 0, true);
}
}

View File

@ -1,208 +1,207 @@
#if !(NET20 || NET35)
using Microsoft.Win32.SafeHandles;
using System;
using System.ComponentModel;
using System.Runtime.InteropServices;
using System.Security.Permissions;
using System.Threading;
using System.Threading.Tasks;
namespace Vanara.PInvoke
{
public static partial class Kernel32
{
/// <summary>
/// Sends a control code directly to a specified device driver, causing the corresponding device to perform the corresponding operation.
/// </summary>
/// <typeparam name="TIn">The type of the <paramref name="inVal"/>.</typeparam>
/// <param name="hDev">A handle to the device on which the operation is to be performed. The device is typically a volume, directory, file, or stream. To retrieve a device
/// handle, use the CreateFile function. For more information, see Remarks.</param>
/// <param name="ioControlCode">The control code for the operation. This value identifies the specific operation to be performed and the type of device on which to perform it.</param>
/// <param name="inVal">The input value required to perform the operation. The type of this data depends on the value of the <paramref name="ioControlCode"/> parameter.</param>
/// <returns>An asynchronous empty result.</returns>
/// <remarks>
/// <para>
/// To retrieve a handle to the device, you must call the CreateFile function with either the name of a device or the name of the driver associated with
/// a device. To specify a device name, use the following format:
/// </para>
/// <para>\\.\DeviceName</para>
/// <para>
/// DeviceIoControl can accept a handle to a specific device. For example, to open a handle to the logical drive
/// A: with CreateFile, specify \\.\a:. Alternatively, you can use the names \\.\PhysicalDrive0, \\.\PhysicalDrive1, and so on, to open handles to the
/// physical drives on a system.
/// </para>
/// <para>
/// You should specify the FILE_SHARE_READ and FILE_SHARE_WRITE access flags when calling CreateFile to open a handle to a device driver. However, when
/// you open a communications resource, such as a serial port, you must specify exclusive access. Use the other CreateFile parameters as follows when
/// opening a device handle:
/// </para>
/// <list type="bullet">
/// <item>
/// <description>The fdwCreate parameter must specify OPEN_EXISTING.</description>
/// </item>
/// <item>
/// <description>The hTemplateFile parameter must be NULL.</description>
/// </item>
/// <item>
/// <description>The fdwAttrsAndFlags parameter can specify FILE_FLAG_OVERLAPPED to indicate that the returned handle can be used in overlapped (asynchronous) I/O operations.</description>
/// </item>
/// </list>
/// </remarks>
public static Task DeviceIoControlAsync<TIn>(HFILE hDev, uint ioControlCode, TIn inVal) where TIn : struct
{
return DeviceIoControlAsync(hDev, ioControlCode, (TIn?)inVal, (int?)null);
}
public static partial class Kernel32
{
/// <summary>
/// Sends a control code directly to a specified device driver, causing the corresponding device to perform the corresponding operation.
/// </summary>
/// <typeparam name="TIn">The type of the <paramref name="inVal"/>.</typeparam>
/// <param name="hDev">A handle to the device on which the operation is to be performed. The device is typically a volume, directory, file, or stream. To retrieve a device
/// handle, use the CreateFile function. For more information, see Remarks.</param>
/// <param name="ioControlCode">The control code for the operation. This value identifies the specific operation to be performed and the type of device on which to perform it.</param>
/// <param name="inVal">The input value required to perform the operation. The type of this data depends on the value of the <paramref name="ioControlCode"/> parameter.</param>
/// <returns>An asynchronous empty result.</returns>
/// <remarks>
/// <para>
/// To retrieve a handle to the device, you must call the CreateFile function with either the name of a device or the name of the driver associated with
/// a device. To specify a device name, use the following format:
/// </para>
/// <para>\\.\DeviceName</para>
/// <para>
/// DeviceIoControl can accept a handle to a specific device. For example, to open a handle to the logical drive
/// A: with CreateFile, specify \\.\a:. Alternatively, you can use the names \\.\PhysicalDrive0, \\.\PhysicalDrive1, and so on, to open handles to the
/// physical drives on a system.
/// </para>
/// <para>
/// You should specify the FILE_SHARE_READ and FILE_SHARE_WRITE access flags when calling CreateFile to open a handle to a device driver. However, when
/// you open a communications resource, such as a serial port, you must specify exclusive access. Use the other CreateFile parameters as follows when
/// opening a device handle:
/// </para>
/// <list type="bullet">
/// <item>
/// <description>The fdwCreate parameter must specify OPEN_EXISTING.</description>
/// </item>
/// <item>
/// <description>The hTemplateFile parameter must be NULL.</description>
/// </item>
/// <item>
/// <description>The fdwAttrsAndFlags parameter can specify FILE_FLAG_OVERLAPPED to indicate that the returned handle can be used in overlapped (asynchronous) I/O operations.</description>
/// </item>
/// </list>
/// </remarks>
public static Task DeviceIoControlAsync<TIn>(HFILE hDev, uint ioControlCode, TIn inVal) where TIn : struct =>
DeviceIoControlAsync(hDev, ioControlCode, (TIn?)inVal, (int?)null);
/// <summary>
/// Sends a control code directly to a specified device driver, causing the corresponding device to perform the corresponding operation.
/// </summary>
/// <typeparam name="TOut">The type of the return value.</typeparam>
/// <param name="hDev">A handle to the device on which the operation is to be performed. The device is typically a volume, directory, file, or stream. To retrieve a device
/// handle, use the CreateFile function. For more information, see Remarks.</param>
/// <param name="ioControlCode">The control code for the operation. This value identifies the specific operation to be performed and the type of device on which to perform it.</param>
/// <returns>An asynchronous result containing the resulting value of type <typeparamref name="TOut"/>.</returns>
/// <remarks>
/// <para>
/// To retrieve a handle to the device, you must call the CreateFile function with either the name of a device or the name of the driver associated with
/// a device. To specify a device name, use the following format:
/// </para>
/// <para>\\.\DeviceName</para>
/// <para>
/// DeviceIoControl can accept a handle to a specific device. For example, to open a handle to the logical drive
/// A: with CreateFile, specify \\.\a:. Alternatively, you can use the names \\.\PhysicalDrive0, \\.\PhysicalDrive1, and so on, to open handles to the
/// physical drives on a system.
/// </para>
/// <para>
/// You should specify the FILE_SHARE_READ and FILE_SHARE_WRITE access flags when calling CreateFile to open a handle to a device driver. However, when
/// you open a communications resource, such as a serial port, you must specify exclusive access. Use the other CreateFile parameters as follows when
/// opening a device handle:
/// </para>
/// <list type="bullet">
/// <item>
/// <description>The fdwCreate parameter must specify OPEN_EXISTING.</description>
/// </item>
/// <item>
/// <description>The hTemplateFile parameter must be NULL.</description>
/// </item>
/// <item>
/// <description>The fdwAttrsAndFlags parameter can specify FILE_FLAG_OVERLAPPED to indicate that the returned handle can be used in overlapped (asynchronous) I/O operations.</description>
/// </item>
/// </list>
/// </remarks>
public static Task<TOut?> DeviceIoControlAsync<TOut>(HFILE hDev, uint ioControlCode) where TOut : struct
{
var outVal = default(TOut);
return DeviceIoControlAsync(hDev, ioControlCode, (int?)null, (TOut?)outVal);
}
/// <summary>
/// Sends a control code directly to a specified device driver, causing the corresponding device to perform the corresponding operation.
/// </summary>
/// <typeparam name="TOut">The type of the return value.</typeparam>
/// <param name="hDev">A handle to the device on which the operation is to be performed. The device is typically a volume, directory, file, or stream. To retrieve a device
/// handle, use the CreateFile function. For more information, see Remarks.</param>
/// <param name="ioControlCode">The control code for the operation. This value identifies the specific operation to be performed and the type of device on which to perform it.</param>
/// <returns>An asynchronous result containing the resulting value of type <typeparamref name="TOut"/>.</returns>
/// <remarks>
/// <para>
/// To retrieve a handle to the device, you must call the CreateFile function with either the name of a device or the name of the driver associated with
/// a device. To specify a device name, use the following format:
/// </para>
/// <para>\\.\DeviceName</para>
/// <para>
/// DeviceIoControl can accept a handle to a specific device. For example, to open a handle to the logical drive
/// A: with CreateFile, specify \\.\a:. Alternatively, you can use the names \\.\PhysicalDrive0, \\.\PhysicalDrive1, and so on, to open handles to the
/// physical drives on a system.
/// </para>
/// <para>
/// You should specify the FILE_SHARE_READ and FILE_SHARE_WRITE access flags when calling CreateFile to open a handle to a device driver. However, when
/// you open a communications resource, such as a serial port, you must specify exclusive access. Use the other CreateFile parameters as follows when
/// opening a device handle:
/// </para>
/// <list type="bullet">
/// <item>
/// <description>The fdwCreate parameter must specify OPEN_EXISTING.</description>
/// </item>
/// <item>
/// <description>The hTemplateFile parameter must be NULL.</description>
/// </item>
/// <item>
/// <description>The fdwAttrsAndFlags parameter can specify FILE_FLAG_OVERLAPPED to indicate that the returned handle can be used in overlapped (asynchronous) I/O operations.</description>
/// </item>
/// </list>
/// </remarks>
public static Task<TOut?> DeviceIoControlAsync<TOut>(HFILE hDev, uint ioControlCode) where TOut : struct
{
var outVal = default(TOut);
return DeviceIoControlAsync(hDev, ioControlCode, (int?)null, (TOut?)outVal);
}
/// <summary>
/// Sends a control code directly to a specified device driver, causing the corresponding device to perform the corresponding operation.
/// </summary>
/// <typeparam name="TIn">The type of the <paramref name="inVal"/>.</typeparam>
/// <typeparam name="TOut">The type of the <paramref name="outVal"/>.</typeparam>
/// <param name="hDevice">A handle to the device on which the operation is to be performed. The device is typically a volume, directory, file, or stream. To retrieve a device
/// handle, use the CreateFile function. For more information, see Remarks.</param>
/// <param name="ioControlCode">The control code for the operation. This value identifies the specific operation to be performed and the type of device on which to perform it.</param>
/// <param name="inVal">The input value required to perform the operation. The type of this data depends on the value of the <paramref name="ioControlCode"/> parameter.</param>
/// <param name="outVal">The output value that is to receive the data returned by the operation. The type of this data depends on the value of the dwIoControlCode parameter.</param>
/// <returns>An asynchronous result containing the populated data supplied by <paramref name="outVal"/>.</returns>
/// <remarks>
/// <para>
/// To retrieve a handle to the device, you must call the CreateFile function with either the name of a device or the name of the driver associated with
/// a device. To specify a device name, use the following format:
/// </para>
/// <para>\\.\DeviceName</para>
/// <para>
/// DeviceIoControl can accept a handle to a specific device. For example, to open a handle to the logical drive
/// A: with CreateFile, specify \\.\a:. Alternatively, you can use the names \\.\PhysicalDrive0, \\.\PhysicalDrive1, and so on, to open handles to the
/// physical drives on a system.
/// </para>
/// <para>
/// You should specify the FILE_SHARE_READ and FILE_SHARE_WRITE access flags when calling CreateFile to open a handle to a device driver. However, when
/// you open a communications resource, such as a serial port, you must specify exclusive access. Use the other CreateFile parameters as follows when
/// opening a device handle:
/// </para>
/// <list type="bullet">
/// <item>
/// <description>The fdwCreate parameter must specify OPEN_EXISTING.</description>
/// </item>
/// <item>
/// <description>The hTemplateFile parameter must be NULL.</description>
/// </item>
/// <item>
/// <description>The fdwAttrsAndFlags parameter can specify FILE_FLAG_OVERLAPPED to indicate that the returned handle can be used in overlapped (asynchronous) I/O operations.</description>
/// </item>
/// </list>
/// </remarks>
public static Task<TOut?> DeviceIoControlAsync<TIn, TOut>(HFILE hDevice, uint ioControlCode, TIn? inVal, TOut? outVal) where TIn : struct where TOut : struct
{
var buf = Pack(inVal, outVal);
return new TaskFactory().FromAsync(BeginDeviceIoControl<TIn, TOut>, EndDeviceIoControl<TIn, TOut>, hDevice, ioControlCode, buf, null);
}
/// <summary>
/// Sends a control code directly to a specified device driver, causing the corresponding device to perform the corresponding operation.
/// </summary>
/// <typeparam name="TIn">The type of the <paramref name="inVal"/>.</typeparam>
/// <typeparam name="TOut">The type of the <paramref name="outVal"/>.</typeparam>
/// <param name="hDevice">A handle to the device on which the operation is to be performed. The device is typically a volume, directory, file, or stream. To retrieve a device
/// handle, use the CreateFile function. For more information, see Remarks.</param>
/// <param name="ioControlCode">The control code for the operation. This value identifies the specific operation to be performed and the type of device on which to perform it.</param>
/// <param name="inVal">The input value required to perform the operation. The type of this data depends on the value of the <paramref name="ioControlCode"/> parameter.</param>
/// <param name="outVal">The output value that is to receive the data returned by the operation. The type of this data depends on the value of the dwIoControlCode parameter.</param>
/// <returns>An asynchronous result containing the populated data supplied by <paramref name="outVal"/>.</returns>
/// <remarks>
/// <para>
/// To retrieve a handle to the device, you must call the CreateFile function with either the name of a device or the name of the driver associated with
/// a device. To specify a device name, use the following format:
/// </para>
/// <para>\\.\DeviceName</para>
/// <para>
/// DeviceIoControl can accept a handle to a specific device. For example, to open a handle to the logical drive
/// A: with CreateFile, specify \\.\a:. Alternatively, you can use the names \\.\PhysicalDrive0, \\.\PhysicalDrive1, and so on, to open handles to the
/// physical drives on a system.
/// </para>
/// <para>
/// You should specify the FILE_SHARE_READ and FILE_SHARE_WRITE access flags when calling CreateFile to open a handle to a device driver. However, when
/// you open a communications resource, such as a serial port, you must specify exclusive access. Use the other CreateFile parameters as follows when
/// opening a device handle:
/// </para>
/// <list type="bullet">
/// <item>
/// <description>The fdwCreate parameter must specify OPEN_EXISTING.</description>
/// </item>
/// <item>
/// <description>The hTemplateFile parameter must be NULL.</description>
/// </item>
/// <item>
/// <description>The fdwAttrsAndFlags parameter can specify FILE_FLAG_OVERLAPPED to indicate that the returned handle can be used in overlapped (asynchronous) I/O operations.</description>
/// </item>
/// </list>
/// </remarks>
public static Task<TOut?> DeviceIoControlAsync<TIn, TOut>(HFILE hDevice, uint ioControlCode, TIn? inVal, TOut? outVal) where TIn : struct where TOut : struct
{
var buf = Pack(inVal, outVal);
return new TaskFactory().FromAsync(BeginDeviceIoControl<TIn, TOut>, EndDeviceIoControl<TIn, TOut>, hDevice, ioControlCode, buf, null);
}
private static unsafe Task<TOut?> ExplicitDeviceIoControlAsync<TIn, TOut>(HFILE hDevice, uint ioControlCode, TIn? inVal, TOut? outVal) where TIn : struct where TOut : struct
{
ThreadPool.BindHandle(hDevice);
var tcs = new TaskCompletionSource<TOut?>();
var buffer = Pack(inVal, outVal);
var nativeOverlapped = new Overlapped().Pack((code, bytes, overlap) =>
{
try
{
switch (code)
{
case Win32Error.ERROR_SUCCESS:
outVal = Unpack<TIn, TOut>(buffer).Item2;
tcs.TrySetResult(outVal);
break;
private static unsafe Task<TOut?> ExplicitDeviceIoControlAsync<TIn, TOut>(HFILE hDevice, uint ioControlCode, TIn? inVal, TOut? outVal) where TIn : struct where TOut : struct
{
#pragma warning disable CS0618 // Type or member is obsolete
ThreadPool.BindHandle((IntPtr)hDevice);
#pragma warning restore CS0618 // Type or member is obsolete
var tcs = new TaskCompletionSource<TOut?>();
var buffer = Pack(inVal, outVal);
var nativeOverlapped = new Overlapped().Pack((code, bytes, overlap) =>
{
try
{
switch (code)
{
case Win32Error.ERROR_SUCCESS:
outVal = Unpack<TIn, TOut>(buffer).Item2;
tcs.TrySetResult(outVal);
break;
case Win32Error.ERROR_OPERATION_ABORTED:
tcs.TrySetCanceled();
break;
case Win32Error.ERROR_OPERATION_ABORTED:
tcs.TrySetCanceled();
break;
default:
tcs.TrySetException(new Win32Exception((int)code));
break;
}
}
finally
{
Overlapped.Unpack(overlap);
Overlapped.Free(overlap);
}
}, buffer);
default:
tcs.TrySetException(new Win32Exception((int)code));
break;
}
}
finally
{
Overlapped.Unpack(overlap);
Overlapped.Free(overlap);
}
}, buffer);
var unpack = true;
try
{
var inSz = Marshal.SizeOf(typeof(TIn));
fixed (byte* pIn = buffer, pOut = &buffer[inSz])
{
uint bRet;
var ret = DeviceIoControl(hDevice, ioControlCode, pIn, (uint)inSz, pOut, (uint)(buffer.Length - inSz), out bRet,
nativeOverlapped);
if (ret)
{
outVal = Unpack<TIn, TOut>(buffer).Item2;
tcs.SetResult(outVal);
return tcs.Task;
}
}
var unpack = true;
try
{
var inSz = Marshal.SizeOf(typeof(TIn));
fixed (byte* pIn = buffer, pOut = &buffer[inSz])
{
uint bRet;
var ret = DeviceIoControl(hDevice, ioControlCode, pIn, (uint)inSz, pOut, (uint)(buffer.Length - inSz), out bRet,
nativeOverlapped);
if (ret)
{
outVal = Unpack<TIn, TOut>(buffer).Item2;
tcs.SetResult(outVal);
return tcs.Task;
}
}
var lastWin32Error = Marshal.GetLastWin32Error();
if (lastWin32Error != Win32Error.ERROR_IO_PENDING && lastWin32Error != Win32Error.ERROR_SUCCESS)
throw new Win32Exception(lastWin32Error);
unpack = false;
return tcs.Task;
}
finally
{
if (unpack)
{
Overlapped.Unpack(nativeOverlapped);
Overlapped.Free(nativeOverlapped);
}
}
}
}
var lastWin32Error = Marshal.GetLastWin32Error();
if (lastWin32Error != Win32Error.ERROR_IO_PENDING && lastWin32Error != Win32Error.ERROR_SUCCESS)
throw new Win32Exception(lastWin32Error);
unpack = false;
return tcs.Task;
}
finally
{
if (unpack)
{
Overlapped.Unpack(nativeOverlapped);
Overlapped.Free(nativeOverlapped);
}
}
}
}
}
#endif

View File

@ -1,5 +1,4 @@
using Microsoft.Win32.SafeHandles;
using System;
using System;
using System.IO;
using System.Runtime.InteropServices;
using System.Threading;
@ -97,17 +96,22 @@ namespace Vanara.PInvoke
IOCTL_STORAGE_BASE = FILE_DEVICE_MASS_STORAGE,
}
/// <summary>Defined access check value for any access within an I/O control code (IOCTL). The FILE_ACCESS_ANY is generally the correct value.</summary>
/// <summary>
/// Defined access check value for any access within an I/O control code (IOCTL). The FILE_ACCESS_ANY is generally the correct value.
/// </summary>
[Flags]
[PInvokeData("WinIOCtl.h")]
public enum IOAccess : byte
{
/// <summary>Request all access.</summary>
FILE_ANY_ACCESS = 0,
/// <summary>Request read access. Can be used with FILE_WRITE_ACCESS.</summary>
FILE_READ_ACCESS = 1,
/// <summary>Request write access. Can be used with FILE_READ_ACCESS.</summary>
FILE_WRITE_ACCESS = 2,
/// <summary>Request read and write access. This value is equivalent to (FILE_READ_ACCESS | FILE_WRITE_ACCESS).</summary>
FILE_READ_WRITE_ACCESS = 3,
}
@ -123,26 +127,27 @@ namespace Vanara.PInvoke
}
/// <summary>
/// Starts the asynchronous operation of sending a control code directly to a specified device driver, causing the corresponding device to perform the
/// corresponding operation.
/// Starts the asynchronous operation of sending a control code directly to a specified device driver, causing the corresponding
/// device to perform the corresponding operation.
/// </summary>
/// <typeparam name="TIn">The type of the <paramref name="inVal"/>.</typeparam>
/// <typeparam name="TOut">The type of the <paramref name="outVal"/>.</typeparam>
/// <param name="hDevice">
/// A handle to the device on which the operation is to be performed. The device is typically a volume, directory, file, or stream. To retrieve a device
/// handle, use the CreateFile function. For more information, see Remarks.
/// A handle to the device on which the operation is to be performed. The device is typically a volume, directory, file, or stream.
/// To retrieve a device handle, use the CreateFile function. For more information, see Remarks.
/// </param>
/// <param name="dwIoControlCode">
/// The control code for the operation. This value identifies the specific operation to be performed and the type of device on which to perform it.
/// The control code for the operation. This value identifies the specific operation to be performed and the type of device on which
/// to perform it.
/// </param>
/// <param name="inVal">
/// A pointer to the input buffer that contains the data required to perform the operation. The format of this data depends on the value of the
/// dwIoControlCode parameter.
/// A pointer to the input buffer that contains the data required to perform the operation. The format of this data depends on the
/// value of the dwIoControlCode parameter.
/// <para>This parameter can be NULL if dwIoControlCode specifies an operation that does not require input data.</para>
/// </param>
/// <param name="outVal">
/// A pointer to the output buffer that is to receive the data returned by the operation. The format of this data depends on the value of the
/// dwIoControlCode parameter.
/// A pointer to the output buffer that is to receive the data returned by the operation. The format of this data depends on the
/// value of the dwIoControlCode parameter.
/// <para>This parameter can be NULL if dwIoControlCode specifies an operation that does not return data.</para>
/// </param>
/// <param name="userCallback">An AsyncCallback delegate that references the method to invoke when the operation is complete.</param>
@ -156,8 +161,8 @@ namespace Vanara.PInvoke
/// <summary>
/// <para>
/// Cancels all pending input and output (I/O) operations that are issued by the calling thread for the specified file. The function does not cancel I/O
/// operations that other threads issue for a file handle.
/// Cancels all pending input and output (I/O) operations that are issued by the calling thread for the specified file. The function
/// does not cancel I/O operations that other threads issue for a file handle.
/// </para>
/// <para>To cancel I/O operations from another thread, use the <c>CancelIoEx</c> function.</para>
/// </summary>
@ -167,9 +172,9 @@ namespace Vanara.PInvoke
/// </param>
/// <returns>
/// <para>
/// If the function succeeds, the return value is nonzero. The cancel operation for all pending I/O operations issued by the calling thread for the
/// specified file handle was successfully requested. The thread can use the <c>GetOverlappedResult</c> function to determine when the I/O operations
/// themselves have been completed.
/// If the function succeeds, the return value is nonzero. The cancel operation for all pending I/O operations issued by the calling
/// thread for the specified file handle was successfully requested. The thread can use the <c>GetOverlappedResult</c> function to
/// determine when the I/O operations themselves have been completed.
/// </para>
/// <para>If the function fails, the return value is zero (0). To get extended error information, call the <c>GetLastError</c> function.</para>
/// </returns>
@ -180,25 +185,25 @@ namespace Vanara.PInvoke
public static extern bool CancelIo([In] HFILE hFile);
/// <summary>
/// Marks any outstanding I/O operations for the specified file handle. The function only cancels I/O operations in the current process, regardless of
/// which thread created the I/O operation.
/// Marks any outstanding I/O operations for the specified file handle. The function only cancels I/O operations in the current
/// process, regardless of which thread created the I/O operation.
/// </summary>
/// <param name="hFile">A handle to the file.</param>
/// <param name="lpOverlapped">
/// <para>A pointer to an <c>OVERLAPPED</c> data structure that contains the data used for asynchronous I/O.</para>
/// <para>If this parameter is <c>NULL</c>, all I/O requests for the hFile parameter are canceled.</para>
/// <para>
/// If this parameter is not <c>NULL</c>, only those specific I/O requests that were issued for the file with the specified lpOverlapped overlapped
/// structure are marked as canceled, meaning that you can cancel one or more requests, while the <c>CancelIo</c> function cancels all outstanding
/// requests on a file handle.
/// If this parameter is not <c>NULL</c>, only those specific I/O requests that were issued for the file with the specified
/// lpOverlapped overlapped structure are marked as canceled, meaning that you can cancel one or more requests, while the
/// <c>CancelIo</c> function cancels all outstanding requests on a file handle.
/// </para>
/// </param>
/// <returns>
/// <para>
/// If the function succeeds, the return value is nonzero. The cancel operation for all pending I/O operations issued by the calling process for the
/// specified file handle was successfully requested. The application must not free or reuse the <c>OVERLAPPED</c> structure associated with the canceled
/// I/O operations until they have completed. The thread can use the <c>GetOverlappedResult</c> function to determine when the I/O operations themselves
/// have been completed.
/// If the function succeeds, the return value is nonzero. The cancel operation for all pending I/O operations issued by the calling
/// process for the specified file handle was successfully requested. The application must not free or reuse the <c>OVERLAPPED</c>
/// structure associated with the canceled I/O operations until they have completed. The thread can use the
/// <c>GetOverlappedResult</c> function to determine when the I/O operations themselves have been completed.
/// </para>
/// <para>If the function fails, the return value is 0 (zero). To get extended error information, call the <c>GetLastError</c> function.</para>
/// <para>If this function cannot find a request to cancel, the return value is 0 (zero), and <c>GetLastError</c> returns <c>ERROR_NOT_FOUND</c>.</para>
@ -220,73 +225,78 @@ namespace Vanara.PInvoke
[DllImport(Lib.Kernel32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("IoAPI.h", MSDNShortId = "aa363794")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern unsafe bool CancelSynchronousIo([In] IntPtr hThread);
public static extern unsafe bool CancelSynchronousIo([In] HTHREAD hThread);
/// <summary>
/// <para>
/// Creates an input/output (I/O) completion port and associates it with a specified file handle, or creates an I/O completion port that is not yet
/// associated with a file handle, allowing association at a later time.
/// Creates an input/output (I/O) completion port and associates it with a specified file handle, or creates an I/O completion port
/// that is not yet associated with a file handle, allowing association at a later time.
/// </para>
/// <para>
/// Associating an instance of an opened file handle with an I/O completion port allows a process to receive notification of the completion of
/// asynchronous I/O operations involving that file handle.
/// Associating an instance of an opened file handle with an I/O completion port allows a process to receive notification of the
/// completion of asynchronous I/O operations involving that file handle.
/// </para>
/// </summary>
/// <param name="FileHandle">
/// <para>An open file handle or <c>INVALID_HANDLE_VALUE</c>.</para>
/// <para>The handle must be to an object that supports overlapped I/O.</para>
/// <para>
/// If a handle is provided, it has to have been opened for overlapped I/O completion. For example, you must specify the <c>FILE_FLAG_OVERLAPPED</c> flag
/// when using the <c>CreateFile</c> function to obtain the handle.
/// If a handle is provided, it has to have been opened for overlapped I/O completion. For example, you must specify the
/// <c>FILE_FLAG_OVERLAPPED</c> flag when using the <c>CreateFile</c> function to obtain the handle.
/// </para>
/// <para>
/// If <c>INVALID_HANDLE_VALUE</c> is specified, the function creates an I/O completion port without associating it with a file handle. In this case, the
/// ExistingCompletionPort parameter must be <c>NULL</c> and the CompletionKey parameter is ignored.
/// If <c>INVALID_HANDLE_VALUE</c> is specified, the function creates an I/O completion port without associating it with a file
/// handle. In this case, the ExistingCompletionPort parameter must be <c>NULL</c> and the CompletionKey parameter is ignored.
/// </para>
/// </param>
/// <param name="ExistingCompletionPort">
/// <para>A handle to an existing I/O completion port or <c>NULL</c>.</para>
/// <para>
/// If this parameter specifies an existing I/O completion port, the function associates it with the handle specified by the FileHandle parameter. The
/// function returns the handle of the existing I/O completion port if successful; it does not create a new I/O completion port.
/// If this parameter specifies an existing I/O completion port, the function associates it with the handle specified by the
/// FileHandle parameter. The function returns the handle of the existing I/O completion port if successful; it does not create a new
/// I/O completion port.
/// </para>
/// <para>
/// If this parameter is <c>NULL</c>, the function creates a new I/O completion port and, if the FileHandle parameter is valid, associates it with the
/// new I/O completion port. Otherwise no file handle association occurs. The function returns the handle to the new I/O completion port if successful.
/// If this parameter is <c>NULL</c>, the function creates a new I/O completion port and, if the FileHandle parameter is valid,
/// associates it with the new I/O completion port. Otherwise no file handle association occurs. The function returns the handle to
/// the new I/O completion port if successful.
/// </para>
/// </param>
/// <param name="CompletionKey">
/// The per-handle user-defined completion key that is included in every I/O completion packet for the specified file handle. For more information, see
/// the Remarks section.
/// The per-handle user-defined completion key that is included in every I/O completion packet for the specified file handle. For
/// more information, see the Remarks section.
/// </param>
/// <param name="NumberOfConcurrentThreads">
/// <para>
/// The maximum number of threads that the operating system can allow to concurrently process I/O completion packets for the I/O completion port. This
/// parameter is ignored if the ExistingCompletionPort parameter is not <c>NULL</c>.
/// The maximum number of threads that the operating system can allow to concurrently process I/O completion packets for the I/O
/// completion port. This parameter is ignored if the ExistingCompletionPort parameter is not <c>NULL</c>.
/// </para>
/// <para>If this parameter is zero, the system allows as many concurrently running threads as there are processors in the system.</para>
/// </param>
/// <returns>
/// <para>If the function succeeds, the return value is the handle to an I/O completion port:</para>
/// <para>If the function fails, the return value is <c>NULL</c>. To get extended error information, call the <c>GetLastError</c> function.</para>
/// <para>
/// If the function fails, the return value is <c>NULL</c>. To get extended error information, call the <c>GetLastError</c> function.
/// </para>
/// </returns>
// HANDLE WINAPI CreateIoCompletionPort( _In_ HANDLE FileHandle, _In_opt_ HANDLE ExistingCompletionPort, _In_ ULONG_PTR CompletionKey, _In_ DWORD
// NumberOfConcurrentThreads); https://msdn.microsoft.com/en-us/library/windows/desktop/aa363862(v=vs.85).aspx
// HANDLE WINAPI CreateIoCompletionPort( _In_ HANDLE FileHandle, _In_opt_ HANDLE ExistingCompletionPort, _In_ ULONG_PTR
// CompletionKey, _In_ DWORD NumberOfConcurrentThreads); https://msdn.microsoft.com/en-us/library/windows/desktop/aa363862(v=vs.85).aspx
[DllImport(Lib.Kernel32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("IoAPI.h", MSDNShortId = "aa363862")]
public static extern IntPtr CreateIoCompletionPort([In] HFILE FileHandle, [In] IntPtr ExistingCompletionPort, UIntPtr CompletionKey, uint NumberOfConcurrentThreads);
/// <summary>This macro is used to create a unique system I/O control code (IOCTL).</summary>
/// <param name="deviceType">
/// Defines the type of device for the given IOCTL. This parameter can be no bigger then a WORD value. The values used by Microsoft are in the range
/// 0-32767 and the values 32768-65535 are reserved for use by OEMs and IHVs.
/// Defines the type of device for the given IOCTL. This parameter can be no bigger then a WORD value. The values used by Microsoft
/// are in the range 0-32767 and the values 32768-65535 are reserved for use by OEMs and IHVs.
/// </param>
/// <param name="function">
/// Defines an action within the device category. That function codes 0-2047 are reserved for Microsoft, and 2048-4095 are reserved for OEMs and IHVs.
/// The function code can be no larger then 4095.
/// Defines an action within the device category. That function codes 0-2047 are reserved for Microsoft, and 2048-4095 are reserved
/// for OEMs and IHVs. The function code can be no larger then 4095.
/// </param>
/// <param name="method">
/// Defines the method codes for how buffers are passed for I/O and file system controls. The following list shows the possible values for this parameter:
/// Defines the method codes for how buffers are passed for I/O and file system controls. The following list shows the possible
/// values for this parameter:
/// <list type="bullet">
/// <item>
/// <description>METHOD_BUFFERED</description>
@ -302,13 +312,13 @@ namespace Vanara.PInvoke
/// </item>
/// </list>
/// <para>
/// This field is ignored under Windows CE and you should always use the METHOD_BUFFERED value unless compatibility with the desktop is required using a
/// different Method value.
/// This field is ignored under Windows CE and you should always use the METHOD_BUFFERED value unless compatibility with the desktop
/// is required using a different Method value.
/// </para>
/// </param>
/// <param name="access">
/// Defines the access check value for any access. The following table shows the possible flags for this parameter. The FILE_ACCESS_ANY is generally the
/// correct value.
/// Defines the access check value for any access. The following table shows the possible flags for this parameter. The
/// FILE_ACCESS_ANY is generally the correct value.
/// <list type="table">
/// <listheader>
/// <term>Flag</term>
@ -338,18 +348,18 @@ namespace Vanara.PInvoke
/// <summary>This macro is used to create a unique system I/O control code (IOCTL).</summary>
/// <param name="deviceType">
/// Defines the type of device for the given IOCTL. This parameter can be no bigger then a WORD value. The values used by Microsoft are in the range
/// 0-32767 and the values 32768-65535 are reserved for use by OEMs and IHVs.
/// Defines the type of device for the given IOCTL. This parameter can be no bigger then a WORD value. The values used by Microsoft
/// are in the range 0-32767 and the values 32768-65535 are reserved for use by OEMs and IHVs.
/// </param>
/// <param name="function">
/// Defines an action within the device category. That function codes 0-2047 are reserved for Microsoft, and 2048-4095 are reserved for OEMs and IHVs.
/// The function code can be no larger then 4095.
/// Defines an action within the device category. That function codes 0-2047 are reserved for Microsoft, and 2048-4095 are reserved
/// for OEMs and IHVs. The function code can be no larger then 4095.
/// </param>
/// <param name="method">
/// Defines the method codes for how buffers are passed for I/O and file system controls.
/// <para>
/// This field is ignored under Windows CE and you should always use the METHOD_BUFFERED value unless compatibility with the desktop is required using a
/// different Method value.
/// This field is ignored under Windows CE and you should always use the METHOD_BUFFERED value unless compatibility with the desktop
/// is required using a different Method value.
/// </para>
/// </param>
/// <param name="access">Defines the access check value for any access.</param>
@ -357,56 +367,62 @@ namespace Vanara.PInvoke
public static uint CTL_CODE(DEVICE_TYPE deviceType, ushort function, IOMethod method, IOAccess access) =>
CTL_CODE((ushort)deviceType, function, (byte)method, (byte)access);
/// <summary>Sends a control code directly to a specified device driver, causing the corresponding device to perform the corresponding operation.</summary>
/// <summary>
/// Sends a control code directly to a specified device driver, causing the corresponding device to perform the corresponding operation.
/// </summary>
/// <param name="hDevice">
/// A handle to the device on which the operation is to be performed. The device is typically a volume, directory, file, or stream. To retrieve a device
/// handle, use the CreateFile function. For more information, see Remarks.
/// A handle to the device on which the operation is to be performed. The device is typically a volume, directory, file, or stream.
/// To retrieve a device handle, use the CreateFile function. For more information, see Remarks.
/// </param>
/// <param name="dwIoControlCode">
/// The control code for the operation. This value identifies the specific operation to be performed and the type of device on which to perform it.
/// The control code for the operation. This value identifies the specific operation to be performed and the type of device on which
/// to perform it.
/// </param>
/// <param name="lpInBuffer">
/// A pointer to the input buffer that contains the data required to perform the operation. The format of this data depends on the value of the
/// dwIoControlCode parameter.
/// A pointer to the input buffer that contains the data required to perform the operation. The format of this data depends on the
/// value of the dwIoControlCode parameter.
/// <para>This parameter can be NULL if dwIoControlCode specifies an operation that does not require input data.</para>
/// </param>
/// <param name="nInBufferSize">The size of the input buffer, in bytes.</param>
/// <param name="lpOutBuffer">
/// A pointer to the output buffer that is to receive the data returned by the operation. The format of this data depends on the value of the
/// dwIoControlCode parameter.
/// A pointer to the output buffer that is to receive the data returned by the operation. The format of this data depends on the
/// value of the dwIoControlCode parameter.
/// <para>This parameter can be NULL if dwIoControlCode specifies an operation that does not return data.</para>
/// </param>
/// <param name="nOutBufferSize">The size of the output buffer, in bytes.</param>
/// <param name="lpBytesReturned">
/// A pointer to a variable that receives the size of the data stored in the output buffer, in bytes.
/// <para>
/// If the output buffer is too small to receive any data, the call fails, GetLastError returns ERROR_INSUFFICIENT_BUFFER, and lpBytesReturned is zero.
/// If the output buffer is too small to receive any data, the call fails, GetLastError returns ERROR_INSUFFICIENT_BUFFER, and
/// lpBytesReturned is zero.
/// </para>
/// <para>
/// If the output buffer is too small to hold all of the data but can hold some entries, some drivers will return as much data as fits. In this case, the
/// call fails, GetLastError returns ERROR_MORE_DATA, and lpBytesReturned indicates the amount of data received. Your application should call
/// DeviceIoControl again with the same operation, specifying a new starting point.
/// If the output buffer is too small to hold all of the data but can hold some entries, some drivers will return as much data as
/// fits. In this case, the call fails, GetLastError returns ERROR_MORE_DATA, and lpBytesReturned indicates the amount of data
/// received. Your application should call DeviceIoControl again with the same operation, specifying a new starting point.
/// </para>
/// <para>
/// If lpOverlapped is NULL, lpBytesReturned cannot be NULL. Even when an operation returns no output data and lpOutBuffer is NULL, DeviceIoControl makes
/// use of lpBytesReturned. After such an operation, the value of lpBytesReturned is meaningless.
/// If lpOverlapped is NULL, lpBytesReturned cannot be NULL. Even when an operation returns no output data and lpOutBuffer is NULL,
/// DeviceIoControl makes use of lpBytesReturned. After such an operation, the value of lpBytesReturned is meaningless.
/// </para>
/// <para>
/// If lpOverlapped is not NULL, lpBytesReturned can be NULL. If this parameter is not NULL and the operation returns data, lpBytesReturned is
/// meaningless until the overlapped operation has completed. To retrieve the number of bytes returned, call GetOverlappedResult. If hDevice is
/// associated with an I/O completion port, you can retrieve the number of bytes returned by calling GetQueuedCompletionStatus.
/// If lpOverlapped is not NULL, lpBytesReturned can be NULL. If this parameter is not NULL and the operation returns data,
/// lpBytesReturned is meaningless until the overlapped operation has completed. To retrieve the number of bytes returned, call
/// GetOverlappedResult. If hDevice is associated with an I/O completion port, you can retrieve the number of bytes returned by
/// calling GetQueuedCompletionStatus.
/// </para>
/// </param>
/// <param name="lpOverlapped">
/// A pointer to an OVERLAPPED structure.
/// <para>If hDevice was opened without specifying FILE_FLAG_OVERLAPPED, lpOverlapped is ignored.</para>
/// <para>
/// If hDevice was opened with the FILE_FLAG_OVERLAPPED flag, the operation is performed as an overlapped (asynchronous) operation. In this case,
/// lpOverlapped must point to a valid OVERLAPPED structure that contains a handle to an event object. Otherwise, the function fails in unpredictable ways.
/// If hDevice was opened with the FILE_FLAG_OVERLAPPED flag, the operation is performed as an overlapped (asynchronous) operation.
/// In this case, lpOverlapped must point to a valid OVERLAPPED structure that contains a handle to an event object. Otherwise, the
/// function fails in unpredictable ways.
/// </para>
/// <para>
/// For overlapped operations, DeviceIoControl returns immediately, and the event object is signaled when the operation has been completed. Otherwise,
/// the function does not return until the operation has been completed or an error occurs.
/// For overlapped operations, DeviceIoControl returns immediately, and the event object is signaled when the operation has been
/// completed. Otherwise, the function does not return until the operation has been completed or an error occurs.
/// </para>
/// </param>
/// <returns>
@ -415,19 +431,19 @@ namespace Vanara.PInvoke
/// </returns>
/// <remarks>
/// <para>
/// To retrieve a handle to the device, you must call the CreateFile function with either the name of a device or the name of the driver associated with
/// a device. To specify a device name, use the following format:
/// To retrieve a handle to the device, you must call the CreateFile function with either the name of a device or the name of the
/// driver associated with a device. To specify a device name, use the following format:
/// </para>
/// <para>\\.\DeviceName</para>
/// <para>
/// DeviceIoControl can accept a handle to a specific device. For example, to open a handle to the logical drive
/// A: with CreateFile, specify \\.\a:. Alternatively, you can use the names \\.\PhysicalDrive0, \\.\PhysicalDrive1, and so on, to open handles to the
/// physical drives on a system.
/// A: with CreateFile, specify \\.\a:. Alternatively, you can use the names \\.\PhysicalDrive0, \\.\PhysicalDrive1, and so on, to
/// open handles to the physical drives on a system.
/// </para>
/// <para>
/// You should specify the FILE_SHARE_READ and FILE_SHARE_WRITE access flags when calling CreateFile to open a handle to a device driver. However, when
/// you open a communications resource, such as a serial port, you must specify exclusive access. Use the other CreateFile parameters as follows when
/// opening a device handle:
/// You should specify the FILE_SHARE_READ and FILE_SHARE_WRITE access flags when calling CreateFile to open a handle to a device
/// driver. However, when you open a communications resource, such as a serial port, you must specify exclusive access. Use the other
/// CreateFile parameters as follows when opening a device handle:
/// </para>
/// <list type="bullet">
/// <item>
@ -438,7 +454,8 @@ namespace Vanara.PInvoke
/// </item>
/// <item>
/// <description>
/// The fdwAttrsAndFlags parameter can specify FILE_FLAG_OVERLAPPED to indicate that the returned handle can be used in overlapped (asynchronous) I/O operations.
/// The fdwAttrsAndFlags parameter can specify FILE_FLAG_OVERLAPPED to indicate that the returned handle can be used in overlapped
/// (asynchronous) I/O operations.
/// </description>
/// </item>
/// </list>
@ -449,56 +466,62 @@ namespace Vanara.PInvoke
public static extern bool DeviceIoControl(HFILE hDevice, uint dwIoControlCode, IntPtr lpInBuffer, uint nInBufferSize, IntPtr lpOutBuffer,
uint nOutBufferSize, out uint lpBytesReturned, IntPtr lpOverlapped);
/// <summary>Sends a control code directly to a specified device driver, causing the corresponding device to perform the corresponding operation.</summary>
/// <summary>
/// Sends a control code directly to a specified device driver, causing the corresponding device to perform the corresponding operation.
/// </summary>
/// <param name="hDevice">
/// A handle to the device on which the operation is to be performed. The device is typically a volume, directory, file, or stream. To retrieve a device
/// handle, use the CreateFile function. For more information, see Remarks.
/// A handle to the device on which the operation is to be performed. The device is typically a volume, directory, file, or stream.
/// To retrieve a device handle, use the CreateFile function. For more information, see Remarks.
/// </param>
/// <param name="dwIoControlCode">
/// The control code for the operation. This value identifies the specific operation to be performed and the type of device on which to perform it.
/// The control code for the operation. This value identifies the specific operation to be performed and the type of device on which
/// to perform it.
/// </param>
/// <param name="lpInBuffer">
/// A pointer to the input buffer that contains the data required to perform the operation. The format of this data depends on the value of the
/// dwIoControlCode parameter.
/// A pointer to the input buffer that contains the data required to perform the operation. The format of this data depends on the
/// value of the dwIoControlCode parameter.
/// <para>This parameter can be NULL if dwIoControlCode specifies an operation that does not require input data.</para>
/// </param>
/// <param name="nInBufferSize">The size of the input buffer, in bytes.</param>
/// <param name="lpOutBuffer">
/// A pointer to the output buffer that is to receive the data returned by the operation. The format of this data depends on the value of the
/// dwIoControlCode parameter.
/// A pointer to the output buffer that is to receive the data returned by the operation. The format of this data depends on the
/// value of the dwIoControlCode parameter.
/// <para>This parameter can be NULL if dwIoControlCode specifies an operation that does not return data.</para>
/// </param>
/// <param name="nOutBufferSize">The size of the output buffer, in bytes.</param>
/// <param name="lpBytesReturned">
/// A pointer to a variable that receives the size of the data stored in the output buffer, in bytes.
/// <para>
/// If the output buffer is too small to receive any data, the call fails, GetLastError returns ERROR_INSUFFICIENT_BUFFER, and lpBytesReturned is zero.
/// If the output buffer is too small to receive any data, the call fails, GetLastError returns ERROR_INSUFFICIENT_BUFFER, and
/// lpBytesReturned is zero.
/// </para>
/// <para>
/// If the output buffer is too small to hold all of the data but can hold some entries, some drivers will return as much data as fits. In this case, the
/// call fails, GetLastError returns ERROR_MORE_DATA, and lpBytesReturned indicates the amount of data received. Your application should call
/// DeviceIoControl again with the same operation, specifying a new starting point.
/// If the output buffer is too small to hold all of the data but can hold some entries, some drivers will return as much data as
/// fits. In this case, the call fails, GetLastError returns ERROR_MORE_DATA, and lpBytesReturned indicates the amount of data
/// received. Your application should call DeviceIoControl again with the same operation, specifying a new starting point.
/// </para>
/// <para>
/// If lpOverlapped is NULL, lpBytesReturned cannot be NULL. Even when an operation returns no output data and lpOutBuffer is NULL, DeviceIoControl makes
/// use of lpBytesReturned. After such an operation, the value of lpBytesReturned is meaningless.
/// If lpOverlapped is NULL, lpBytesReturned cannot be NULL. Even when an operation returns no output data and lpOutBuffer is NULL,
/// DeviceIoControl makes use of lpBytesReturned. After such an operation, the value of lpBytesReturned is meaningless.
/// </para>
/// <para>
/// If lpOverlapped is not NULL, lpBytesReturned can be NULL. If this parameter is not NULL and the operation returns data, lpBytesReturned is
/// meaningless until the overlapped operation has completed. To retrieve the number of bytes returned, call GetOverlappedResult. If hDevice is
/// associated with an I/O completion port, you can retrieve the number of bytes returned by calling GetQueuedCompletionStatus.
/// If lpOverlapped is not NULL, lpBytesReturned can be NULL. If this parameter is not NULL and the operation returns data,
/// lpBytesReturned is meaningless until the overlapped operation has completed. To retrieve the number of bytes returned, call
/// GetOverlappedResult. If hDevice is associated with an I/O completion port, you can retrieve the number of bytes returned by
/// calling GetQueuedCompletionStatus.
/// </para>
/// </param>
/// <param name="lpOverlapped">
/// A pointer to an OVERLAPPED structure.
/// <para>If hDevice was opened without specifying FILE_FLAG_OVERLAPPED, lpOverlapped is ignored.</para>
/// <para>
/// If hDevice was opened with the FILE_FLAG_OVERLAPPED flag, the operation is performed as an overlapped (asynchronous) operation. In this case,
/// lpOverlapped must point to a valid OVERLAPPED structure that contains a handle to an event object. Otherwise, the function fails in unpredictable ways.
/// If hDevice was opened with the FILE_FLAG_OVERLAPPED flag, the operation is performed as an overlapped (asynchronous) operation.
/// In this case, lpOverlapped must point to a valid OVERLAPPED structure that contains a handle to an event object. Otherwise, the
/// function fails in unpredictable ways.
/// </para>
/// <para>
/// For overlapped operations, DeviceIoControl returns immediately, and the event object is signaled when the operation has been completed. Otherwise,
/// the function does not return until the operation has been completed or an error occurs.
/// For overlapped operations, DeviceIoControl returns immediately, and the event object is signaled when the operation has been
/// completed. Otherwise, the function does not return until the operation has been completed or an error occurs.
/// </para>
/// </param>
/// <returns>
@ -507,19 +530,19 @@ namespace Vanara.PInvoke
/// </returns>
/// <remarks>
/// <para>
/// To retrieve a handle to the device, you must call the CreateFile function with either the name of a device or the name of the driver associated with
/// a device. To specify a device name, use the following format:
/// To retrieve a handle to the device, you must call the CreateFile function with either the name of a device or the name of the
/// driver associated with a device. To specify a device name, use the following format:
/// </para>
/// <para>\\.\DeviceName</para>
/// <para>
/// DeviceIoControl can accept a handle to a specific device. For example, to open a handle to the logical drive
/// A: with CreateFile, specify \\.\a:. Alternatively, you can use the names \\.\PhysicalDrive0, \\.\PhysicalDrive1, and so on, to open handles to the
/// physical drives on a system.
/// A: with CreateFile, specify \\.\a:. Alternatively, you can use the names \\.\PhysicalDrive0, \\.\PhysicalDrive1, and so on, to
/// open handles to the physical drives on a system.
/// </para>
/// <para>
/// You should specify the FILE_SHARE_READ and FILE_SHARE_WRITE access flags when calling CreateFile to open a handle to a device driver. However, when
/// you open a communications resource, such as a serial port, you must specify exclusive access. Use the other CreateFile parameters as follows when
/// opening a device handle:
/// You should specify the FILE_SHARE_READ and FILE_SHARE_WRITE access flags when calling CreateFile to open a handle to a device
/// driver. However, when you open a communications resource, such as a serial port, you must specify exclusive access. Use the other
/// CreateFile parameters as follows when opening a device handle:
/// </para>
/// <list type="bullet">
/// <item>
@ -530,7 +553,8 @@ namespace Vanara.PInvoke
/// </item>
/// <item>
/// <description>
/// The fdwAttrsAndFlags parameter can specify FILE_FLAG_OVERLAPPED to indicate that the returned handle can be used in overlapped (asynchronous) I/O operations.
/// The fdwAttrsAndFlags parameter can specify FILE_FLAG_OVERLAPPED to indicate that the returned handle can be used in overlapped
/// (asynchronous) I/O operations.
/// </description>
/// </item>
/// </list>
@ -541,76 +565,95 @@ namespace Vanara.PInvoke
public static extern unsafe bool DeviceIoControl(HFILE hDevice, uint dwIoControlCode, byte* lpInBuffer, uint nInBufferSize, byte* lpOutBuffer,
uint nOutBufferSize, out uint lpBytesReturned, NativeOverlapped* lpOverlapped);
/// <summary>Sends a control code directly to a specified device driver, causing the corresponding device to perform the corresponding operation.</summary>
/// <summary>
/// Sends a control code directly to a specified device driver, causing the corresponding device to perform the corresponding operation.
/// </summary>
/// <typeparam name="TIn">The type of the <paramref name="inVal"/>.</typeparam>
/// <typeparam name="TOut">The type of the <paramref name="outVal"/>.</typeparam>
/// <param name="hDev">
/// A handle to the device on which the operation is to be performed. The device is typically a volume, directory, file, or stream. To retrieve a device
/// handle, use the CreateFile function. For more information, see Remarks.
/// A handle to the device on which the operation is to be performed. The device is typically a volume, directory, file, or stream.
/// To retrieve a device handle, use the CreateFile function. For more information, see Remarks.
/// </param>
/// <param name="ioControlCode">
/// The control code for the operation. This value identifies the specific operation to be performed and the type of device on which to perform it.
/// The control code for the operation. This value identifies the specific operation to be performed and the type of device on which
/// to perform it.
/// </param>
/// <param name="inVal">
/// The data required to perform the operation. The format of this data depends on the value of the dwIoControlCode parameter.
/// </param>
/// <param name="outVal">
/// The data returned by the operation. The format of this data depends on the value of the dwIoControlCode parameter.
/// </param>
/// <param name="inVal">The data required to perform the operation. The format of this data depends on the value of the dwIoControlCode parameter.</param>
/// <param name="outVal">The data returned by the operation. The format of this data depends on the value of the dwIoControlCode parameter.</param>
/// <returns><c>true</c> if successful.</returns>
[PInvokeData("Winbase.h", MSDNShortId = "aa363216")]
public static bool DeviceIoControl<TIn, TOut>(HFILE hDev, uint ioControlCode, TIn inVal, out TOut outVal) where TIn : struct where TOut : struct
{
using (SafeHGlobalHandle ptrIn = SafeHGlobalHandle.CreateFromStructure(inVal), ptrOut = SafeHGlobalHandle.CreateFromStructure<TOut>())
{
var ret = DeviceIoControl(hDev, ioControlCode, (IntPtr)ptrIn, (uint)ptrIn.Size, (IntPtr)ptrOut, (uint)ptrOut.Size, out uint bRet, IntPtr.Zero);
var ret = DeviceIoControl(hDev, ioControlCode, (IntPtr)ptrIn, (uint)ptrIn.Size, (IntPtr)ptrOut, (uint)ptrOut.Size, out var bRet, IntPtr.Zero);
outVal = ptrOut.ToStructure<TOut>();
return ret;
}
}
/// <summary>Sends a control code directly to a specified device driver, causing the corresponding device to perform the corresponding operation.</summary>
/// <summary>
/// Sends a control code directly to a specified device driver, causing the corresponding device to perform the corresponding operation.
/// </summary>
/// <typeparam name="TOut">The type of the <paramref name="outVal"/>.</typeparam>
/// <param name="hDev">
/// A handle to the device on which the operation is to be performed. The device is typically a volume, directory, file, or stream. To retrieve a device
/// handle, use the CreateFile function. For more information, see Remarks.
/// A handle to the device on which the operation is to be performed. The device is typically a volume, directory, file, or stream.
/// To retrieve a device handle, use the CreateFile function. For more information, see Remarks.
/// </param>
/// <param name="ioControlCode">
/// The control code for the operation. This value identifies the specific operation to be performed and the type of device on which to perform it.
/// The control code for the operation. This value identifies the specific operation to be performed and the type of device on which
/// to perform it.
/// </param>
/// <param name="outVal">
/// The data returned by the operation. The format of this data depends on the value of the dwIoControlCode parameter.
/// </param>
/// <param name="outVal">The data returned by the operation. The format of this data depends on the value of the dwIoControlCode parameter.</param>
/// <returns><c>true</c> if successful.</returns>
[PInvokeData("Winbase.h", MSDNShortId = "aa363216")]
public static bool DeviceIoControl<TOut>(HFILE hDev, uint ioControlCode, out TOut outVal) where TOut : struct
{
using (var ptrOut = SafeHGlobalHandle.CreateFromStructure<TOut>())
{
var ret = DeviceIoControl(hDev, ioControlCode, IntPtr.Zero, 0, (IntPtr)ptrOut, (uint)ptrOut.Size, out uint bRet, IntPtr.Zero);
var ret = DeviceIoControl(hDev, ioControlCode, IntPtr.Zero, 0, (IntPtr)ptrOut, (uint)ptrOut.Size, out var bRet, IntPtr.Zero);
outVal = ptrOut.ToStructure<TOut>();
return ret;
}
}
/// <summary>Sends a control code directly to a specified device driver, causing the corresponding device to perform the corresponding operation.</summary>
/// <summary>
/// Sends a control code directly to a specified device driver, causing the corresponding device to perform the corresponding operation.
/// </summary>
/// <typeparam name="TIn">The type of the <paramref name="inVal"/>.</typeparam>
/// <param name="hDev">
/// A handle to the device on which the operation is to be performed. The device is typically a volume, directory, file, or stream. To retrieve a device
/// handle, use the CreateFile function. For more information, see Remarks.
/// A handle to the device on which the operation is to be performed. The device is typically a volume, directory, file, or stream.
/// To retrieve a device handle, use the CreateFile function. For more information, see Remarks.
/// </param>
/// <param name="ioControlCode">
/// The control code for the operation. This value identifies the specific operation to be performed and the type of device on which to perform it.
/// The control code for the operation. This value identifies the specific operation to be performed and the type of device on which
/// to perform it.
/// </param>
/// <param name="inVal">
/// The data required to perform the operation. The format of this data depends on the value of the dwIoControlCode parameter.
/// </param>
/// <param name="inVal">The data required to perform the operation. The format of this data depends on the value of the dwIoControlCode parameter.</param>
/// <returns><c>true</c> if successful.</returns>
[PInvokeData("Winbase.h", MSDNShortId = "aa363216")]
public static bool DeviceIoControl<TIn>(HFILE hDev, uint ioControlCode, TIn inVal) where TIn : struct
{
using (var ptrIn = SafeHGlobalHandle.CreateFromStructure(inVal))
{
return DeviceIoControl(hDev, ioControlCode, (IntPtr)ptrIn, (uint)ptrIn.Size, IntPtr.Zero, 0, out uint bRet, IntPtr.Zero);
return DeviceIoControl(hDev, ioControlCode, (IntPtr)ptrIn, (uint)ptrIn.Size, IntPtr.Zero, 0, out var bRet, IntPtr.Zero);
}
}
/// <summary>Ends the asynchronous call to <see cref="BeginDeviceIoControl{TIn, TOut}(HFILE, uint, TIn?, TOut?, AsyncCallback)"/>.</summary>
/// <typeparam name="TIn">The type of the input value.</typeparam>
/// <typeparam name="TOut">The type of the output value.</typeparam>
/// <param name="asyncResult">The asynchronous result returned from <see cref="BeginDeviceIoControl{TIn, TOut}(HFILE, uint, TIn?, TOut?, AsyncCallback)"/>.</param>
/// <param name="asyncResult">
/// The asynchronous result returned from <see cref="BeginDeviceIoControl{TIn, TOut}(HFILE, uint, TIn?, TOut?, AsyncCallback)"/>.
/// </param>
/// <returns>The output value, if exists; <c>null</c> otherwise.</returns>
[PInvokeData("Winbase.h", MSDNShortId = "aa363216")]
public static TOut? EndDeviceIoControl<TIn, TOut>(IAsyncResult asyncResult) where TIn : struct where TOut : struct
@ -620,79 +663,93 @@ namespace Vanara.PInvoke
}
/// <summary>
/// Retrieves the results of an overlapped operation on the specified file, named pipe, or communications device. To specify a timeout interval or wait
/// on an alertable thread, use <c>GetOverlappedResultEx</c>.
/// Retrieves the results of an overlapped operation on the specified file, named pipe, or communications device. To specify a
/// timeout interval or wait on an alertable thread, use <c>GetOverlappedResultEx</c>.
/// </summary>
/// <param name="hFile">
/// A handle to the file, named pipe, or communications device. This is the same handle that was specified when the overlapped operation was started by a
/// call to the <c>ReadFile</c>, <c>WriteFile</c>, <c>ConnectNamedPipe</c>, <c>TransactNamedPipe</c>, <c>DeviceIoControl</c>, or <c>WaitCommEvent</c> function.
/// A handle to the file, named pipe, or communications device. This is the same handle that was specified when the overlapped
/// operation was started by a call to the <c>ReadFile</c>, <c>WriteFile</c>, <c>ConnectNamedPipe</c>, <c>TransactNamedPipe</c>,
/// <c>DeviceIoControl</c>, or <c>WaitCommEvent</c> function.
/// </param>
/// <param name="lpOverlapped">
/// A pointer to an <c>OVERLAPPED</c> structure that was specified when the overlapped operation was started.
/// </param>
/// <param name="lpOverlapped">A pointer to an <c>OVERLAPPED</c> structure that was specified when the overlapped operation was started.</param>
/// <param name="lpNumberOfBytesTransferred">
/// A pointer to a variable that receives the number of bytes that were actually transferred by a read or write operation. For a <c>TransactNamedPipe</c>
/// operation, this is the number of bytes that were read from the pipe. For a <c>DeviceIoControl</c> operation, this is the number of bytes of output
/// data returned by the device driver. For a <c>ConnectNamedPipe</c> or <c>WaitCommEvent</c> operation, this value is undefined.
/// A pointer to a variable that receives the number of bytes that were actually transferred by a read or write operation. For a
/// <c>TransactNamedPipe</c> operation, this is the number of bytes that were read from the pipe. For a <c>DeviceIoControl</c>
/// operation, this is the number of bytes of output data returned by the device driver. For a <c>ConnectNamedPipe</c> or
/// <c>WaitCommEvent</c> operation, this value is undefined.
/// </param>
/// <param name="bWait">
/// If this parameter is <c>TRUE</c>, and the <c>Internal</c> member of the lpOverlapped structure is <c>STATUS_PENDING</c>, the function does not return
/// until the operation has been completed. If this parameter is <c>FALSE</c> and the operation is still pending, the function returns <c>FALSE</c> and
/// the <c>GetLastError</c> function returns <c>ERROR_IO_INCOMPLETE</c>.
/// If this parameter is <c>TRUE</c>, and the <c>Internal</c> member of the lpOverlapped structure is <c>STATUS_PENDING</c>, the
/// function does not return until the operation has been completed. If this parameter is <c>FALSE</c> and the operation is still
/// pending, the function returns <c>FALSE</c> and the <c>GetLastError</c> function returns <c>ERROR_IO_INCOMPLETE</c>.
/// </param>
/// <returns>
/// <para>If the function succeeds, the return value is nonzero.</para>
/// <para>If the function fails, the return value is zero. To get extended error information, call <c>GetLastError</c>.</para>
/// </returns>
// BOOL WINAPI GetOverlappedResult( _In_ HANDLE hFile, _In_ LPOVERLAPPED lpOverlapped, _Out_ LPDWORD lpNumberOfBytesTransferred, _In_ BOOL bWait); https://msdn.microsoft.com/en-us/library/windows/desktop/ms683209(v=vs.85).aspx
// BOOL WINAPI GetOverlappedResult( _In_ HANDLE hFile, _In_ LPOVERLAPPED lpOverlapped, _Out_ LPDWORD lpNumberOfBytesTransferred, _In_
// BOOL bWait); https://msdn.microsoft.com/en-us/library/windows/desktop/ms683209(v=vs.85).aspx
[DllImport(Lib.Kernel32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("WinBase.h", MSDNShortId = "ms683209")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern unsafe bool GetOverlappedResult([In] HFILE hFile, [In] NativeOverlapped* lpOverlapped, out uint lpNumberOfBytesTransferred, [MarshalAs(UnmanagedType.Bool)] bool bWait);
/// <summary>
/// Retrieves the results of an overlapped operation on the specified file, named pipe, or communications device within the specified time-out interval.
/// The calling thread can perform an alertable wait.
/// Retrieves the results of an overlapped operation on the specified file, named pipe, or communications device within the specified
/// time-out interval. The calling thread can perform an alertable wait.
/// </summary>
/// <param name="hFile">
/// A handle to the file, named pipe, or communications device. This is the same handle that was specified when the overlapped operation was started by a
/// call to the <c>ReadFile</c>, <c>WriteFile</c>, <c>ConnectNamedPipe</c>, <c>TransactNamedPipe</c>, <c>DeviceIoControl</c>, or <c>WaitCommEvent</c> function.
/// A handle to the file, named pipe, or communications device. This is the same handle that was specified when the overlapped
/// operation was started by a call to the <c>ReadFile</c>, <c>WriteFile</c>, <c>ConnectNamedPipe</c>, <c>TransactNamedPipe</c>,
/// <c>DeviceIoControl</c>, or <c>WaitCommEvent</c> function.
/// </param>
/// <param name="lpOverlapped">
/// A pointer to an <c>OVERLAPPED</c> structure that was specified when the overlapped operation was started.
/// </param>
/// <param name="lpOverlapped">A pointer to an <c>OVERLAPPED</c> structure that was specified when the overlapped operation was started.</param>
/// <param name="lpNumberOfBytesTransferred">
/// A pointer to a variable that receives the number of bytes that were actually transferred by a read or write operation. For a <c>TransactNamedPipe</c>
/// operation, this is the number of bytes that were read from the pipe. For a <c>DeviceIoControl</c> operation, this is the number of bytes of output
/// data returned by the device driver. For a <c>ConnectNamedPipe</c> or <c>WaitCommEvent</c> operation, this value is undefined.
/// A pointer to a variable that receives the number of bytes that were actually transferred by a read or write operation. For a
/// <c>TransactNamedPipe</c> operation, this is the number of bytes that were read from the pipe. For a <c>DeviceIoControl</c>
/// operation, this is the number of bytes of output data returned by the device driver. For a <c>ConnectNamedPipe</c> or
/// <c>WaitCommEvent</c> operation, this value is undefined.
/// </param>
/// <param name="dwMilliseconds">
/// <para>The time-out interval, in milliseconds.</para>
/// <para>
/// If dwMilliseconds is zero and the operation is still in progress, the function returns immediately and the <c>GetLastError</c> function returns <c>ERROR_IO_INCOMPLETE</c>.
/// If dwMilliseconds is zero and the operation is still in progress, the function returns immediately and the <c>GetLastError</c>
/// function returns <c>ERROR_IO_INCOMPLETE</c>.
/// </para>
/// <para>
/// If dwMilliseconds is nonzero and the operation is still in progress, the function waits until the object is signaled, an I/O completion routine or
/// APC is queued, or the interval elapses before returning. Use <c>GetLastError</c> to get extended error information.
/// If dwMilliseconds is nonzero and the operation is still in progress, the function waits until the object is signaled, an I/O
/// completion routine or APC is queued, or the interval elapses before returning. Use <c>GetLastError</c> to get extended error information.
/// </para>
/// <para>
/// If dwMilliseconds is <c>INFINITE</c>, the function returns only when the object is signaled or an I/O completion routine or APC
/// is queued.
/// </para>
/// <para>If dwMilliseconds is <c>INFINITE</c>, the function returns only when the object is signaled or an I/O completion routine or APC is queued.</para>
/// </param>
/// <param name="bAlertable">
/// <para>
/// If this parameter is <c>TRUE</c> and the calling thread is in the waiting state, the function returns when the system queues an I/O completion
/// routine or APC. The calling thread then runs the routine or function. Otherwise, the function does not return, and the completion routine or APC
/// function is not executed.
/// If this parameter is <c>TRUE</c> and the calling thread is in the waiting state, the function returns when the system queues an
/// I/O completion routine or APC. The calling thread then runs the routine or function. Otherwise, the function does not return, and
/// the completion routine or APC function is not executed.
/// </para>
/// <para>
/// A completion routine is queued when the <c>ReadFileEx</c> or <c>WriteFileEx</c> function in which it was specified has completed. The function
/// returns and the completion routine is called only if bAlertable is <c>TRUE</c>, and the calling thread is the thread that initiated the read or write
/// operation. An APC is queued when you call <c>QueueUserAPC</c>.
/// A completion routine is queued when the <c>ReadFileEx</c> or <c>WriteFileEx</c> function in which it was specified has completed.
/// The function returns and the completion routine is called only if bAlertable is <c>TRUE</c>, and the calling thread is the thread
/// that initiated the read or write operation. An APC is queued when you call <c>QueueUserAPC</c>.
/// </para>
/// </param>
/// <returns>
/// <para>If the function succeeds, the return value is nonzero.</para>
/// <para>
/// If the function fails, the return value is zero. To get extended error information, call <c>GetLastError</c>. Common error codes include the following:
/// If the function fails, the return value is zero. To get extended error information, call <c>GetLastError</c>. Common error codes
/// include the following:
/// </para>
/// </returns>
// WINBASEAPI BOOL WINAPI GetOverlappedResultEx( _In_ HANDLE hFile, _In_ LPOVERLAPPED lpOverlapped, _Out_ LPDWORD lpNumberOfBytesTransferred, _In_ DWORD
// dwMilliseconds, _In_ BOOL bAlertable); https://msdn.microsoft.com/en-us/library/windows/desktop/hh448542(v=vs.85).aspx
// WINBASEAPI BOOL WINAPI GetOverlappedResultEx( _In_ HANDLE hFile, _In_ LPOVERLAPPED lpOverlapped, _Out_ LPDWORD
// lpNumberOfBytesTransferred, _In_ DWORD dwMilliseconds, _In_ BOOL bAlertable); https://msdn.microsoft.com/en-us/library/windows/desktop/hh448542(v=vs.85).aspx
[DllImport(Lib.Kernel32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("Ioapiset.h", MSDNShortId = "hh448542")]
[return: MarshalAs(UnmanagedType.Bool)]
@ -700,35 +757,42 @@ namespace Vanara.PInvoke
/// <summary>
/// <para>
/// Attempts to dequeue an I/O completion packet from the specified I/O completion port. If there is no completion packet queued, the function waits for
/// a pending I/O operation associated with the completion port to complete.
/// Attempts to dequeue an I/O completion packet from the specified I/O completion port. If there is no completion packet queued, the
/// function waits for a pending I/O operation associated with the completion port to complete.
/// </para>
/// <para>To dequeue multiple I/O completion packets at once, use the <c>GetQueuedCompletionStatusEx</c> function.</para>
/// </summary>
/// <param name="CompletionPort">A handle to the completion port. To create a completion port, use the <c>CreateIoCompletionPort</c> function.</param>
/// <param name="lpNumberOfBytes">A pointer to a variable that receives the number of bytes transferred during an I/O operation that has completed.</param>
/// <param name="CompletionPort">
/// A handle to the completion port. To create a completion port, use the <c>CreateIoCompletionPort</c> function.
/// </param>
/// <param name="lpNumberOfBytes">
/// A pointer to a variable that receives the number of bytes transferred during an I/O operation that has completed.
/// </param>
/// <param name="lpCompletionKey">
/// A pointer to a variable that receives the completion key value associated with the file handle whose I/O operation has completed. A completion key is
/// a per-file key that is specified in a call to <c>CreateIoCompletionPort</c>.
/// A pointer to a variable that receives the completion key value associated with the file handle whose I/O operation has completed.
/// A completion key is a per-file key that is specified in a call to <c>CreateIoCompletionPort</c>.
/// </param>
/// <param name="lpOverlapped">
/// <para>
/// A pointer to a variable that receives the address of the <c>OVERLAPPED</c> structure that was specified when the completed I/O operation was started.
/// A pointer to a variable that receives the address of the <c>OVERLAPPED</c> structure that was specified when the completed I/O
/// operation was started.
/// </para>
/// <para>
/// Even if you have passed the function a file handle associated with a completion port and a valid <c>OVERLAPPED</c> structure, an application can
/// prevent completion port notification. This is done by specifying a valid event handle for the <c>hEvent</c> member of the <c>OVERLAPPED</c>
/// structure, and setting its low-order bit. A valid event handle whose low-order bit is set keeps I/O completion from being queued to the completion port.
/// Even if you have passed the function a file handle associated with a completion port and a valid <c>OVERLAPPED</c> structure, an
/// application can prevent completion port notification. This is done by specifying a valid event handle for the <c>hEvent</c>
/// member of the <c>OVERLAPPED</c> structure, and setting its low-order bit. A valid event handle whose low-order bit is set keeps
/// I/O completion from being queued to the completion port.
/// </para>
/// </param>
/// <param name="dwMilliseconds">
/// <para>
/// The number of milliseconds that the caller is willing to wait for a completion packet to appear at the completion port. If a completion packet does
/// not appear within the specified time, the function times out, returns <c>FALSE</c>, and sets *lpOverlapped to <c>NULL</c>.
/// The number of milliseconds that the caller is willing to wait for a completion packet to appear at the completion port. If a
/// completion packet does not appear within the specified time, the function times out, returns <c>FALSE</c>, and sets *lpOverlapped
/// to <c>NULL</c>.
/// </para>
/// <para>
/// If dwMilliseconds is <c>INFINITE</c>, the function will never time out. If dwMilliseconds is zero and there is no I/O operation to dequeue, the
/// function will time out immediately.
/// If dwMilliseconds is <c>INFINITE</c>, the function will never time out. If dwMilliseconds is zero and there is no I/O operation
/// to dequeue, the function will time out immediately.
/// </para>
/// </param>
/// <returns>
@ -736,7 +800,8 @@ namespace Vanara.PInvoke
/// <para>To get extended error information, call <c>GetLastError</c>.</para>
/// <para>For more information, see the Remarks section.</para>
/// </returns>
// BOOL WINAPI GetQueuedCompletionStatus( _In_ HANDLE CompletionPort, _Out_ LPDWORD lpNumberOfBytes, _Out_ PULONG_PTR lpCompletionKey, _Out_ LPOVERLAPPED
// BOOL WINAPI GetQueuedCompletionStatus( _In_ HANDLE CompletionPort, _Out_ LPDWORD lpNumberOfBytes, _Out_ PULONG_PTR
// lpCompletionKey, _Out_ LPOVERLAPPED
// *lpOverlapped, _In_ DWORD dwMilliseconds); https://msdn.microsoft.com/en-us/library/windows/desktop/aa364986(v=vs.85).aspx
[DllImport(Lib.Kernel32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("WinBase.h", MSDNShortId = "aa364986")]
@ -745,49 +810,54 @@ namespace Vanara.PInvoke
/// <summary>
/// <para>
/// Retrieves multiple completion port entries simultaneously. It waits for pending I/O operations that are associated with the specified completion port
/// to complete.
/// Retrieves multiple completion port entries simultaneously. It waits for pending I/O operations that are associated with the
/// specified completion port to complete.
/// </para>
/// <para>To dequeue I/O completion packets one at a time, use the <c>GetQueuedCompletionStatus</c> function.</para>
/// </summary>
/// <param name="CompletionPort">A handle to the completion port. To create a completion port, use the <c>CreateIoCompletionPort</c> function.</param>
/// <param name="CompletionPort">
/// A handle to the completion port. To create a completion port, use the <c>CreateIoCompletionPort</c> function.
/// </param>
/// <param name="lpCompletionPortEntries">
/// <para>On input, points to a pre-allocated array of <c>OVERLAPPED_ENTRY</c> structures.</para>
/// <para>On output, receives an array of <c>OVERLAPPED_ENTRY</c> structures that hold the entries. The number of array elements is provided by ulNumEntriesRemoved.</para>
/// <para>
/// The number of bytes transferred during each I/O, the completion key that indicates on which file each I/O occurred, and the overlapped structure
/// address used in each original I/O are all returned in the lpCompletionPortEntries array.
/// On output, receives an array of <c>OVERLAPPED_ENTRY</c> structures that hold the entries. The number of array elements is
/// provided by ulNumEntriesRemoved.
/// </para>
/// <para>
/// The number of bytes transferred during each I/O, the completion key that indicates on which file each I/O occurred, and the
/// overlapped structure address used in each original I/O are all returned in the lpCompletionPortEntries array.
/// </para>
/// </param>
/// <param name="ulCount">The maximum number of entries to remove.</param>
/// <param name="ulNumEntriesRemoved">A pointer to a variable that receives the number of entries actually removed.</param>
/// <param name="dwMilliseconds">
/// <para>
/// The number of milliseconds that the caller is willing to wait for a completion packet to appear at the completion port. If a completion packet does
/// not appear within the specified time, the function times out and returns <c>FALSE</c>.
/// The number of milliseconds that the caller is willing to wait for a completion packet to appear at the completion port. If a
/// completion packet does not appear within the specified time, the function times out and returns <c>FALSE</c>.
/// </para>
/// <para>
/// If dwMilliseconds is <c>INFINITE</c> (0xFFFFFFFF), the function will never time out. If dwMilliseconds is zero and there is no I/O operation to
/// dequeue, the function will time out immediately.
/// If dwMilliseconds is <c>INFINITE</c> (0xFFFFFFFF), the function will never time out. If dwMilliseconds is zero and there is no
/// I/O operation to dequeue, the function will time out immediately.
/// </para>
/// </param>
/// <param name="fAlertable">
/// <para>If this parameter is <c>FALSE</c>, the function does not return until the time-out period has elapsed or an entry is retrieved.</para>
/// <para>
/// If the parameter is <c>TRUE</c> and there are no available entries, the function performs an alertable wait. The thread returns when the system
/// queues an I/O completion routine or APC to the thread and the thread executes the function.
/// If the parameter is <c>TRUE</c> and there are no available entries, the function performs an alertable wait. The thread returns
/// when the system queues an I/O completion routine or APC to the thread and the thread executes the function.
/// </para>
/// <para>
/// A completion routine is queued when the <c>ReadFileEx</c> or <c>WriteFileEx</c> function in which it was specified has completed, and the calling
/// thread is the thread that initiated the operation. An APC is queued when you call <c>QueueUserAPC</c>.
/// A completion routine is queued when the <c>ReadFileEx</c> or <c>WriteFileEx</c> function in which it was specified has completed,
/// and the calling thread is the thread that initiated the operation. An APC is queued when you call <c>QueueUserAPC</c>.
/// </para>
/// </param>
/// <returns>
/// <para>Returns nonzero ( <c>TRUE</c>) if successful or zero ( <c>FALSE</c>) otherwise.</para>
/// <para>To get extended error information, call <c>GetLastError</c>.</para>
/// </returns>
// BOOL WINAPI GetQueuedCompletionStatusEx( _In_ HANDLE CompletionPort, _Out_ LPOVERLAPPED_ENTRY lpCompletionPortEntries, _In_ ULONG ulCount, _Out_
// PULONG ulNumEntriesRemoved, _In_ DWORD dwMilliseconds, _In_ BOOL fAlertable); https://msdn.microsoft.com/en-us/library/windows/desktop/aa364988(v=vs.85).aspx
// BOOL WINAPI GetQueuedCompletionStatusEx( _In_ HANDLE CompletionPort, _Out_ LPOVERLAPPED_ENTRY lpCompletionPortEntries, _In_ ULONG
// ulCount, _Out_ PULONG ulNumEntriesRemoved, _In_ DWORD dwMilliseconds, _In_ BOOL fAlertable); https://msdn.microsoft.com/en-us/library/windows/desktop/aa364988(v=vs.85).aspx
[DllImport(Lib.Kernel32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("IoAPI.h", MSDNShortId = "aa364988")]
public static extern void GetQueuedCompletionStatusEx(IntPtr CompletionPort, IntPtr lpCompletionPortEntries, uint ulCount, out uint ulNumEntriesRemoved, uint dwMilliseconds, [MarshalAs(UnmanagedType.Bool)] bool fAlertable);
@ -797,14 +867,18 @@ namespace Vanara.PInvoke
/// <param name="dwNumberOfBytesTransferred">
/// The value to be returned through the lpNumberOfBytesTransferred parameter of the <c>GetQueuedCompletionStatus</c> function.
/// </param>
/// <param name="dwCompletionKey">The value to be returned through the lpCompletionKey parameter of the <c>GetQueuedCompletionStatus</c> function.</param>
/// <param name="lpOverlapped">The value to be returned through the lpOverlapped parameter of the <c>GetQueuedCompletionStatus</c> function.</param>
/// <param name="dwCompletionKey">
/// The value to be returned through the lpCompletionKey parameter of the <c>GetQueuedCompletionStatus</c> function.
/// </param>
/// <param name="lpOverlapped">
/// The value to be returned through the lpOverlapped parameter of the <c>GetQueuedCompletionStatus</c> function.
/// </param>
/// <returns>
/// <para>If the function succeeds, the return value is nonzero.</para>
/// <para>If the function fails, the return value is zero. To get extended error information, call <c>GetLastError</c> .</para>
/// </returns>
// BOOL WINAPI PostQueuedCompletionStatus( _In_ HANDLE CompletionPort, _In_ DWORD dwNumberOfBytesTransferred, _In_ ULONG_PTR dwCompletionKey, _In_opt_
// LPOVERLAPPED lpOverlapped); https://msdn.microsoft.com/en-us/library/windows/desktop/aa365458(v=vs.85).aspx
// BOOL WINAPI PostQueuedCompletionStatus( _In_ HANDLE CompletionPort, _In_ DWORD dwNumberOfBytesTransferred, _In_ ULONG_PTR
// dwCompletionKey, _In_opt_ LPOVERLAPPED lpOverlapped); https://msdn.microsoft.com/en-us/library/windows/desktop/aa365458(v=vs.85).aspx
[DllImport(Lib.Kernel32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("IoAPI.h", MSDNShortId = "aa365458")]
[return: MarshalAs(UnmanagedType.Bool)]
@ -816,7 +890,7 @@ namespace Vanara.PInvoke
var inSz = Marshal.SizeOf(typeof(TIn));
fixed (byte* pIn = buffer, pOut = &buffer[inSz])
{
var ret = DeviceIoControl(hDevice, dwIoControlCode, pIn, (uint)inSz, pOut, (uint)(buffer.Length - inSz), out uint bRet, ar.Overlapped);
var ret = DeviceIoControl(hDevice, dwIoControlCode, pIn, (uint)inSz, pOut, (uint)(buffer.Length - inSz), out var bRet, ar.Overlapped);
return OverlappedAsync.EvaluateOverlappedFunction(ar, ret);
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -4,7 +4,6 @@ using System.ComponentModel;
using System.Runtime.InteropServices;
using System.Security;
using System.Text;
using Vanara.InteropServices;
namespace Vanara.PInvoke
{
@ -61,7 +60,7 @@ namespace Vanara.PInvoke
[PInvokeData("Winbase.h", MSDNShortId = "ms648033")]
[UnmanagedFunctionPointer(CallingConvention.Winapi, CharSet = CharSet.Unicode)]
[return: MarshalAs(UnmanagedType.Bool)]
public delegate bool EnumResLangProc([In] IntPtr hModule, [In] SafeResourceId lpszType, [In] SafeResourceId lpszName, ushort wIDLanguage, [In] IntPtr lParam);
public delegate bool EnumResLangProc([In] HINSTANCE hModule, [In] SafeResourceId lpszType, [In] SafeResourceId lpszName, ushort wIDLanguage, [In] IntPtr lParam);
/// <summary>
/// An application-defined callback function used with the <c>EnumResourceNames</c> and <c>EnumResourceNamesEx</c> functions. It
@ -106,7 +105,7 @@ namespace Vanara.PInvoke
[SuppressUnmanagedCodeSecurity]
[PInvokeData("Winbase.h", MSDNShortId = "ms648034")]
[return: MarshalAs(UnmanagedType.Bool)]
public delegate bool EnumResNameProc(IntPtr hModule, SafeResourceId lpszType, SafeResourceId lpszName, IntPtr lParam);
public delegate bool EnumResNameProc(HINSTANCE hModule, SafeResourceId lpszType, SafeResourceId lpszName, IntPtr lParam);
/// <summary>
/// An application-defined callback function used with the <c>EnumResourceTypes</c> and <c>EnumResourceTypesEx</c> functions. It
@ -143,7 +142,7 @@ namespace Vanara.PInvoke
[UnmanagedFunctionPointer(CallingConvention.Winapi, CharSet = CharSet.Unicode)]
[PInvokeData("Winbase.h", MSDNShortId = "ms648041")]
[return: MarshalAs(UnmanagedType.Bool)]
public delegate bool EnumResTypeProc(IntPtr hModule, SafeResourceId lpszType, IntPtr lParam);
public delegate bool EnumResTypeProc(HINSTANCE hModule, SafeResourceId lpszType, IntPtr lParam);
/// <summary>Flags used by <see cref="GetModuleHandleEx"/>.</summary>
[PInvokeData("Winbase.h", MSDNShortId = "ms683200")]
@ -1227,7 +1226,7 @@ namespace Vanara.PInvoke
// DWORD WINAPI GetModuleFileName( _In_opt_ HMODULE hModule, _Out_ LPTSTR lpFilename, _In_ DWORD nSize); https://msdn.microsoft.com/en-us/library/windows/desktop/ms683197(v=vs.85).aspx
[DllImport(Lib.Kernel32, SetLastError = true, CharSet = CharSet.Auto)]
[PInvokeData("Winbase.h", MSDNShortId = "ms683197")]
public static extern uint GetModuleFileName(HINSTANCE hModule, [Out] StringBuilder lpFilename, uint nSize);
public static extern uint GetModuleFileName(HINSTANCE hModule, StringBuilder lpFilename, uint nSize);
/// <summary>
/// Retrieves the fully qualified path for the file that contains the specified module. The module must have been loaded by the
@ -1290,7 +1289,7 @@ namespace Vanara.PInvoke
// HMODULE WINAPI GetModuleHandle( _In_opt_ LPCTSTR lpModuleName); https://msdn.microsoft.com/en-us/library/windows/desktop/ms683199(v=vs.85).aspx
[DllImport(Lib.Kernel32, SetLastError = true, CharSet = CharSet.Auto)]
[PInvokeData("Winbase.h", MSDNShortId = "ms683199")]
public static extern IntPtr GetModuleHandle([Optional] string lpModuleName);
public static extern HINSTANCE GetModuleHandle([Optional] string lpModuleName);
/// <summary>
/// Retrieves a module handle for the specified module and increments the module's reference count unless
@ -1457,7 +1456,7 @@ namespace Vanara.PInvoke
/// <item>
/// <term>LOAD_LIBRARY_AS_DATAFILE0x00000002</term>
/// <term>
/// If this value is used, the system maps the file into the calling process&amp;#39;s virtual address space as if it were a data
/// If this value is used, the system maps the file into the calling process's virtual address space as if it were a data
/// file. Nothing is done to execute or prepare to execute the mapped file. Therefore, you cannot call functions like
/// GetModuleFileName, GetModuleHandle or GetProcAddress with this DLL. Using this value causes writes to read-only memory to raise
/// an access violation. Use this flag when you want to load a DLL only to extract messages or resources from it.This value can be
@ -1476,7 +1475,7 @@ namespace Vanara.PInvoke
/// <item>
/// <term>LOAD_LIBRARY_AS_IMAGE_RESOURCE0x00000020</term>
/// <term>
/// If this value is used, the system maps the file into the process&amp;#39;s virtual address space as an image file. However, the
/// If this value is used, the system maps the file into the process's virtual address space as an image file. However, the
/// loader does not load the static imports or perform the other usual initialization steps. Use this flag when you want to load a
/// DLL only to extract messages or resources from it.Unless the application depends on the file having the in-memory layout of an
/// image, this value should be used with either LOAD_LIBRARY_AS_DATAFILE_EXCLUSIVE or LOAD_LIBRARY_AS_DATAFILE. For more
@ -1486,7 +1485,7 @@ namespace Vanara.PInvoke
/// <item>
/// <term>LOAD_LIBRARY_SEARCH_APPLICATION_DIR0x00000200</term>
/// <term>
/// If this value is used, the application&amp;#39;s installation directory is searched for the DLL and its dependencies. Directories
/// If this value is used, the application's installation directory is searched for the DLL and its dependencies. Directories
/// in the standard search path are not searched. This value cannot be combined with LOAD_WITH_ALTERED_SEARCH_PATH.Windows 7, Windows
/// Server 2008 R2, Windows Vista and Windows Server 2008: This value requires KB2533623 to be installed.Windows Server 2003 and
/// Windows XP: This value is not supported.
@ -1506,7 +1505,7 @@ namespace Vanara.PInvoke
/// <term>LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR0x00000100</term>
/// <term>
/// If this value is used, the directory that contains the DLL is temporarily added to the beginning of the list of directories that
/// are searched for the DLL&amp;#39;s dependencies. Directories in the standard search path are not searched.The lpFileName
/// are searched for the DLL's dependencies. Directories in the standard search path are not searched.The lpFileName
/// parameter must specify a fully qualified path. This value cannot be combined with LOAD_WITH_ALTERED_SEARCH_PATH.For example, if
/// Lib2.dll is a dependency of C:\Dir1\Lib1.dll, loading Lib1.dll with this value causes the system to search for Lib2.dll only in
/// C:\Dir1. To search for Lib2.dll in C:\Dir1 and all of the directories in the DLL search path, combine this value with
@ -1554,7 +1553,7 @@ namespace Vanara.PInvoke
[DllImport(Lib.Kernel32, CharSet = CharSet.Auto, SetLastError = true, BestFitMapping = false, ThrowOnUnmappableChar = true)]
[PInvokeData("LibLoaderAPI.h", MSDNShortId = "ms684179")]
[SuppressUnmanagedCodeSecurity]
public static extern SafeHINSTANCE LoadLibraryEx([In] string lpFileName, [Optional] IntPtr hFile, LoadLibraryExFlags dwFlags);
public static extern SafeHINSTANCE LoadLibraryEx(string lpFileName, [Optional] IntPtr hFile, LoadLibraryExFlags dwFlags);
/// <summary>
/// Loads the specified module into the address space of the calling process. The specified module may cause other modules to be loaded.
@ -1625,7 +1624,7 @@ namespace Vanara.PInvoke
/// <item>
/// <term>LOAD_LIBRARY_AS_DATAFILE0x00000002</term>
/// <term>
/// If this value is used, the system maps the file into the calling process&amp;#39;s virtual address space as if it were a data
/// If this value is used, the system maps the file into the calling process's virtual address space as if it were a data
/// file. Nothing is done to execute or prepare to execute the mapped file. Therefore, you cannot call functions like
/// GetModuleFileName, GetModuleHandle or GetProcAddress with this DLL. Using this value causes writes to read-only memory to raise
/// an access violation. Use this flag when you want to load a DLL only to extract messages or resources from it.This value can be
@ -1644,7 +1643,7 @@ namespace Vanara.PInvoke
/// <item>
/// <term>LOAD_LIBRARY_AS_IMAGE_RESOURCE0x00000020</term>
/// <term>
/// If this value is used, the system maps the file into the process&amp;#39;s virtual address space as an image file. However, the
/// If this value is used, the system maps the file into the process's virtual address space as an image file. However, the
/// loader does not load the static imports or perform the other usual initialization steps. Use this flag when you want to load a
/// DLL only to extract messages or resources from it.Unless the application depends on the file having the in-memory layout of an
/// image, this value should be used with either LOAD_LIBRARY_AS_DATAFILE_EXCLUSIVE or LOAD_LIBRARY_AS_DATAFILE. For more
@ -1654,7 +1653,7 @@ namespace Vanara.PInvoke
/// <item>
/// <term>LOAD_LIBRARY_SEARCH_APPLICATION_DIR0x00000200</term>
/// <term>
/// If this value is used, the application&amp;#39;s installation directory is searched for the DLL and its dependencies. Directories
/// If this value is used, the application's installation directory is searched for the DLL and its dependencies. Directories
/// in the standard search path are not searched. This value cannot be combined with LOAD_WITH_ALTERED_SEARCH_PATH.Windows 7, Windows
/// Server 2008 R2, Windows Vista and Windows Server 2008: This value requires KB2533623 to be installed.Windows Server 2003 and
/// Windows XP: This value is not supported.
@ -1674,7 +1673,7 @@ namespace Vanara.PInvoke
/// <term>LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR0x00000100</term>
/// <term>
/// If this value is used, the directory that contains the DLL is temporarily added to the beginning of the list of directories that
/// are searched for the DLL&amp;#39;s dependencies. Directories in the standard search path are not searched.The lpFileName
/// are searched for the DLL's dependencies. Directories in the standard search path are not searched.The lpFileName
/// parameter must specify a fully qualified path. This value cannot be combined with LOAD_WITH_ALTERED_SEARCH_PATH.For example, if
/// Lib2.dll is a dependency of C:\Dir1\Lib1.dll, loading Lib1.dll with this value causes the system to search for Lib2.dll only in
/// C:\Dir1. To search for Lib2.dll in C:\Dir1 and all of the directories in the DLL search path, combine this value with
@ -1721,7 +1720,7 @@ namespace Vanara.PInvoke
// HMODULE WINAPI LoadLibraryEx( _In_ LPCTSTR lpFileName, _Reserved_ HANDLE hFile, _In_ DWORD dwFlags); https://msdn.microsoft.com/en-us/library/windows/desktop/ms684179(v=vs.85).aspx
[PInvokeData("LibLoaderAPI.h", MSDNShortId = "ms684179")]
[SuppressUnmanagedCodeSecurity]
public static SafeHINSTANCE LoadLibraryEx([In] string lpFileName, LoadLibraryExFlags dwFlags = 0) => LoadLibraryEx(lpFileName, IntPtr.Zero, dwFlags);
public static SafeHINSTANCE LoadLibraryEx(string lpFileName, LoadLibraryExFlags dwFlags = 0) => LoadLibraryEx(lpFileName, IntPtr.Zero, dwFlags);
/// <summary>Retrieves a handle that can be used to obtain a pointer to the first byte of the specified resource in memory.</summary>
/// <param name="hModule">
@ -1856,7 +1855,7 @@ namespace Vanara.PInvoke
/// </listheader>
/// <item>
/// <term>LOAD_LIBRARY_SEARCH_APPLICATION_DIR0x00000200</term>
/// <term>If this value is used, the application&amp;#39;s installation directory is searched.</term>
/// <term>If this value is used, the application's installation directory is searched.</term>
/// </item>
/// <item>
/// <term>LOAD_LIBRARY_SEARCH_DEFAULT_DIRS0x00001000</term>
@ -1909,15 +1908,19 @@ namespace Vanara.PInvoke
[PInvokeData("Winbase.h", MSDNShortId = "ms648048")]
public static extern uint SizeofResource(HINSTANCE hModule, SafeResourceHandle hResInfo);
/// <summary>Provides a <see cref="SafeHandle"/> to a that releases a created HINSTANCE instance at disposal using FreeLibrary.</summary>
/// <summary>Provides a <see cref="SafeHandle"/> to a that releases a created HINSTANCE instance at disposal using FreeLibrary.</summary>
[PInvokeData("LibLoaderAPI.h")]
public class SafeHINSTANCE : HINSTANCE
public class SafeHINSTANCE : HANDLE
{
/// <summary>Initializes a new instance of the <see cref="HINSTANCE"/> class and assigns an existing handle.</summary>
/// <param name="preexistingHandle">An <see cref="IntPtr"/> object that represents the pre-existing handle to use.</param>
/// <param name="ownsHandle"><see langword="true"/> to reliably release the handle during the finalization phase; otherwise, <see langword="false"/> (not recommended).</param>
/// <param name="ownsHandle">
/// <see langword="true"/> to reliably release the handle during the finalization phase; otherwise, <see langword="false"/> (not recommended).
/// </param>
public SafeHINSTANCE(IntPtr preexistingHandle, bool ownsHandle = true) : base(preexistingHandle, ownsHandle) { }
private SafeHINSTANCE() : base() { }
/// <summary>
/// Gets a value indicating whether the module was loaded as a data file (LOAD_LIBRARY_AS_DATAFILE or
/// LOAD_LIBRARY_AS_DATAFILE_EXCLUSIVE). Equivalent to LDR_IS_DATAFILE.
@ -1934,22 +1937,27 @@ namespace Vanara.PInvoke
/// </summary>
public bool IsResource => (handle.ToInt64() & 3) != 0;
/// <summary>Performs an implicit conversion from <see cref="SafeHINSTANCE"/> to <see cref="HINSTANCE"/>.</summary>
/// <param name="h">The safe handle instance.</param>
/// <returns>The result of the conversion.</returns>
public static implicit operator HINSTANCE(SafeHINSTANCE h) => h.handle;
/// <inheritdoc/>
protected override bool InternalReleaseHandle() => FreeLibrary(this);
}
/// <summary>Represents a loaded resource handle.</summary>
/// <seealso cref="Vanara.InteropServices.GenericSafeHandle"/>
public class SafeResourceDataHandle : GenericSafeHandle
public class SafeResourceDataHandle : HANDLE
{
private IntPtr bptr;
/// <summary>Initializes a new instance of the <see cref="SafeResourceDataHandle"/> class.</summary>
public SafeResourceDataHandle() : this(IntPtr.Zero) { }
public SafeResourceDataHandle() : base() { }
/// <summary>Initializes a new instance of the <see cref="SafeResourceDataHandle"/> class.</summary>
/// <param name="handle">The handle.</param>
public SafeResourceDataHandle(IntPtr handle) : base(handle, h => true, false) { }
public SafeResourceDataHandle(IntPtr handle) : base(handle, false) { }
/// <summary>Gets the pointer to the memory of the resource.</summary>
public IntPtr LockedPtr => bptr != null ? bptr : (bptr = LockResource(this));
@ -1957,14 +1965,14 @@ namespace Vanara.PInvoke
/// <summary>Represents a resource data block handle.</summary>
/// <seealso cref="Vanara.InteropServices.GenericSafeHandle"/>
public class SafeResourceHandle : GenericSafeHandle
public class SafeResourceHandle : HANDLE
{
/// <summary>Initializes a new instance of the <see cref="SafeResourceHandle"/> class.</summary>
public SafeResourceHandle() : this(IntPtr.Zero) { }
public SafeResourceHandle() : base() { }
/// <summary>Initializes a new instance of the <see cref="SafeResourceHandle"/> class.</summary>
/// <param name="handle">The handle.</param>
public SafeResourceHandle(IntPtr handle) : base(handle, h => true, false) { }
public SafeResourceHandle(IntPtr handle) : base(handle, false) { }
}
}
}

View File

@ -15,7 +15,7 @@ namespace Vanara.PInvoke
// INT WINAPI GetExpandedName( _In_ LPTSTR lpszSource, _Out_ LPTSTR lpszBuffer); https://msdn.microsoft.com/en-us/library/windows/desktop/aa364941(v=vs.85).aspx
[DllImport(Lib.Kernel32, SetLastError = true, CharSet = CharSet.Auto)]
[PInvokeData("LzExpand.h", MSDNShortId = "aa364941")]
public static extern int GetExpandedName(string lpszSource, [Out] StringBuilder lpszBuffer);
public static extern int GetExpandedName(string lpszSource, StringBuilder lpszBuffer);
/// <summary>Closes a file that was opened by using the <c>LZOpenFile</c> function.</summary>
/// <param name="hFile">A handle to the file to be closed.</param>
@ -144,7 +144,7 @@ namespace Vanara.PInvoke
/// </item>
/// <item>
/// <term>OF_EXIST0x4000</term>
/// <term>Opens the file and then closes it to test for a file&amp;#39;s existence.</term>
/// <term>Opens the file and then closes it to test for a file's existence.</term>
/// </item>
/// <item>
/// <term>OF_PARSE0x0100</term>
@ -288,7 +288,7 @@ namespace Vanara.PInvoke
// INT WINAPI LZRead( _In_ INT hFile, _Out_ LPSTR lpBuffer, _In_ INT cbRead); https://msdn.microsoft.com/en-us/library/windows/desktop/aa365226(v=vs.85).aspx
[DllImport(Lib.Kernel32, SetLastError = true, ExactSpelling = true, CharSet = CharSet.Ansi)]
[PInvokeData("LzExpand.h", MSDNShortId = "aa365226")]
public static extern int LZRead(int hFile, [Out] StringBuilder lpBuffer, int cbRead);
public static extern int LZRead(int hFile, StringBuilder lpBuffer, int cbRead);
/// <summary>Moves a file pointer the specified number of bytes from a starting position.</summary>
/// <param name="hFile">A handle to the file.</param>

View File

@ -1,6 +1,4 @@
// ReSharper disable UnusedMember.Global ReSharper disable InconsistentNaming
using Microsoft.Win32.SafeHandles;
using Microsoft.Win32.SafeHandles;
using System;
using System.Runtime.InteropServices;
@ -109,7 +107,7 @@ namespace Vanara.PInvoke
/// </summary>
MEM_COMMIT = 0x00001000,
/// <summary>
/// Reserves a range of the process&amp;#39;s virtual address space without allocating any actual physical storage in memory or in the paging file on
/// Reserves a range of the process's virtual address space without allocating any actual physical storage in memory or in the paging file on
/// disk.You can commit reserved pages in subsequent calls to the VirtualAlloc function. To reserve and commit pages in one step, call VirtualAlloc
/// with MEM_COMMIT | MEM_RESERVE.Other memory allocation functions, such as malloc and LocalAlloc, cannot use a reserved range of memory until it is released.
/// </summary>
@ -362,7 +360,7 @@ namespace Vanara.PInvoke
/// parameter is a handle to an executable image or data file).The maximum size of the file mapping object must be a multiple of the minimum size of a
/// large page returned by the GetLargePageMinimum function. If it is not, CreateFileMapping fails. When mapping a view of a file mapping object created
/// with SEC_LARGE_PAGES, the base address and view size must also be multiples of the minimum large page size.SEC_LARGE_PAGES requires the
/// SeLockMemoryPrivilege privilege to be enabled in the caller&amp;#39;s token.If SEC_LARGE_PAGES is specified, SEC_COMMIT must also be
/// SeLockMemoryPrivilege privilege to be enabled in the caller's token.If SEC_LARGE_PAGES is specified, SEC_COMMIT must also be
/// specified.Windows Server 2003: This value is not supported until Windows Server 2003 with SP1.Windows XP: This value is not supported.
/// </summary>
SEC_LARGE_PAGES = 0x80000000,
@ -445,7 +443,7 @@ namespace Vanara.PInvoke
[DllImport(Lib.Kernel32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("WinBase.h", MSDNShortId = "aa366528")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool AllocateUserPhysicalPages([In] IntPtr hProcess, ref SizeT NumberOfPages, out IntPtr UserPfnArray);
public static extern bool AllocateUserPhysicalPages([In] HPROCESS hProcess, ref SizeT NumberOfPages, out IntPtr UserPfnArray);
/// <summary>
/// Allocates physical memory pages to be mapped and unmapped within any Address Windowing Extensions (AWE) region of a specified process and specifies
@ -484,7 +482,7 @@ namespace Vanara.PInvoke
[DllImport(Lib.Kernel32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("WinBase.h", MSDNShortId = "aa366529")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool AllocateUserPhysicalPagesNuma([In] IntPtr hProcess, ref SizeT NumberOfPages, out IntPtr PageArray, uint nndPreferred);
public static extern bool AllocateUserPhysicalPagesNuma([In] HPROCESS hProcess, ref SizeT NumberOfPages, out IntPtr PageArray, uint nndPreferred);
/// <summary>
/// <para>Creates or opens a named or unnamed file mapping object for a specified file.</para>
@ -615,7 +613,7 @@ namespace Vanara.PInvoke
/// parameter is a handle to an executable image or data file).The maximum size of the file mapping object must be a multiple of the minimum size of a
/// large page returned by the GetLargePageMinimum function. If it is not, CreateFileMapping fails. When mapping a view of a file mapping object created
/// with SEC_LARGE_PAGES, the base address and view size must also be multiples of the minimum large page size.SEC_LARGE_PAGES requires the
/// SeLockMemoryPrivilege privilege to be enabled in the caller&amp;#39;s token.If SEC_LARGE_PAGES is specified, SEC_COMMIT must also be
/// SeLockMemoryPrivilege privilege to be enabled in the caller's token.If SEC_LARGE_PAGES is specified, SEC_COMMIT must also be
/// specified.Windows Server 2003: This value is not supported until Windows Server 2003 with SP1.Windows XP: This value is not supported.
/// </term>
/// </item>
@ -693,7 +691,7 @@ namespace Vanara.PInvoke
[DllImport(Lib.Kernel32, SetLastError = true, CharSet = CharSet.Auto)]
[PInvokeData("WinBase.h", MSDNShortId = "aa366537")]
public static extern IntPtr CreateFileMapping([In] HFILE hFile, [In] SECURITY_ATTRIBUTES lpAttributes, MEM_PROTECTION flProtect,
uint dwMaximumSizeHigh, uint dwMaximumSizeLow, [In] string lpName);
uint dwMaximumSizeHigh, uint dwMaximumSizeLow, string lpName);
/// <summary>Creates or opens a named or unnamed file mapping object for a specified file from a Windows Store app.</summary>
/// <param name="hFile">
@ -788,7 +786,7 @@ namespace Vanara.PInvoke
/// parameter is a handle to an executable image or data file).The maximum size of the file mapping object must be a multiple of the minimum size of a
/// large page returned by the GetLargePageMinimum function. If it is not, CreateFileMappingFromApp fails. When mapping a view of a file mapping object
/// created with SEC_LARGE_PAGES, the base address and view size must also be multiples of the minimum large page size.SEC_LARGE_PAGES requires the
/// SeLockMemoryPrivilege privilege to be enabled in the caller&amp;#39;s token.If SEC_LARGE_PAGES is specified, SEC_COMMIT must also be specified.
/// SeLockMemoryPrivilege privilege to be enabled in the caller's token.If SEC_LARGE_PAGES is specified, SEC_COMMIT must also be specified.
/// </term>
/// </item>
/// <item>
@ -861,7 +859,7 @@ namespace Vanara.PInvoke
[DllImport(Lib.Kernel32, SetLastError = true, ExactSpelling = true, CharSet = CharSet.Unicode)]
[PInvokeData("MemoryApi.h", MSDNShortId = "hh994453")]
public static extern IntPtr CreateFileMappingFromApp([In] HFILE hFile, [In] SECURITY_ATTRIBUTES SecurityAttributes,
MEM_PROTECTION PageProtection, ulong MaximumSize, [In] string Name);
MEM_PROTECTION PageProtection, ulong MaximumSize, string Name);
/// <summary>Creates or opens a named or unnamed file mapping object for a specified file and specifies the NUMA node for the physical memory.</summary>
/// <param name="hFile">
@ -1069,7 +1067,7 @@ namespace Vanara.PInvoke
[DllImport(Lib.Kernel32, SetLastError = true, CharSet = CharSet.Auto)]
[PInvokeData("WinBase.h", MSDNShortId = "aa366539")]
public static extern SafeHFILE CreateFileMappingNuma([In] HFILE hFile, [In] SECURITY_ATTRIBUTES lpFileMappingAttributes, MEM_PROTECTION flProtect,
uint dwMaximumSizeHigh, uint dwMaximumSizeLow, [In] string lpName, uint nndPreferred);
uint dwMaximumSizeHigh, uint dwMaximumSizeLow, string lpName, uint nndPreferred);
/// <summary>
/// <para>Creates a memory resource notification object.</para>
@ -1103,7 +1101,7 @@ namespace Vanara.PInvoke
// HANDLE WINAPI CreateMemoryResourceNotification( _In_ MEMORY_RESOURCE_NOTIFICATION_TYPE NotificationType);
[DllImport(Lib.Kernel32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("WinBase.h", MSDNShortId = "aa366541")]
public static extern SafeHFILE CreateMemoryResourceNotification(MEMORY_RESOURCE_NOTIFICATION_TYPE NotificationType);
public static extern SafeMemoryResourceNotification CreateMemoryResourceNotification(MEMORY_RESOURCE_NOTIFICATION_TYPE NotificationType);
/// <summary>
/// Discards the memory contents of a range of memory pages, without decommitting the memory. The contents of discarded memory is undefined and must be
@ -1162,7 +1160,7 @@ namespace Vanara.PInvoke
[DllImport(Lib.Kernel32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("WinBase.h", MSDNShortId = "aa366566")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool FreeUserPhysicalPages([In] IntPtr hProcess, ref SizeT NumberOfPages, [In] IntPtr UserPfnArray);
public static extern bool FreeUserPhysicalPages([In] HPROCESS hProcess, ref SizeT NumberOfPages, [In] IntPtr UserPfnArray);
/// <summary>Retrieves the minimum size of a large page.</summary>
/// <returns>
@ -1225,7 +1223,7 @@ namespace Vanara.PInvoke
[DllImport(Lib.Kernel32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("WinBase.h", MSDNShortId = "ms683226")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool GetProcessWorkingSetSizeEx([In] IntPtr hProcess, [Out] out SizeT lpMinimumWorkingSetSize, [Out] out SizeT lpMaximumWorkingSetSize, out QUOTA_LIMITS_HARDWS Flags);
public static extern bool GetProcessWorkingSetSizeEx([In] HPROCESS hProcess, [Out] out SizeT lpMinimumWorkingSetSize, [Out] out SizeT lpMaximumWorkingSetSize, out QUOTA_LIMITS_HARDWS Flags);
/// <summary>Retrieves the current size limits for the working set of the system cache.</summary>
/// <param name="lpMinimumFileCacheSize">
@ -1636,7 +1634,7 @@ namespace Vanara.PInvoke
// SIZE_T ViewSize, _In_ ULONG AllocationType, _In_ ULONG PageProtection, _In_ ULONG PreferredNode);
[DllImport("Api-ms-win-core-memory-l1-1-5.dll", SetLastError = true, ExactSpelling = true)]
[PInvokeData("WinBase.h", MSDNShortId = "mt492558")]
public static extern IntPtr MapViewOfFileNuma2([In] HFILE FileMappingHandle, [In] IntPtr ProcessHandle, ulong Offset, IntPtr BaseAddress, SizeT ViewSize,
public static extern IntPtr MapViewOfFileNuma2([In] HFILE FileMappingHandle, [In] HPROCESS ProcessHandle, ulong Offset, IntPtr BaseAddress, SizeT ViewSize,
MEM_ALLOCATION_TYPE AllocationType, MEM_PROTECTION PageProtection, uint PreferredNode);
/// <summary>
@ -1708,7 +1706,7 @@ namespace Vanara.PInvoke
// HANDLE WINAPI OpenFileMapping( _In_ DWORD dwDesiredAccess, _In_ BOOL bInheritHandle, _In_ LPCTSTR lpName);
[DllImport(Lib.Kernel32, SetLastError = true, CharSet = CharSet.Auto)]
[PInvokeData("WinBase.h", MSDNShortId = "aa366791")]
public static extern SafeHFILE OpenFileMapping(FILE_MAP dwDesiredAccess, [MarshalAs(UnmanagedType.Bool)] bool bInheritHandle, [In] string lpName);
public static extern SafeHFILE OpenFileMapping(FILE_MAP dwDesiredAccess, [MarshalAs(UnmanagedType.Bool)] bool bInheritHandle, string lpName);
/// <summary>Opens a named file mapping object.</summary>
/// <param name="DesiredAccess">
@ -1754,7 +1752,7 @@ namespace Vanara.PInvoke
[DllImport(Lib.Kernel32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("WinBase.h", MSDNShortId = "hh780543")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool PrefetchVirtualMemory(IntPtr hProcess, UIntPtr NumberOfEntries, IntPtr VirtualAddresses, uint Flags);
public static extern bool PrefetchVirtualMemory(HPROCESS hProcess, UIntPtr NumberOfEntries, IntPtr VirtualAddresses, uint Flags);
/// <summary>Retrieves the state of the specified memory resource object.</summary>
/// <param name="ResourceNotificationHandle">
@ -1772,7 +1770,7 @@ namespace Vanara.PInvoke
[DllImport(Lib.Kernel32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("WinBase.h", MSDNShortId = "aa366799")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool QueryMemoryResourceNotification([In] HFILE ResourceNotificationHandle, [Out, MarshalAs(UnmanagedType.Bool)] out bool ResourceState);
public static extern bool QueryMemoryResourceNotification([In] SafeMemoryResourceNotification ResourceNotificationHandle, [Out, MarshalAs(UnmanagedType.Bool)] out bool ResourceState);
/// <summary>
/// The <c>QueryVirtualMemoryInformation</c> function returns information about a page or a set of pages within the virtual address space of the
@ -1795,7 +1793,7 @@ namespace Vanara.PInvoke
[DllImport(Lib.Kernel32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("MemoryApi.h", MSDNShortId = "mt845761")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool QueryVirtualMemoryInformation([In] IntPtr Process, IntPtr VirtualAddress, WIN32_MEMORY_INFORMATION_CLASS MemoryInformationClass, IntPtr MemoryInformation, SizeT MemoryInformationSize, out SizeT ReturnSize);
public static extern bool QueryVirtualMemoryInformation([In] HPROCESS Process, IntPtr VirtualAddress, WIN32_MEMORY_INFORMATION_CLASS MemoryInformationClass, IntPtr MemoryInformation, SizeT MemoryInformationSize, out SizeT ReturnSize);
/// <summary>Reads data from an area of memory in a specified process. The entire area to be read must be accessible or the operation fails.</summary>
/// <param name="hProcess">A handle to the process with memory that is being read. The handle must have PROCESS_VM_READ access to the process.</param>
@ -1818,7 +1816,7 @@ namespace Vanara.PInvoke
[DllImport(Lib.Kernel32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("WinBase.h", MSDNShortId = "ms680553")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool ReadProcessMemory([In] IntPtr hProcess, [In] IntPtr lpBaseAddress, IntPtr lpBuffer, SizeT nSize, out SizeT lpNumberOfBytesRead);
public static extern bool ReadProcessMemory([In] HPROCESS hProcess, [In] IntPtr lpBaseAddress, IntPtr lpBuffer, SizeT nSize, out SizeT lpNumberOfBytesRead);
/// <summary>
/// <para>Reclaims a range of memory pages that were offered to the system with <c>OfferVirtualMemory</c>.</para>
@ -1898,7 +1896,7 @@ namespace Vanara.PInvoke
[DllImport(Lib.Kernel32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("WinBase.h", MSDNShortId = "dn934202")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SetProcessValidCallTargets(IntPtr hProcess, IntPtr VirtualAddress, SizeT RegionSize, uint NumberOfOffsets, [In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 3)] CFG_CALL_TARGET_INFO[] OffsetInformation);
public static extern bool SetProcessValidCallTargets(HPROCESS hProcess, IntPtr VirtualAddress, SizeT RegionSize, uint NumberOfOffsets, [In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 3)] CFG_CALL_TARGET_INFO[] OffsetInformation);
/// <summary>Sets the minimum and maximum working set sizes for the specified process.</summary>
/// <param name="hProcess">
@ -1971,7 +1969,7 @@ namespace Vanara.PInvoke
[DllImport(Lib.Kernel32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("WinBase.h", MSDNShortId = "ms686237")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SetProcessWorkingSetSizeEx([In] IntPtr hProcess, SizeT dwMinimumWorkingSetSize, SizeT dwMaximumWorkingSetSize, QUOTA_LIMITS_HARDWS Flags);
public static extern bool SetProcessWorkingSetSizeEx([In] HPROCESS hProcess, SizeT dwMinimumWorkingSetSize, SizeT dwMaximumWorkingSetSize, QUOTA_LIMITS_HARDWS Flags);
/// <summary>Limits the size of the working set for the file system cache.</summary>
/// <param name="MinimumFileCacheSize">
@ -2055,7 +2053,7 @@ namespace Vanara.PInvoke
[DllImport(Lib.Kernel32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("MemoryApi.h", MSDNShortId = "mt492559")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool UnmapViewOfFile2([In] IntPtr ProcessHandle, IntPtr BaseAddress, uint UnmapFlags);
public static extern bool UnmapViewOfFile2([In] HPROCESS ProcessHandle, IntPtr BaseAddress, uint UnmapFlags);
/// <summary>This is an extended version of UnmapViewOfFile that takes an additional flags parameter.</summary>
/// <param name="BaseAddress">
@ -2137,7 +2135,7 @@ namespace Vanara.PInvoke
/// <item>
/// <term>MEM_RESERVE0x00002000</term>
/// <term>
/// Reserves a range of the process&amp;#39;s virtual address space without allocating any actual physical storage in memory or in the paging file on
/// Reserves a range of the process's virtual address space without allocating any actual physical storage in memory or in the paging file on
/// disk.You can commit reserved pages in subsequent calls to the VirtualAlloc function. To reserve and commit pages in one step, call VirtualAlloc with
/// MEM_COMMIT | MEM_RESERVE.Other memory allocation functions, such as malloc and LocalAlloc, cannot use a reserved range of memory until it is released.
/// </term>
@ -2275,7 +2273,7 @@ namespace Vanara.PInvoke
/// <item>
/// <term>MEM_RESERVE0x00002000</term>
/// <term>
/// Reserves a range of the process&amp;#39;s virtual address space without allocating any actual physical storage in memory or in the paging file on
/// Reserves a range of the process's virtual address space without allocating any actual physical storage in memory or in the paging file on
/// disk.You commit reserved pages by calling VirtualAllocEx again with MEM_COMMIT. To reserve and commit pages in one step, call VirtualAllocEx with
/// .Other memory allocation functions, such as malloc and LocalAlloc, cannot use reserved memory until it has been released.
/// </term>
@ -2345,7 +2343,7 @@ namespace Vanara.PInvoke
// LPVOID WINAPI VirtualAllocEx( _In_ HANDLE hProcess, _In_opt_ LPVOID lpAddress, _In_ SIZE_T dwSize, _In_ DWORD flAllocationType, _In_ DWORD flProtect);
[DllImport(Lib.Kernel32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("WinBase.h", MSDNShortId = "aa366890")]
public static extern IntPtr VirtualAllocEx([In] IntPtr hProcess, [In] IntPtr lpAddress, SizeT dwSize, MEM_ALLOCATION_TYPE flAllocationType, MEM_PROTECTION flProtect);
public static extern IntPtr VirtualAllocEx([In] HPROCESS hProcess, [In] IntPtr lpAddress, SizeT dwSize, MEM_ALLOCATION_TYPE flAllocationType, MEM_PROTECTION flProtect);
/// <summary>
/// Reserves, commits, or changes the state of a region of memory within the virtual address space of the specified process, and specifies the NUMA node
@ -2394,7 +2392,7 @@ namespace Vanara.PInvoke
/// <item>
/// <term>MEM_RESERVE0x00002000</term>
/// <term>
/// Reserves a range of the process&amp;#39;s virtual address space without allocating any actual physical storage in memory or in the paging file on
/// Reserves a range of the process's virtual address space without allocating any actual physical storage in memory or in the paging file on
/// disk.You commit reserved pages by calling the function again with MEM_COMMIT. To reserve and commit pages in one step, call the function with .Other
/// memory allocation functions, such as malloc and LocalAlloc, cannot use reserved memory until it has been released.
/// </term>
@ -2472,7 +2470,7 @@ namespace Vanara.PInvoke
// flProtect, _In_ DWORD nndPreferred);
[DllImport(Lib.Kernel32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("WinBase.h", MSDNShortId = "aa366891")]
public static extern IntPtr VirtualAllocExNuma([In] IntPtr hProcess, [In] IntPtr lpAddress, SizeT dwSize, MEM_ALLOCATION_TYPE flAllocationType, MEM_PROTECTION flProtect, uint nndPreferred);
public static extern IntPtr VirtualAllocExNuma([In] HPROCESS hProcess, [In] IntPtr lpAddress, SizeT dwSize, MEM_ALLOCATION_TYPE flAllocationType, MEM_PROTECTION flProtect, uint nndPreferred);
/// <summary>
/// Reserves, commits, or changes the state of a region of pages in the virtual address space of the calling process. Memory allocated by this function
@ -2511,7 +2509,7 @@ namespace Vanara.PInvoke
/// <item>
/// <term>MEM_RESERVE0x00002000</term>
/// <term>
/// Reserves a range of the process&amp;#39;s virtual address space without allocating any actual physical storage in memory or in the paging file on
/// Reserves a range of the process's virtual address space without allocating any actual physical storage in memory or in the paging file on
/// disk.You can commit reserved pages in subsequent calls to the VirtualAllocFromApp function. To reserve and commit pages in one step, call
/// VirtualAllocFromApp with MEM_COMMIT | MEM_RESERVE.Other memory allocation functions, such as malloc and LocalAlloc, cannot use a reserved range of
/// memory until it is released.
@ -2715,7 +2713,7 @@ namespace Vanara.PInvoke
[DllImport(Lib.Kernel32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("WinBase.h", MSDNShortId = "aa366894")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool VirtualFreeEx([In] IntPtr hProcess, [In] IntPtr lpAddress, SizeT dwSize, MEM_ALLOCATION_TYPE dwFreeType);
public static extern bool VirtualFreeEx([In] HPROCESS hProcess, [In] IntPtr lpAddress, SizeT dwSize, MEM_ALLOCATION_TYPE dwFreeType);
/// <summary>
/// Locks the specified region of the process's virtual address space into physical memory, ensuring that subsequent access to the region will not incur
@ -2811,7 +2809,7 @@ namespace Vanara.PInvoke
[DllImport(Lib.Kernel32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("WinBase.h", MSDNShortId = "aa366899")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool VirtualProtectEx([In] IntPtr hProcess, [In] IntPtr lpAddress, SizeT dwSize, MEM_PROTECTION flNewProtect, [Out] out MEM_PROTECTION lpflOldProtect);
public static extern bool VirtualProtectEx([In] HPROCESS hProcess, [In] IntPtr lpAddress, SizeT dwSize, MEM_PROTECTION flNewProtect, [Out] out MEM_PROTECTION lpflOldProtect);
/// <summary>Changes the protection on a region of committed pages in the virtual address space of the calling process.</summary>
/// <param name="Address">
@ -2896,7 +2894,7 @@ namespace Vanara.PInvoke
// SIZE_T WINAPI VirtualQueryEx( _In_ HANDLE hProcess, _In_opt_ LPCVOID lpAddress, _Out_ PMEMORY_BASIC_INFORMATION lpBuffer, _In_ SIZE_T dwLength);
[DllImport(Lib.Kernel32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("WinBase.h", MSDNShortId = "aa366907")]
public static extern SizeT VirtualQueryEx([In] IntPtr hProcess, [In] IntPtr lpAddress, IntPtr lpBuffer, SizeT dwLength);
public static extern SizeT VirtualQueryEx([In] HPROCESS hProcess, [In] IntPtr lpAddress, IntPtr lpBuffer, SizeT dwLength);
/// <summary>
/// Unlocks a specified range of pages in the virtual address space of a process, enabling the system to swap the pages out to the
@ -2942,7 +2940,7 @@ namespace Vanara.PInvoke
[DllImport(Lib.Kernel32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("WinBase.h", MSDNShortId = "ms681674")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool WriteProcessMemory([In] IntPtr hProcess, [In] IntPtr lpBaseAddress, [In] IntPtr lpBuffer, SizeT nSize, out SizeT lpNumberOfBytesWritten);
public static extern bool WriteProcessMemory([In] HPROCESS hProcess, [In] IntPtr lpBaseAddress, [In] IntPtr lpBuffer, SizeT nSize, out SizeT lpNumberOfBytesWritten);
/// <summary>Represents information about call targets for Control Flow Guard (CFG).</summary>
// typedef struct _CFG_CALL_TARGET_INFO { ULONG_PTR Offset; ULONG_PTR Flags;} CFG_CALL_TARGET_INFO, *PCFG_CALL_TARGET_INFO;
@ -2968,5 +2966,14 @@ namespace Vanara.PInvoke
/// <summary></summary>
public IntPtr VirtualAddress;
}
/// <summary>Provides a <see cref="SafeHandle"/> to a memory resource notification object that releases its instance at disposal using CloseHandle.</summary>
public class SafeMemoryResourceNotification : SafeSyncHandle
{
/// <summary>Initializes a new instance of the <see cref="MemoryResourceNotification"/> class and assigns an existing handle.</summary>
/// <param name="preexistingHandle">An <see cref="IntPtr"/> object that represents the pre-existing handle to use.</param>
/// <param name="ownsHandle"><see langword="true"/> to reliably release the handle during the finalization phase; otherwise, <see langword="false"/> (not recommended).</param>
public SafeMemoryResourceNotification(IntPtr preexistingHandle, bool ownsHandle = true) : base(preexistingHandle, ownsHandle) { }
}
}
}

View File

@ -8,8 +8,54 @@ namespace Vanara.PInvoke
/// <summary>Indicates that the namespace is destroyed on closing.</summary>
public const uint PRIVATE_NAMESPACE_FLAG_DESTROY = 0x00000001;
/// <summary>
/// <para>Adds a new required security identifier (SID) to the specified boundary descriptor.</para>
/// </summary>
/// <param name="BoundaryDescriptor">
/// <para>A handle to the boundary descriptor. The CreateBoundaryDescriptor function returns this handle.</para>
/// </param>
/// <param name="IntegrityLabel">
/// <para>
/// A pointer to a SID structure that represents the mandatory integrity level for the namespace. Use one of the following RID values
/// to create the SID:
/// </para>
/// <para>
/// <c>SECURITY_MANDATORY_UNTRUSTED_RID</c><c>SECURITY_MANDATORY_LOW_RID</c><c>SECURITY_MANDATORY_MEDIUM_RID</c><c>SECURITY_MANDATORY_SYSTEM_RID</c><c>SECURITY_MANDATORY_PROTECTED_PROCESS_RID</c>
/// For more information, see Well-Known SIDs.
/// </para>
/// </param>
/// <returns>
/// <para>If the function succeeds, the return value is nonzero.</para>
/// <para>If the function fails, the return value is zero. To get extended error information, call GetLastError.</para>
/// </returns>
/// <remarks>
/// <para>
/// A process can create a private namespace only with an integrity level that is equal to or lower than the current integrity level
/// of the process. Therefore, a high integrity-level process can create a high, medium or low integrity-level namespace. A medium
/// integrity-level process can create only a medium or low integrity-level namespace.
/// </para>
/// <para>
/// A process would usually specify a namespace at the same integrity level as the process for protection against squatting attacks
/// by lower integrity-level processes.
/// </para>
/// <para>
/// The security descriptor that the creator places on the namespace determines who can open the namespace. So a low or medium
/// integrity-level process could be given permission to open a high integrity level namespace if the security descriptor of the
/// namespace permits it.
/// </para>
/// <para>To compile an application that uses this function, define <c>_WIN32_WINNT</c> as 0x0601 or later.</para>
/// </remarks>
// https://docs.microsoft.com/en-us/windows/desktop/api/winbase/nf-winbase-addintegritylabeltoboundarydescriptor BOOL
// AddIntegrityLabelToBoundaryDescriptor( HANDLE *BoundaryDescriptor, PSID IntegrityLabel );
[DllImport(Lib.Kernel32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("winbase.h", MSDNShortId = "6b56e664-7795-4e30-8bca-1e4df2764606")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool AddIntegrityLabelToBoundaryDescriptor(ref BoundaryDescriptorHandle BoundaryDescriptor, IntPtr IntegrityLabel);
/// <summary>Adds a security identifier (SID) to the specified boundary descriptor.</summary>
/// <param name="BoundaryDescriptor">A handle to the boundary descriptor. The <c>CreateBoundaryDescriptor</c> function returns this handle.</param>
/// <param name="BoundaryDescriptor">
/// A handle to the boundary descriptor. The <c>CreateBoundaryDescriptor</c> function returns this handle.
/// </param>
/// <param name="RequiredSid">A pointer to a <c>SID</c> structure.</param>
/// <returns>
/// <para>If the function succeeds, the return value is nonzero.</para>
@ -19,7 +65,7 @@ namespace Vanara.PInvoke
[DllImport(Lib.Kernel32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("WinBase.h", MSDNShortId = "ms681937")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool AddSIDToBoundaryDescriptor(ref IntPtr BoundaryDescriptor, IntPtr RequiredSid);
public static extern bool AddSIDToBoundaryDescriptor(ref BoundaryDescriptorHandle BoundaryDescriptor, IntPtr RequiredSid);
/// <summary>Closes an open namespace handle.</summary>
/// <param name="Handle">The namespace handle. This handle is created by <c>CreatePrivateNamespace</c> or <c>OpenPrivateNamespace</c>.</param>
@ -32,7 +78,7 @@ namespace Vanara.PInvoke
[DllImport(Lib.Kernel32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("WinBase.h", MSDNShortId = "ms682026")]
[return: MarshalAs(UnmanagedType.U1)]
public static extern bool ClosePrivateNamespace(IntPtr Handle, uint Flags);
public static extern bool ClosePrivateNamespace(NamespaceHandle Handle, uint Flags);
/// <summary>Creates a boundary descriptor.</summary>
/// <param name="Name">The name of the boundary descriptor.</param>
@ -44,15 +90,15 @@ namespace Vanara.PInvoke
// HANDLE WINAPI CreateBoundaryDescriptor( _In_ LPCTSTR Name, _In_ ULONG Flags); https://msdn.microsoft.com/en-us/library/windows/desktop/ms682121(v=vs.85).aspx
[DllImport(Lib.Kernel32, SetLastError = true, CharSet = CharSet.Auto)]
[PInvokeData("WinBase.h", MSDNShortId = "ms682121")]
public static extern IntPtr CreateBoundaryDescriptor(string Name, [Optional] uint Flags);
public static extern SafeBoundaryDescriptorHandle CreateBoundaryDescriptor(string Name, [Optional] uint Flags);
/// <summary>Creates a private namespace.</summary>
/// <param name="lpPrivateNamespaceAttributes">
/// A pointer to a <c>SECURITY_ATTRIBUTES</c> structure that specifies the security attributes of the namespace object.
/// </param>
/// <param name="lpBoundaryDescriptor">
/// A descriptor that defines how the namespace is to be isolated. The caller must be within this boundary. The <c>CreateBoundaryDescriptor</c> function
/// creates a boundary descriptor.
/// A descriptor that defines how the namespace is to be isolated. The caller must be within this boundary. The
/// <c>CreateBoundaryDescriptor</c> function creates a boundary descriptor.
/// </param>
/// <param name="lpAliasPrefix">
/// <para>The prefix for the namespace. To create an object in this namespace, specify the object name as prefix\objectname.</para>
@ -62,29 +108,174 @@ namespace Vanara.PInvoke
/// <para>If the function succeeds, it returns a handle to the new namespace.</para>
/// <para>If the function fails, the return value is <c>NULL</c>. To get extended error information, call <c>GetLastError</c>.</para>
/// </returns>
// HANDLE WINAPI CreatePrivateNamespace( _In_opt_ LPSECURITY_ATTRIBUTES lpPrivateNamespaceAttributes, _In_ LPVOID lpBoundaryDescriptor, _In_ LPCTSTR
// lpAliasPrefix); https://msdn.microsoft.com/en-us/library/windows/desktop/ms682419(v=vs.85).aspx
// HANDLE WINAPI CreatePrivateNamespace( _In_opt_ LPSECURITY_ATTRIBUTES lpPrivateNamespaceAttributes, _In_ LPVOID
// lpBoundaryDescriptor, _In_ LPCTSTR lpAliasPrefix); https://msdn.microsoft.com/en-us/library/windows/desktop/ms682419(v=vs.85).aspx
[DllImport(Lib.Kernel32, SetLastError = true, CharSet = CharSet.Auto)]
[PInvokeData("WinBase.h", MSDNShortId = "ms682419")]
public static extern IntPtr CreatePrivateNamespace(SECURITY_ATTRIBUTES lpPrivateNamespaceAttributes, IntPtr lpBoundaryDescriptor, string lpAliasPrefix);
public static extern SafeNamespaceHandle CreatePrivateNamespace(SECURITY_ATTRIBUTES lpPrivateNamespaceAttributes, BoundaryDescriptorHandle lpBoundaryDescriptor, string lpAliasPrefix);
/// <summary>Deletes the specified boundary descriptor.</summary>
/// <param name="BoundaryDescriptor">A handle to the boundary descriptor. The <c>CreateBoundaryDescriptor</c> function returns this handle.</param>
/// <param name="BoundaryDescriptor">
/// A handle to the boundary descriptor. The <c>CreateBoundaryDescriptor</c> function returns this handle.
/// </param>
/// <returns>This function does not return a value.</returns>
// VOID WINAPI DeleteBoundaryDescriptor( _In_ HANDLE BoundaryDescriptor); https://msdn.microsoft.com/en-us/library/windows/desktop/ms682549(v=vs.85).aspx
[DllImport(Lib.Kernel32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("WinBase.h", MSDNShortId = "ms682549")]
public static extern void DeleteBoundaryDescriptor(IntPtr BoundaryDescriptor);
public static extern void DeleteBoundaryDescriptor(BoundaryDescriptorHandle BoundaryDescriptor);
/// <summary>Opens a private namespace.</summary>
/// <param name="lpBoundaryDescriptor">
/// A descriptor that defines how the namespace is to be isolated. The <c>CreateBoundaryDescriptor</c> function creates a boundary descriptor.
/// </param>
/// <param name="lpAliasPrefix">The prefix for the namespace. To create an object in this namespace, specify the object name as prefix\objectname.</param>
/// <param name="lpAliasPrefix">
/// The prefix for the namespace. To create an object in this namespace, specify the object name as prefix\objectname.
/// </param>
/// <returns>The function returns the handle to the existing namespace.</returns>
// HANDLE WINAPI OpenPrivateNamespace( _In_ LPVOID lpBoundaryDescriptor, _In_ LPCTSTR lpAliasPrefix); https://msdn.microsoft.com/en-us/library/windows/desktop/ms684318(v=vs.85).aspx
[DllImport(Lib.Kernel32, SetLastError = false, CharSet = CharSet.Auto)]
[PInvokeData("WinBase.h", MSDNShortId = "ms684318")]
public static extern IntPtr OpenPrivateNamespace(IntPtr lpBoundaryDescriptor, string lpAliasPrefix);
public static extern NamespaceHandle OpenPrivateNamespace(BoundaryDescriptorHandle lpBoundaryDescriptor, string lpAliasPrefix);
/// <summary>Provides a handle to a boundary descriptor.</summary>
[StructLayout(LayoutKind.Sequential)]
public struct BoundaryDescriptorHandle : IHandle
{
private IntPtr handle;
/// <summary>Initializes a new instance of the <see cref="BoundaryDescriptorHandle"/> struct.</summary>
/// <param name="preexistingHandle">An <see cref="IntPtr"/> object that represents the pre-existing handle to use.</param>
public BoundaryDescriptorHandle(IntPtr preexistingHandle) => handle = preexistingHandle;
/// <summary>Returns an invalid handle by instantiating a <see cref="BoundaryDescriptorHandle"/> object with <see cref="IntPtr.Zero"/>.</summary>
public static BoundaryDescriptorHandle NULL => new BoundaryDescriptorHandle(IntPtr.Zero);
/// <summary>Gets a value indicating whether this instance is a null handle.</summary>
public bool IsNull => handle == IntPtr.Zero;
/// <summary>Performs an explicit conversion from <see cref="BoundaryDescriptorHandle"/> to <see cref="IntPtr"/>.</summary>
/// <param name="h">The handle.</param>
/// <returns>The result of the conversion.</returns>
public static explicit operator IntPtr(BoundaryDescriptorHandle h) => h.handle;
/// <summary>Performs an implicit conversion from <see cref="IntPtr"/> to <see cref="BoundaryDescriptorHandle"/>.</summary>
/// <param name="h">The pointer to a handle.</param>
/// <returns>The result of the conversion.</returns>
public static implicit operator BoundaryDescriptorHandle(IntPtr h) => new BoundaryDescriptorHandle(h);
/// <summary>Implements the operator !=.</summary>
/// <param name="h1">The first handle.</param>
/// <param name="h2">The second handle.</param>
/// <returns>The result of the operator.</returns>
public static bool operator !=(BoundaryDescriptorHandle h1, BoundaryDescriptorHandle h2) => !(h1 == h2);
/// <summary>Implements the operator ==.</summary>
/// <param name="h1">The first handle.</param>
/// <param name="h2">The second handle.</param>
/// <returns>The result of the operator.</returns>
public static bool operator ==(BoundaryDescriptorHandle h1, BoundaryDescriptorHandle h2) => h1.Equals(h2);
/// <inheritdoc/>
public override bool Equals(object obj) => obj is BoundaryDescriptorHandle h ? handle == h.handle : false;
/// <inheritdoc/>
public override int GetHashCode() => handle.GetHashCode();
/// <inheritdoc/>
public IntPtr DangerousGetHandle() => handle;
}
/// <summary>Provides a handle to a private namespace.</summary>
[StructLayout(LayoutKind.Sequential)]
public struct NamespaceHandle
{
private IntPtr handle;
/// <summary>Initializes a new instance of the <see cref="NamespaceHandle"/> struct.</summary>
/// <param name="preexistingHandle">An <see cref="IntPtr"/> object that represents the pre-existing handle to use.</param>
public NamespaceHandle(IntPtr preexistingHandle) => handle = preexistingHandle;
/// <summary>Returns an invalid handle by instantiating a <see cref="NamespaceHandle"/> object with <see cref="IntPtr.Zero"/>.</summary>
public static NamespaceHandle NULL => new NamespaceHandle(IntPtr.Zero);
/// <summary>Gets a value indicating whether this instance is a null handle.</summary>
public bool IsNull => handle == IntPtr.Zero;
/// <summary>Performs an explicit conversion from <see cref="NamespaceHandle"/> to <see cref="IntPtr"/>.</summary>
/// <param name="h">The handle.</param>
/// <returns>The result of the conversion.</returns>
public static explicit operator IntPtr(NamespaceHandle h) => h.handle;
/// <summary>Performs an implicit conversion from <see cref="IntPtr"/> to <see cref="NamespaceHandle"/>.</summary>
/// <param name="h">The pointer to a handle.</param>
/// <returns>The result of the conversion.</returns>
public static implicit operator NamespaceHandle(IntPtr h) => new NamespaceHandle(h);
/// <summary>Implements the operator !=.</summary>
/// <param name="h1">The first handle.</param>
/// <param name="h2">The second handle.</param>
/// <returns>The result of the operator.</returns>
public static bool operator !=(NamespaceHandle h1, NamespaceHandle h2) => !(h1 == h2);
/// <summary>Implements the operator ==.</summary>
/// <param name="h1">The first handle.</param>
/// <param name="h2">The second handle.</param>
/// <returns>The result of the operator.</returns>
public static bool operator ==(NamespaceHandle h1, NamespaceHandle h2) => h1.Equals(h2);
/// <inheritdoc/>
public override bool Equals(object obj) => obj is NamespaceHandle h ? handle == h.handle : false;
/// <inheritdoc/>
public override int GetHashCode() => handle.GetHashCode();
}
/// <summary>
/// Provides a <see cref="SafeHandle"/> to a boundary descriptor that releases a created BoundaryDescriptorHandle instance at
/// disposal using DeleteBoundaryDescriptor.
/// </summary>
public class SafeBoundaryDescriptorHandle : HANDLE
{
/// <summary>Initializes a new instance of the <see cref="BoundaryDescriptorHandle"/> class and assigns an existing handle.</summary>
/// <param name="preexistingHandle">An <see cref="IntPtr"/> object that represents the pre-existing handle to use.</param>
/// <param name="ownsHandle">
/// <see langword="true"/> to reliably release the handle during the finalization phase; otherwise, <see langword="false"/> (not recommended).
/// </param>
public SafeBoundaryDescriptorHandle(IntPtr preexistingHandle, bool ownsHandle = true) : base(preexistingHandle, ownsHandle) { }
/// <summary>Initializes a new instance of the <see cref="BoundaryDescriptorHandle"/> class.</summary>
private SafeBoundaryDescriptorHandle() : base() { }
/// <summary>Performs an implicit conversion from <see cref="SafeBoundaryDescriptorHandle"/> to <see cref="BoundaryDescriptorHandle"/>.</summary>
/// <param name="h">The safe handle instance.</param>
/// <returns>The result of the conversion.</returns>
public static implicit operator BoundaryDescriptorHandle(SafeBoundaryDescriptorHandle h) => h.handle;
/// <inheritdoc/>
protected override bool InternalReleaseHandle() { DeleteBoundaryDescriptor(this); return true; }
}
/// <summary>Provides a <see cref="SafeHandle"/> to a that releases a created NamespaceHandle instance at disposal using CloseHandle.</summary>
public class SafeNamespaceHandle : HANDLE
{
/// <summary>Initializes a new instance of the <see cref="NamespaceHandle"/> class and assigns an existing handle.</summary>
/// <param name="preexistingHandle">An <see cref="IntPtr"/> object that represents the pre-existing handle to use.</param>
/// <param name="ownsHandle">
/// <see langword="true"/> to reliably release the handle during the finalization phase; otherwise, <see langword="false"/> (not recommended).
/// </param>
public SafeNamespaceHandle(IntPtr preexistingHandle, bool ownsHandle = true) : base(preexistingHandle, ownsHandle) { }
private SafeNamespaceHandle() : base()
{
}
/// <summary>Performs an implicit conversion from <see cref="SafeNamespaceHandle"/> to <see cref="NamespaceHandle"/>.</summary>
/// <param name="h">The safe handle instance.</param>
/// <returns>The result of the conversion.</returns>
public static implicit operator NamespaceHandle(SafeNamespaceHandle h) => h.handle;
/// <inheritdoc/>
protected override bool InternalReleaseHandle() => ClosePrivateNamespace(this, 1);
}
}
}

View File

@ -130,7 +130,7 @@ namespace Vanara.PInvoke
[DllImport(Lib.Kernel32, SetLastError = true, CharSet = CharSet.Auto)]
[PInvokeData("Winbase.h", MSDNShortId = "aa365144")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool CallNamedPipe([In] string lpNamedPipeName, [In] IntPtr lpInBuffer, uint nInBufferSize, IntPtr lpOutBuffer, uint nOutBufferSize,
public static extern bool CallNamedPipe(string lpNamedPipeName, [In] IntPtr lpInBuffer, uint nInBufferSize, IntPtr lpOutBuffer, uint nOutBufferSize,
[Out] out uint lpBytesRead, uint nTimeOut);
/// <summary>
@ -174,7 +174,7 @@ namespace Vanara.PInvoke
[DllImport(Lib.Kernel32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("Winbase.h", MSDNShortId = "aa365146")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern unsafe bool ConnectNamedPipe([In] IntPtr hNamedPipe, NativeOverlapped* lpOverlapped);
public static extern unsafe bool ConnectNamedPipe([In] HFILE hNamedPipe, NativeOverlapped* lpOverlapped);
/// <summary>
/// Creates an instance of a named pipe and returns a handle for subsequent pipe operations. A named pipe server process uses this function either to
@ -245,7 +245,7 @@ namespace Vanara.PInvoke
/// <term>
/// Write-through mode is enabled. This mode affects only write operations on byte-type pipes and, then, only when the client and server processes are on
/// different computers. If this mode is enabled, functions writing to a named pipe do not return until the data written is transmitted across the
/// network and is in the pipe&amp;#39;s buffer on the remote computer. If this mode is not enabled, the system enhances the efficiency of network
/// network and is in the pipe's buffer on the remote computer. If this mode is not enabled, the system enhances the efficiency of network
/// operations by buffering data until a minimum number of bytes accumulate or until a maximum time elapses.
/// </term>
/// </item>
@ -274,16 +274,16 @@ namespace Vanara.PInvoke
/// </listheader>
/// <item>
/// <term>WRITE_DAC0x00040000L</term>
/// <term>The caller will have write access to the named pipe&amp;#39;s discretionary access control list (ACL).</term>
/// <term>The caller will have write access to the named pipe's discretionary access control list (ACL).</term>
/// </item>
/// <item>
/// <term>WRITE_OWNER0x00080000L</term>
/// <term>The caller will have write access to the named pipe&amp;#39;s owner.</term>
/// <term>The caller will have write access to the named pipe's owner.</term>
/// </item>
/// <item>
/// <term>ACCESS_SYSTEM_SECURITY0x01000000L</term>
/// <term>
/// The caller will have write access to the named pipe&amp;#39;s SACL. For more information, see Access-Control Lists (ACLs) and SACL Access Right.
/// The caller will have write access to the named pipe's SACL. For more information, see Access-Control Lists (ACLs) and SACL Access Right.
/// </term>
/// </item>
/// </list>
@ -412,7 +412,7 @@ namespace Vanara.PInvoke
// _In_ DWORD nInBufferSize, _In_ DWORD nDefaultTimeOut, _In_opt_ LPSECURITY_ATTRIBUTES lpSecurityAttributes); https://msdn.microsoft.com/en-us/library/windows/desktop/aa365150(v=vs.85).aspx
[DllImport(Lib.Kernel32, SetLastError = true, CharSet = CharSet.Auto)]
[PInvokeData("Winbase.h", MSDNShortId = "aa365150")]
public static extern IntPtr CreateNamedPipe([In] string lpName, uint dwOpenMode, PIPE_TYPE dwPipeMode, uint nMaxInstances, uint nOutBufferSize, uint nInBufferSize,
public static extern SafeHFILE CreateNamedPipe(string lpName, uint dwOpenMode, PIPE_TYPE dwPipeMode, uint nMaxInstances, uint nOutBufferSize, uint nInBufferSize,
uint nDefaultTimeOut, [In] SECURITY_ATTRIBUTES lpSecurityAttributes);
/// <summary>Creates an anonymous pipe, and returns handles to the read and write ends of the pipe.</summary>
@ -440,7 +440,7 @@ namespace Vanara.PInvoke
[DllImport(Lib.Kernel32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("Winbase.h", MSDNShortId = "aa365152")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool CreatePipe(out IntPtr hReadPipe, out IntPtr hWritePipe, [In] SECURITY_ATTRIBUTES lpPipeAttributes, uint nSize);
public static extern bool CreatePipe(out SafeHFILE hReadPipe, out SafeHFILE hWritePipe, [In] SECURITY_ATTRIBUTES lpPipeAttributes, uint nSize);
/// <summary>Disconnects the server end of a named pipe instance from a client process.</summary>
/// <param name="hNamedPipe">A handle to an instance of a named pipe. This handle must be created by the <c>CreateNamedPipe</c> function.</param>
@ -452,7 +452,7 @@ namespace Vanara.PInvoke
[DllImport(Lib.Kernel32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("Winbase.h", MSDNShortId = "aa365166")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool DisconnectNamedPipe([In] IntPtr hNamedPipe);
public static extern bool DisconnectNamedPipe([In] HFILE hNamedPipe);
/// <summary>Retrieves the client computer name for the specified named pipe.</summary>
/// <param name="Pipe">A handle to an instance of a named pipe. This handle must be created by the <c>CreateNamedPipe</c> function.</param>
@ -466,7 +466,7 @@ namespace Vanara.PInvoke
[DllImport(Lib.Kernel32, SetLastError = true, CharSet = CharSet.Auto)]
[PInvokeData("Winbase.h", MSDNShortId = "aa365437")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool GetNamedPipeClientComputerName(IntPtr Pipe, StringBuilder ClientComputerName, uint ClientComputerNameLength);
public static extern bool GetNamedPipeClientComputerName(HFILE Pipe, StringBuilder ClientComputerName, uint ClientComputerNameLength);
/// <summary>
/// Retrieves information about a specified named pipe. The information returned can vary during the lifetime of an instance of the named pipe.
@ -535,8 +535,8 @@ namespace Vanara.PInvoke
[DllImport(Lib.Kernel32, SetLastError = true, CharSet = CharSet.Auto)]
[PInvokeData("Winbase.h", MSDNShortId = "aa365443")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool GetNamedPipeHandleState([In] IntPtr hNamedPipe, out PIPE_TYPE lpState, out uint lpCurInstances, out uint lpMaxCollectionCount, out uint lpCollectDataTimeout,
[Out] StringBuilder lpUserName, uint nMaxUserNameSize);
public static extern bool GetNamedPipeHandleState([In] HFILE hNamedPipe, out PIPE_TYPE lpState, out uint lpCurInstances, out uint lpMaxCollectionCount, out uint lpCollectDataTimeout,
StringBuilder lpUserName, uint nMaxUserNameSize);
/// <summary>Retrieves information about the specified named pipe.</summary>
/// <param name="hNamedPipe">
@ -600,7 +600,7 @@ namespace Vanara.PInvoke
[DllImport(Lib.Kernel32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("Winbase.h", MSDNShortId = "aa365445")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool GetNamedPipeInfo([In] IntPtr hNamedPipe, out PIPE_TYPE lpFlags, out uint lpOutBufferSize, out uint lpInBufferSize, out uint lpMaxInstances);
public static extern bool GetNamedPipeInfo([In] HFILE hNamedPipe, out PIPE_TYPE lpFlags, out uint lpOutBufferSize, out uint lpInBufferSize, out uint lpMaxInstances);
/// <summary>
/// Copies data from a named or anonymous pipe into a buffer without removing it from the pipe. It also returns information about data in the pipe.
@ -632,7 +632,7 @@ namespace Vanara.PInvoke
[DllImport(Lib.Kernel32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("Winbase.h", MSDNShortId = "aa365779")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool PeekNamedPipe([In] IntPtr hNamedPipe, IntPtr lpBuffer, uint nBufferSize, out uint lpBytesRead, out uint lpTotalBytesAvail, out uint lpBytesLeftThisMessage);
public static extern bool PeekNamedPipe([In] HFILE hNamedPipe, IntPtr lpBuffer, uint nBufferSize, out uint lpBytesRead, out uint lpTotalBytesAvail, out uint lpBytesLeftThisMessage);
/// <summary>
/// Sets the read mode and the blocking mode of the specified named pipe. If the specified handle is to the client end of a named pipe and if the named
@ -713,7 +713,88 @@ namespace Vanara.PInvoke
[DllImport(Lib.Kernel32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("Winbase.h", MSDNShortId = "aa365787")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SetNamedPipeHandleState([In] IntPtr hNamedPipe, [In] IntPtr lpMode, [In] IntPtr lpMaxCollectionCount, [In] IntPtr lpCollectDataTimeout);
public static extern bool SetNamedPipeHandleState([In] HFILE hNamedPipe, [In] in uint lpMode, [In] in uint lpMaxCollectionCount, [In] in uint lpCollectDataTimeout);
/// <summary>
/// Sets the read mode and the blocking mode of the specified named pipe. If the specified handle is to the client end of a named pipe and if the named
/// pipe server process is on a remote computer, the function can also be used to control local buffering.
/// </summary>
/// <param name="hNamedPipe">
/// <para>
/// A handle to the named pipe instance. This parameter can be a handle to the server end of the pipe, as returned by the <c>CreateNamedPipe</c>
/// function, or to the client end of the pipe, as returned by the <c>CreateFile</c> function. The handle must have GENERIC_WRITE access to the named
/// pipe for a write-only or read/write pipe, or it must have GENERIC_READ and FILE_WRITE_ATTRIBUTES access for a read-only pipe.
/// </para>
/// <para>This parameter can also be a handle to an anonymous pipe, as returned by the <c>CreatePipe</c> function.</para>
/// </param>
/// <param name="lpMode">
/// <para>
/// The new pipe mode. The mode is a combination of a read-mode flag and a wait-mode flag. This parameter can be <c>NULL</c> if the mode is not being
/// set. Specify one of the following modes.
/// </para>
/// <para>
/// <list type="table">
/// <listheader>
/// <term>Mode</term>
/// <term>Meaning</term>
/// </listheader>
/// <item>
/// <term>PIPE_READMODE_BYTE0x00000000</term>
/// <term>Data is read from the pipe as a stream of bytes. This mode is the default if no read-mode flag is specified.</term>
/// </item>
/// <item>
/// <term>PIPE_READMODE_MESSAGE0x00000002</term>
/// <term>Data is read from the pipe as a stream of messages. The function fails if this flag is specified for a byte-type pipe.</term>
/// </item>
/// </list>
/// </para>
/// <para>One of the following wait modes can be specified.</para>
/// <para>
/// <list type="table">
/// <listheader>
/// <term>Mode</term>
/// <term>Meaning</term>
/// </listheader>
/// <item>
/// <term>PIPE_WAIT0x00000000</term>
/// <term>
/// Blocking mode is enabled. This mode is the default if no wait-mode flag is specified. When a blocking mode pipe handle is specified in the ReadFile,
/// WriteFile, or ConnectNamedPipe function, operations are not finished until there is data to read, all data is written, or a client is connected. Use
/// of this mode can mean waiting indefinitely in some situations for a client process to perform an action.
/// </term>
/// </item>
/// <item>
/// <term>PIPE_NOWAIT0x00000001</term>
/// <term>
/// Nonblocking mode is enabled. In this mode, ReadFile, WriteFile, and ConnectNamedPipe always return immediately. Note that nonblocking mode is
/// supported for compatibility with Microsoft LAN Manager version 2.0 and should not be used to achieve asynchronous input and output (I/O) with named pipes.
/// </term>
/// </item>
/// </list>
/// </para>
/// </param>
/// <param name="lpMaxCollectionCount">
/// The maximum number of bytes collected on the client computer before transmission to the server. This parameter must be <c>NULL</c> if the specified
/// pipe handle is to the server end of a named pipe or if client and server processes are on the same machine. This parameter is ignored if the client
/// process specifies the FILE_FLAG_WRITE_THROUGH flag in the <c>CreateFile</c> function when the handle was created. This parameter can be <c>NULL</c>
/// if the collection count is not being set.
/// </param>
/// <param name="lpCollectDataTimeout">
/// The maximum time, in milliseconds, that can pass before a remote named pipe transfers information over the network. This parameter must be
/// <c>NULL</c> if the specified pipe handle is to the server end of a named pipe or if client and server processes are on the same computer. This
/// parameter is ignored if the client process specified the FILE_FLAG_WRITE_THROUGH flag in the <c>CreateFile</c> function when the handle was created.
/// This parameter can be <c>NULL</c> if the collection count is not being set.
/// </param>
/// <returns>
/// <para>If the function succeeds, the return value is nonzero.</para>
/// <para>If the function fails, the return value is zero. To get extended error information, call <c>GetLastError</c>.</para>
/// </returns>
// BOOL WINAPI SetNamedPipeHandleState( _In_ HANDLE hNamedPipe, _In_opt_ LPDWORD lpMode, _In_opt_ LPDWORD lpMaxCollectionCount, _In_opt_ LPDWORD
// lpCollectDataTimeout); https://msdn.microsoft.com/en-us/library/windows/desktop/aa365787(v=vs.85).aspx
[DllImport(Lib.Kernel32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("Winbase.h", MSDNShortId = "aa365787")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SetNamedPipeHandleState([In] HFILE hNamedPipe, [In] IntPtr lpMode, [In] IntPtr lpMaxCollectionCount, [In] IntPtr lpCollectDataTimeout);
/// <summary>Combines the functions that write a message to and read a message from the specified named pipe into a single network operation.</summary>
/// <param name="hNamedPipe">
@ -765,7 +846,7 @@ namespace Vanara.PInvoke
[DllImport(Lib.Kernel32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("Winbase.h", MSDNShortId = "aa365790")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern unsafe bool TransactNamedPipe([In] IntPtr hNamedPipe, [In] IntPtr lpInBuffer, uint nInBufferSize, IntPtr lpOutBuffer, uint nOutBufferSize, [Out] out uint lpBytesRead,
public static extern unsafe bool TransactNamedPipe([In] HFILE hNamedPipe, [In] IntPtr lpInBuffer, uint nInBufferSize, IntPtr lpOutBuffer, uint nOutBufferSize, [Out] out uint lpBytesRead,
NativeOverlapped* lpOverlapped);
/// <summary>
@ -811,6 +892,6 @@ namespace Vanara.PInvoke
[DllImport(Lib.Kernel32, SetLastError = true, CharSet = CharSet.Auto)]
[PInvokeData("Winbase.h", MSDNShortId = "aa365800")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool WaitNamedPipe([In] string lpNamedPipeName, uint nTimeOut);
public static extern bool WaitNamedPipe(string lpNamedPipeName, uint nTimeOut);
}
}

View File

@ -16,12 +16,141 @@ namespace Vanara.PInvoke
{
/// <summary>The standard input device. Initially, this is the console input buffer, CONIN$.</summary>
STD_INPUT_HANDLE = -10,
/// <summary>The standard output device. Initially, this is the active console screen buffer, CONOUT$.</summary>
STD_OUTPUT_HANDLE = -11,
/// <summary>The standard error device. Initially, this is the active console screen buffer, CONOUT$.</summary>
STD_ERROR_HANDLE = -12,
}
/// <summary>
/// <para>Expands environment-variable strings and replaces them with the values defined for the current user.</para>
/// <para>To specify the environment block for a particular user or the system, use the <c>ExpandEnvironmentStringsForUser</c> function.</para>
/// </summary>
/// <param name="lpSrc">
/// <para>
/// A buffer that contains one or more environment-variable strings in the form: %variableName%. For each such reference, the
/// %variableName% portion is replaced with the current value of that environment variable.
/// </para>
/// <para>
/// Case is ignored when looking up the environment-variable name. If the name is not found, the %variableName% portion is left unexpanded.
/// </para>
/// <para>
/// Note that this function does not support all the features that Cmd.exe supports. For example, it does not support
/// %variableName:str1=str2% or %variableName:~offset,length%.
/// </para>
/// </param>
/// <param name="lpDst">
/// A pointer to a buffer that receives the result of expanding the environment variable strings in the lpSrc buffer. Note that this
/// buffer cannot be the same as the lpSrc buffer.
/// </param>
/// <param name="nSize">
/// The maximum number of characters that can be stored in the buffer pointed to by the lpDst parameter. When using ANSI strings, the
/// buffer size should be the string length, plus terminating null character, plus one. When using Unicode strings, the buffer size
/// should be the string length plus the terminating null character.
/// </param>
/// <returns>
/// <para>
/// If the function succeeds, the return value is the number of <c>TCHARs</c> stored in the destination buffer, including the
/// terminating null character. If the destination buffer is too small to hold the expanded string, the return value is the required
/// buffer size, in characters.
/// </para>
/// <para>If the function fails, the return value is zero. To get extended error information, call <c>GetLastError</c>.</para>
/// </returns>
// DWORD WINAPI ExpandEnvironmentStrings( _In_ LPCTSTR lpSrc, _Out_opt_ LPTSTR lpDst, _In_ DWORD nSize); https://msdn.microsoft.com/en-us/library/windows/desktop/ms724265(v=vs.85).aspx
[DllImport(Lib.Kernel32, SetLastError = true, CharSet = CharSet.Auto)]
[PInvokeData("Winbase.h", MSDNShortId = "ms724265")]
public static extern uint ExpandEnvironmentStrings(string lpSrc, StringBuilder lpDst, uint nSize);
/// <summary>Frees a block of environment strings.</summary>
/// <param name="lpszEnvironmentBlock">
/// A pointer to a block of environment strings. The pointer to the block must be obtained by calling the
/// <c>GetEnvironmentStrings</c> function.
/// </param>
/// <returns>
/// <para>If the function succeeds, the return value is nonzero.</para>
/// <para>If the function fails, the return value is zero To get extended error information, call <c>GetLastError</c>.</para>
/// </returns>
// BOOL WINAPI FreeEnvironmentStrings( _In_ LPTCH lpszEnvironmentBlock); https://msdn.microsoft.com/en-us/library/windows/desktop/ms683151(v=vs.85).aspx
[DllImport(Lib.Kernel32, SetLastError = true, CharSet = CharSet.Auto)]
[PInvokeData("WinBase.h", MSDNShortId = "ms683151")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool FreeEnvironmentStrings(IntPtr lpszEnvironmentBlock);
/// <summary>Retrieves the command-line string for the current process.</summary>
/// <returns>The return value is a pointer to the command-line string for the current process.</returns>
// LPTSTR WINAPI GetCommandLine(void); https://msdn.microsoft.com/en-us/library/windows/desktop/ms683156(v=vs.85).aspx
[DllImport(Lib.Kernel32, SetLastError = false, CharSet = CharSet.Auto)]
[PInvokeData("WinBase.h", MSDNShortId = "ms683156")]
public static extern string GetCommandLine();
/// <summary>Retrieves the current directory for the current process.</summary>
/// <param name="nBufferLength">
/// The length of the buffer for the current directory string, in <c>TCHARs</c>. The buffer length must include room for a
/// terminating null character.
/// </param>
/// <param name="lpBuffer">
/// <para>
/// A pointer to the buffer that receives the current directory string. This null-terminated string specifies the absolute path to
/// the current directory.
/// </para>
/// <para>To determine the required buffer size, set this parameter to <c>NULL</c> and the nBufferLength parameter to 0.</para>
/// </param>
/// <returns>
/// <para>
/// If the function succeeds, the return value specifies the number of characters that are written to the buffer, not including the
/// terminating null character.
/// </para>
/// <para>If the function fails, the return value is zero. To get extended error information, call <c>GetLastError</c>.</para>
/// <para>
/// If the buffer that is pointed to by lpBuffer is not large enough, the return value specifies the required size of the buffer, in
/// characters, including the null-terminating character.
/// </para>
/// </returns>
// DWORD WINAPI GetCurrentDirectory( _In_ DWORD nBufferLength, _Out_ LPTSTR lpBuffer); https://msdn.microsoft.com/en-us/library/windows/desktop/aa364934(v=vs.85).aspx
[DllImport(Lib.Kernel32, SetLastError = true, CharSet = CharSet.Auto)]
[PInvokeData("WinBase.h", MSDNShortId = "aa364934")]
public static extern uint GetCurrentDirectory(uint nBufferLength, StringBuilder lpBuffer);
/// <summary>Retrieves the environment variables for the current process.</summary>
/// <returns>
/// <para>If the function succeeds, the return value is a pointer to the environment block of the current process.</para>
/// <para>If the function fails, the return value is NULL.</para>
/// </returns>
// LPTCH WINAPI GetEnvironmentStrings(void); https://msdn.microsoft.com/en-us/library/windows/desktop/ms683187(v=vs.85).aspx
[DllImport(Lib.Kernel32, SetLastError = false, CharSet = CharSet.Auto)]
[PInvokeData("WinBase.h", MSDNShortId = "ms683187")]
public static extern EnvironmentStrings GetEnvironmentStrings();
/// <summary>Retrieves the contents of the specified variable from the environment block of the calling process.</summary>
/// <param name="lpName">The name of the environment variable.</param>
/// <param name="lpBuffer">
/// A pointer to a buffer that receives the contents of the specified environment variable as a null-terminated string. An
/// environment variable has a maximum size limit of 32,767 characters, including the null-terminating character.
/// </param>
/// <param name="nSize">
/// The size of the buffer pointed to by the lpBuffer parameter, including the null-terminating character, in characters.
/// </param>
/// <returns>
/// <para>
/// If the function succeeds, the return value is the number of characters stored in the buffer pointed to by lpBuffer, not including
/// the terminating null character.
/// </para>
/// <para>
/// If lpBuffer is not large enough to hold the data, the return value is the buffer size, in characters, required to hold the string
/// and its terminating null character and the contents of lpBuffer are undefined.
/// </para>
/// <para>
/// If the function fails, the return value is zero. If the specified environment variable was not found in the environment block,
/// <c>GetLastError</c> returns ERROR_ENVVAR_NOT_FOUND.
/// </para>
/// </returns>
// DWORD WINAPI GetEnvironmentVariable( _In_opt_ LPCTSTR lpName, _Out_opt_ LPTSTR lpBuffer, _In_ DWORD nSize); https://msdn.microsoft.com/en-us/library/windows/desktop/ms683188(v=vs.85).aspx
[DllImport(Lib.Kernel32, SetLastError = true, CharSet = CharSet.Auto)]
[PInvokeData("WinBase.h", MSDNShortId = "ms683188")]
public static extern uint GetEnvironmentVariable(string lpName, StringBuilder lpBuffer, uint nSize);
/// <summary>Retrieves a handle to the specified standard device (standard input, standard output, or standard error).</summary>
/// <param name="nStdHandle">
/// <para>The standard device. This parameter can be one of the following values.</para>
@ -48,24 +177,102 @@ namespace Vanara.PInvoke
/// </param>
/// <returns>
/// <para>
/// If the function succeeds, the return value is a handle to the specified device, or a redirected handle set by a previous call to <c>SetStdHandle</c>.
/// The handle has <c>GENERIC_READ</c> and <c>GENERIC_WRITE</c> access rights, unless the application has used <c>SetStdHandle</c> to set a standard
/// handle with lesser access.
/// If the function succeeds, the return value is a handle to the specified device, or a redirected handle set by a previous call to
/// <c>SetStdHandle</c>. The handle has <c>GENERIC_READ</c> and <c>GENERIC_WRITE</c> access rights, unless the application has used
/// <c>SetStdHandle</c> to set a standard handle with lesser access.
/// </para>
/// <para>If the function fails, the return value is <c>INVALID_HANDLE_VALUE</c>. To get extended error information, call <c>GetLastError</c>.</para>
/// <para>
/// If an application does not have associated standard handles, such as a service running on an interactive desktop, and has not redirected them, the
/// return value is <c>NULL</c>.
/// If an application does not have associated standard handles, such as a service running on an interactive desktop, and has not
/// redirected them, the return value is <c>NULL</c>.
/// </para>
/// </returns>
// HANDLE WINAPI GetStdHandle( _In_ DWORD nStdHandle );
// https://docs.microsoft.com/en-us/windows/console/getstdhandle
// HANDLE WINAPI GetStdHandle( _In_ DWORD nStdHandle ); https://docs.microsoft.com/en-us/windows/console/getstdhandle
[DllImport(Lib.Kernel32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("Winbase.h")]
public static extern IntPtr GetStdHandle(StdHandleType nStdHandle);
public static extern HFILE GetStdHandle(StdHandleType nStdHandle);
/// <summary>Determines whether the current directory should be included in the search path for the specified executable.</summary>
/// <param name="ExeName">The name of the executable file.</param>
/// <returns>
/// If the current directory should be part of the search path, the return value is TRUE. Otherwise, the return value is FALSE.
/// </returns>
// BOOL WINAPI NeedCurrentDirectoryForExePath( _In_ LPCTSTR ExeName); https://msdn.microsoft.com/en-us/library/windows/desktop/ms684269(v=vs.85).aspx
[DllImport(Lib.Kernel32, SetLastError = false, CharSet = CharSet.Auto)]
[PInvokeData("WinBase.h", MSDNShortId = "ms684269")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool NeedCurrentDirectoryForExePath(string ExeName);
/// <summary>Searches for a specified file in a specified path.</summary>
/// <param name="lpPath">
/// <para>The path to be searched for the file.</para>
/// <para>
/// If this parameter is <c>NULL</c>, the function searches for a matching file using a registry-dependent system search path. For
/// more information, see the Remarks section.
/// </para>
/// </param>
/// <param name="lpFileName">The name of the file for which to search.</param>
/// <param name="lpExtension">
/// <para>
/// The extension to be added to the file name when searching for the file. The first character of the file name extension must be a
/// period (.). The extension is added only if the specified file name does not end with an extension.
/// </para>
/// <para>If a file name extension is not required or if the file name contains an extension, this parameter can be <c>NULL</c>.</para>
/// </param>
/// <param name="nBufferLength">
/// The size of the buffer that receives the valid path and file name (including the terminating null character), in <c>TCHARs</c>.
/// </param>
/// <param name="lpBuffer">
/// A pointer to the buffer to receive the path and file name of the file found. The string is a null-terminated string.
/// </param>
/// <param name="lpFilePart">
/// A pointer to the variable to receive the address (within lpBuffer) of the last component of the valid path and file name, which
/// is the address of the character immediately following the final backslash (\) in the path.
/// </param>
/// <returns>
/// <para>
/// If the function succeeds, the value returned is the length, in <c>TCHARs</c>, of the string that is copied to the buffer, not
/// including the terminating null character. If the return value is greater than nBufferLength, the value returned is the size of
/// the buffer that is required to hold the path, including the terminating null character.
/// </para>
/// <para>If the function fails, the return value is zero. To get extended error information, call <c>GetLastError</c>.</para>
/// </returns>
// DWORD WINAPI SearchPath( _In_opt_ LPCTSTR lpPath, _In_ LPCTSTR lpFileName, _In_opt_ LPCTSTR lpExtension, _In_ DWORD nBufferLength,
// _Out_ LPTSTR lpBuffer, _Out_opt_ LPTSTR *lpFilePart); https://msdn.microsoft.com/en-us/library/windows/desktop/aa365527(v=vs.85).aspx
[PInvokeData("WinBase.h", MSDNShortId = "aa365527")]
[DllImport(Lib.Kernel32, SetLastError = true, CharSet = CharSet.Auto)]
public static extern uint SearchPath([In, Optional] string lpPath, string lpFileName, [In, Optional] string lpExtension, uint nBufferLength, StringBuilder lpBuffer, out IntPtr lpFilePart);
/// <summary>Changes the current directory for the current process.</summary>
/// <param name="lpPathName">
/// <para>
/// The path to the new current directory. This parameter may specify a relative path or a full path. In either case, the full path
/// of the specified directory is calculated and stored as the current directory. For more information, see File Names, Paths, and Namespaces.
/// </para>
/// <para>
/// In the ANSI version of this function, the name is limited to <c>MAX_PATH</c> characters. To extend this limit to 32,767 wide
/// characters, call the Unicode version of the function and prepend "\\?\" to the path. For more information, see Naming a File.
/// </para>
/// <para>
/// The final character before the null character must be a backslash ('\'). If you do not specify the backslash, it will be added
/// for you; therefore, specify <c>MAX_PATH</c>-2 characters for the path unless you include the trailing backslash, in which case,
/// specify <c>MAX_PATH</c>-1 characters for the path.
/// </para>
/// </param>
/// <returns>
/// <para>If the function succeeds, the return value is nonzero.</para>
/// <para>If the function fails, the return value is zero. To get extended error information, call <c>GetLastError</c>.</para>
/// </returns>
// BOOL WINAPI SetCurrentDirectory( _In_ LPCTSTR lpPathName); https://msdn.microsoft.com/en-us/library/windows/desktop/aa365530(v=vs.85).aspx
[DllImport(Lib.Kernel32, SetLastError = true, CharSet = CharSet.Auto)]
[PInvokeData("WinBase.h", MSDNShortId = "aa365530")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SetCurrentDirectory(string lpPathName);
/// <summary>Sets the environment strings.</summary>
/// <param name="NewEnvironment">The new environment strings. List of unicode null terminated strings with a double null termination at the end.</param>
/// <param name="NewEnvironment">
/// The new environment strings. List of unicode null terminated strings with a double null termination at the end.
/// </param>
/// <returns>
/// <para>If the function succeeds, the return value is nonzero.</para>
/// <para>If the function fails, the return value is zero. To get extended error information, call <c>GetLastError</c>.</para>
@ -75,6 +282,31 @@ namespace Vanara.PInvoke
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SetEnvironmentStringsW(string NewEnvironment);
/// <summary>Sets the contents of the specified environment variable for the current process.</summary>
/// <param name="lpName">
/// The name of the environment variable. The operating system creates the environment variable if it does not exist and lpValue is
/// not NULL.
/// </param>
/// <param name="lpValue">
/// <para>
/// The contents of the environment variable. The maximum size of a user-defined environment variable is 32,767 characters. For more
/// information, see Environment Variables.
/// </para>
/// <para>
/// <c>Windows Server 2003 and Windows XP:</c> The total size of the environment block for a process may not exceed 32,767 characters.
/// </para>
/// <para>If this parameter is NULL, the variable is deleted from the current process's environment.</para>
/// </param>
/// <returns>
/// <para>If the function succeeds, the return value is nonzero.</para>
/// <para>If the function fails, the return value is zero. To get extended error information, call <c>GetLastError</c>.</para>
/// </returns>
// BOOL WINAPI SetEnvironmentVariable( _In_ LPCTSTR lpName, _In_opt_ LPCTSTR lpValue); https://msdn.microsoft.com/en-us/library/windows/desktop/ms686206(v=vs.85).aspx
[DllImport(Lib.Kernel32, SetLastError = true, CharSet = CharSet.Auto)]
[PInvokeData("WinBase.h", MSDNShortId = "ms686206")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SetEnvironmentVariable(string lpName, [Optional] string lpValue);
/// <summary>Sets the handle for the specified standard device (standard input, standard output, or standard error).</summary>
/// <param name="nStdHandle">
/// <para>The standard device for which the handle is to be set. This parameter can be one of the following values.</para>
@ -104,268 +336,48 @@ namespace Vanara.PInvoke
/// <para>If the function succeeds, the return value is nonzero.</para>
/// <para>If the function fails, the return value is zero. To get extended error information, call <c>GetLastError</c>.</para>
/// </returns>
// BOOL WINAPI SetStdHandle( _In_ DWORD nStdHandle, _In_ HANDLE hHandle );
// https://docs.microsoft.com/en-us/windows/console/setstdhandle
// BOOL WINAPI SetStdHandle( _In_ DWORD nStdHandle, _In_ HANDLE hHandle ); https://docs.microsoft.com/en-us/windows/console/setstdhandle
[DllImport(Lib.Kernel32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("Winbase.h", MSDNShortId = "")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SetStdHandle(StdHandleType nStdHandle, IntPtr hHandle);
public static extern bool SetStdHandle(StdHandleType nStdHandle, HFILE hHandle);
/// <summary>Sets the handle for the specified standard device and returns the previous one</summary>
/// <param name="nStdHandle">The standard handle to replace. Can be STD_INPUT_HANDLE, STD_OUTPUT_HANDLE or STD_ERROR_HANDLE</param>
/// <param name="hHandle">The new handle</param>
/// <param name="phPrevValue">A pointer to a handle that receives the previous value. Can be NULL in which case the function behaves exactly as SetStdHandle</param>
/// <param name="phPrevValue">
/// A pointer to a handle that receives the previous value. Can be NULL in which case the function behaves exactly as SetStdHandle
/// </param>
/// <returns>Non-zero if the function succeeds, zero otherwise. More information is available via GetLastError</returns>
// BOOL WINAPI SetStdHandleEx (DWORD nStdHandle, HANDLE hHandle, HANDLE* phPrevValue)
// http://undoc.airesoft.co.uk/kernel32.dll/SetStdHandleEx.php
// BOOL WINAPI SetStdHandleEx (DWORD nStdHandle, HANDLE hHandle, HANDLE* phPrevValue) http://undoc.airesoft.co.uk/kernel32.dll/SetStdHandleEx.php
[DllImport(Lib.Kernel32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("Winbase.h", MSDNShortId = "")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SetStdHandleEx(StdHandleType nStdHandle, IntPtr hHandle, out IntPtr phPrevValue);
/// <summary>Retrieves the command-line string for the current process.</summary>
/// <returns>The return value is a pointer to the command-line string for the current process.</returns>
// LPTSTR WINAPI GetCommandLine(void);
// https://msdn.microsoft.com/en-us/library/windows/desktop/ms683156(v=vs.85).aspx
[DllImport(Lib.Kernel32, SetLastError = false, CharSet = CharSet.Auto)]
[PInvokeData("WinBase.h", MSDNShortId = "ms683156")]
public static extern string GetCommandLine();
/// <summary>Retrieves the environment variables for the current process.</summary>
/// <returns>
/// <para>If the function succeeds, the return value is a pointer to the environment block of the current process.</para>
/// <para>If the function fails, the return value is NULL.</para>
/// </returns>
// LPTCH WINAPI GetEnvironmentStrings(void);
// https://msdn.microsoft.com/en-us/library/windows/desktop/ms683187(v=vs.85).aspx
[DllImport(Lib.Kernel32, SetLastError = false, CharSet = CharSet.Auto)]
[PInvokeData("WinBase.h", MSDNShortId = "ms683187")]
public static extern EnvironmentStrings GetEnvironmentStrings();
/// <summary>Frees a block of environment strings.</summary>
/// <param name="lpszEnvironmentBlock">
/// A pointer to a block of environment strings. The pointer to the block must be obtained by calling the <c>GetEnvironmentStrings</c> function.
/// </param>
/// <returns>
/// <para>If the function succeeds, the return value is nonzero.</para>
/// <para>If the function fails, the return value is zero To get extended error information, call <c>GetLastError</c>.</para>
/// </returns>
// BOOL WINAPI FreeEnvironmentStrings( _In_ LPTCH lpszEnvironmentBlock);
// https://msdn.microsoft.com/en-us/library/windows/desktop/ms683151(v=vs.85).aspx
[DllImport(Lib.Kernel32, SetLastError = true, CharSet = CharSet.Auto)]
[PInvokeData("WinBase.h", MSDNShortId = "ms683151")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool FreeEnvironmentStrings(IntPtr lpszEnvironmentBlock);
public static extern bool SetStdHandleEx(StdHandleType nStdHandle, HFILE hHandle, out HFILE phPrevValue);
/// <summary>Represents a block of environment strings obtained by <see cref="GetEnvironmentStrings"/> and freed by <see cref="FreeEnvironmentStrings"/>.</summary>
/// <seealso cref="Vanara.InteropServices.GenericSafeHandle"/>
/// <seealso cref="System.Collections.Generic.IEnumerable{System.String}"/>
/// <seealso cref="System.Collections.Generic.IEnumerable{string}"/>
public sealed class EnvironmentStrings : GenericSafeHandle, IEnumerable<string>
{
/// <summary>Initializes a new instance of the <see cref="EnvironmentStrings"/> class.</summary>
public EnvironmentStrings() : this(IntPtr.Zero) { }
/// <summary>Initializes a new instance of the <see cref="EnvironmentStrings"/> class.</summary>
/// <param name="handle">The handle.</param>
public EnvironmentStrings(IntPtr handle) : base(handle, FreeEnvironmentStrings) { }
/// <summary>Gets the value.</summary>
/// <value>The value.</value>
public IEnumerable<string> Value => handle.ToStringEnum();
/// <summary>Returns an enumerator that iterates through the collection.</summary>
/// <returns>
/// A <see cref="T:System.Collections.Generic.IEnumerator`1" /> that can be used to iterate through the collection.
/// </returns>
/// <returns>A <see cref="T:System.Collections.Generic.IEnumerator`1"/> that can be used to iterate through the collection.</returns>
public IEnumerator<string> GetEnumerator() => Value.GetEnumerator();
/// <summary>Returns an enumerator that iterates through a collection.</summary>
/// <returns>
/// An <see cref="T:System.Collections.IEnumerator" /> object that can be used to iterate through the collection.
/// </returns>
/// <returns>An <see cref="T:System.Collections.IEnumerator"/> object that can be used to iterate through the collection.</returns>
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
}
/// <summary>Retrieves the contents of the specified variable from the environment block of the calling process.</summary>
/// <param name="lpName">The name of the environment variable.</param>
/// <param name="lpBuffer">
/// A pointer to a buffer that receives the contents of the specified environment variable as a null-terminated string. An environment variable has a
/// maximum size limit of 32,767 characters, including the null-terminating character.
/// </param>
/// <param name="nSize">The size of the buffer pointed to by the lpBuffer parameter, including the null-terminating character, in characters.</param>
/// <returns>
/// <para>
/// If the function succeeds, the return value is the number of characters stored in the buffer pointed to by lpBuffer, not including the terminating
/// null character.
/// </para>
/// <para>
/// If lpBuffer is not large enough to hold the data, the return value is the buffer size, in characters, required to hold the string and its terminating
/// null character and the contents of lpBuffer are undefined.
/// </para>
/// <para>
/// If the function fails, the return value is zero. If the specified environment variable was not found in the environment block, <c>GetLastError</c>
/// returns ERROR_ENVVAR_NOT_FOUND.
/// </para>
/// </returns>
// DWORD WINAPI GetEnvironmentVariable( _In_opt_ LPCTSTR lpName, _Out_opt_ LPTSTR lpBuffer, _In_ DWORD nSize);
// https://msdn.microsoft.com/en-us/library/windows/desktop/ms683188(v=vs.85).aspx
[DllImport(Lib.Kernel32, SetLastError = true, CharSet = CharSet.Auto)]
[PInvokeData("WinBase.h", MSDNShortId = "ms683188")]
public static extern uint GetEnvironmentVariable(string lpName, StringBuilder lpBuffer, uint nSize);
/// <summary>Sets the contents of the specified environment variable for the current process.</summary>
/// <param name="lpName">
/// The name of the environment variable. The operating system creates the environment variable if it does not exist and lpValue is not NULL.
/// </param>
/// <param name="lpValue">
/// <para>
/// The contents of the environment variable. The maximum size of a user-defined environment variable is 32,767 characters. For more information, see
/// Environment Variables.
/// </para>
/// <para><c>Windows Server 2003 and Windows XP:</c> The total size of the environment block for a process may not exceed 32,767 characters.</para>
/// <para>If this parameter is NULL, the variable is deleted from the current process's environment.</para>
/// </param>
/// <returns>
/// <para>If the function succeeds, the return value is nonzero.</para>
/// <para>If the function fails, the return value is zero. To get extended error information, call <c>GetLastError</c>.</para>
/// </returns>
// BOOL WINAPI SetEnvironmentVariable( _In_ LPCTSTR lpName, _In_opt_ LPCTSTR lpValue);
// https://msdn.microsoft.com/en-us/library/windows/desktop/ms686206(v=vs.85).aspx
[DllImport(Lib.Kernel32, SetLastError = true, CharSet = CharSet.Auto)]
[PInvokeData("WinBase.h", MSDNShortId = "ms686206")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SetEnvironmentVariable(string lpName, [Optional] string lpValue);
/// <summary>
/// <para>Expands environment-variable strings and replaces them with the values defined for the current user.</para>
/// <para>To specify the environment block for a particular user or the system, use the <c>ExpandEnvironmentStringsForUser</c> function.</para>
/// </summary>
/// <param name="lpSrc">
/// <para>
/// A buffer that contains one or more environment-variable strings in the form: %variableName%. For each such reference, the %variableName% portion is
/// replaced with the current value of that environment variable.
/// </para>
/// <para>Case is ignored when looking up the environment-variable name. If the name is not found, the %variableName% portion is left unexpanded.</para>
/// <para>
/// Note that this function does not support all the features that Cmd.exe supports. For example, it does not support %variableName:str1=str2% or %variableName:~offset,length%.
/// </para>
/// </param>
/// <param name="lpDst">
/// A pointer to a buffer that receives the result of expanding the environment variable strings in the lpSrc buffer. Note that this buffer cannot be the
/// same as the lpSrc buffer.
/// </param>
/// <param name="nSize">
/// The maximum number of characters that can be stored in the buffer pointed to by the lpDst parameter. When using ANSI strings, the buffer size should
/// be the string length, plus terminating null character, plus one. When using Unicode strings, the buffer size should be the string length plus the
/// terminating null character.
/// </param>
/// <returns>
/// <para>
/// If the function succeeds, the return value is the number of <c>TCHARs</c> stored in the destination buffer, including the terminating null character.
/// If the destination buffer is too small to hold the expanded string, the return value is the required buffer size, in characters.
/// </para>
/// <para>If the function fails, the return value is zero. To get extended error information, call <c>GetLastError</c>.</para>
/// </returns>
// DWORD WINAPI ExpandEnvironmentStrings( _In_ LPCTSTR lpSrc, _Out_opt_ LPTSTR lpDst, _In_ DWORD nSize);
// https://msdn.microsoft.com/en-us/library/windows/desktop/ms724265(v=vs.85).aspx
[DllImport(Lib.Kernel32, SetLastError = true, CharSet = CharSet.Auto)]
[PInvokeData("Winbase.h", MSDNShortId = "ms724265")]
public static extern uint ExpandEnvironmentStrings([In] string lpSrc, StringBuilder lpDst, uint nSize);
/// <summary>Changes the current directory for the current process.</summary>
/// <param name="lpPathName">
/// <para>
/// The path to the new current directory. This parameter may specify a relative path or a full path. In either case, the full path of the specified
/// directory is calculated and stored as the current directory. For more information, see File Names, Paths, and Namespaces.
/// </para>
/// <para>
/// In the ANSI version of this function, the name is limited to <c>MAX_PATH</c> characters. To extend this limit to 32,767 wide characters, call the
/// Unicode version of the function and prepend "\\?\" to the path. For more information, see Naming a File.
/// </para>
/// <para>
/// The final character before the null character must be a backslash ('\'). If you do not specify the backslash, it will be added for you; therefore,
/// specify <c>MAX_PATH</c>-2 characters for the path unless you include the trailing backslash, in which case, specify <c>MAX_PATH</c>-1 characters for
/// the path.
/// </para>
/// </param>
/// <returns>
/// <para>If the function succeeds, the return value is nonzero.</para>
/// <para>If the function fails, the return value is zero. To get extended error information, call <c>GetLastError</c>.</para>
/// </returns>
// BOOL WINAPI SetCurrentDirectory( _In_ LPCTSTR lpPathName);
// https://msdn.microsoft.com/en-us/library/windows/desktop/aa365530(v=vs.85).aspx
[DllImport(Lib.Kernel32, SetLastError = true, CharSet = CharSet.Auto)]
[PInvokeData("WinBase.h", MSDNShortId = "aa365530")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SetCurrentDirectory([In] string lpPathName);
/// <summary>Retrieves the current directory for the current process.</summary>
/// <param name="nBufferLength">
/// The length of the buffer for the current directory string, in <c>TCHARs</c>. The buffer length must include room for a terminating null character.
/// </param>
/// <param name="lpBuffer">
/// <para>
/// A pointer to the buffer that receives the current directory string. This null-terminated string specifies the absolute path to the current directory.
/// </para>
/// <para>To determine the required buffer size, set this parameter to <c>NULL</c> and the nBufferLength parameter to 0.</para>
/// </param>
/// <returns>
/// <para>
/// If the function succeeds, the return value specifies the number of characters that are written to the buffer, not including the terminating null character.
/// </para>
/// <para>If the function fails, the return value is zero. To get extended error information, call <c>GetLastError</c>.</para>
/// <para>
/// If the buffer that is pointed to by lpBuffer is not large enough, the return value specifies the required size of the buffer, in characters,
/// including the null-terminating character.
/// </para>
/// </returns>
// DWORD WINAPI GetCurrentDirectory( _In_ DWORD nBufferLength, _Out_ LPTSTR lpBuffer);
// https://msdn.microsoft.com/en-us/library/windows/desktop/aa364934(v=vs.85).aspx
[DllImport(Lib.Kernel32, SetLastError = true, CharSet = CharSet.Auto)]
[PInvokeData("WinBase.h", MSDNShortId = "aa364934")]
public static extern uint GetCurrentDirectory(uint nBufferLength, StringBuilder lpBuffer);
/// <summary>Searches for a specified file in a specified path.</summary>
/// <param name="lpPath">
/// <para>The path to be searched for the file.</para>
/// <para>
/// If this parameter is <c>NULL</c>, the function searches for a matching file using a registry-dependent system search path. For more information, see
/// the Remarks section.
/// </para>
/// </param>
/// <param name="lpFileName">The name of the file for which to search.</param>
/// <param name="lpExtension">
/// <para>
/// The extension to be added to the file name when searching for the file. The first character of the file name extension must be a period (.). The
/// extension is added only if the specified file name does not end with an extension.
/// </para>
/// <para>If a file name extension is not required or if the file name contains an extension, this parameter can be <c>NULL</c>.</para>
/// </param>
/// <param name="nBufferLength">The size of the buffer that receives the valid path and file name (including the terminating null character), in <c>TCHARs</c>.</param>
/// <param name="lpBuffer">A pointer to the buffer to receive the path and file name of the file found. The string is a null-terminated string.</param>
/// <param name="lpFilePart">
/// A pointer to the variable to receive the address (within lpBuffer) of the last component of the valid path and file name, which is the address of the
/// character immediately following the final backslash (\) in the path.
/// </param>
/// <returns>
/// <para>
/// If the function succeeds, the value returned is the length, in <c>TCHARs</c>, of the string that is copied to the buffer, not including the
/// terminating null character. If the return value is greater than nBufferLength, the value returned is the size of the buffer that is required to hold
/// the path, including the terminating null character.
/// </para>
/// <para>If the function fails, the return value is zero. To get extended error information, call <c>GetLastError</c>.</para>
/// </returns>
// DWORD WINAPI SearchPath( _In_opt_ LPCTSTR lpPath, _In_ LPCTSTR lpFileName, _In_opt_ LPCTSTR lpExtension, _In_ DWORD nBufferLength, _Out_ LPTSTR lpBuffer, _Out_opt_ LPTSTR *lpFilePart);
// https://msdn.microsoft.com/en-us/library/windows/desktop/aa365527(v=vs.85).aspx
[PInvokeData("WinBase.h", MSDNShortId = "aa365527")]
[DllImport(Lib.Kernel32, SetLastError = true, CharSet = CharSet.Auto)]
public static extern uint SearchPath([In, Optional] string lpPath, [In] string lpFileName, [In, Optional] string lpExtension, uint nBufferLength, StringBuilder lpBuffer, out IntPtr lpFilePart);
/// <summary>Determines whether the current directory should be included in the search path for the specified executable.</summary>
/// <param name="ExeName">The name of the executable file.</param>
/// <returns>If the current directory should be part of the search path, the return value is TRUE. Otherwise, the return value is FALSE.</returns>
// BOOL WINAPI NeedCurrentDirectoryForExePath( _In_ LPCTSTR ExeName);
// https://msdn.microsoft.com/en-us/library/windows/desktop/ms684269(v=vs.85).aspx
[DllImport(Lib.Kernel32, SetLastError = false, CharSet = CharSet.Auto)]
[PInvokeData("WinBase.h", MSDNShortId = "ms684269")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool NeedCurrentDirectoryForExePath(string ExeName);
}
}
}

View File

@ -342,7 +342,7 @@ namespace Vanara.PInvoke
// PssCaptureSnapshot( HANDLE ProcessHandle, PSS_CAPTURE_FLAGS CaptureFlags, DWORD ThreadContextFlags, HPSS *SnapshotHandle );
[DllImport(Lib.Kernel32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("processsnapshot.h", MSDNShortId = "44F2CB48-A9F6-4131-B21C-9F27A27CECD5")]
public static extern Win32Error PssCaptureSnapshot(IntPtr ProcessHandle, PSS_CAPTURE_FLAGS CaptureFlags, uint ThreadContextFlags, out IntPtr SnapshotHandle);
public static extern Win32Error PssCaptureSnapshot(HPROCESS ProcessHandle, PSS_CAPTURE_FLAGS CaptureFlags, uint ThreadContextFlags, out IntPtr SnapshotHandle);
/// <summary>
/// <para>Duplicates a snapshot handle from one process to another.</para>
@ -390,7 +390,7 @@ namespace Vanara.PInvoke
// *TargetSnapshotHandle, PSS_DUPLICATE_FLAGS Flags );
[DllImport(Lib.Kernel32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("processsnapshot.h", MSDNShortId = "5D2751F3-E7E1-4917-8060-E2BC8A7A3DEA")]
public static extern Win32Error PssDuplicateSnapshot(IntPtr SourceProcessHandle, IntPtr SnapshotHandle, IntPtr TargetProcessHandle, out IntPtr TargetSnapshotHandle, PSS_DUPLICATE_FLAGS Flags);
public static extern Win32Error PssDuplicateSnapshot(HPROCESS SourceProcessHandle, IntPtr SnapshotHandle, HPROCESS TargetProcessHandle, out IntPtr TargetSnapshotHandle, PSS_DUPLICATE_FLAGS Flags);
/// <summary>
/// <para>Frees a snapshot.</para>
@ -444,7 +444,7 @@ namespace Vanara.PInvoke
// PssFreeSnapshot( HANDLE ProcessHandle, HPSS SnapshotHandle );
[DllImport(Lib.Kernel32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("processsnapshot.h", MSDNShortId = "5D062AE6-2F7C-4121-AB6E-9BFA06AB36C6")]
public static extern Win32Error PssFreeSnapshot(IntPtr ProcessHandle, IntPtr SnapshotHandle);
public static extern Win32Error PssFreeSnapshot(HPROCESS ProcessHandle, IntPtr SnapshotHandle);
/// <summary>
/// <para>Queries the snapshot.</para>

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,4 @@
using System;
using System.Runtime.InteropServices;
using System.Runtime.InteropServices;
namespace Vanara.PInvoke
{
@ -9,34 +8,38 @@ namespace Vanara.PInvoke
/// <param name="hProcess">
/// <para>A handle to the process.</para>
/// <para>
/// This handle must have the PROCESS_QUERY_INFORMATION or PROCESS_QUERY_LIMITED_INFORMATION access right. For more information, see Process Security and
/// Access Rights.
/// This handle must have the PROCESS_QUERY_INFORMATION or PROCESS_QUERY_LIMITED_INFORMATION access right. For more information, see
/// Process Security and Access Rights.
/// </para>
/// </param>
/// <param name="GroupCount">
/// On input, specifies the number of elements in GroupArray array. On output, specifies the number of processor groups written to the array. If the
/// array is too small, the function fails with ERROR_INSUFFICIENT_BUFFER and sets the GroupCount parameter to the number of elements required.
/// On input, specifies the number of elements in GroupArray array. On output, specifies the number of processor groups written to
/// the array. If the array is too small, the function fails with ERROR_INSUFFICIENT_BUFFER and sets the GroupCount parameter to the
/// number of elements required.
/// </param>
/// <param name="GroupArray">
/// An array of processor group numbers. A group number is included in the array if a thread in the process is assigned to a processor in the group.
/// An array of processor group numbers. A group number is included in the array if a thread in the process is assigned to a
/// processor in the group.
/// </param>
/// <returns>
/// <para>If the function succeeds, the return value is nonzero.</para>
/// <para>If the function fails, the return value is zero. To get extended error information, use <c>GetLastError</c>.</para>
/// <para>If the error value is ERROR_INSUFFICIENT_BUFFER, the GroupCount parameter contains the required buffer size in number of elements.</para>
/// <para>
/// If the error value is ERROR_INSUFFICIENT_BUFFER, the GroupCount parameter contains the required buffer size in number of elements.
/// </para>
/// </returns>
// BOOL GetProcessGroupAffinity( _In_ HANDLE hProcess, _Inout_ PUSHORT GroupCount, _Out_ PUSHORT GroupArray); https://msdn.microsoft.com/en-us/library/windows/desktop/dd405496(v=vs.85).aspx
[DllImport(Lib.Kernel32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("WinBase.h", MSDNShortId = "dd405496")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool GetProcessGroupAffinity(IntPtr hProcess, ref ushort GroupCount, [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)] ref ushort[] GroupArray);
public static extern bool GetProcessGroupAffinity(HPROCESS hProcess, ref ushort GroupCount, [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)] ushort[] GroupArray);
/// <summary>Retrieves the processor group affinity of the specified thread.</summary>
/// <param name="hThread">
/// <para>A handle to the thread for which the processor group affinity is desired.</para>
/// <para>
/// The handle must have the THREAD_QUERY_INFORMATION or THREAD_QUERY_LIMITED_INFORMATION access right. For more information, see Thread Security and
/// Access Rights.
/// The handle must have the THREAD_QUERY_INFORMATION or THREAD_QUERY_LIMITED_INFORMATION access right. For more information, see
/// Thread Security and Access Rights.
/// </para>
/// </param>
/// <param name="GroupAffinity">A pointer to a GROUP_AFFINITY structure to receive the group affinity of the thread.</param>
@ -48,14 +51,16 @@ namespace Vanara.PInvoke
[DllImport(Lib.Kernel32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("WinBase.h", MSDNShortId = "dd405498")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool GetThreadGroupAffinity(IntPtr hThread, out GROUP_AFFINITY GroupAffinity);
public static extern bool GetThreadGroupAffinity(HTHREAD hThread, out GROUP_AFFINITY GroupAffinity);
/// <summary>Sets the processor group affinity for the specified thread.</summary>
/// <param name="hThread">
/// <para>A handle to the thread.</para>
/// <para>The handle must have the THREAD_SET_INFORMATION access right. For more information, see Thread Security and Access Rights.</para>
/// </param>
/// <param name="GroupAffinity">A <c>GROUP_AFFINITY</c> structure that specifies the processor group affinity to be used for the specified thread.</param>
/// <param name="GroupAffinity">
/// A <c>GROUP_AFFINITY</c> structure that specifies the processor group affinity to be used for the specified thread.
/// </param>
/// <param name="PreviousGroupAffinity">
/// A pointer to a <c>GROUP_AFFINITY</c> structure to receive the thread's previous group affinity. This parameter can be NULL.
/// </param>
@ -63,10 +68,11 @@ namespace Vanara.PInvoke
/// <para>If the function succeeds, the return value is nonzero.</para>
/// <para>If the function fails, the return value is zero. To get extended error information, use <c>GetLastError</c>.</para>
/// </returns>
// BOOL SetThreadGroupAffinity( _In_ HANDLE hThread, _In_ const GROUP_AFFINITY *GroupAffinity, _Out_opt_ PGROUP_AFFINITY PreviousGroupAffinity); https://msdn.microsoft.com/en-us/library/windows/desktop/dd405516(v=vs.85).aspx
// BOOL SetThreadGroupAffinity( _In_ HANDLE hThread, _In_ const GROUP_AFFINITY *GroupAffinity, _Out_opt_ PGROUP_AFFINITY
// PreviousGroupAffinity); https://msdn.microsoft.com/en-us/library/windows/desktop/dd405516(v=vs.85).aspx
[DllImport(Lib.Kernel32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("WinBase.h", MSDNShortId = "dd405516")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SetThreadGroupAffinity(IntPtr hThread, ref GROUP_AFFINITY GroupAffinity, out GROUP_AFFINITY PreviousGroupAffinity);
public static extern bool SetThreadGroupAffinity(HTHREAD hThread, in GROUP_AFFINITY GroupAffinity, out GROUP_AFFINITY PreviousGroupAffinity);
}
}

View File

@ -88,7 +88,7 @@ namespace Vanara.PInvoke
[DllImport(Lib.Kernel32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("psapi.h", MSDNShortId = "76f2252e-7305-46b0-b1af-40ac084e6696")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool EmptyWorkingSet(IntPtr hProcess);
public static extern bool EmptyWorkingSet(HPROCESS hProcess);
/// <summary>
/// <para>Retrieves the load address for each device driver in the system.</para>
@ -136,16 +136,16 @@ namespace Vanara.PInvoke
[DllImport(Lib.Kernel32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("psapi.h", MSDNShortId = "55925741-da23-44b1-93e8-0e9468434a61")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool EnumDeviceDrivers([In, MarshalAs(UnmanagedType.LPArray)] IntPtr[] lpImageBase, uint cb, out uint lpcbNeeded);
public static extern bool EnumDeviceDrivers([In, Out, MarshalAs(UnmanagedType.LPArray)] IntPtr[] lpImageBase, uint cb, out uint lpcbNeeded);
/// <summary>
/// <para>Calls the callback routine for each installed pagefile in the system.</para>
/// </summary>
/// <param name="pCallBackRoutine">
/// <para>TBD</para>
/// <para>A pointer to the routine called for each pagefile. For more information, see EnumPageFilesProc.</para>
/// </param>
/// <param name="pContext">
/// <para>TBD</para>
/// <para>The user-defined data passed to the callback routine.</para>
/// </param>
/// <returns>
/// <para>
@ -171,7 +171,7 @@ namespace Vanara.PInvoke
/// </remarks>
// https://docs.microsoft.com/en-us/windows/desktop/api/psapi/nf-psapi-enumpagefilesa BOOL EnumPageFilesA( PENUM_PAGE_FILE_CALLBACKA
// pCallBackRoutine, LPVOID pContext );
[DllImport(Lib.Kernel32, SetLastError = true, ExactSpelling = true)]
[DllImport(Lib.Kernel32, SetLastError = true, CharSet = CharSet.Auto)]
[PInvokeData("psapi.h", MSDNShortId = "9289fe3c-a7d9-4acb-aeb6-a50de65db0a2")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool EnumPageFiles(PenumPageFileCallback pCallBackRoutine, IntPtr pContext);
@ -180,13 +180,13 @@ namespace Vanara.PInvoke
/// <para>Retrieves the process identifier for each process object in the system.</para>
/// </summary>
/// <param name="lpidProcess">
/// <para>TBD</para>
/// <para>A pointer to an array that receives the list of process identifiers.</para>
/// </param>
/// <param name="cb">
/// <para>The size of the pProcessIds array, in bytes.</para>
/// </param>
/// <param name="lpcbNeeded">
/// <para>TBD</para>
/// <para>The number of bytes returned in the pProcessIds array.</para>
/// </param>
/// <returns>
/// <para>If the function succeeds, the return value is nonzero.</para>
@ -221,10 +221,10 @@ namespace Vanara.PInvoke
/// </remarks>
// https://docs.microsoft.com/en-us/windows/desktop/api/psapi/nf-psapi-enumprocesses BOOL EnumProcesses( DWORD *lpidProcess, DWORD
// cb, LPDWORD lpcbNeeded );
[DllImport(Lib.Kernel32, SetLastError = true, ExactSpelling = true)]
[DllImport(Lib.Kernel32, SetLastError = true, CharSet = CharSet.Auto)]
[PInvokeData("psapi.h", MSDNShortId = "0c0445cb-27d2-4857-a4a5-7a4c180b068b")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool EnumProcesses([In, MarshalAs(UnmanagedType.LPArray)] uint[] lpidProcess, uint cb, out uint lpcbNeeded);
public static extern bool EnumProcesses([In, Out, MarshalAs(UnmanagedType.LPArray)] uint[] lpidProcess, uint cb, out uint lpcbNeeded);
/// <summary>
/// <para>Retrieves a handle for each module in the specified process.</para>
@ -304,7 +304,7 @@ namespace Vanara.PInvoke
[DllImport(Lib.Kernel32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("psapi.h", MSDNShortId = "b4088506-2f69-4cf0-9bab-3e6a7185f5b2")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool EnumProcessModules(IntPtr hProcess, [In, MarshalAs(UnmanagedType.LPArray)] IntPtr[] lphModule, uint cb, out uint lpcbNeeded);
public static extern bool EnumProcessModules(HPROCESS hProcess, [In, Out, MarshalAs(UnmanagedType.LPArray)] IntPtr[] lphModule, uint cb, out uint lpcbNeeded);
/// <summary>
/// <para>Retrieves a handle for each module in the specified process that meets the specified filter criteria.</para>
@ -403,7 +403,7 @@ namespace Vanara.PInvoke
[DllImport(Lib.Kernel32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("psapi.h", MSDNShortId = "0f982f32-31f4-47b6-85d2-d6e17aa4eeb9")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool EnumProcessModulesEx(IntPtr hProcess, [In, MarshalAs(UnmanagedType.LPArray)] IntPtr[] lphModule, uint cb, out uint lpcbNeeded, LIST_MODULES dwFilterFlag);
public static extern bool EnumProcessModulesEx(HPROCESS hProcess, [In, Out, MarshalAs(UnmanagedType.LPArray)] IntPtr[] lphModule, uint cb, out uint lpcbNeeded, LIST_MODULES dwFilterFlag);
/// <summary>
/// <para>Retrieves the base name of the specified device driver.</para>
@ -412,7 +412,7 @@ namespace Vanara.PInvoke
/// <para>The load address of the device driver. This value can be retrieved using the EnumDeviceDrivers function.</para>
/// </param>
/// <param name="lpFilename">
/// <para>TBD</para>
/// <para>A pointer to the buffer that receives the base name of the device driver.</para>
/// </param>
/// <param name="nSize">
/// <para>
@ -569,7 +569,7 @@ namespace Vanara.PInvoke
// LPVOID lpv, LPSTR lpFilename, DWORD nSize );
[DllImport(Lib.Kernel32, SetLastError = true, CharSet = CharSet.Auto)]
[PInvokeData("psapi.h", MSDNShortId = "10a2e5ab-f495-486d-8ef7-ef763716afd1")]
public static extern uint GetMappedFileName(IntPtr hProcess, IntPtr lpv, StringBuilder lpFilename, uint nSize);
public static extern uint GetMappedFileName(HPROCESS hProcess, IntPtr lpv, StringBuilder lpFilename, uint nSize);
/// <summary>
/// <para>Retrieves the base name of the specified module.</para>
@ -641,7 +641,7 @@ namespace Vanara.PInvoke
// HMODULE hModule, LPSTR lpBaseName, DWORD nSize );
[DllImport(Lib.Kernel32, SetLastError = true, CharSet = CharSet.Auto)]
[PInvokeData("psapi.h", MSDNShortId = "31a9eb69-95f0-4dd7-8fd5-296f2cff0b8a")]
public static extern uint GetModuleBaseName(IntPtr hProcess, HINSTANCE hModule, StringBuilder lpBaseName, uint nSize);
public static extern uint GetModuleBaseName(HPROCESS hProcess, [Optional] HINSTANCE hModule, StringBuilder lpBaseName, uint nSize);
/// <summary>
/// <para>Retrieves information about the specified module in the MODULEINFO structure.</para>
@ -692,7 +692,7 @@ namespace Vanara.PInvoke
[DllImport(Lib.Kernel32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("psapi.h", MSDNShortId = "afb9f4c8-c8ae-4497-96c1-b559cfa2cedf")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool GetModuleInformation(IntPtr hProcess, HINSTANCE hModule, ref MODULEINFO lpmodinfo, uint cb);
public static extern bool GetModuleInformation(HPROCESS hProcess, HINSTANCE hModule, out MODULEINFO lpmodinfo, uint cb);
/// <summary>
/// <para>Retrieves the performance values contained in the PERFORMANCE_INFORMATION structure.</para>
@ -790,7 +790,7 @@ namespace Vanara.PInvoke
// HANDLE hProcess, LPSTR lpImageFileName, DWORD nSize );
[DllImport(Lib.Kernel32, SetLastError = true, CharSet = CharSet.Auto)]
[PInvokeData("psapi.h", MSDNShortId = "819fc2f4-0801-417b-9cbb-d7fd2894634e")]
public static extern uint GetProcessImageFileName(IntPtr hProcess, StringBuilder lpImageFileName, uint nSize);
public static extern uint GetProcessImageFileName(HPROCESS hProcess, StringBuilder lpImageFileName, uint nSize);
/// <summary>
/// <para>Retrieves information about the memory usage of the specified process.</para>
@ -841,7 +841,7 @@ namespace Vanara.PInvoke
[DllImport(Lib.Kernel32, SetLastError = true, CharSet = CharSet.Auto)]
[PInvokeData("psapi.h", MSDNShortId = "12990e8d-6097-4502-824e-db6c3f76c715")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool GetProcessMemoryInfo(IntPtr Process, ref PROCESS_MEMORY_COUNTERS ppsmemCounters, uint cb);
public static extern bool GetProcessMemoryInfo(HPROCESS Process, ref PROCESS_MEMORY_COUNTERS ppsmemCounters, uint cb);
/// <summary>
/// <para>
@ -913,7 +913,7 @@ namespace Vanara.PInvoke
[DllImport(Lib.Kernel32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("psapi.h", MSDNShortId = "ace5106c-9c7b-4d5f-a69a-c3a8bff0bb2d")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool GetWsChanges(IntPtr hProcess, IntPtr lpWatchInfo, uint cb);
public static extern bool GetWsChanges(HPROCESS hProcess, IntPtr lpWatchInfo, uint cb);
/// <summary>
/// <para>
@ -980,7 +980,7 @@ namespace Vanara.PInvoke
[DllImport(Lib.Kernel32, SetLastError = true, CharSet = CharSet.Auto)]
[PInvokeData("psapi.h", MSDNShortId = "8572db5c-2ffc-424f-8cec-b6a6902fed62")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool GetWsChangesEx(IntPtr hProcess, IntPtr lpWatchInfoEx, ref uint cb);
public static extern bool GetWsChangesEx(HPROCESS hProcess, IntPtr lpWatchInfoEx, ref uint cb);
/// <summary>
/// <para>
@ -1018,7 +1018,7 @@ namespace Vanara.PInvoke
[DllImport(Lib.Kernel32, SetLastError = true, CharSet = CharSet.Auto)]
[PInvokeData("psapi.h", MSDNShortId = "c928656c-a59d-41b5-9434-911329b0278e")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool InitializeProcessForWsWatch(IntPtr hProcess);
public static extern bool InitializeProcessForWsWatch(HPROCESS hProcess);
/// <summary>
/// <para>Retrieves information about the pages currently added to the working set of the specified process.</para>
@ -1069,7 +1069,7 @@ namespace Vanara.PInvoke
[DllImport(Lib.Kernel32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("psapi.h", MSDNShortId = "b932153f-2bbd-460e-8ff7-b3e493c397bb")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool QueryWorkingSet(IntPtr hProcess, IntPtr pv, uint cb);
public static extern bool QueryWorkingSet(HPROCESS hProcess, IntPtr pv, uint cb);
/// <summary>
/// <para>Retrieves extended information about the pages at specific virtual addresses in the address space of the specified process.</para>
@ -1121,7 +1121,7 @@ namespace Vanara.PInvoke
[DllImport(Lib.Kernel32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("psapi.h", MSDNShortId = "59ae76c9-e954-4648-9c9f-787136375b02")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool QueryWorkingSetEx(IntPtr hProcess, IntPtr pv, uint cb);
public static extern bool QueryWorkingSetEx(HPROCESS hProcess, IntPtr pv, uint cb);
/// <summary>
/// <para>Contains information about a pagefile.</para>

View File

@ -184,7 +184,7 @@ namespace Vanara.PInvoke
[DllImport(Lib.Kernel32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("WinBase.h", MSDNShortId = "ms684929")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool QueryProcessCycleTime(IntPtr ProcessHandle, out ulong CycleTime);
public static extern bool QueryProcessCycleTime(HPROCESS ProcessHandle, out ulong CycleTime);
/// <summary>Retrieves the cycle time for the specified thread.</summary>
/// <param name="ThreadHandle">
@ -200,7 +200,7 @@ namespace Vanara.PInvoke
[DllImport(Lib.Kernel32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("WinBase.h", MSDNShortId = "ms684943")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool QueryThreadCycleTime(IntPtr ThreadHandle, out ulong CycleTime);
public static extern bool QueryThreadCycleTime(HTHREAD ThreadHandle, out ulong CycleTime);
/// <summary>
/// Gets the current unbiased interrupt-time count, in units of 100 nanoseconds. The unbiased interrupt-time count does not include time the system

View File

@ -26,6 +26,6 @@ namespace Vanara.PInvoke
[DllImport(Lib.Kernel32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("Securityappcontainer.h", MSDNShortId = "hh448493")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool GetAppContainerNamedObjectPath(IntPtr Token, IntPtr AppContainerSid, uint ObjectPathLength, [Out] StringBuilder ObjectPath, out uint ReturnLength);
public static extern bool GetAppContainerNamedObjectPath([Optional] HTOKEN Token, IntPtr AppContainerSid, uint ObjectPathLength, StringBuilder ObjectPath, out uint ReturnLength);
}
}

View File

@ -90,7 +90,7 @@ namespace Vanara.PInvoke
[DllImport(Lib.Kernel32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("securitybaseapi.h", MSDNShortId = "AA2064E4-6F76-4D7B-8540-D55A91168825")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool AddResourceAttributeAce(PACL pAcl, uint dwAceRevision, uint AceFlags, uint AccessMask, PSID pSid, ref CLAIM_SECURITY_ATTRIBUTES_INFORMATION pAttributeInfo, ref uint pReturnLength);
public static extern bool AddResourceAttributeAce(PACL pAcl, uint dwAceRevision, uint AceFlags, uint AccessMask, PSID pSid, in CLAIM_SECURITY_ATTRIBUTES_INFORMATION pAttributeInfo, ref uint pReturnLength);
/// <summary>
/// <para>
@ -199,7 +199,7 @@ namespace Vanara.PInvoke
[DllImport(Lib.Kernel32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("securitybaseapi.h", MSDNShortId = "436A5110-B79E-4E64-92E8-1C9E713D0948")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool CheckTokenCapability(IntPtr TokenHandle, PSID CapabilitySidToCheck, [MarshalAs(UnmanagedType.Bool)] out bool HasCapability);
public static extern bool CheckTokenCapability(HTOKEN TokenHandle, PSID CapabilitySidToCheck, [MarshalAs(UnmanagedType.Bool)] out bool HasCapability);
/// <summary>
/// <para>

View File

@ -190,7 +190,7 @@ namespace Vanara.PInvoke
// int CompareString( _In_ LCID Locale, _In_ DWORD dwCmpFlags, _In_ LPCTSTR lpString1, _In_ int cchCount1, _In_ LPCTSTR lpString2, _In_ int cchCount2); https://msdn.microsoft.com/en-us/library/windows/desktop/dd317759(v=vs.85).aspx
[DllImport(Lib.Kernel32, SetLastError = false, CharSet = CharSet.Auto)]
[PInvokeData("Winnls.h", MSDNShortId = "dd317759")]
public static extern int CompareString(uint Locale, COMPARE_STRING dwCmpFlags, [In] string lpString1, int cchCount1, [In] string lpString2, int cchCount2);
public static extern int CompareString(uint Locale, COMPARE_STRING dwCmpFlags, string lpString1, int cchCount1, string lpString2, int cchCount2);
/// <summary>Compares two Unicode (wide character) strings, for a locale specified by name.</summary>
/// <param name="lpLocaleName">Pointer to a locale name, or one of the following predefined values.</param>
@ -397,7 +397,7 @@ namespace Vanara.PInvoke
// int FoldString( _In_ DWORD dwMapFlags, _In_ LPCTSTR lpSrcStr, _In_ int cchSrc, _Out_opt_ LPTSTR lpDestStr, _In_ int cchDest); https://msdn.microsoft.com/en-us/library/windows/desktop/dd318063(v=vs.85).aspx
[DllImport(Lib.Kernel32, SetLastError = true, CharSet = CharSet.Auto)]
[PInvokeData("Winnls.h", MSDNShortId = "dd318063")]
public static extern int FoldString(STRING_MAPPING dwMapFlags, [In] string lpSrcStr, int cchSrc, [Out] StringBuilder lpDestStr, int cchDest);
public static extern int FoldString(STRING_MAPPING dwMapFlags, string lpSrcStr, int cchSrc, StringBuilder lpDestStr, int cchDest);
/// <summary>
/// Deprecated. Retrieves character type information for the characters in the specified source string. For each character in the string, the function
@ -493,7 +493,7 @@ namespace Vanara.PInvoke
[DllImport(Lib.Kernel32, SetLastError = true, ExactSpelling = true, CharSet = CharSet.Unicode)]
[PInvokeData("Stringapiset.h", MSDNShortId = "dd318119")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool GetStringTypeW(CHAR_TYPE_INFO dwInfoType, [In] string lpSrcStr, int cchSrc, out ushort lpCharType);
public static extern bool GetStringTypeW(CHAR_TYPE_INFO dwInfoType, string lpSrcStr, int cchSrc, out ushort lpCharType);
/// <summary>
/// Retrieves character type information for the characters in the specified source string. For each character in the string, the function sets one or
@ -533,7 +533,7 @@ namespace Vanara.PInvoke
[DllImport(Lib.Kernel32, SetLastError = true, CharSet = CharSet.Auto)]
[PInvokeData("Winnls.h", MSDNShortId = "dd318118")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool GetStringTypeEx(uint Locale, CHAR_TYPE_INFO dwInfoType, [In] string lpSrcStr, int cchSrc, out ushort lpCharType);
public static extern bool GetStringTypeEx(uint Locale, CHAR_TYPE_INFO dwInfoType, string lpSrcStr, int cchSrc, out ushort lpCharType);
/// <summary>Maps a character string to a UTF-16 (wide character) string. The character string is not necessarily from a multibyte character set.</summary>
/// <param name="CodePage">

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -53,7 +53,7 @@ namespace Vanara.PInvoke
// typedef struct _GROUP_AFFINITY { KAFFINITY Mask; WORD Group; WORD Reserved[3];} GROUP_AFFINITY, *PGROUP_AFFINITY;
// https://msdn.microsoft.com/en-us/library/windows/desktop/dd405500(v=vs.85).aspx
[PInvokeData("WinNT.h", MSDNShortId = "dd405500")]
[StructLayout(LayoutKind.Sequential)]
[StructLayout(LayoutKind.Sequential, Pack = 4)]
public struct GROUP_AFFINITY
{
/// <summary>A bitmap that specifies the affinity for zero or more processors within the specified group.</summary>
@ -61,8 +61,11 @@ namespace Vanara.PInvoke
/// <summary>The processor group number.</summary>
public ushort Group;
/// <summary>This member is reserved.</summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)]
public ushort[] Reserved;
private ushort Reserved1;
/// <summary>This member is reserved.</summary>
private ushort Reserved2;
/// <summary>This member is reserved.</summary>
private ushort Reserved3;
}
}
}

View File

@ -1,39 +1,34 @@
using Microsoft.Win32.SafeHandles;
using System;
using System;
using System.Runtime.InteropServices;
using FILETIME = System.Runtime.InteropServices.ComTypes.FILETIME;
namespace Vanara.PInvoke
{
using PTP_CALLBACK_INSTANCE = IntPtr;
using PTP_CLEANUP_GROUP = IntPtr;
using PTP_IO = IntPtr;
using PTP_POOL = IntPtr;
using PTP_TIMER = IntPtr;
using PTP_WAIT = IntPtr;
using PTP_WORK = IntPtr;
public static partial class Kernel32
{
/// <summary>
/// Applications implement this callback if they call the SetThreadpoolCallbackCleanupGroup function to specify the callback to use when CloseThreadpoolCleanupGroup is called.
/// Applications implement this callback if they call the SetThreadpoolCallbackCleanupGroup function to specify the callback to use
/// when CloseThreadpoolCleanupGroup is called.
/// </summary>
/// <param name="ObjectContext">Optional application-defined data specified during creation of the object.</param>
/// <param name="CleanupContext">Optional application-defined data specified using CloseThreadpoolCleanupGroupMembers.</param>
[UnmanagedFunctionPointer(CallingConvention.Winapi)]
public delegate void PTP_CLEANUP_GROUP_CANCEL_CALLBACK(IntPtr ObjectContext, IntPtr CleanupContext);
/// <summary>
/// Applications implement this callback if they call the TrySubmitThreadpoolCallback function to start a worker thread.
/// </summary>
/// <param name="Instance">A TP_CALLBACK_INSTANCE structure that defines the callback instance. Applications do not modify the members of this structure.</param>
/// <summary>Applications implement this callback if they call the TrySubmitThreadpoolCallback function to start a worker thread.</summary>
/// <param name="Instance">
/// A TP_CALLBACK_INSTANCE structure that defines the callback instance. Applications do not modify the members of this structure.
/// </param>
/// <param name="Context">The application-defined data.</param>
[UnmanagedFunctionPointer(CallingConvention.Winapi)]
public delegate void PTP_SIMPLE_CALLBACK(PTP_CALLBACK_INSTANCE Instance, IntPtr Context);
/// <summary>Applications implement this callback if they call the SetThreadpoolTimer function to start a worker thread for the timer object.</summary>
/// <param name="Instance">A TP_CALLBACK_INSTANCE structure that defines the callback instance. Applications do not modify the members of this structure.</param>
/// <summary>
/// Applications implement this callback if they call the SetThreadpoolTimer function to start a worker thread for the timer object.
/// </summary>
/// <param name="Instance">
/// A TP_CALLBACK_INSTANCE structure that defines the callback instance. Applications do not modify the members of this structure.
/// </param>
/// <param name="Context">The application-defined data.</param>
/// <param name="Timer">A TP_TIMER structure that defines the timer object that generated the callback.</param>
[UnmanagedFunctionPointer(CallingConvention.Winapi)]
@ -42,20 +37,32 @@ namespace Vanara.PInvoke
/// <summary>
/// Applications implement this callback if they call the SetThreadpoolWait function to start a worker thread for the wait object.
/// </summary>
/// <param name="Instance">A TP_CALLBACK_INSTANCE structure that defines the callback instance. Applications do not modify the members of this structure.</param>
/// <param name="Instance">
/// A TP_CALLBACK_INSTANCE structure that defines the callback instance. Applications do not modify the members of this structure.
/// </param>
/// <param name="Context">The application-defined data.</param>
/// <param name="Wait">A TP_WAIT structure that defines the wait object that generated the callback.</param>
/// <param name="WaitResult">The result of the wait operation. This parameter can be one of the following values from WaitForMultipleObjects: WAIT_OBJECT_0, WAIT_TIMEOUT</param>
/// <param name="WaitResult">
/// The result of the wait operation. This parameter can be one of the following values from WaitForMultipleObjects: WAIT_OBJECT_0, WAIT_TIMEOUT
/// </param>
[UnmanagedFunctionPointer(CallingConvention.Winapi)]
public delegate void PTP_WAIT_CALLBACK(PTP_CALLBACK_INSTANCE Instance, IntPtr Context, PTP_WAIT Wait, uint WaitResult);
/// <summary>
/// Applications implement this callback if they call the StartThreadpoolIo function to start a worker thread for the I/O completion object.
/// </summary>
/// <param name="Instance">A TP_CALLBACK_INSTANCE structure that defines the callback instance. Applications do not modify the members of this structure.</param>
/// <param name="Instance">
/// A TP_CALLBACK_INSTANCE structure that defines the callback instance. Applications do not modify the members of this structure.
/// </param>
/// <param name="Context">The application-defined data.</param>
/// <param name="Overlapped">A pointer to a variable that receives the address of the OVERLAPPED structure that was specified when the completed I/O operation was started.</param>
/// <param name="IoResult">The result of the I/O operation. If the I/O is successful, this parameter is NO_ERROR. Otherwise, this parameter is one of the system error codes.</param>
/// <param name="Overlapped">
/// A pointer to a variable that receives the address of the OVERLAPPED structure that was specified when the completed I/O operation
/// was started.
/// </param>
/// <param name="IoResult">
/// The result of the I/O operation. If the I/O is successful, this parameter is NO_ERROR. Otherwise, this parameter is one of the
/// system error codes.
/// </param>
/// <param name="NumberOfBytesTransferred">The number of bytes transferred during the I/O operation that has completed.</param>
/// <param name="Io">A TP_IO structure that defines the I/O completion object that generated the callback.</param>
[UnmanagedFunctionPointer(CallingConvention.Winapi)]
@ -65,7 +72,9 @@ namespace Vanara.PInvoke
/// <summary>
/// Applications implement this callback if they call the SubmitThreadpoolWork function to start a worker thread for the work object.
/// </summary>
/// <param name="Instance">A TP_CALLBACK_INSTANCE structure that defines the callback instance. Applications do not modify the members of this structure.</param>
/// <param name="Instance">
/// A TP_CALLBACK_INSTANCE structure that defines the callback instance. Applications do not modify the members of this structure.
/// </param>
/// <param name="Context">The application-defined data.</param>
/// <param name="Work">A TP_WORK structure that defines the work object that generated the callback.</param>
[UnmanagedFunctionPointer(CallingConvention.Winapi)]
@ -84,25 +93,30 @@ namespace Vanara.PInvoke
{
/// <summary>The callback should run at high priority.</summary>
TP_CALLBACK_PRIORITY_HIGH,
/// <summary>The callback should run at normal priority.</summary>
TP_CALLBACK_PRIORITY_NORMAL,
/// <summary>The callback should run at low priority.</summary>
TP_CALLBACK_PRIORITY_LOW,
/// <summary>The callback is invalid.</summary>
TP_CALLBACK_PRIORITY_INVALID,
}
/// <summary>Indicates that the callback may not return quickly.</summary>
/// <param name="pci">A <c>TP_CALLBACK_INSTANCE</c> structure that defines the callback instance. The structure is passed to the callback function.</param>
/// <param name="pci">
/// A <c>TP_CALLBACK_INSTANCE</c> structure that defines the callback instance. The structure is passed to the callback function.
/// </param>
/// <returns>
/// <para>
/// The function returns TRUE if another thread in the thread pool is available for processing callbacks or the thread pool was able to spin up a new
/// thread. In this case, the current callback function may use the current thread indefinitely.
/// The function returns TRUE if another thread in the thread pool is available for processing callbacks or the thread pool was able
/// to spin up a new thread. In this case, the current callback function may use the current thread indefinitely.
/// </para>
/// <para>
/// The function returns FALSE if another thread in the thread pool is not available to process callbacks and the thread pool was not able to spin up a
/// new thread. The thread pool will attempt to spin up a new thread after a delay, but if the current callback function runs long, the thread pool may
/// lose efficiency.
/// The function returns FALSE if another thread in the thread pool is not available to process callbacks and the thread pool was not
/// able to spin up a new thread. The thread pool will attempt to spin up a new thread after a delay, but if the current callback
/// function runs long, the thread pool may lose efficiency.
/// </para>
/// </returns>
// BOOL WINAPI CallbackMayRunLong( _Inout_ PTP_CALLBACK_INSTANCE pci); https://msdn.microsoft.com/en-us/library/windows/desktop/ms681981(v=vs.85).aspx
@ -112,7 +126,9 @@ namespace Vanara.PInvoke
public static extern bool CallbackMayRunLong(PTP_CALLBACK_INSTANCE pci);
/// <summary>Cancels the notification from the <c>StartThreadpoolIo</c> function.</summary>
/// <param name="pio">A <c>TP_IO</c> structure that defines the I/O completion object. The <c>CreateThreadpoolIo</c> function returns this structure.</param>
/// <param name="pio">
/// A <c>TP_IO</c> structure that defines the I/O completion object. The <c>CreateThreadpoolIo</c> function returns this structure.
/// </param>
/// <returns>This function does not return a value.</returns>
// VOID WINAPI CancelThreadpoolIo( _Inout_ PTP_IO pio); https://msdn.microsoft.com/en-us/library/windows/desktop/ms681983(v=vs.85).aspx
[DllImport(Lib.Kernel32, SetLastError = false, ExactSpelling = true)]
@ -120,7 +136,9 @@ namespace Vanara.PInvoke
public static extern void CancelThreadpoolIo(PTP_IO pio);
/// <summary>Closes the specified thread pool.</summary>
/// <param name="ptpp">A <c>TP_POOL</c> structure that defines the thread pool. The <c>CreateThreadpool</c> function returns this structure.</param>
/// <param name="ptpp">
/// A <c>TP_POOL</c> structure that defines the thread pool. The <c>CreateThreadpool</c> function returns this structure.
/// </param>
/// <returns>This function does not return a value.</returns>
// VOID WINAPI CloseThreadpool( _Inout_ PTP_POOL ptpp); https://msdn.microsoft.com/en-us/library/windows/desktop/ms682030(v=vs.85).aspx
[DllImport(Lib.Kernel32, SetLastError = false, ExactSpelling = true)]
@ -128,7 +146,9 @@ namespace Vanara.PInvoke
public static extern void CloseThreadpool(PTP_POOL ptpp);
/// <summary>Closes the specified cleanup group.</summary>
/// <param name="ptpcg">A <c>TP_CLEANUP_GROUP</c> structure that defines the cleanup group. The <c>CreateThreadpoolCleanupGroup</c> returns this structure.</param>
/// <param name="ptpcg">
/// A <c>TP_CLEANUP_GROUP</c> structure that defines the cleanup group. The <c>CreateThreadpoolCleanupGroup</c> returns this structure.
/// </param>
/// <returns>This function does not return a value.</returns>
// VOID WINAPI CloseThreadpoolCleanupGroup( _Inout_ PTP_CLEANUP_GROUP ptpcg); https://msdn.microsoft.com/en-us/library/windows/desktop/ms682033(v=vs.85).aspx
[DllImport(Lib.Kernel32, SetLastError = false, ExactSpelling = true)]
@ -136,27 +156,31 @@ namespace Vanara.PInvoke
public static extern void CloseThreadpoolCleanupGroup(PTP_CLEANUP_GROUP ptpcg);
/// <summary>
/// Releases the members of the specified cleanup group, waits for all callback functions to complete, and optionally cancels any outstanding callback functions.
/// Releases the members of the specified cleanup group, waits for all callback functions to complete, and optionally cancels any
/// outstanding callback functions.
/// </summary>
/// <param name="ptpcg">
/// A <c>TP_CLEANUP_GROUP</c> structure that defines the cleanup group. The <c>CreateThreadpoolCleanupGroup</c> function returns this structure.
/// </param>
/// <param name="fCancelPendingCallbacks">
/// If this parameter is TRUE, the function cancels outstanding callbacks that have not yet started. If this parameter is FALSE, the function waits for
/// outstanding callback functions to complete.
/// If this parameter is TRUE, the function cancels outstanding callbacks that have not yet started. If this parameter is FALSE, the
/// function waits for outstanding callback functions to complete.
/// </param>
/// <param name="pvCleanupContext">
/// The application-defined data to pass to the application's cleanup group callback function. You can specify the callback function when you call <c>SetThreadpoolCallbackCleanupGroup</c>.
/// The application-defined data to pass to the application's cleanup group callback function. You can specify the callback function
/// when you call <c>SetThreadpoolCallbackCleanupGroup</c>.
/// </param>
/// <returns>This function does not return a value.</returns>
// VOID WINAPI CloseThreadpoolCleanupGroupMembers( _Inout_ PTP_CLEANUP_GROUP ptpcg, _In_ BOOL fCancelPendingCallbacks, _Inout_opt_ PVOID
// pvCleanupContext); https://msdn.microsoft.com/en-us/library/windows/desktop/ms682036(v=vs.85).aspx
// VOID WINAPI CloseThreadpoolCleanupGroupMembers( _Inout_ PTP_CLEANUP_GROUP ptpcg, _In_ BOOL fCancelPendingCallbacks, _Inout_opt_
// PVOID pvCleanupContext); https://msdn.microsoft.com/en-us/library/windows/desktop/ms682036(v=vs.85).aspx
[DllImport(Lib.Kernel32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("WinBase.h", MSDNShortId = "ms682036")]
public static extern void CloseThreadpoolCleanupGroupMembers(PTP_CLEANUP_GROUP ptpcg, [MarshalAs(UnmanagedType.Bool)] bool fCancelPendingCallbacks, IntPtr pvCleanupContext);
/// <summary>Releases the specified I/O completion object.</summary>
/// <param name="pio">A <c>TP_IO</c> structure that defines the I/O completion object. The <c>CreateThreadpoolIo</c> function returns this structure.</param>
/// <param name="pio">
/// A <c>TP_IO</c> structure that defines the I/O completion object. The <c>CreateThreadpoolIo</c> function returns this structure.
/// </param>
/// <returns>This function does not return a value.</returns>
// VOID WINAPI CloseThreadpoolIo( _Inout_ PTP_IO pio); https://msdn.microsoft.com/en-us/library/windows/desktop/ms682038(v=vs.85).aspx
[DllImport(Lib.Kernel32, SetLastError = false, ExactSpelling = true)]
@ -164,7 +188,9 @@ namespace Vanara.PInvoke
public static extern void CloseThreadpoolIo(PTP_IO pio);
/// <summary>Releases the specified timer object.</summary>
/// <param name="pti">A <c>TP_TIMER</c> structure that defines the timer object. The <c>CreateThreadpoolTimer</c> function returns this structure.</param>
/// <param name="pti">
/// A <c>TP_TIMER</c> structure that defines the timer object. The <c>CreateThreadpoolTimer</c> function returns this structure.
/// </param>
/// <returns>This function does not return a value.</returns>
// VOID WINAPI CloseThreadpoolTimer( _Inout_ PTP_TIMER pti); https://msdn.microsoft.com/en-us/library/windows/desktop/ms682040(v=vs.85).aspx
[DllImport(Lib.Kernel32, SetLastError = false, ExactSpelling = true)]
@ -172,7 +198,9 @@ namespace Vanara.PInvoke
public static extern void CloseThreadpoolTimer(PTP_TIMER pti);
/// <summary>Releases the specified wait object.</summary>
/// <param name="pwa">A <c>TP_WAIT</c> structure that defines the wait object. The <c>CreateThreadpoolWait</c> function returns this structure.</param>
/// <param name="pwa">
/// A <c>TP_WAIT</c> structure that defines the wait object. The <c>CreateThreadpoolWait</c> function returns this structure.
/// </param>
/// <returns>This function does not return a value.</returns>
// VOID WINAPI CloseThreadpoolWait( _Inout_ PTP_WAIT pwa); https://msdn.microsoft.com/en-us/library/windows/desktop/ms682042(v=vs.85).aspx
[DllImport(Lib.Kernel32, SetLastError = false, ExactSpelling = true)]
@ -180,7 +208,9 @@ namespace Vanara.PInvoke
public static extern void CloseThreadpoolWait(PTP_WAIT pwa);
/// <summary>Releases the specified work object.</summary>
/// <param name="pwk">A <c>TP_WORK</c> structure that defines the work object. The <c>CreateThreadpoolWork</c> function returns this structure.</param>
/// <param name="pwk">
/// A <c>TP_WORK</c> structure that defines the work object. The <c>CreateThreadpoolWork</c> function returns this structure.
/// </param>
/// <returns>This function does not return a value.</returns>
// VOID WINAPI CloseThreadpoolWork( _Inout_ PTP_WORK pwk); https://msdn.microsoft.com/en-us/library/windows/desktop/ms682043(v=vs.85).aspx
[DllImport(Lib.Kernel32, SetLastError = false, ExactSpelling = true)]
@ -191,21 +221,21 @@ namespace Vanara.PInvoke
/// <param name="reserved">This parameter is reserved and must be NULL.</param>
/// <returns>
/// <para>
/// If the function succeeds, it returns a <c>TP_POOL</c> structure representing the newly allocated thread pool. Applications do not modify the members
/// of this structure.
/// If the function succeeds, it returns a <c>TP_POOL</c> structure representing the newly allocated thread pool. Applications do not
/// modify the members of this structure.
/// </para>
/// <para>If function fails, it returns NULL. To retrieve extended error information, call <c>GetLastError</c>.</para>
/// </returns>
// PTP_POOL WINAPI CreateThreadpool( _Reserved_ PVOID reserved); https://msdn.microsoft.com/en-us/library/windows/desktop/ms682456(v=vs.85).aspx
[DllImport(Lib.Kernel32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("WinBase.h", MSDNShortId = "ms682456")]
public static extern PTP_POOL CreateThreadpool(IntPtr reserved = default(IntPtr));
public static extern PTP_POOL CreateThreadpool(IntPtr reserved = default);
/// <summary>Creates a cleanup group that applications can use to track one or more thread pool callbacks.</summary>
/// <returns>
/// <para>
/// If the function succeeds, it returns a <c>TP_CLEANUP_GROUP</c> structure of the newly allocated cleanup group. Applications do not modify the members
/// of this structure.
/// If the function succeeds, it returns a <c>TP_CLEANUP_GROUP</c> structure of the newly allocated cleanup group. Applications do
/// not modify the members of this structure.
/// </para>
/// <para>If function fails, it returns NULL. To retrieve extended error information, call <c>GetLastError</c>.</para>
/// </returns>
@ -216,22 +246,26 @@ namespace Vanara.PInvoke
/// <summary>Creates a new I/O completion object.</summary>
/// <param name="fl">The file handle to bind to this I/O completion object.</param>
/// <param name="pfnio">The callback function to be called each time an overlapped I/O operation completes on the file. For details, see <c>IoCompletionCallback</c>.</param>
/// <param name="pfnio">
/// The callback function to be called each time an overlapped I/O operation completes on the file. For details, see <c>IoCompletionCallback</c>.
/// </param>
/// <param name="pv">Optional application-defined data to pass to the callback function.</param>
/// <param name="pcbe">
/// <para>
/// A <c>TP_CALLBACK_ENVIRON</c> structure that defines the environment in which to execute the callback. The <c>InitializeThreadpoolEnvironment</c>
/// function returns this structure.
/// A <c>TP_CALLBACK_ENVIRON</c> structure that defines the environment in which to execute the callback. The
/// <c>InitializeThreadpoolEnvironment</c> function returns this structure.
/// </para>
/// <para>If this parameter is NULL, the callback executes in the default callback environment. For more information, see <c>InitializeThreadpoolEnvironment</c>.</para>
/// </param>
/// <returns>
/// <para>
/// If the function succeeds, it returns a <c>TP_IO</c> structure that defines the I/O object. Applications do not modify the members of this structure.
/// If the function succeeds, it returns a <c>TP_IO</c> structure that defines the I/O object. Applications do not modify the members
/// of this structure.
/// </para>
/// <para>If the function fails, it returns NULL. To retrieve extended error information, call <c>GetLastError</c>.</para>
/// </returns>
// PTP_IO WINAPI CreateThreadpoolIo( _In_ HANDLE fl, _In_ PTP_WIN32_IO_CALLBACK pfnio, _Inout_opt_ PVOID pv, _In_opt_ PTP_CALLBACK_ENVIRON pcbe); https://msdn.microsoft.com/en-us/library/windows/desktop/ms682464(v=vs.85).aspx
// PTP_IO WINAPI CreateThreadpoolIo( _In_ HANDLE fl, _In_ PTP_WIN32_IO_CALLBACK pfnio, _Inout_opt_ PVOID pv, _In_opt_
// PTP_CALLBACK_ENVIRON pcbe); https://msdn.microsoft.com/en-us/library/windows/desktop/ms682464(v=vs.85).aspx
[DllImport(Lib.Kernel32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("WinBase.h", MSDNShortId = "ms682464")]
public static extern PTP_IO CreateThreadpoolIo(HFILE fl, PTP_WIN32_IO_CALLBACK pfnio, IntPtr pv, PTP_CALLBACK_ENVIRON pcbe);
@ -241,14 +275,15 @@ namespace Vanara.PInvoke
/// <param name="pv">Optional application-defined data to pass to the callback function.</param>
/// <param name="pcbe">
/// <para>
/// A <c>TP_CALLBACK_ENVIRON</c> structure that defines the environment in which to execute the callback. The <c>InitializeThreadpoolEnvironment</c>
/// function returns this structure.
/// A <c>TP_CALLBACK_ENVIRON</c> structure that defines the environment in which to execute the callback. The
/// <c>InitializeThreadpoolEnvironment</c> function returns this structure.
/// </para>
/// <para>If this parameter is NULL, the callback executes in the default callback environment. For more information, see <c>InitializeThreadpoolEnvironment</c>.</para>
/// </param>
/// <returns>
/// <para>
/// If the function succeeds, it returns a <c>TP_TIMER</c> structure that defines the timer object. Applications do not modify the members of this structure.
/// If the function succeeds, it returns a <c>TP_TIMER</c> structure that defines the timer object. Applications do not modify the
/// members of this structure.
/// </para>
/// <para>If the function fails, it returns NULL. To retrieve extended error information, call <c>GetLastError</c>.</para>
/// </returns>
@ -262,14 +297,15 @@ namespace Vanara.PInvoke
/// <param name="pv">Optional application-defined data to pass to the callback function.</param>
/// <param name="pcbe">
/// <para>
/// A <c>TP_CALLBACK_ENVIRON</c> structure that defines the environment in which to execute the callback. The <c>InitializeThreadpoolEnvironment</c>
/// function returns this structure.
/// A <c>TP_CALLBACK_ENVIRON</c> structure that defines the environment in which to execute the callback. The
/// <c>InitializeThreadpoolEnvironment</c> function returns this structure.
/// </para>
/// <para>If this parameter is NULL, the callback executes in the default callback environment. For more information, see <c>InitializeThreadpoolEnvironment</c>.</para>
/// </param>
/// <returns>
/// <para>
/// If the function succeeds, it returns a <c>TP_WAIT</c> structure that defines the wait object. Applications do not modify the members of this structure.
/// If the function succeeds, it returns a <c>TP_WAIT</c> structure that defines the wait object. Applications do not modify the
/// members of this structure.
/// </para>
/// <para>If the function fails, it returns NULL. To retrieve extended error information, call <c>GetLastError</c>.</para>
/// </returns>
@ -280,19 +316,21 @@ namespace Vanara.PInvoke
/// <summary>Creates a new work object.</summary>
/// <param name="pfnwk">
/// The callback function. A worker thread calls this callback each time you call <c>SubmitThreadpoolWork</c> to post the work object. For details, see <c>WorkCallback</c>.
/// The callback function. A worker thread calls this callback each time you call <c>SubmitThreadpoolWork</c> to post the work
/// object. For details, see <c>WorkCallback</c>.
/// </param>
/// <param name="pv">Optional application-defined data to pass to the callback function.</param>
/// <param name="pcbe">
/// <para>
/// A <c>TP_CALLBACK_ENVIRON</c> structure that defines the environment in which to execute the callback. The <c>InitializeThreadpoolEnvironment</c>
/// function returns this structure.
/// A <c>TP_CALLBACK_ENVIRON</c> structure that defines the environment in which to execute the callback. The
/// <c>InitializeThreadpoolEnvironment</c> function returns this structure.
/// </para>
/// <para>If this parameter is NULL, the callback executes in the default callback environment. For more information, see <c>InitializeThreadpoolEnvironment</c>.</para>
/// </param>
/// <returns>
/// <para>
/// If the function succeeds, it returns a <c>TP_WORK</c> structure that defines the work object. Applications do not modify the members of this structure.
/// If the function succeeds, it returns a <c>TP_WORK</c> structure that defines the work object. Applications do not modify the
/// members of this structure.
/// </para>
/// <para>If the function fails, it returns NULL. To retrieve extended error information, call <c>GetLastError</c>.</para>
/// </returns>
@ -302,10 +340,12 @@ namespace Vanara.PInvoke
public static extern PTP_WORK CreateThreadpoolWork(PTP_WORK_CALLBACK pfnwk, IntPtr pv, PTP_CALLBACK_ENVIRON pcbe);
/// <summary>
/// Removes the association between the currently executing callback function and the object that initiated the callback. The current thread will no
/// longer count as executing a callback on behalf of the object.
/// Removes the association between the currently executing callback function and the object that initiated the callback. The current
/// thread will no longer count as executing a callback on behalf of the object.
/// </summary>
/// <param name="pci">A <c>TP_CALLBACK_INSTANCE</c> structure that defines the callback instance. The structure is passed to the callback function.</param>
/// <param name="pci">
/// A <c>TP_CALLBACK_INSTANCE</c> structure that defines the callback instance. The structure is passed to the callback function.
/// </param>
/// <returns>This function does not return a value.</returns>
// VOID WINAPI DisassociateCurrentThreadFromCallback( _Inout_ PTP_CALLBACK_INSTANCE pci); https://msdn.microsoft.com/en-us/library/windows/desktop/ms682581(v=vs.85).aspx
[DllImport(Lib.Kernel32, SetLastError = false, ExactSpelling = true)]
@ -313,23 +353,27 @@ namespace Vanara.PInvoke
public static extern void DisassociateCurrentThreadFromCallback(PTP_CALLBACK_INSTANCE pci);
/// <summary>Specifies the DLL that the thread pool will unload when the current callback completes.</summary>
/// <param name="pci">A <c>TP_CALLBACK_INSTANCE</c> structure that defines the callback instance. The structure is passed to the callback function.</param>
/// <param name="pci">
/// A <c>TP_CALLBACK_INSTANCE</c> structure that defines the callback instance. The structure is passed to the callback function.
/// </param>
/// <param name="mod">A handle to the DLL.</param>
/// <returns>This function does not return a value.</returns>
// VOID WINAPI FreeLibraryWhenCallbackReturns( _Inout_ PTP_CALLBACK_INSTANCE pci, _In_ HMODULE mod); https://msdn.microsoft.com/en-us/library/windows/desktop/ms683154(v=vs.85).aspx
[DllImport(Lib.Kernel32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("WinBase.h", MSDNShortId = "ms683154")]
public static extern void FreeLibraryWhenCallbackReturns(PTP_CALLBACK_INSTANCE pci, IntPtr mod);
public static extern void FreeLibraryWhenCallbackReturns(PTP_CALLBACK_INSTANCE pci, HINSTANCE mod);
/// <summary>Initializes a callback environment.</summary>
/// <param name="pcbe">A <c>TP_CALLBACK_ENVIRON</c> structure that defines a callback environment.</param>
/// <returns>This function does not return a value.</returns>
// VOID InitializeThreadpoolEnvironment( _Out_ PTP_CALLBACK_ENVIRON pcbe); https://msdn.microsoft.com/en-us/library/windows/desktop/ms683486(v=vs.85).aspx
[PInvokeData("WinBase.h", MSDNShortId = "ms683486")]
public static void InitializeThreadpoolEnvironment(out PTP_CALLBACK_ENVIRON pcbe) { pcbe = new PTP_CALLBACK_ENVIRON(); }
public static void InitializeThreadpoolEnvironment(out PTP_CALLBACK_ENVIRON pcbe) => pcbe = new PTP_CALLBACK_ENVIRON();
/// <summary>Determines whether the specified timer object is currently set.</summary>
/// <param name="pti">A <c>TP_TIMER</c> structure that defines the timer object. The <c>CreateThreadpoolTimer</c> function returns this structure.</param>
/// <param name="pti">
/// A <c>TP_TIMER</c> structure that defines the timer object. The <c>CreateThreadpoolTimer</c> function returns this structure.
/// </param>
/// <returns>The return value is TRUE if the timer is set; otherwise, the return value is FALSE.</returns>
// BOOL WINAPI IsThreadpoolTimerSet( _Inout_ PTP_TIMER pti); https://msdn.microsoft.com/en-us/library/windows/desktop/ms684133(v=vs.85).aspx
[DllImport(Lib.Kernel32, SetLastError = false, ExactSpelling = true)]
@ -338,16 +382,20 @@ namespace Vanara.PInvoke
public static extern bool IsThreadpoolTimerSet(PTP_TIMER pti);
/// <summary>Specifies the critical section that the thread pool will release when the current callback completes.</summary>
/// <param name="pci">A <c>TP_CALLBACK_INSTANCE</c> structure that defines the callback instance. The structure is passed to the callback function.</param>
/// <param name="pci">
/// A <c>TP_CALLBACK_INSTANCE</c> structure that defines the callback instance. The structure is passed to the callback function.
/// </param>
/// <param name="pcs">The critical section.</param>
/// <returns>This function does not return a value.</returns>
// VOID WINAPI LeaveCriticalSectionWhenCallbackReturns( _Inout_ PTP_CALLBACK_INSTANCE pci, _Inout_ PCRITICAL_SECTION pcs); https://msdn.microsoft.com/en-us/library/windows/desktop/ms684171(v=vs.85).aspx
[DllImport(Lib.Kernel32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("WinBase.h", MSDNShortId = "ms684171")]
public static extern void LeaveCriticalSectionWhenCallbackReturns(PTP_CALLBACK_INSTANCE pci, IntPtr pcs);
public static extern void LeaveCriticalSectionWhenCallbackReturns(PTP_CALLBACK_INSTANCE pci, ref CRITICAL_SECTION pcs);
/// <summary>Retrieves the stack reserve and commit sizes for threads in the specified thread pool.</summary>
/// <param name="ptpp">A <c>TP_POOL</c> structure that specifies the thread pool. The <c>CreateThreadpool</c> function returns this structure.</param>
/// <param name="ptpp">
/// A <c>TP_POOL</c> structure that specifies the thread pool. The <c>CreateThreadpool</c> function returns this structure.
/// </param>
/// <param name="ptpsi">A <c>TP_POOL_STACK_INFORMATION</c> structure that receives the stack reserve and commit size.</param>
/// <returns>
/// <para>If the function succeeds, the return value is nonzero.</para>
@ -360,46 +408,54 @@ namespace Vanara.PInvoke
public static extern bool QueryThreadpoolStackInformation(PTP_POOL ptpp, out TP_POOL_STACK_INFORMATION ptpsi);
/// <summary>Specifies the mutex that the thread pool will release when the current callback completes.</summary>
/// <param name="pci">A <c>TP_CALLBACK_INSTANCE</c> structure that defines the callback instance. The structure is passed to the callback function.</param>
/// <param name="pci">
/// A <c>TP_CALLBACK_INSTANCE</c> structure that defines the callback instance. The structure is passed to the callback function.
/// </param>
/// <param name="mut">A handle to the mutex.</param>
/// <returns>This function does not return a value.</returns>
// VOID WINAPI ReleaseMutexWhenCallbackReturns( _Inout_ PTP_CALLBACK_INSTANCE pci, _In_ HANDLE mut); https://msdn.microsoft.com/en-us/library/windows/desktop/ms685070(v=vs.85).aspx
[DllImport(Lib.Kernel32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("WinBase.h", MSDNShortId = "ms685070")]
public static extern void ReleaseMutexWhenCallbackReturns(PTP_CALLBACK_INSTANCE pci, IntPtr mut);
public static extern void ReleaseMutexWhenCallbackReturns(PTP_CALLBACK_INSTANCE pci, SafeMutexHandle mut);
/// <summary>Specifies the semaphore that the thread pool will release when the current callback completes.</summary>
/// <param name="pci">A <c>TP_CALLBACK_INSTANCE</c> structure that defines the callback instance. The structure is passed to the callback function.</param>
/// <param name="pci">
/// A <c>TP_CALLBACK_INSTANCE</c> structure that defines the callback instance. The structure is passed to the callback function.
/// </param>
/// <param name="sem">A handle to the semaphore.</param>
/// <param name="crel">The amount by which to increment the semaphore object's count.</param>
/// <returns>This function does not return a value.</returns>
// VOID WINAPI ReleaseSemaphoreWhenCallbackReturns( _Inout_ PTP_CALLBACK_INSTANCE pci, _In_ HANDLE sem, _In_ DWORD crel); https://msdn.microsoft.com/en-us/library/windows/desktop/ms685073(v=vs.85).aspx
[DllImport(Lib.Kernel32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("WinBase.h", MSDNShortId = "ms685073")]
public static extern void ReleaseSemaphoreWhenCallbackReturns(PTP_CALLBACK_INSTANCE pci, IntPtr sem, uint crel);
public static extern void ReleaseSemaphoreWhenCallbackReturns(PTP_CALLBACK_INSTANCE pci, SafeSemaphoreHandle sem, uint crel);
/// <summary>Specifies the event that the thread pool will set when the current callback completes.</summary>
/// <param name="pci">A <c>TP_CALLBACK_INSTANCE</c> structure that defines the callback instance. The structure is passed to the callback function.</param>
/// <param name="pci">
/// A <c>TP_CALLBACK_INSTANCE</c> structure that defines the callback instance. The structure is passed to the callback function.
/// </param>
/// <param name="evt">A handle to the event to be set.</param>
/// <returns>This function does not return a value.</returns>
// VOID WINAPI SetEventWhenCallbackReturns( _Inout_ PTP_CALLBACK_INSTANCE pci, _In_ HANDLE evt); https://msdn.microsoft.com/en-us/library/windows/desktop/ms686214(v=vs.85).aspx
[DllImport(Lib.Kernel32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("WinBase.h", MSDNShortId = "ms686214")]
public static extern void SetEventWhenCallbackReturns(PTP_CALLBACK_INSTANCE pci, IntPtr evt);
public static extern void SetEventWhenCallbackReturns(PTP_CALLBACK_INSTANCE pci, SafeEventHandle evt);
/// <summary>Associates the specified cleanup group with the specified callback environment.</summary>
/// <param name="pcbe">
/// A <c>TP_CALLBACK_ENVIRON</c> structure that defines the callback environment. The <c>InitializeThreadpoolEnvironment</c> function returns this structure.
/// A <c>TP_CALLBACK_ENVIRON</c> structure that defines the callback environment. The <c>InitializeThreadpoolEnvironment</c> function
/// returns this structure.
/// </param>
/// <param name="ptpcg">
/// A <c>TP_CLEANUP_GROUP</c> structure that defines the cleanup group. The <c>CreateThreadpoolCleanupGroup</c> function returns this structure.
/// </param>
/// <param name="pfng">
/// The cleanup callback to be called if the cleanup group is canceled before the associated object is released. The function is called when you call <c>CloseThreadpoolCleanupGroupMembers</c>.
/// The cleanup callback to be called if the cleanup group is canceled before the associated object is released. The function is
/// called when you call <c>CloseThreadpoolCleanupGroupMembers</c>.
/// </param>
/// <returns>This function does not return a value.</returns>
// VOID SetThreadpoolCallbackCleanupGroup( _Inout_ PTP_CALLBACK_ENVIRON pcbe, _In_ PTP_CLEANUP_GROUP ptpcg, _In_opt_ PTP_CLEANUP_GROUP_CANCEL_CALLBACK pfng);
// https://msdn.microsoft.com/en-us/library/windows/desktop/ms686255(v=vs.85).aspx
// VOID SetThreadpoolCallbackCleanupGroup( _Inout_ PTP_CALLBACK_ENVIRON pcbe, _In_ PTP_CLEANUP_GROUP ptpcg, _In_opt_
// PTP_CLEANUP_GROUP_CANCEL_CALLBACK pfng); https://msdn.microsoft.com/en-us/library/windows/desktop/ms686255(v=vs.85).aspx
[PInvokeData("WinBase.h", MSDNShortId = "ms686255")]
public static void SetThreadpoolCallbackCleanupGroup(this PTP_CALLBACK_ENVIRON pcbe, PTP_CLEANUP_GROUP ptpcg, PTP_CLEANUP_GROUP_CANCEL_CALLBACK pfng)
{
@ -409,53 +465,94 @@ namespace Vanara.PInvoke
/// <summary>Ensures that the specified DLL remains loaded as long as there are outstanding callbacks.</summary>
/// <param name="pcbe">
/// A <c>TP_CALLBACK_ENVIRON</c> structure that defines the callback environment. The <c>InitializeThreadpoolEnvironment</c> function returns this structure.
/// A <c>TP_CALLBACK_ENVIRON</c> structure that defines the callback environment. The <c>InitializeThreadpoolEnvironment</c> function
/// returns this structure.
/// </param>
/// <param name="mod">A handle to the DLL.</param>
/// <returns>This function does not return a value.</returns>
// VOID SetThreadpoolCallbackLibrary( _Inout_ PTP_CALLBACK_ENVIRON pcbe, _In_ PVOID mod);
// https://msdn.microsoft.com/en-us/library/windows/desktop/ms686258(v=vs.85).aspx
// VOID SetThreadpoolCallbackLibrary( _Inout_ PTP_CALLBACK_ENVIRON pcbe, _In_ PVOID mod); https://msdn.microsoft.com/en-us/library/windows/desktop/ms686258(v=vs.85).aspx
[PInvokeData("WinBase.h", MSDNShortId = "ms686258")]
public static void SetThreadpoolCallbackLibrary(this PTP_CALLBACK_ENVIRON pcbe, IntPtr mod) { pcbe.RaceDll = mod; }
public static void SetThreadpoolCallbackLibrary(this PTP_CALLBACK_ENVIRON pcbe, HINSTANCE mod) => pcbe.RaceDll = mod;
/// <summary>Specifies that the callback should run on a persistent thread.</summary>
/// <param name="pcbe">
/// A <c>TP_CALLBACK_ENVIRON</c> structure that defines the callback environment. The <c>InitializeThreadpoolEnvironment</c> function returns this structure.
/// A <c>TP_CALLBACK_ENVIRON</c> structure that defines the callback environment. The <c>InitializeThreadpoolEnvironment</c> function
/// returns this structure.
/// </param>
/// <returns>This function does not return a value.</returns>
// VOID SetThreadpoolCallbackPersistent( _Inout_ PTP_CALLBACK_ENVIRON pcbe);
// https://msdn.microsoft.com/en-us/library/windows/desktop/dd405518(v=vs.85).aspx
// VOID SetThreadpoolCallbackPersistent( _Inout_ PTP_CALLBACK_ENVIRON pcbe); https://msdn.microsoft.com/en-us/library/windows/desktop/dd405518(v=vs.85).aspx
[PInvokeData("WinBase.h", MSDNShortId = "dd405518")]
public static void SetThreadpoolCallbackPersistent(this PTP_CALLBACK_ENVIRON pcbe) { pcbe.Flags |= TP_CALLBACK_ENV_FLAGS.Persistent; }
public static void SetThreadpoolCallbackPersistent(this PTP_CALLBACK_ENVIRON pcbe) => pcbe.Flags |= TP_CALLBACK_ENV_FLAGS.Persistent;
/// <summary>Sets the thread pool to be used when generating callbacks.</summary>
/// <param name="pcbe">
/// A <c>TP_CALLBACK_ENVIRON</c> structure that defines the callback environment. The <c>InitializeThreadpoolEnvironment</c> function returns this structure.
/// A <c>TP_CALLBACK_ENVIRON</c> structure that defines the callback environment. The <c>InitializeThreadpoolEnvironment</c> function
/// returns this structure.
/// </param>
/// <param name="ptpp">
/// A <c>TP_POOL</c> structure that defines the thread pool. The <c>CreateThreadpool</c> function returns this structure.
/// </param>
/// <param name="ptpp">A <c>TP_POOL</c> structure that defines the thread pool. The <c>CreateThreadpool</c> function returns this structure.</param>
/// <returns>This function does not return a value.</returns>
// VOID SetThreadpoolCallbackPool( _Inout_ PTP_CALLBACK_ENVIRON pcbe, _In_ PTP_POOL ptpp);
// https://msdn.microsoft.com/en-us/library/windows/desktop/ms686261(v=vs.85).aspx
// VOID SetThreadpoolCallbackPool( _Inout_ PTP_CALLBACK_ENVIRON pcbe, _In_ PTP_POOL ptpp); https://msdn.microsoft.com/en-us/library/windows/desktop/ms686261(v=vs.85).aspx
[PInvokeData("WinBase.h", MSDNShortId = "ms686261")]
public static void SetThreadpoolCallbackPool(this PTP_CALLBACK_ENVIRON pcbe, PTP_POOL ptpp) { pcbe.Pool = ptpp; }
public static void SetThreadpoolCallbackPool(this PTP_CALLBACK_ENVIRON pcbe, PTP_POOL ptpp) => pcbe.Pool = ptpp;
/// <summary>Specifies the priority of a callback function relative to other work items in the same thread pool.</summary><param name="pcbe">A <c>TP_CALLBACK_ENVIRON</c> structure that defines the callback environment. The <c>InitializeThreadpoolEnvironment</c> function returns this structure.</param><param name="Priority"><para>The priority for the callback relative to other callbacks in the same thread pool. This parameter can be one of the following <c>TP_CALLBACK_PRIORITY</c> enumeration values:</para><para><list type="table"><listheader><term>Value</term><term>Meaning</term></listheader><item><term>TP_CALLBACK_PRIORITY_HIGH</term><term>The callback should run at high priority. </term></item><item><term>TP_CALLBACK_PRIORITY_LOW</term><term>The callback should run at low priority.</term></item><item><term>TP_CALLBACK_PRIORITY_NORMAL</term><term>The callback should run at normal priority.</term></item></list></para></param><returns>This function does not return a value.</returns>
// VOID SetThreadpoolCallbackPriority( _Inout_ PTP_CALLBACK_ENVIRON pcbe, _In_ TP_CALLBACK_PRIORITY Priority);
// https://msdn.microsoft.com/en-us/library/windows/desktop/dd405519(v=vs.85).aspx
/// <summary>Specifies the priority of a callback function relative to other work items in the same thread pool.</summary>
/// <param name="pcbe">
/// A <c>TP_CALLBACK_ENVIRON</c> structure that defines the callback environment. The <c>InitializeThreadpoolEnvironment</c> function
/// returns this structure.
/// </param>
/// <param name="Priority">
/// <para>
/// The priority for the callback relative to other callbacks in the same thread pool. This parameter can be one of the following
/// <c>TP_CALLBACK_PRIORITY</c> enumeration values:
/// </para>
/// <para>
/// <list type="table">
/// <listheader>
/// <term>Value</term>
/// <term>Meaning</term>
/// </listheader>
/// <item>
/// <term>TP_CALLBACK_PRIORITY_HIGH</term>
/// <term>The callback should run at high priority.</term>
/// </item>
/// <item>
/// <term>TP_CALLBACK_PRIORITY_LOW</term>
/// <term>The callback should run at low priority.</term>
/// </item>
/// <item>
/// <term>TP_CALLBACK_PRIORITY_NORMAL</term>
/// <term>The callback should run at normal priority.</term>
/// </item>
/// </list>
/// </para>
/// </param>
/// <returns>This function does not return a value.</returns>
// VOID SetThreadpoolCallbackPriority( _Inout_ PTP_CALLBACK_ENVIRON pcbe, _In_ TP_CALLBACK_PRIORITY Priority); https://msdn.microsoft.com/en-us/library/windows/desktop/dd405519(v=vs.85).aspx
[PInvokeData("WinBase.h", MSDNShortId = "dd405519")]
public static void SetThreadpoolCallbackPriority(this PTP_CALLBACK_ENVIRON pcbe, TP_CALLBACK_PRIORITY Priority) { pcbe.CallbackPriority = Priority; }
public static void SetThreadpoolCallbackPriority(this PTP_CALLBACK_ENVIRON pcbe, TP_CALLBACK_PRIORITY Priority) => pcbe.CallbackPriority = Priority;
/// <summary>Indicates that callbacks associated with this callback environment may not return quickly.</summary><param name="pcbe">A <c>TP_CALLBACK_ENVIRON</c> structure that defines the callback environment. The <c>InitializeThreadpoolEnvironment</c> function returns this structure.</param><returns>This function does not return a value.</returns>
// VOID SetThreadpoolCallbackRunsLong( _Inout_ PTP_CALLBACK_ENVIRON pcbe);
// https://msdn.microsoft.com/en-us/library/windows/desktop/ms686263(v=vs.85).aspx
/// <summary>Indicates that callbacks associated with this callback environment may not return quickly.</summary>
/// <param name="pcbe">
/// A <c>TP_CALLBACK_ENVIRON</c> structure that defines the callback environment. The <c>InitializeThreadpoolEnvironment</c> function
/// returns this structure.
/// </param>
/// <returns>This function does not return a value.</returns>
// VOID SetThreadpoolCallbackRunsLong( _Inout_ PTP_CALLBACK_ENVIRON pcbe); https://msdn.microsoft.com/en-us/library/windows/desktop/ms686263(v=vs.85).aspx
[PInvokeData("WinBase.h", MSDNShortId = "ms686263")]
public static void SetThreadpoolCallbackRunsLong(this PTP_CALLBACK_ENVIRON pcbe) { pcbe.Flags |= TP_CALLBACK_ENV_FLAGS.LongFunction; }
public static void SetThreadpoolCallbackRunsLong(this PTP_CALLBACK_ENVIRON pcbe) => pcbe.Flags |= TP_CALLBACK_ENV_FLAGS.LongFunction;
/// <summary>
/// Sets the stack reserve and commit sizes for new threads in the specified thread pool. Stack reserve and commit sizes for existing threads are not changed.
/// Sets the stack reserve and commit sizes for new threads in the specified thread pool. Stack reserve and commit sizes for existing
/// threads are not changed.
/// </summary>
/// <param name="ptpp">A <c>TP_POOL</c> structure that specifies the thread pool. The <c>CreateThreadpool</c> function returns this structure.</param>
/// <param name="ptpsi">A <c>TP_POOL_STACK_INFORMATION</c> structure that specifies the stack reserve and commit size for threads in the pool.</param>
/// <param name="ptpp">
/// A <c>TP_POOL</c> structure that specifies the thread pool. The <c>CreateThreadpool</c> function returns this structure.
/// </param>
/// <param name="ptpsi">
/// A <c>TP_POOL_STACK_INFORMATION</c> structure that specifies the stack reserve and commit size for threads in the pool.
/// </param>
/// <returns>
/// <para>If the function succeeds, the return value is nonzero.</para>
/// <para>If the function fails, the return value is zero. To get extended error information, call <c>GetLastError</c>.</para>
@ -464,10 +561,12 @@ namespace Vanara.PInvoke
[DllImport(Lib.Kernel32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("WinBase.h", MSDNShortId = "dd405520")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SetThreadpoolStackInformation(PTP_POOL ptpp, ref TP_POOL_STACK_INFORMATION ptpsi);
public static extern bool SetThreadpoolStackInformation(PTP_POOL ptpp, in TP_POOL_STACK_INFORMATION ptpsi);
/// <summary>Sets the maximum number of threads that the specified thread pool can allocate to process callbacks.</summary>
/// <param name="ptpp">A <c>TP_POOL</c> structure that defines the thread pool. The <c>CreateThreadpool</c> function returns this structure.</param>
/// <param name="ptpp">
/// A <c>TP_POOL</c> structure that defines the thread pool. The <c>CreateThreadpool</c> function returns this structure.
/// </param>
/// <param name="cthrdMost">The maximum number of threads.</param>
/// <returns>This function does not return a value.</returns>
// VOID WINAPI SetThreadpoolThreadMaximum( _Inout_ PTP_POOL ptpp, _In_ DWORD cthrdMost); https://msdn.microsoft.com/en-us/library/windows/desktop/ms686266(v=vs.85).aspx
@ -476,7 +575,9 @@ namespace Vanara.PInvoke
public static extern void SetThreadpoolThreadMaximum(PTP_POOL ptpp, uint cthrdMost);
/// <summary>Sets the minimum number of threads that the specified thread pool must make available to process callbacks.</summary>
/// <param name="ptpp">A <c>TP_POOL</c> structure that defines the thread pool. The <c>CreateThreadpool</c> function returns this structure.</param>
/// <param name="ptpp">
/// A <c>TP_POOL</c> structure that defines the thread pool. The <c>CreateThreadpool</c> function returns this structure.
/// </param>
/// <param name="cthrdMic">The minimum number of threads.</param>
/// <returns>
/// <para>If the function succeeds, it returns TRUE.</para>
@ -489,89 +590,101 @@ namespace Vanara.PInvoke
public static extern bool SetThreadpoolThreadMinimum(PTP_POOL ptpp, uint cthrdMic);
/// <summary>
/// Sets the timer object—, replacing the previous timer, if any. A worker thread calls the timer object's callback after the specified timeout expires.
/// Sets the timer object—, replacing the previous timer, if any. A worker thread calls the timer object's callback after the
/// specified timeout expires.
/// </summary>
/// <param name="pti">
/// A pointer to a <c>TP_TIMER</c> structure that defines the timer object to set. The <c>CreateThreadpoolTimer</c> function returns this structure.
/// A pointer to a <c>TP_TIMER</c> structure that defines the timer object to set. The <c>CreateThreadpoolTimer</c> function returns
/// this structure.
/// </param>
/// <param name="pftDueTime">
/// <para>
/// A pointer to a <c>FILETIME</c> structure that specifies the absolute or relative time at which the timer should expire. If positive or zero, it
/// indicates the absolute time since January 1, 1601 (UTC), measured in 100 nanosecond units. If negative, it indicates the amount of time to wait
/// relative to the current time. For more information about time values, see File Times.
/// A pointer to a <c>FILETIME</c> structure that specifies the absolute or relative time at which the timer should expire. If
/// positive or zero, it indicates the absolute time since January 1, 1601 (UTC), measured in 100 nanosecond units. If negative, it
/// indicates the amount of time to wait relative to the current time. For more information about time values, see File Times.
/// </para>
/// <para>
/// If this parameter is NULL, the timer object will cease to queue new callbacks (but callbacks already queued will still occur). Note that if this
/// parameter is zero, the timer will expire immediately.
/// If this parameter is NULL, the timer object will cease to queue new callbacks (but callbacks already queued will still occur).
/// Note that if this parameter is zero, the timer will expire immediately.
/// </para>
/// </param>
/// <param name="msPeriod">
/// The timer period, in milliseconds. If this parameter is zero, the timer is signaled once. If this parameter is greater than zero, the timer is
/// periodic. A periodic timer automatically reactivates each time the period elapses, until the timer is canceled.
/// The timer period, in milliseconds. If this parameter is zero, the timer is signaled once. If this parameter is greater than zero,
/// the timer is periodic. A periodic timer automatically reactivates each time the period elapses, until the timer is canceled.
/// </param>
/// <param name="msWindowLength">
/// The maximum amount of time the system can delay before calling the timer callback. If this parameter is set, the system can batch calls to conserve power.
/// The maximum amount of time the system can delay before calling the timer callback. If this parameter is set, the system can batch
/// calls to conserve power.
/// </param>
/// <returns>This function does not return a value.</returns>
// VOID WINAPI SetThreadpoolTimer( _Inout_ PTP_TIMER pti, _In_opt_ PFILETIME pftDueTime, _In_ DWORD msPeriod, _In_opt_ DWORD msWindowLength); https://msdn.microsoft.com/en-us/library/windows/desktop/ms686271(v=vs.85).aspx
// VOID WINAPI SetThreadpoolTimer( _Inout_ PTP_TIMER pti, _In_opt_ PFILETIME pftDueTime, _In_ DWORD msPeriod, _In_opt_ DWORD
// msWindowLength); https://msdn.microsoft.com/en-us/library/windows/desktop/ms686271(v=vs.85).aspx
[DllImport(Lib.Kernel32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("WinBase.h", MSDNShortId = "ms686271")]
public static extern void SetThreadpoolTimer(PTP_TIMER pti, ref FILETIME pftDueTime, uint msPeriod, uint msWindowLength);
public static extern void SetThreadpoolTimer(PTP_TIMER pti, in FILETIME pftDueTime, uint msPeriod, uint msWindowLength);
/// <summary>
/// Sets the timer object—, replacing the previous timer, if any. A worker thread calls the timer object's callback after the specified timeout expires.
/// Sets the timer object—, replacing the previous timer, if any. A worker thread calls the timer object's callback after the
/// specified timeout expires.
/// </summary>
/// <param name="pti">
/// A pointer to a <c>TP_TIMER</c> structure that defines the timer object to set. The <c>CreateThreadpoolTimer</c> function returns this structure.
/// A pointer to a <c>TP_TIMER</c> structure that defines the timer object to set. The <c>CreateThreadpoolTimer</c> function returns
/// this structure.
/// </param>
/// <param name="pftDueTime">
/// <para>
/// A pointer to a <c>FILETIME</c> structure that specifies the absolute or relative time at which the timer should expire. If positive or zero, it
/// indicates the absolute time since January 1, 1601 (UTC), measured in 100 nanosecond units. If negative, it indicates the amount of time to wait
/// relative to the current time. For more information about time values, see File Times.
/// A pointer to a <c>FILETIME</c> structure that specifies the absolute or relative time at which the timer should expire. If
/// positive or zero, it indicates the absolute time since January 1, 1601 (UTC), measured in 100 nanosecond units. If negative, it
/// indicates the amount of time to wait relative to the current time. For more information about time values, see File Times.
/// </para>
/// <para>
/// If this parameter is NULL, the timer object will cease to queue new callbacks (but callbacks already queued will still occur). Note that if this
/// parameter is zero, the timer will expire immediately.
/// If this parameter is NULL, the timer object will cease to queue new callbacks (but callbacks already queued will still occur).
/// Note that if this parameter is zero, the timer will expire immediately.
/// </para>
/// </param>
/// <param name="msPeriod">
/// The timer period, in milliseconds. If this parameter is zero, the timer is signaled once. If this parameter is greater than zero, the timer is
/// periodic. A periodic timer automatically reactivates each time the period elapses, until the timer is canceled.
/// The timer period, in milliseconds. If this parameter is zero, the timer is signaled once. If this parameter is greater than zero,
/// the timer is periodic. A periodic timer automatically reactivates each time the period elapses, until the timer is canceled.
/// </param>
/// <param name="msWindowLength">
/// The maximum amount of time the system can delay before calling the timer callback. If this parameter is set, the system can batch calls to conserve power.
/// The maximum amount of time the system can delay before calling the timer callback. If this parameter is set, the system can batch
/// calls to conserve power.
/// </param>
/// <returns>
/// If the timer was previously active and was canceled, a value of TRUE is returned. Otherwise a value of FALSE is returned. If FALSE is returned, a
/// callback may be in progress or about to commence. If this is the case, a subsequent SetThreadpoolTimerEx operation will be properly synchronized with
/// completion of the timer callback.
/// If the timer was previously active and was canceled, a value of TRUE is returned. Otherwise a value of FALSE is returned. If
/// FALSE is returned, a callback may be in progress or about to commence. If this is the case, a subsequent SetThreadpoolTimerEx
/// operation will be properly synchronized with completion of the timer callback.
/// </returns>
// https://msdn.microsoft.com/en-us/library/windows/desktop/dn894018(v=vs.85).aspx
[DllImport(Lib.Kernel32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("Threadpoolapiset.h", MSDNShortId = "dn894018")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SetThreadpoolTimerEx(PTP_TIMER pti, ref FILETIME pftDueTime, uint msPeriod, uint msWindowLength);
public static extern bool SetThreadpoolTimerEx(PTP_TIMER pti, in FILETIME pftDueTime, uint msPeriod, uint msWindowLength);
/// <summary>
/// Sets the wait object—replacing the previous wait object, if any. A worker thread calls the wait object's callback function after the handle becomes
/// signaled or after the specified timeout expires.
/// Sets the wait object—replacing the previous wait object, if any. A worker thread calls the wait object's callback function after
/// the handle becomes signaled or after the specified timeout expires.
/// </summary>
/// <param name="pwa">A pointer to a <c>TP_WAIT</c> structure that defines the wait object. The <c>CreateThreadpoolWait</c> function returns this structure.</param>
/// <param name="pwa">
/// A pointer to a <c>TP_WAIT</c> structure that defines the wait object. The <c>CreateThreadpoolWait</c> function returns this structure.
/// </param>
/// <param name="h">
/// <para>A handle.</para>
/// <para>If this parameter is NULL, the wait object will cease to queue new callbacks (but callbacks already queued will still occur).</para>
/// <para>
/// If this parameter is NULL, the wait object will cease to queue new callbacks (but callbacks already queued will still occur).
/// </para>
/// <para>If this parameter is not NULL, it must refer to a valid waitable object.</para>
/// <para>
/// If this handle is closed while the wait is still pending, the function's behavior is undefined. If the wait is still pending and the handle must be
/// closed, use <c>CloseThreadpoolWait</c> to cancel the wait and then close the handle.
/// If this handle is closed while the wait is still pending, the function's behavior is undefined. If the wait is still pending and
/// the handle must be closed, use <c>CloseThreadpoolWait</c> to cancel the wait and then close the handle.
/// </para>
/// </param>
/// <param name="pftTimeout">
/// <para>
/// A pointer to a <c>FILETIME</c> structure that specifies the absolute or relative time at which the wait operation should time out. If this parameter
/// points to a positive value, it indicates the absolute time since January 1, 1601 (UTC), in 100-nanosecond intervals. If this parameter points to a
/// negative value, it indicates the amount of time to wait relative to the current time. For more information about time values, see File Times.
/// A pointer to a <c>FILETIME</c> structure that specifies the absolute or relative time at which the wait operation should time
/// out. If this parameter points to a positive value, it indicates the absolute time since January 1, 1601 (UTC), in 100-nanosecond
/// intervals. If this parameter points to a negative value, it indicates the amount of time to wait relative to the current time.
/// For more information about time values, see File Times.
/// </para>
/// <para>If this parameter points to 0, the wait times out immediately. If this parameter is NULL, the wait will not time out.</para>
/// </param>
@ -579,45 +692,54 @@ namespace Vanara.PInvoke
// VOID WINAPI SetThreadpoolWait( _Inout_ PTP_WAIT pwa, _In_opt_ HANDLE h, _In_opt_ PFILETIME pftTimeout); https://msdn.microsoft.com/en-us/library/windows/desktop/ms686273(v=vs.85).aspx
[DllImport(Lib.Kernel32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("WinBase.h", MSDNShortId = "ms686273")]
public static extern void SetThreadpoolWait(PTP_WAIT pwa, IntPtr h, ref FILETIME pftTimeout);
public static extern void SetThreadpoolWait(PTP_WAIT pwa, SafeEventHandle h, in FILETIME pftTimeout);
/// <summary>
/// Sets the wait object—replacing the previous wait object, if any. A worker thread calls the wait object's callback function after the handle becomes
/// signaled or after the specified timeout expires.
/// Sets the wait object—replacing the previous wait object, if any. A worker thread calls the wait object's callback function after
/// the handle becomes signaled or after the specified timeout expires.
/// </summary>
/// <param name="pwa">A pointer to a <c>TP_WAIT</c> structure that defines the wait object. The <c>CreateThreadpoolWait</c> function returns this structure.</param>
/// <param name="pwa">
/// A pointer to a <c>TP_WAIT</c> structure that defines the wait object. The <c>CreateThreadpoolWait</c> function returns this structure.
/// </param>
/// <param name="h">
/// <para>A handle.</para>
/// <para>If this parameter is NULL, the wait object will cease to queue new callbacks (but callbacks already queued will still occur).</para>
/// <para>
/// If this parameter is NULL, the wait object will cease to queue new callbacks (but callbacks already queued will still occur).
/// </para>
/// <para>If this parameter is not NULL, it must refer to a valid waitable object.</para>
/// <para>
/// If this handle is closed while the wait is still pending, the function's behavior is undefined. If the wait is still pending and the handle must be
/// closed, use <c>CloseThreadpoolWait</c> to cancel the wait and then close the handle.
/// If this handle is closed while the wait is still pending, the function's behavior is undefined. If the wait is still pending and
/// the handle must be closed, use <c>CloseThreadpoolWait</c> to cancel the wait and then close the handle.
/// </para>
/// </param>
/// <param name="pftTimeout">
/// A pointer to a <c>FILETIME</c> structure that specifies the absolute or relative time at which the wait operation should time out. If this parameter
/// points to a positive value, it indicates the absolute time since January 1, 1601 (UTC), in 100-nanosecond intervals. If this parameter points to a
/// negative value, it indicates the amount of time to wait relative to the current time. For more information about time values, see File Times.
/// A pointer to a <c>FILETIME</c> structure that specifies the absolute or relative time at which the wait operation should time
/// out. If this parameter points to a positive value, it indicates the absolute time since January 1, 1601 (UTC), in 100-nanosecond
/// intervals. If this parameter points to a negative value, it indicates the amount of time to wait relative to the current time.
/// For more information about time values, see File Times.
/// </param>
/// <param name="Reserved">Reserved.</param>
/// <returns>
/// TRUE, if the timer was previously active and was canceled; otherwise, FALSE. This return value can be used to maintain reference counts to
/// synchronize between completion and cancellation of a non-periodic timer operation. If FALSE is returned, a callback may be in progress or about to
/// commence. If FALSE is returned, a subsequent <c>WaitForThreadpool</c> or <c>WaitForThreadpoolEx</c> Callback operation will complete after that
/// callback is completed. A subsequent <c>SetThreadpool</c> or <c>SetThreadpoolEx</c> operation that is not later canceled will result in an additional callback.”
/// TRUE, if the timer was previously active and was canceled; otherwise, FALSE. This return value can be used to maintain reference
/// counts to synchronize between completion and cancellation of a non-periodic timer operation. If FALSE is returned, a callback may
/// be in progress or about to commence. If FALSE is returned, a subsequent <c>WaitForThreadpool</c> or <c>WaitForThreadpoolEx</c>
/// Callback operation will complete after that callback is completed. A subsequent <c>SetThreadpool</c> or <c>SetThreadpoolEx</c>
/// operation that is not later canceled will result in an additional callback.”
/// </returns>
// BOOL WINAPI SetThreadpoolWaitEx( _Inout_ PTP_WAIT pwa, _In_opt_ HANDLE h, _In_opt_ PFILETIME pftTimeout, _Reserved_ PVOID Reserved); https://msdn.microsoft.com/en-us/library/windows/desktop/mt186618(v=vs.85).aspx
// BOOL WINAPI SetThreadpoolWaitEx( _Inout_ PTP_WAIT pwa, _In_opt_ HANDLE h, _In_opt_ PFILETIME pftTimeout, _Reserved_ PVOID
// Reserved); https://msdn.microsoft.com/en-us/library/windows/desktop/mt186618(v=vs.85).aspx
[DllImport(Lib.Kernel32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("Threadpoolapiset.h", MSDNShortId = "mt186618")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SetThreadpoolWaitEx(PTP_WAIT pwa, IntPtr h, ref FILETIME pftTimeout, IntPtr Reserved);
public static extern bool SetThreadpoolWaitEx(PTP_WAIT pwa, IntPtr h, in FILETIME pftTimeout, IntPtr Reserved = default);
/// <summary>
/// Notifies the thread pool that I/O operations may possibly begin for the specified I/O completion object. A worker thread calls the I/O completion
/// object's callback function after the operation completes on the file handle bound to this object.
/// Notifies the thread pool that I/O operations may possibly begin for the specified I/O completion object. A worker thread calls
/// the I/O completion object's callback function after the operation completes on the file handle bound to this object.
/// </summary>
/// <param name="pio">A <c>TP_IO</c> structure that defines the I/O completion object. The <c>CreateThreadpoolIo</c> function returns this structure.</param>
/// <param name="pio">
/// A <c>TP_IO</c> structure that defines the I/O completion object. The <c>CreateThreadpoolIo</c> function returns this structure.
/// </param>
/// <returns>This function does not return a value.</returns>
// VOID WINAPI StartThreadpoolIo( _Inout_ PTP_IO pio); https://msdn.microsoft.com/en-us/library/windows/desktop/ms686326(v=vs.85).aspx
[DllImport(Lib.Kernel32, SetLastError = false, ExactSpelling = true)]
@ -625,7 +747,9 @@ namespace Vanara.PInvoke
public static extern void StartThreadpoolIo(PTP_IO pio);
/// <summary>Posts a work object to the thread pool. A worker thread calls the work object's callback function.</summary>
/// <param name="pwk">A <c>TP_WORK</c> structure that defines the work object. The <c>CreateThreadpoolWork</c> function returns this structure.</param>
/// <param name="pwk">
/// A <c>TP_WORK</c> structure that defines the work object. The <c>CreateThreadpoolWork</c> function returns this structure.
/// </param>
/// <returns>This function does not return a value.</returns>
// VOID WINAPI SubmitThreadpoolWork( _Inout_ PTP_WORK pwk); https://msdn.microsoft.com/en-us/library/windows/desktop/ms686338(v=vs.85).aspx
[DllImport(Lib.Kernel32, SetLastError = false, ExactSpelling = true)]
@ -652,8 +776,12 @@ namespace Vanara.PInvoke
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool TrySubmitThreadpoolCallback(PTP_SIMPLE_CALLBACK pfns, IntPtr pv, PTP_CALLBACK_ENVIRON pcbe);
/// <summary>Waits for outstanding I/O completion callbacks to complete and optionally cancels pending callbacks that have not yet started to execute.</summary>
/// <param name="pio">A <c>TP_IO</c> structure that defines the I/O completion object. The <c>CreateThreadpoolIo</c> function returns this structure.</param>
/// <summary>
/// Waits for outstanding I/O completion callbacks to complete and optionally cancels pending callbacks that have not yet started to execute.
/// </summary>
/// <param name="pio">
/// A <c>TP_IO</c> structure that defines the I/O completion object. The <c>CreateThreadpoolIo</c> function returns this structure.
/// </param>
/// <param name="fCancelPendingCallbacks">Indicates whether to cancel queued callbacks that have not yet started to execute.</param>
/// <returns>This function does not return a value.</returns>
// VOID WINAPI WaitForThreadpoolIoCallbacks( _Inout_ PTP_IO pio, _In_ BOOL fCancelPendingCallbacks); https://msdn.microsoft.com/en-us/library/windows/desktop/ms687038(v=vs.85).aspx
@ -661,7 +789,9 @@ namespace Vanara.PInvoke
[PInvokeData("WinBase.h", MSDNShortId = "ms687038")]
public static extern void WaitForThreadpoolIoCallbacks(PTP_IO pio, [MarshalAs(UnmanagedType.Bool)] bool fCancelPendingCallbacks);
/// <summary>Waits for outstanding timer callbacks to complete and optionally cancels pending callbacks that have not yet started to execute.</summary>
/// <summary>
/// Waits for outstanding timer callbacks to complete and optionally cancels pending callbacks that have not yet started to execute.
/// </summary>
/// <param name="pti">
/// A <c>TP_TIMER</c> structure that defines the timer object. The <c>CreateThreadpoolTimer</c> function returns the <c>TP_TIMER</c> structure.
/// </param>
@ -672,7 +802,9 @@ namespace Vanara.PInvoke
[PInvokeData("WinBase.h", MSDNShortId = "ms687042")]
public static extern void WaitForThreadpoolTimerCallbacks(PTP_TIMER pti, [MarshalAs(UnmanagedType.Bool)] bool fCancelPendingCallbacks);
/// <summary>Waits for outstanding wait callbacks to complete and optionally cancels pending callbacks that have not yet started to execute.</summary>
/// <summary>
/// Waits for outstanding wait callbacks to complete and optionally cancels pending callbacks that have not yet started to execute.
/// </summary>
/// <param name="pwa">
/// A <c>TP_WAIT</c> structure that defines the wait object. The <c>CreateThreadpoolWait</c> function returns the <c>TP_WAIT</c> structure.
/// </param>
@ -683,8 +815,12 @@ namespace Vanara.PInvoke
[PInvokeData("WinBase.h", MSDNShortId = "ms687047")]
public static extern void WaitForThreadpoolWaitCallbacks(PTP_WAIT pwa, [MarshalAs(UnmanagedType.Bool)] bool fCancelPendingCallbacks);
/// <summary>Waits for outstanding work callbacks to complete and optionally cancels pending callbacks that have not yet started to execute.</summary>
/// <param name="pwk">A <c>TP_WORK</c> structure that defines the work object. The <c>CreateThreadpoolWork</c> function returns this structure.</param>
/// <summary>
/// Waits for outstanding work callbacks to complete and optionally cancels pending callbacks that have not yet started to execute.
/// </summary>
/// <param name="pwk">
/// A <c>TP_WORK</c> structure that defines the work object. The <c>CreateThreadpoolWork</c> function returns this structure.
/// </param>
/// <param name="fCancelPendingCallbacks">Indicates whether to cancel queued callbacks that have not yet started to execute.</param>
/// <returns>This function does not return a value.</returns>
// VOID WINAPI WaitForThreadpoolWorkCallbacks( _Inout_ PTP_WORK pwk, _In_ BOOL fCancelPendingCallbacks); https://msdn.microsoft.com/en-us/library/windows/desktop/ms687053(v=vs.85).aspx
@ -692,6 +828,48 @@ namespace Vanara.PInvoke
[PInvokeData("WinBase.h", MSDNShortId = "ms687053")]
public static extern void WaitForThreadpoolWorkCallbacks(PTP_WORK pwk, [MarshalAs(UnmanagedType.Bool)] bool fCancelPendingCallbacks);
[StructLayout(LayoutKind.Sequential)]
public struct PTP_CALLBACK_INSTANCE
{
private readonly IntPtr handle;
}
[StructLayout(LayoutKind.Sequential)]
public struct PTP_CLEANUP_GROUP
{
private readonly IntPtr handle;
}
[StructLayout(LayoutKind.Sequential)]
public struct PTP_IO
{
private readonly IntPtr handle;
}
[StructLayout(LayoutKind.Sequential)]
public struct PTP_POOL
{
private readonly IntPtr handle;
}
[StructLayout(LayoutKind.Sequential)]
public struct PTP_TIMER
{
private readonly IntPtr handle;
}
[StructLayout(LayoutKind.Sequential)]
public struct PTP_WAIT
{
private readonly IntPtr handle;
}
[StructLayout(LayoutKind.Sequential)]
public struct PTP_WORK
{
private readonly IntPtr handle;
}
/// <summary>Used to set the stack reserve and commit sizes for new threads in a thread pool.</summary>
[PInvokeData("threadpoolapiset.h")]
[StructLayout(LayoutKind.Sequential)]
@ -699,11 +877,12 @@ namespace Vanara.PInvoke
{
/// <summary>The stack reserve size.</summary>
public SizeT StackReserve;
/// <summary>The stack commit size.</summary>
public SizeT StackCommit;
}
/// <summary>Defines a callback environment.</summary>
/// <summary>Defines a callback environment.</summary>`
[PInvokeData("threadpoolapiset.h")]
[StructLayout(LayoutKind.Sequential)]
public class PTP_CALLBACK_ENVIRON
@ -712,8 +891,8 @@ namespace Vanara.PInvoke
internal PTP_POOL Pool;
internal PTP_CLEANUP_GROUP CleanupGroup;
internal PTP_CLEANUP_GROUP_CANCEL_CALLBACK CleanupGroupCancelCallback;
internal IntPtr RaceDll;
internal IntPtr _ActivationContext;
internal HINSTANCE RaceDll;
internal HACTCTX _ActivationContext;
internal PTP_SIMPLE_CALLBACK _FinalizationCallback;
internal TP_CALLBACK_ENV_FLAGS Flags;
internal TP_CALLBACK_PRIORITY CallbackPriority;
@ -736,7 +915,7 @@ namespace Vanara.PInvoke
/// <summary>Assigns an activation context to the callback environment.</summary>
/// <value>Pointer to an _ACTIVATION_CONTEXT structure.</value>
public ActCtxSafeHandle ActivationContext { set => _ActivationContext = value.DangerousGetHandle(); }
public HACTCTX ActivationContext { set => _ActivationContext = value; }
}
}
}

View File

@ -1,5 +1,4 @@
using Microsoft.Win32.SafeHandles;
using System;
using System;
using System.Runtime.InteropServices;
namespace Vanara.PInvoke
@ -7,14 +6,15 @@ namespace Vanara.PInvoke
public static partial class Kernel32
{
/// <summary>
/// An application-defined function that serves as the starting address for a timer callback or a registered wait callback. Specify this address when
/// calling the CreateTimerQueueTimer, RegisterWaitForSingleObject function.
/// An application-defined function that serves as the starting address for a timer callback or a registered wait callback. Specify
/// this address when calling the CreateTimerQueueTimer, RegisterWaitForSingleObject function.
/// </summary>
/// <param name="lpParameter">
/// The thread data passed to the function using a parameter of the CreateTimerQueueTimer or RegisterWaitForSingleObject function.
/// </param>
/// <param name="TimerOrWaitFired">
/// If this parameter is TRUE, the wait timed out. If this parameter is FALSE, the wait event has been signaled. (This parameter is always TRUE for timer callbacks.)
/// If this parameter is TRUE, the wait timed out. If this parameter is FALSE, the wait event has been signaled. (This parameter is
/// always TRUE for timer callbacks.)
/// </param>
// https://msdn.microsoft.com/en-us/library/windows/desktop/ms687066(v=vs.85).aspx
[PInvokeData("WinBase.h", MSDNShortId = "ms687066")]
@ -27,59 +27,76 @@ namespace Vanara.PInvoke
/// <summary>
/// By default, the callback function is queued to a non-I/O worker thread.
/// <para>
/// The callback function is queued to a thread that uses I/O completion ports, which means they cannot perform an alertable wait. Therefore, if I/O
/// completes and generates an APC, the APC might wait indefinitely because there is no guarantee that the thread will enter an alertable wait state
/// after the callback completes.
/// The callback function is queued to a thread that uses I/O completion ports, which means they cannot perform an alertable
/// wait. Therefore, if I/O completes and generates an APC, the APC might wait indefinitely because there is no guarantee that
/// the thread will enter an alertable wait state after the callback completes.
/// </para>
/// </summary>
WT_EXECUTEDEFAULT = 0x00000000,
/// <summary>
/// This flag is not used.
/// <para>
/// Windows Server 2003 and Windows XP: The callback function is queued to an I/O worker thread. This flag should be used if the function should be
/// executed in a thread that waits in an alertable state. I/O worker threads were removed starting with Windows Vista and Windows Server 2008.
/// Windows Server 2003 and Windows XP: The callback function is queued to an I/O worker thread. This flag should be used if the
/// function should be executed in a thread that waits in an alertable state. I/O worker threads were removed starting with
/// Windows Vista and Windows Server 2008.
/// </para>
/// </summary>
WT_EXECUTEINIOTHREAD = 0x00000001,
/// <summary>Undocumented.</summary>
WT_EXECUTEINUITHREAD = 0x00000002,
/// <summary>
/// The callback function is invoked by the wait thread itself. This flag should be used only for short tasks or it could affect other wait operations.
/// The callback function is invoked by the wait thread itself. This flag should be used only for short tasks or it could affect
/// other wait operations.
/// <para>
/// Deadlocks can occur if some other thread acquires an exclusive lock and calls the UnregisterWait or UnregisterWaitEx function while the callback
/// function is trying to acquire the same lock.
/// Deadlocks can occur if some other thread acquires an exclusive lock and calls the UnregisterWait or UnregisterWaitEx function
/// while the callback function is trying to acquire the same lock.
/// </para>
/// </summary>
WT_EXECUTEINWAITTHREAD = 0x00000004,
/// <summary>The timer will be set to the signaled state only once. If this flag is set, the Period parameter must be zero.</summary>
WT_EXECUTEONLYONCE = 0x00000008,
/// <summary>
/// The callback function is invoked by the timer thread itself. This flag should be used only for short tasks or it could affect other timer operations.
/// The callback function is invoked by the timer thread itself. This flag should be used only for short tasks or it could affect
/// other timer operations.
/// <para>The callback function is queued as an APC. It should not perform alertable wait operations.</para>
/// </summary>
WT_EXECUTEINTIMERTHREAD = 0x00000020,
/// <summary>The callback function can perform a long wait. This flag helps the system to decide if it should create a new thread.</summary>
/// <summary>
/// The callback function can perform a long wait. This flag helps the system to decide if it should create a new thread.
/// </summary>
WT_EXECUTELONGFUNCTION = 0x00000010,
/// <summary>Undocumented.</summary>
WT_EXECUTEINPERSISTENTIOTHREAD = 0x00000040,
/// <summary>
/// The callback function is queued to a thread that never terminates. It does not guarantee that the same thread is used each time. This flag should
/// be used only for short tasks or it could affect other timer operations. This flag must be set if the thread calls functions that use APCs. For
/// more information, see Asynchronous Procedure Calls.
/// <para>Note that currently no worker thread is truly persistent, although worker threads do not terminate if there are any pending I/O requests.</para>
/// The callback function is queued to a thread that never terminates. It does not guarantee that the same thread is used each
/// time. This flag should be used only for short tasks or it could affect other timer operations. This flag must be set if the
/// thread calls functions that use APCs. For more information, see Asynchronous Procedure Calls.
/// <para>
/// Note that currently no worker thread is truly persistent, although worker threads do not terminate if there are any pending
/// I/O requests.
/// </para>
/// </summary>
WT_EXECUTEINPERSISTENTTHREAD = 0x00000080,
/// <summary>
/// Callback functions will use the current access token, whether it is a process or impersonation token. If this flag is not specified, callback
/// functions execute only with the process token.
/// Callback functions will use the current access token, whether it is a process or impersonation token. If this flag is not
/// specified, callback functions execute only with the process token.
/// <para>Windows XP: This flag is not supported until Windows XP SP2 and Windows Server 2003.</para>
/// </summary>
WT_TRANSFER_IMPERSONATION = 0x00000100,
}
/// <summary>
/// Associates the I/O completion port owned by the thread pool with the specified file handle. On completion of an I/O request involving this file, a
/// non-I/O worker thread will execute the specified callback function.
/// Associates the I/O completion port owned by the thread pool with the specified file handle. On completion of an I/O request
/// involving this file, a non-I/O worker thread will execute the specified callback function.
/// </summary>
/// <param name="FileHandle">
/// A handle to the file opened for overlapped I/O completion. This handle is returned by the <c>CreateFile</c> function, with the
@ -87,8 +104,8 @@ namespace Vanara.PInvoke
/// </param>
/// <param name="Function">
/// <para>
/// A pointer to the callback function to be executed in a non-I/O worker thread when the I/O operation is complete. This callback function must not call
/// the <c>TerminateThread</c> function.
/// A pointer to the callback function to be executed in a non-I/O worker thread when the I/O operation is complete. This callback
/// function must not call the <c>TerminateThread</c> function.
/// </para>
/// <para>For more information about the completion routine, see <c>FileIOCompletionRoutine</c>.</para>
/// </param>
@ -96,8 +113,9 @@ namespace Vanara.PInvoke
/// <returns>
/// <para>If the function succeeds, the return value is nonzero.</para>
/// <para>
/// If the function fails, the return value is zero. To get extended error information, call the <c>GetLastError</c> function. The value returned is an
/// <c>NTSTATUS</c> error code. To retrieve the corresponding system error code, use the <c>RtlNtStatusToDosError</c> function.
/// If the function fails, the return value is zero. To get extended error information, call the <c>GetLastError</c> function. The
/// value returned is an <c>NTSTATUS</c> error code. To retrieve the corresponding system error code, use the
/// <c>RtlNtStatusToDosError</c> function.
/// </para>
/// </returns>
// BOOL WINAPI BindIoCompletionCallback( _In_ HANDLE FileHandle, _In_ LPOVERLAPPED_COMPLETION_ROUTINE Function, _In_ ULONG Flags); https://msdn.microsoft.com/en-us/library/windows/desktop/aa363484(v=vs.85).aspx
@ -114,9 +132,9 @@ namespace Vanara.PInvoke
/// <param name="Timer">A handle to the timer-queue timer. This handle is returned by the <c>CreateTimerQueueTimer</c> function.</param>
/// <param name="DueTime">The time after which the timer should expire, in milliseconds.</param>
/// <param name="Period">
/// The period of the timer, in milliseconds. If this parameter is zero, the timer is signaled once. If this parameter is greater than zero, the timer is
/// periodic. A periodic timer automatically reactivates each time the period elapses, until the timer is canceled using the <c>DeleteTimerQueueTimer</c>
/// function or reset using <c>ChangeTimerQueueTimer</c>.
/// The period of the timer, in milliseconds. If this parameter is zero, the timer is signaled once. If this parameter is greater
/// than zero, the timer is periodic. A periodic timer automatically reactivates each time the period elapses, until the timer is
/// canceled using the <c>DeleteTimerQueueTimer</c> function or reset using <c>ChangeTimerQueueTimer</c>.
/// </param>
/// <returns>
/// <para>If the function succeeds, the return value is nonzero.</para>
@ -126,44 +144,47 @@ namespace Vanara.PInvoke
[DllImport(Lib.Kernel32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("WinBase.h", MSDNShortId = "ms682004")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool ChangeTimerQueueTimer([In] IntPtr TimerQueue, IntPtr Timer, uint DueTime, uint Period);
public static extern bool ChangeTimerQueueTimer([In] TimerQueueHandle TimerQueue, TimerQueueTimerHandle Timer, uint DueTime, uint Period);
/// <summary>
/// Creates a queue for timers. Timer-queue timers are lightweight objects that enable you to specify a callback function to be called at a specified time.
/// Creates a queue for timers. Timer-queue timers are lightweight objects that enable you to specify a callback function to be
/// called at a specified time.
/// </summary>
/// <returns>
/// <para>
/// If the function succeeds, the return value is a handle to the timer queue. This handle can be used only in functions that require a handle to a timer queue.
/// If the function succeeds, the return value is a handle to the timer queue. This handle can be used only in functions that require
/// a handle to a timer queue.
/// </para>
/// <para>If the function fails, the return value is <c>NULL</c>. To get extended error information, call <c>GetLastError</c>.</para>
/// </returns>
// HANDLE WINAPI CreateTimerQueue(void); https://msdn.microsoft.com/en-us/library/windows/desktop/ms682483(v=vs.85).aspx
[DllImport(Lib.Kernel32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("WinBase.h", MSDNShortId = "ms682483")]
public static extern IntPtr CreateTimerQueue();
public static extern SafeTimerQueueHandle CreateTimerQueue();
/// <summary>
/// Creates a timer-queue timer. This timer expires at the specified due time, then after every specified period. When the timer expires, the callback
/// function is called.
/// Creates a timer-queue timer. This timer expires at the specified due time, then after every specified period. When the timer
/// expires, the callback function is called.
/// </summary>
/// <param name="phNewTimer">
/// A pointer to a buffer that receives a handle to the timer-queue timer on return. When this handle has expired and is no longer required, release it
/// by calling <c>DeleteTimerQueueTimer</c>.
/// A pointer to a buffer that receives a handle to the timer-queue timer on return. When this handle has expired and is no longer
/// required, release it by calling <c>DeleteTimerQueueTimer</c>.
/// </param>
/// <param name="TimerQueue">
/// <para>A handle to the timer queue. This handle is returned by the <c>CreateTimerQueue</c> function.</para>
/// <para>If this parameter is <c>NULL</c>, the timer is associated with the default timer queue.</para>
/// </param>
/// <param name="Callback">
/// A pointer to the application-defined function of type <c>WAITORTIMERCALLBACK</c> to be executed when the timer expires. For more information, see <c>WaitOrTimerCallback</c>.
/// A pointer to the application-defined function of type <c>WAITORTIMERCALLBACK</c> to be executed when the timer expires. For more
/// information, see <c>WaitOrTimerCallback</c>.
/// </param>
/// <param name="Parameter">A single parameter value that will be passed to the callback function.</param>
/// <param name="DueTime">
/// The amount of time in milliseconds relative to the current time that must elapse before the timer is signaled for the first time.
/// </param>
/// <param name="Period">
/// The period of the timer, in milliseconds. If this parameter is zero, the timer is signaled once. If this parameter is greater than zero, the timer is
/// periodic. A periodic timer automatically reactivates each time the period elapses, until the timer is canceled.
/// The period of the timer, in milliseconds. If this parameter is zero, the timer is signaled once. If this parameter is greater
/// than zero, the timer is periodic. A periodic timer automatically reactivates each time the period elapses, until the timer is canceled.
/// </param>
/// <param name="Flags">
/// <para>This parameter can be one or more of the following values from WinNT.h.</para>
@ -180,25 +201,25 @@ namespace Vanara.PInvoke
/// <item>
/// <term>WT_EXECUTEINTIMERTHREAD0x00000020</term>
/// <term>
/// The callback function is invoked by the timer thread itself. This flag should be used only for short tasks or it could affect other timer operations.
/// The callback function is queued as an APC. It should not perform alertable wait operations.
/// The callback function is invoked by the timer thread itself. This flag should be used only for short tasks or it could affect
/// other timer operations. The callback function is queued as an APC. It should not perform alertable wait operations.
/// </term>
/// </item>
/// <item>
/// <term>WT_EXECUTEINIOTHREAD0x00000001</term>
/// <term>
/// This flag is not used.Windows Server 2003 and Windows XP: The callback function is queued to an I/O worker thread. This flag should be used if the
/// function should be executed in a thread that waits in an alertable state. I/O worker threads were removed starting with Windows Vista and Windows
/// Server 2008.
/// This flag is not used.Windows Server 2003 and Windows XP: The callback function is queued to an I/O worker thread. This flag
/// should be used if the function should be executed in a thread that waits in an alertable state. I/O worker threads were removed
/// starting with Windows Vista and Windows Server 2008.
/// </term>
/// </item>
/// <item>
/// <term>WT_EXECUTEINPERSISTENTTHREAD0x00000080</term>
/// <term>
/// The callback function is queued to a thread that never terminates. It does not guarantee that the same thread is used each time. This flag should be
/// used only for short tasks or it could affect other timer operations. This flag must be set if the thread calls functions that use APCs. For more
/// information, see Asynchronous Procedure Calls.Note that currently no worker thread is truly persistent, although no worker thread will terminate if
/// there are any pending I/O requests.
/// The callback function is queued to a thread that never terminates. It does not guarantee that the same thread is used each time.
/// This flag should be used only for short tasks or it could affect other timer operations. This flag must be set if the thread
/// calls functions that use APCs. For more information, see Asynchronous Procedure Calls.Note that currently no worker thread is
/// truly persistent, although no worker thread will terminate if there are any pending I/O requests.
/// </term>
/// </item>
/// <item>
@ -212,8 +233,9 @@ namespace Vanara.PInvoke
/// <item>
/// <term>WT_TRANSFER_IMPERSONATION0x00000100</term>
/// <term>
/// Callback functions will use the current access token, whether it is a process or impersonation token. If this flag is not specified, callback
/// functions execute only with the process token.Windows XP: This flag is not supported until Windows XP with SP2 and Windows Server 2003.
/// Callback functions will use the current access token, whether it is a process or impersonation token. If this flag is not
/// specified, callback functions execute only with the process token.Windows XP: This flag is not supported until Windows XP with
/// SP2 and Windows Server 2003.
/// </term>
/// </item>
/// </list>
@ -223,23 +245,27 @@ namespace Vanara.PInvoke
/// <para>If the function succeeds, the return value is nonzero.</para>
/// <para>If the function fails, the return value is zero. To get extended error information, call <c>GetLastError</c>.</para>
/// </returns>
// BOOL WINAPI CreateTimerQueueTimer( _Out_ PHANDLE phNewTimer, _In_opt_ HANDLE TimerQueue, _In_ WAITORTIMERCALLBACK Callback, _In_opt_ PVOID Parameter,
// _In_ DWORD DueTime, _In_ DWORD Period, _In_ ULONG Flags); https://msdn.microsoft.com/en-us/library/windows/desktop/ms682485(v=vs.85).aspx
[DllImport(Lib.Kernel32, SetLastError = true, ExactSpelling = true)]
// BOOL WINAPI CreateTimerQueueTimer( _Out_ PHANDLE phNewTimer, _In_opt_ HANDLE TimerQueue, _In_ WAITORTIMERCALLBACK Callback,
// _In_opt_ PVOID Parameter, _In_ DWORD DueTime, _In_ DWORD Period, _In_ ULONG Flags); https://msdn.microsoft.com/en-us/library/windows/desktop/ms682485(v=vs.85).aspx
[PInvokeData("WinBase.h", MSDNShortId = "ms682485")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool CreateTimerQueueTimer(out IntPtr phNewTimer, [In] IntPtr TimerQueue, WaitOrTimerCallback Callback, [In] IntPtr Parameter, uint DueTime, uint Period, WT Flags);
public static bool CreateTimerQueueTimer(out SafeTimerQueueTimerHandle phNewTimer, [In] SafeTimerQueueHandle TimerQueue, WaitOrTimerCallback Callback, [In] IntPtr Parameter, uint DueTime, uint Period, WT Flags)
{
var b = _CreateTimerQueueTimer(out phNewTimer, TimerQueue, Callback, Parameter, DueTime, Period, Flags);
if (b) phNewTimer.TimerQueue = TimerQueue;
return b;
}
/// <summary>Deletes a timer queue. Any pending timers in the queue are canceled and deleted.</summary>
/// <param name="TimerQueue">A handle to the timer queue. This handle is returned by the <c>CreateTimerQueue</c> function.</param>
/// <param name="CompletionEvent">
/// <para>
/// A handle to the event object to be signaled when the function is successful and all callback functions have completed. This parameter can be <c>NULL</c>.
/// A handle to the event object to be signaled when the function is successful and all callback functions have completed. This
/// parameter can be <c>NULL</c>.
/// </para>
/// <para>If this parameter is <c>INVALID_HANDLE_VALUE</c>, the function waits for all callback functions to complete before returning.</para>
/// <para>
/// If this parameter is <c>NULL</c>, the function marks the timer for deletion and returns immediately. However, most callers should wait for the
/// callback function to complete so they can perform any needed cleanup.
/// If this parameter is <c>NULL</c>, the function marks the timer for deletion and returns immediately. However, most callers should
/// wait for the callback function to complete so they can perform any needed cleanup.
/// </para>
/// </param>
/// <returns>
@ -250,10 +276,11 @@ namespace Vanara.PInvoke
[DllImport(Lib.Kernel32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("WinBase.h", MSDNShortId = "ms682568")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool DeleteTimerQueueEx([In] IntPtr TimerQueue, [In] IntPtr CompletionEvent);
public static extern bool DeleteTimerQueueEx([In] TimerQueueHandle TimerQueue, [In] SafeEventHandle CompletionEvent);
/// <summary>
/// Removes a timer from the timer queue and optionally waits for currently running timer callback functions to complete before deleting the timer.
/// Removes a timer from the timer queue and optionally waits for currently running timer callback functions to complete before
/// deleting the timer.
/// </summary>
/// <param name="TimerQueue">
/// <para>A handle to the timer queue. This handle is returned by the <c>CreateTimerQueue</c> function.</para>
@ -262,32 +289,36 @@ namespace Vanara.PInvoke
/// <param name="Timer">A handle to the timer-queue timer. This handle is returned by the <c>CreateTimerQueueTimer</c> function.</param>
/// <param name="CompletionEvent">
/// <para>
/// A handle to the event object to be signaled when the system has canceled the timer and all callback functions have completed. This parameter can be <c>NULL</c>.
/// A handle to the event object to be signaled when the system has canceled the timer and all callback functions have completed.
/// This parameter can be <c>NULL</c>.
/// </para>
/// <para>If this parameter is <c>INVALID_HANDLE_VALUE</c>, the function waits for any running timer callback functions to complete before returning.</para>
/// <para>
/// If this parameter is <c>NULL</c>, the function marks the timer for deletion and returns immediately. If the timer has already expired, the timer
/// callback function will run to completion. However, there is no notification sent when the timer callback function has completed. Most callers should
/// not use this option, and should wait for running timer callback functions to complete so they can perform any needed cleanup.
/// If this parameter is <c>INVALID_HANDLE_VALUE</c>, the function waits for any running timer callback functions to complete before returning.
/// </para>
/// <para>
/// If this parameter is <c>NULL</c>, the function marks the timer for deletion and returns immediately. If the timer has already
/// expired, the timer callback function will run to completion. However, there is no notification sent when the timer callback
/// function has completed. Most callers should not use this option, and should wait for running timer callback functions to complete
/// so they can perform any needed cleanup.
/// </para>
/// </param>
/// <returns>
/// <para>If the function succeeds, the return value is nonzero.</para>
/// <para>
/// If the function fails, the return value is zero. To get extended error information, call <c>GetLastError</c>. If the error code is
/// <c>ERROR_IO_PENDING</c>, it is not necessary to call this function again. For any other error, you should retry the call.
/// If the function fails, the return value is zero. To get extended error information, call <c>GetLastError</c>. If the error code
/// is <c>ERROR_IO_PENDING</c>, it is not necessary to call this function again. For any other error, you should retry the call.
/// </para>
/// </returns>
// BOOL WINAPI DeleteTimerQueueTimer( _In_opt_ HANDLE TimerQueue, _In_ HANDLE Timer, _In_opt_ HANDLE CompletionEvent); https://msdn.microsoft.com/en-us/library/windows/desktop/ms682569(v=vs.85).aspx
[DllImport(Lib.Kernel32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("WinBase.h", MSDNShortId = "ms682569")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool DeleteTimerQueueTimer([In] IntPtr TimerQueue, [In] IntPtr Timer, [In] IntPtr CompletionEvent);
public static extern bool DeleteTimerQueueTimer([In] TimerQueueHandle TimerQueue, [In] TimerQueueTimerHandle Timer, [In] SafeEventHandle CompletionEvent);
/// <summary>Queues a work item to a worker thread in the thread pool.</summary>
/// <param name="Function">
/// A pointer to the application-defined callback function of type LPTHREAD_START_ROUTINE to be executed by the thread in the thread pool. This value
/// represents the starting address of the thread. This callback function must not call the TerminateThread function.
/// A pointer to the application-defined callback function of type LPTHREAD_START_ROUTINE to be executed by the thread in the thread
/// pool. This value represents the starting address of the thread. This callback function must not call the TerminateThread function.
/// <para>For more information, see ThreadProc.</para>
/// </param>
/// <param name="Context">A single parameter value to be passed to the thread function.</param>
@ -303,12 +334,12 @@ namespace Vanara.PInvoke
public static extern bool QueueUserWorkItem(PTHREAD_START_ROUTINE Function, [In] IntPtr Context, WT Flags);
/// <summary>
/// Directs a wait thread in the thread pool to wait on the object. The wait thread queues the specified callback function to the thread pool when one of
/// the following occurs:
/// Directs a wait thread in the thread pool to wait on the object. The wait thread queues the specified callback function to the
/// thread pool when one of the following occurs:
/// </summary>
/// <param name="phNewWaitObject">
/// A pointer to a variable that receives a wait handle on return. Note that a wait handle cannot be used in functions that require an object handle,
/// such as <c>CloseHandle</c>.
/// A pointer to a variable that receives a wait handle on return. Note that a wait handle cannot be used in functions that require
/// an object handle, such as <c>CloseHandle</c>.
/// </param>
/// <param name="hObject">
/// <para>A handle to the object. For a list of the object types whose handles can be specified, see the following Remarks section.</para>
@ -316,18 +347,19 @@ namespace Vanara.PInvoke
/// <para>The handles must have the <c>SYNCHRONIZE</c> access right. For more information, see Standard Access Rights.</para>
/// </param>
/// <param name="Callback">
/// A pointer to the application-defined function of type <c>WAITORTIMERCALLBACK</c> to be executed when hObject is in the signaled state, or
/// dwMilliseconds elapses. For more information, see <c>WaitOrTimerCallback</c>.
/// A pointer to the application-defined function of type <c>WAITORTIMERCALLBACK</c> to be executed when hObject is in the signaled
/// state, or dwMilliseconds elapses. For more information, see <c>WaitOrTimerCallback</c>.
/// </param>
/// <param name="Context">A single value that is passed to the callback function.</param>
/// <param name="dwMilliseconds">
/// The time-out interval, in milliseconds. The function returns if the interval elapses, even if the object's state is nonsignaled. If dwMilliseconds is
/// zero, the function tests the object's state and returns immediately. If dwMilliseconds is <c>INFINITE</c>, the function's time-out interval never elapses.
/// The time-out interval, in milliseconds. The function returns if the interval elapses, even if the object's state is nonsignaled.
/// If dwMilliseconds is zero, the function tests the object's state and returns immediately. If dwMilliseconds is <c>INFINITE</c>,
/// the function's time-out interval never elapses.
/// </param>
/// <param name="dwFlags">
/// <para>
/// This parameter can be one or more of the following values. For information about using these values with objects that remain signaled, see the
/// Remarks section.
/// This parameter can be one or more of the following values. For information about using these values with objects that remain
/// signaled, see the Remarks section.
/// </para>
/// <para>
/// <list type="table">
@ -342,26 +374,26 @@ namespace Vanara.PInvoke
/// <item>
/// <term>WT_EXECUTEINIOTHREAD0x00000001</term>
/// <term>
/// This flag is not used.Windows Server 2003 and Windows XP: The callback function is queued to an I/O worker thread. This flag should be used if the
/// function should be executed in a thread that waits in an alertable state. I/O worker threads were removed starting with Windows Vista and Windows
/// Server 2008.
/// This flag is not used.Windows Server 2003 and Windows XP: The callback function is queued to an I/O worker thread. This flag
/// should be used if the function should be executed in a thread that waits in an alertable state. I/O worker threads were removed
/// starting with Windows Vista and Windows Server 2008.
/// </term>
/// </item>
/// <item>
/// <term>WT_EXECUTEINPERSISTENTTHREAD0x00000080</term>
/// <term>
/// The callback function is queued to a thread that never terminates. It does not guarantee that the same thread is used each time. This flag should be
/// used only for short tasks or it could affect other wait operations. This flag must be set if the thread calls functions that use APCs. For more
/// information, see Asynchronous Procedure Calls.Note that currently no worker thread is truly persistent, although no worker thread will terminate if
/// there are any pending I/O requests.
/// The callback function is queued to a thread that never terminates. It does not guarantee that the same thread is used each time.
/// This flag should be used only for short tasks or it could affect other wait operations. This flag must be set if the thread calls
/// functions that use APCs. For more information, see Asynchronous Procedure Calls.Note that currently no worker thread is truly
/// persistent, although no worker thread will terminate if there are any pending I/O requests.
/// </term>
/// </item>
/// <item>
/// <term>WT_EXECUTEINWAITTHREAD0x00000004</term>
/// <term>
/// The callback function is invoked by the wait thread itself. This flag should be used only for short tasks or it could affect other wait operations.
/// Deadlocks can occur if some other thread acquires an exclusive lock and calls the UnregisterWait or UnregisterWaitEx function while the callback
/// function is trying to acquire the same lock.
/// The callback function is invoked by the wait thread itself. This flag should be used only for short tasks or it could affect
/// other wait operations. Deadlocks can occur if some other thread acquires an exclusive lock and calls the UnregisterWait or
/// UnregisterWaitEx function while the callback function is trying to acquire the same lock.
/// </term>
/// </item>
/// <item>
@ -371,15 +403,16 @@ namespace Vanara.PInvoke
/// <item>
/// <term>WT_EXECUTEONLYONCE0x00000008</term>
/// <term>
/// The thread will no longer wait on the handle after the callback function has been called once. Otherwise, the timer is reset every time the wait
/// operation completes until the wait operation is canceled.
/// The thread will no longer wait on the handle after the callback function has been called once. Otherwise, the timer is reset
/// every time the wait operation completes until the wait operation is canceled.
/// </term>
/// </item>
/// <item>
/// <term>WT_TRANSFER_IMPERSONATION0x00000100</term>
/// <term>
/// Callback functions will use the current access token, whether it is a process or impersonation token. If this flag is not specified, callback
/// functions execute only with the process token.Windows XP: This flag is not supported until Windows XP with SP2 and Windows Server 2003.
/// Callback functions will use the current access token, whether it is a process or impersonation token. If this flag is not
/// specified, callback functions execute only with the process token.Windows XP: This flag is not supported until Windows XP with
/// SP2 and Windows Server 2003.
/// </term>
/// </item>
/// </list>
@ -389,12 +422,11 @@ namespace Vanara.PInvoke
/// <para>If the function succeeds, the return value is nonzero.</para>
/// <para>If the function fails, the return value is zero. To get extended error information, call <c>GetLastError</c>.</para>
/// </returns>
// BOOL WINAPI RegisterWaitForSingleObject( _Out_ PHANDLE phNewWaitObject, _In_ HANDLE hObject, _In_ WAITORTIMERCALLBACK Callback, _In_opt_ PVOID
// Context, _In_ ULONG dwMilliseconds, _In_ ULONG dwFlags); https://msdn.microsoft.com/en-us/library/windows/desktop/ms685061(v=vs.85).aspx
[DllImport(Lib.Kernel32, SetLastError = true, ExactSpelling = true)]
// BOOL WINAPI RegisterWaitForSingleObject( _Out_ PHANDLE phNewWaitObject, _In_ HANDLE hObject, _In_ WAITORTIMERCALLBACK Callback,
// _In_opt_ PVOID Context, _In_ ULONG dwMilliseconds, _In_ ULONG dwFlags); https://msdn.microsoft.com/en-us/library/windows/desktop/ms685061(v=vs.85).aspx
[PInvokeData("WinBase.h", MSDNShortId = "ms685061")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool RegisterWaitForSingleObject(out IntPtr phNewWaitObject, [In] IntPtr hObject, WaitOrTimerCallback Callback, [In] IntPtr Context, uint dwMilliseconds, WT dwFlags);
public static bool RegisterWaitForSingleObject(out SafeRegisteredWaitHandle phNewWaitObject, ISyncHandle hObject, WaitOrTimerCallback Callback, IntPtr Context, uint dwMilliseconds, WT dwFlags) =>
RegisterWaitForSingleObject(out phNewWaitObject, hObject?.DangerousGetHandle() ?? IntPtr.Zero, Callback, Context, dwMilliseconds, dwFlags);
/// <summary>Cancels a registered wait operation issued by the <c>RegisterWaitForSingleObject</c> function.</summary>
/// <param name="WaitHandle">The wait handle. This handle is returned by the <c>RegisterWaitForSingleObject</c> function.</param>
@ -402,11 +434,12 @@ namespace Vanara.PInvoke
/// <para>A handle to the event object to be signaled when the wait operation has been unregistered. This parameter can be <c>NULL</c>.</para>
/// <para>If this parameter is <c>INVALID_HANDLE_VALUE</c>, the function waits for all callback functions to complete before returning.</para>
/// <para>
/// If this parameter is <c>NULL</c>, the function marks the timer for deletion and returns immediately. However, most callers should wait for the
/// callback function to complete so they can perform any needed cleanup.
/// If this parameter is <c>NULL</c>, the function marks the timer for deletion and returns immediately. However, most callers should
/// wait for the callback function to complete so they can perform any needed cleanup.
/// </para>
/// <para>
/// If the caller provides this event and the function succeeds or the function fails with <c>ERROR_IO_PENDING</c>, do not close the event until it is signaled.
/// If the caller provides this event and the function succeeds or the function fails with <c>ERROR_IO_PENDING</c>, do not close the
/// event until it is signaled.
/// </para>
/// </param>
/// <returns>
@ -417,6 +450,159 @@ namespace Vanara.PInvoke
[DllImport(Lib.Kernel32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("LibLoaderAPI.h", MSDNShortId = "ms686876")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool UnregisterWaitEx([In] IntPtr WaitHandle, [In] IntPtr CompletionEvent);
public static extern bool UnregisterWaitEx([In] SafeRegisteredWaitHandle WaitHandle, [In] SafeEventHandle CompletionEvent);
[DllImport(Lib.Kernel32, SetLastError = true, EntryPoint = "CreateTimerQueueTimer")]
[return: MarshalAs(UnmanagedType.Bool)]
private static extern bool _CreateTimerQueueTimer(out SafeTimerQueueTimerHandle phNewTimer, [In] TimerQueueHandle TimerQueue, WaitOrTimerCallback Callback, [In] IntPtr Parameter, uint DueTime, uint Period, WT Flags);
[DllImport(Lib.Kernel32, SetLastError = true, ExactSpelling = true)]
[return: MarshalAs(UnmanagedType.Bool)]
private static extern bool RegisterWaitForSingleObject(out SafeRegisteredWaitHandle phNewWaitObject, [In] IntPtr hObject, WaitOrTimerCallback Callback, [In] IntPtr Context, uint dwMilliseconds, WT dwFlags);
/// <summary>Provides a handle to a timer queue.</summary>
[StructLayout(LayoutKind.Sequential)]
public struct TimerQueueHandle : IHandle
{
private IntPtr handle;
/// <summary>Initializes a new instance of the <see cref="TimerQueueHandle"/> struct.</summary>
/// <param name="preexistingHandle">An <see cref="IntPtr"/> object that represents the pre-existing handle to use.</param>
public TimerQueueHandle(IntPtr preexistingHandle) => handle = preexistingHandle;
/// <summary>Returns an invalid handle by instantiating a <see cref="TimerQueueHandle"/> object with <see cref="IntPtr.Zero"/>.</summary>
public static TimerQueueHandle NULL => new TimerQueueHandle(IntPtr.Zero);
/// <summary>Gets a value indicating whether this instance is a null handle.</summary>
public bool IsNull => handle == IntPtr.Zero;
/// <summary>Performs an explicit conversion from <see cref="TimerQueueHandle"/> to <see cref="IntPtr"/>.</summary>
/// <param name="h">The handle.</param>
/// <returns>The result of the conversion.</returns>
public static explicit operator IntPtr(TimerQueueHandle h) => h.handle;
/// <summary>Performs an implicit conversion from <see cref="IntPtr"/> to <see cref="TimerQueueHandle"/>.</summary>
/// <param name="h">The pointer to a handle.</param>
/// <returns>The result of the conversion.</returns>
public static implicit operator TimerQueueHandle(IntPtr h) => new TimerQueueHandle(h);
/// <summary>Implements the operator !=.</summary>
/// <param name="h1">The first handle.</param>
/// <param name="h2">The second handle.</param>
/// <returns>The result of the operator.</returns>
public static bool operator !=(TimerQueueHandle h1, TimerQueueHandle h2) => !(h1 == h2);
/// <summary>Implements the operator ==.</summary>
/// <param name="h1">The first handle.</param>
/// <param name="h2">The second handle.</param>
/// <returns>The result of the operator.</returns>
public static bool operator ==(TimerQueueHandle h1, TimerQueueHandle h2) => h1.Equals(h2);
/// <inheritdoc/>
public override bool Equals(object obj) => obj is TimerQueueHandle h ? handle == h.handle : false;
/// <inheritdoc/>
public override int GetHashCode() => handle.GetHashCode();
/// <inheritdoc/>
public IntPtr DangerousGetHandle() => handle;
}
/// <summary>Provides a handle to a timer queue timer.</summary>
[StructLayout(LayoutKind.Sequential)]
public struct TimerQueueTimerHandle : IHandle
{
private IntPtr handle;
/// <summary>Initializes a new instance of the <see cref="TimerQueueTimerHandle"/> struct.</summary>
/// <param name="preexistingHandle">An <see cref="IntPtr"/> object that represents the pre-existing handle to use.</param>
public TimerQueueTimerHandle(IntPtr preexistingHandle) => handle = preexistingHandle;
/// <summary>Returns an invalid handle by instantiating a <see cref="TimerQueueTimerHandle"/> object with <see cref="IntPtr.Zero"/>.</summary>
public static TimerQueueTimerHandle NULL => new TimerQueueTimerHandle(IntPtr.Zero);
/// <summary>Gets a value indicating whether this instance is a null handle.</summary>
public bool IsNull => handle == IntPtr.Zero;
/// <summary>Performs an explicit conversion from <see cref="TimerQueueTimerHandle"/> to <see cref="IntPtr"/>.</summary>
/// <param name="h">The handle.</param>
/// <returns>The result of the conversion.</returns>
public static explicit operator IntPtr(TimerQueueTimerHandle h) => h.handle;
/// <summary>Performs an implicit conversion from <see cref="IntPtr"/> to <see cref="TimerQueueTimerHandle"/>.</summary>
/// <param name="h">The pointer to a handle.</param>
/// <returns>The result of the conversion.</returns>
public static implicit operator TimerQueueTimerHandle(IntPtr h) => new TimerQueueTimerHandle(h);
/// <summary>Implements the operator !=.</summary>
/// <param name="h1">The first handle.</param>
/// <param name="h2">The second handle.</param>
/// <returns>The result of the operator.</returns>
public static bool operator !=(TimerQueueTimerHandle h1, TimerQueueTimerHandle h2) => !(h1 == h2);
/// <summary>Implements the operator ==.</summary>
/// <param name="h1">The first handle.</param>
/// <param name="h2">The second handle.</param>
/// <returns>The result of the operator.</returns>
public static bool operator ==(TimerQueueTimerHandle h1, TimerQueueTimerHandle h2) => h1.Equals(h2);
/// <inheritdoc/>
public override bool Equals(object obj) => obj is TimerQueueTimerHandle h ? handle == h.handle : false;
/// <inheritdoc/>
public override int GetHashCode() => handle.GetHashCode();
/// <inheritdoc/>
public IntPtr DangerousGetHandle() => handle;
}
/// <summary>
/// Provides a <see cref="SafeHandle"/> to a timer queue that releases a created TimerQueueHandle instance at disposal using CloseHandle.
/// </summary>
public class SafeTimerQueueHandle : HANDLE
{
/// <summary>Initializes a new instance of the <see cref="TimerQueueHandle"/> class and assigns an existing handle.</summary>
/// <param name="preexistingHandle">An <see cref="IntPtr"/> object that represents the pre-existing handle to use.</param>
/// <param name="ownsHandle">
/// <see langword="true"/> to reliably release the handle during the finalization phase; otherwise, <see langword="false"/> (not recommended).
/// </param>
public SafeTimerQueueHandle(IntPtr preexistingHandle, bool ownsHandle = true) : base(preexistingHandle, ownsHandle) { }
private SafeTimerQueueHandle() : base() { }
/// <summary>Performs an implicit conversion from <see cref="SafeTimerQueueHandle"/> to <see cref="TimerQueueHandle"/>.</summary>
/// <param name="h">The safe handle instance.</param>
/// <returns>The result of the conversion.</returns>
public static implicit operator TimerQueueHandle(SafeTimerQueueHandle h) => h.handle;
/// <inheritdoc/>
protected override bool InternalReleaseHandle() => DeleteTimerQueueEx(this, new SafeEventHandle(new IntPtr(-1), false));
}
/// <summary>
/// Provides a <see cref="SafeHandle"/> to a timer queue timer that releases a created TimerQueueTimerHandle instance at disposal
/// using DeleteTimerQueueTimer.
/// </summary>
public class SafeTimerQueueTimerHandle : HANDLE
{
/// <summary>Initializes a new instance of the <see cref="TimerQueueTimerHandle"/> class and assigns an existing handle.</summary>
/// <param name="preexistingHandle">An <see cref="IntPtr"/> object that represents the pre-existing handle to use.</param>
/// <param name="ownsHandle">
/// <see langword="true"/> to reliably release the handle during the finalization phase; otherwise, <see langword="false"/> (not recommended).
/// </param>
public SafeTimerQueueTimerHandle(IntPtr preexistingHandle, bool ownsHandle = true) : base(preexistingHandle, ownsHandle) { }
private SafeTimerQueueTimerHandle() : base() { }
public SafeTimerQueueHandle TimerQueue { get; internal set; }
/// <summary>Performs an implicit conversion from <see cref="SafeTimerQueueTimerHandle"/> to <see cref="TimerQueueTimerHandle"/>.</summary>
/// <param name="h">The safe handle instance.</param>
/// <returns>The result of the conversion.</returns>
public static implicit operator TimerQueueTimerHandle(SafeTimerQueueTimerHandle h) => h.handle;
/// <inheritdoc/>
protected override bool InternalReleaseHandle() => DeleteTimerQueueTimer(TimerQueue, this, new SafeEventHandle(new IntPtr(-1), false));
}
}
}

View File

@ -1,5 +1,4 @@
using FILETIME = System.Runtime.InteropServices.ComTypes.FILETIME;
// ReSharper disable InconsistentNaming
namespace Vanara.PInvoke
{
@ -10,8 +9,7 @@ namespace Vanara.PInvoke
/// <returns>The converted <see cref="FILETIME"/> value.</returns>
public static FILETIME ToFILETIME(this SYSTEMTIME st)
{
var ft = new FILETIME();
SystemTimeToFileTime(ref st, ref ft);
SystemTimeToFileTime(st, out var ft);
return ft;
}
@ -20,8 +18,7 @@ namespace Vanara.PInvoke
/// <returns>The converted <see cref="SYSTEMTIME"/> value.</returns>
public static SYSTEMTIME ToSYSTEMTIME(this FILETIME ft)
{
var st = new SYSTEMTIME();
FileTimeToSystemTime(ref ft, ref st);
FileTimeToSystemTime(ft, out var st);
return st;
}
}

View File

@ -1,4 +1,5 @@
using System.Runtime.InteropServices;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Security;
using FILETIME = System.Runtime.InteropServices.ComTypes.FILETIME;
@ -23,18 +24,40 @@ namespace Vanara.PInvoke
}
/// <summary>
/// Enumerates <c>DYNAMIC_TIME_ZONE_INFORMATION</c> entries stored in the registry. This information is used to support time zones that experience annual
/// boundary changes due to daylight saving time adjustments. Use the information returned by this function when calling
/// <c>GetDynamicTimeZoneInformationEffectiveYears</c> to retrieve the specific range of years to pass to <c>GetTimeZoneInformationForYear</c>.
/// <para>
/// Enumerates DYNAMIC_TIME_ZONE_INFORMATION entries stored in the registry. This information is used to support time zones that
/// experience annual boundary changes due to daylight saving time adjustments. Use the information returned by this function when
/// calling GetDynamicTimeZoneInformationEffectiveYears to retrieve the specific range of years to pass to GetTimeZoneInformationForYear.
/// </para>
/// </summary>
/// <param name="dwIndex">Index value that represents the location of a <c>DYNAMIC_TIME_ZONE_INFORMATION</c> entry.</param>
/// <param name="lpTimeZoneInformation">Specifies settings for a time zone and dynamic daylight saving time.</param>
/// <returns></returns>
// DWORD WINAPI EnumDynamicTimeZoneInformation( _In_ const DWORD dwIndex, _Out_ PDYNAMIC_TIME_ZONE_INFORMATION lpTimeZoneInformation); https://msdn.microsoft.com/en-us/library/windows/desktop/hh706893(v=vs.85).aspx
/// <param name="dwIndex">
/// <para>Index value that represents the location of a DYNAMIC_TIME_ZONE_INFORMATION entry.</para>
/// </param>
/// <param name="lpTimeZoneInformation">
/// <para>Specifies settings for a time zone and dynamic daylight saving time.</para>
/// </param>
/// <returns>
/// <para>None</para>
/// </returns>
// https://docs.microsoft.com/en-us/windows/desktop/api/timezoneapi/nf-timezoneapi-enumdynamictimezoneinformation
// DWORD EnumDynamicTimeZoneInformation( const DWORD dwIndex, PDYNAMIC_TIME_ZONE_INFORMATION lpTimeZoneInformation );
[DllImport(Lib.Kernel32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("Winbase.h", MSDNShortId = "hh706893")]
[PInvokeData("timezoneapi.h", MSDNShortId = "EBB2366A-86FE-4764-B7F9-5D305993CE0A")]
public static extern uint EnumDynamicTimeZoneInformation(uint dwIndex, out DYNAMIC_TIME_ZONE_INFORMATION lpTimeZoneInformation);
/// <summary>
/// Enumerates DYNAMIC_TIME_ZONE_INFORMATION entries stored in the registry. This information is used to support time zones that
/// experience annual boundary changes due to daylight saving time adjustments. Use the information returned by this function when
/// calling GetDynamicTimeZoneInformationEffectiveYears to retrieve the specific range of years to pass to GetTimeZoneInformationForYear.
/// </summary>
/// <returns>An enumeration of settings for a time zone and dynamic daylight saving time.</returns>
public static IEnumerable<DYNAMIC_TIME_ZONE_INFORMATION> EnumDynamicTimeZoneInformation()
{
var i = 0U;
while (EnumDynamicTimeZoneInformation(i++, out var tz) != 0)
yield return tz;
}
/// <summary>Converts a file time to system time format. System time is based on Coordinated Universal Time (UTC).</summary>
/// <param name="lpFileTime">
/// A pointer to a FILETIME structure containing the file time to be converted to system (UTC) date and time format. This value must be less than
@ -47,7 +70,7 @@ namespace Vanara.PInvoke
[PInvokeData("FileAPI.h", MSDNShortId = "ms724280")]
[DllImport(Lib.Kernel32, ExactSpelling = true, SetLastError = true), SuppressUnmanagedCodeSecurity]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool FileTimeToSystemTime(ref FILETIME lpFileTime, ref SYSTEMTIME lpSystemTime);
public static extern bool FileTimeToSystemTime(in FILETIME lpFileTime, out SYSTEMTIME lpSystemTime);
/// <summary>
/// Retrieves the current time zone and dynamic daylight saving time settings. These settings control the translations between Coordinated Universal Time
@ -142,7 +165,7 @@ namespace Vanara.PInvoke
[DllImport(Lib.Kernel32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("Winbase.h", MSDNShortId = "bb540851")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool GetTimeZoneInformationForYear(ushort wYear, [In] ref DYNAMIC_TIME_ZONE_INFORMATION pdtzi, out TIME_ZONE_INFORMATION ptzi);
public static extern bool GetTimeZoneInformationForYear(ushort wYear, in DYNAMIC_TIME_ZONE_INFORMATION pdtzi, out TIME_ZONE_INFORMATION ptzi);
/// <summary>
/// Sets the current time zone and dynamic daylight saving time settings. These settings control translations from Coordinated Universal Time (UTC) to
@ -157,7 +180,7 @@ namespace Vanara.PInvoke
[DllImport(Lib.Kernel32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("Winbase.h", MSDNShortId = "ms724932")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SetDynamicTimeZoneInformation(ref DYNAMIC_TIME_ZONE_INFORMATION lpTimeZoneInformation);
public static extern bool SetDynamicTimeZoneInformation(in DYNAMIC_TIME_ZONE_INFORMATION lpTimeZoneInformation);
/// <summary>
/// <para>
@ -176,7 +199,7 @@ namespace Vanara.PInvoke
[DllImport(Lib.Kernel32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("Winbase.h", MSDNShortId = "ms724944")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SetTimeZoneInformation(ref TIME_ZONE_INFORMATION lpTimeZoneInformation);
public static extern bool SetTimeZoneInformation(in TIME_ZONE_INFORMATION lpTimeZoneInformation);
/// <summary>Converts a system time to file time format. System time is based on Coordinated Universal Time (UTC).</summary>
/// <param name="lpSystemTime">
@ -190,7 +213,7 @@ namespace Vanara.PInvoke
[DllImport(Lib.Kernel32, ExactSpelling = true, SetLastError = true), SuppressUnmanagedCodeSecurity]
[return: MarshalAs(UnmanagedType.Bool)]
[PInvokeData("Winbase.h", MSDNShortId = "ms724948")]
public static extern bool SystemTimeToFileTime(ref SYSTEMTIME lpSystemTime, ref FILETIME lpFileTime);
public static extern bool SystemTimeToFileTime(in SYSTEMTIME lpSystemTime, out FILETIME lpFileTime);
/// <summary>Converts a time in Coordinated Universal Time (UTC) to a specified time zone's corresponding local time.</summary>
/// <param name="lpTimeZone">
@ -213,8 +236,8 @@ namespace Vanara.PInvoke
[DllImport(Lib.Kernel32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("Winbase.h", MSDNShortId = "ms724949")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SystemTimeToTzSpecificLocalTime([In, MarshalAs(UnmanagedType.LPStruct)] TIME_ZONE_INFORMATION lpTimeZone,
[In, MarshalAs(UnmanagedType.LPStruct)] SYSTEMTIME lpUniversalTime, [Out] out SYSTEMTIME lpLocalTime);
public static extern bool SystemTimeToTzSpecificLocalTime(in TIME_ZONE_INFORMATION lpTimeZone,
in SYSTEMTIME lpUniversalTime, [Out] out SYSTEMTIME lpLocalTime);
/// <summary>
/// Converts a time in Coordinated Universal Time (UTC) with dynamic daylight saving time settings to a specified time zone's corresponding local time.
@ -233,7 +256,7 @@ namespace Vanara.PInvoke
[DllImport(Lib.Kernel32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("Winbase.h", MSDNShortId = "jj206642")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SystemTimeToTzSpecificLocalTimeEx([In] ref DYNAMIC_TIME_ZONE_INFORMATION lpTimeZoneInformation, [In] ref SYSTEMTIME lpUniversalTime, out SYSTEMTIME lpLocalTime);
public static extern bool SystemTimeToTzSpecificLocalTimeEx(in DYNAMIC_TIME_ZONE_INFORMATION lpTimeZoneInformation, in SYSTEMTIME lpUniversalTime, out SYSTEMTIME lpLocalTime);
/// <summary>
/// <para>Converts a local time to a time in Coordinated Universal Time (UTC).</para>
@ -261,7 +284,7 @@ namespace Vanara.PInvoke
[DllImport(Lib.Kernel32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("Winbase.h", MSDNShortId = "ms725485")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool TzSpecificLocalTimeToSystemTime([In, MarshalAs(UnmanagedType.LPStruct)] TIME_ZONE_INFORMATION lpTimeZoneInformation, [In, MarshalAs(UnmanagedType.LPStruct)] SYSTEMTIME lpLocalTime, [Out] out SYSTEMTIME lpUniversalTime);
public static extern bool TzSpecificLocalTimeToSystemTime(in TIME_ZONE_INFORMATION lpTimeZoneInformation, in SYSTEMTIME lpLocalTime, [Out] out SYSTEMTIME lpUniversalTime);
/// <summary>Converts a local time to a time with dynamic daylight saving time settings to Coordinated Universal Time (UTC).</summary>
/// <param name="lpTimeZoneInformation">
@ -277,7 +300,7 @@ namespace Vanara.PInvoke
[DllImport(Lib.Kernel32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("Winbase.h", MSDNShortId = "jj206643")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool TzSpecificLocalTimeToSystemTimeEx([In] ref DYNAMIC_TIME_ZONE_INFORMATION lpTimeZoneInformation, [In] ref SYSTEMTIME lpLocalTime, out SYSTEMTIME lpUniversalTime);
public static extern bool TzSpecificLocalTimeToSystemTimeEx(in DYNAMIC_TIME_ZONE_INFORMATION lpTimeZoneInformation, in SYSTEMTIME lpLocalTime, out SYSTEMTIME lpUniversalTime);
/// <summary>Specifies settings for a time zone and dynamic daylight saving time.</summary>
// typedef struct _TIME_DYNAMIC_ZONE_INFORMATION { LONG Bias; WCHAR StandardName[32]; SYSTEMTIME StandardDate; LONG StandardBias; WCHAR DaylightName[32];

View File

@ -193,7 +193,7 @@ namespace Vanara.PInvoke
// CreateToolhelp32Snapshot( DWORD dwFlags, DWORD th32ProcessID );
[DllImport(Lib.Kernel32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("tlhelp32.h", MSDNShortId = "df643c25-7558-424c-b187-b3f86ba51358")]
public static extern IntPtr CreateToolhelp32Snapshot(TH32CS dwFlags, uint th32ProcessID);
public static extern SafeHSNAPSHOT CreateToolhelp32Snapshot(TH32CS dwFlags, uint th32ProcessID);
/// <summary>
/// <para>Retrieves information about the first block of a heap that has been allocated by a process.</para>
@ -263,7 +263,7 @@ namespace Vanara.PInvoke
[DllImport(Lib.Kernel32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("tlhelp32.h", MSDNShortId = "b9a2992b-0dc1-41c3-aa23-796def674831")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool Heap32ListFirst(IntPtr hSnapshot, ref HEAPLIST32 lphl);
public static extern bool Heap32ListFirst(HSNAPSHOT hSnapshot, ref HEAPLIST32 lphl);
/// <summary>
/// <para>Retrieves information about the next heap that has been allocated by a process.</para>
@ -290,7 +290,7 @@ namespace Vanara.PInvoke
[DllImport(Lib.Kernel32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("tlhelp32.h", MSDNShortId = "bb4d573c-a82f-48ac-be22-440d6a1d0c9c")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool Heap32ListNext(IntPtr hSnapshot, ref HEAPLIST32 lphl);
public static extern bool Heap32ListNext(HSNAPSHOT hSnapshot, ref HEAPLIST32 lphl);
/// <summary>
/// <para>Retrieves information about the next block of a heap that has been allocated by a process.</para>
@ -348,7 +348,7 @@ namespace Vanara.PInvoke
[DllImport(Lib.Kernel32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("tlhelp32.h", MSDNShortId = "bb41cab9-13a1-469d-bf76-68c172e982f6")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool Module32First(IntPtr hSnapshot, out MODULEENTRY32 lpme);
public static extern bool Module32First(HSNAPSHOT hSnapshot, out MODULEENTRY32 lpme);
/// <summary>
/// <para>Retrieves information about the next module associated with a process or thread.</para>
@ -375,7 +375,7 @@ namespace Vanara.PInvoke
[DllImport(Lib.Kernel32, SetLastError = true, CharSet = CharSet.Auto)]
[PInvokeData("tlhelp32.h", MSDNShortId = "88ec1af4-bae7-4cd7-b830-97a98fb337f4")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool Module32Next(IntPtr hSnapshot, out MODULEENTRY32 lpme);
public static extern bool Module32Next(HSNAPSHOT hSnapshot, out MODULEENTRY32 lpme);
/// <summary>
/// <para>Retrieves information about the first process encountered in a system snapshot.</para>
@ -407,7 +407,7 @@ namespace Vanara.PInvoke
[DllImport(Lib.Kernel32, SetLastError = true, CharSet = CharSet.Auto)]
[PInvokeData("tlhelp32.h", MSDNShortId = "097790e8-30c2-4b00-9256-fa26e2ceb893")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool Process32First(IntPtr hSnapshot, ref PROCESSENTRY32 lppe);
public static extern bool Process32First(HSNAPSHOT hSnapshot, ref PROCESSENTRY32 lppe);
/// <summary>
/// <para>Retrieves information about the next process recorded in a system snapshot.</para>
@ -435,7 +435,7 @@ namespace Vanara.PInvoke
[DllImport(Lib.Kernel32, SetLastError = true, CharSet = CharSet.Auto)]
[PInvokeData("tlhelp32.h", MSDNShortId = "843a95fd-27ae-4215-83d0-82fc402b82b6")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool Process32Next(IntPtr hSnapshot, ref PROCESSENTRY32 lppe);
public static extern bool Process32Next(HSNAPSHOT hSnapshot, ref PROCESSENTRY32 lppe);
/// <summary>
/// <para>Retrieves information about the first thread of any process encountered in a system snapshot.</para>
@ -469,7 +469,7 @@ namespace Vanara.PInvoke
[DllImport(Lib.Kernel32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("tlhelp32.h", MSDNShortId = "d4cb7a19-850e-43b5-bda5-91be48382d2a")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool Thread32First(IntPtr hSnapshot, ref THREADENTRY32 lpte);
public static extern bool Thread32First(HSNAPSHOT hSnapshot, ref THREADENTRY32 lpte);
/// <summary>
/// <para>Retrieves information about the next thread of any process encountered in the system memory snapshot.</para>
@ -497,7 +497,7 @@ namespace Vanara.PInvoke
[DllImport(Lib.Kernel32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("tlhelp32.h", MSDNShortId = "5efe514e-626c-4138-97a0-bdad217c424f")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool Thread32Next(IntPtr hSnapshot, ref THREADENTRY32 lpte);
public static extern bool Thread32Next(HSNAPSHOT hSnapshot, ref THREADENTRY32 lpte);
/// <summary>
/// <para>Copies memory allocated to another process into an application-supplied buffer.</para>
@ -654,6 +654,54 @@ namespace Vanara.PInvoke
public HEAPLIST32_FLAGS dwFlags;
}
/// <summary>Provides a handle to a snapshot.</summary>
[StructLayout(LayoutKind.Sequential)]
public struct HSNAPSHOT : IKernelHandle
{
private IntPtr handle;
/// <summary>Initializes a new instance of the <see cref="HSNAPSHOT"/> struct.</summary>
/// <param name="preexistingHandle">An <see cref="IntPtr"/> object that represents the pre-existing handle to use.</param>
public HSNAPSHOT(IntPtr preexistingHandle) => handle = preexistingHandle;
/// <summary>Returns an invalid handle by instantiating a <see cref="HSNAPSHOT"/> object with <see cref="IntPtr.Zero"/>.</summary>
public static HSNAPSHOT NULL => new HSNAPSHOT(IntPtr.Zero);
/// <summary>Gets a value indicating whether this instance is a null handle.</summary>
public bool IsNull => handle == IntPtr.Zero;
/// <summary>Performs an explicit conversion from <see cref="HSNAPSHOT"/> to <see cref="IntPtr"/>.</summary>
/// <param name="h">The handle.</param>
/// <returns>The result of the conversion.</returns>
public static explicit operator IntPtr(HSNAPSHOT h) => h.handle;
/// <summary>Performs an implicit conversion from <see cref="IntPtr"/> to <see cref="HSNAPSHOT"/>.</summary>
/// <param name="h">The pointer to a handle.</param>
/// <returns>The result of the conversion.</returns>
public static implicit operator HSNAPSHOT(IntPtr h) => new HSNAPSHOT(h);
/// <summary>Implements the operator !=.</summary>
/// <param name="h1">The first handle.</param>
/// <param name="h2">The second handle.</param>
/// <returns>The result of the operator.</returns>
public static bool operator !=(HSNAPSHOT h1, HSNAPSHOT h2) => !(h1 == h2);
/// <summary>Implements the operator ==.</summary>
/// <param name="h1">The first handle.</param>
/// <param name="h2">The second handle.</param>
/// <returns>The result of the operator.</returns>
public static bool operator ==(HSNAPSHOT h1, HSNAPSHOT h2) => h1.Equals(h2);
/// <inheritdoc/>
public override bool Equals(object obj) => obj is HSNAPSHOT h ? handle == h.handle : false;
/// <inheritdoc/>
public override int GetHashCode() => handle.GetHashCode();
/// <inheritdoc/>
public IntPtr DangerousGetHandle() => handle;
}
/// <summary>
/// <para>Describes an entry from a list of the modules belonging to the specified process.</para>
/// </summary>
@ -666,7 +714,7 @@ namespace Vanara.PInvoke
// dwSize; DWORD th32ModuleID; DWORD th32ProcessID; DWORD GlblcntUsage; DWORD ProccntUsage; BYTE *modBaseAddr; DWORD modBaseSize;
// HMODULE hModule; char szModule[MAX_MODULE_NAME32 + 1]; char szExePath[MAX_PATH]; } MODULEENTRY32;
[PInvokeData("tlhelp32.h", MSDNShortId = "305fab35-625c-42e3-a434-e2513e4c8870")]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
public struct MODULEENTRY32
{
private const int MAX_MODULE_NAME32 = 255;
@ -712,7 +760,7 @@ namespace Vanara.PInvoke
/// <summary>
/// <para>A handle to the module in the context of the owning process.</para>
/// </summary>
public IntPtr hModule;
public HINSTANCE hModule;
/// <summary>
/// <para>The module name.</para>
@ -734,7 +782,7 @@ namespace Vanara.PInvoke
// DWORD dwSize; DWORD cntUsage; DWORD th32ProcessID; ULONG_PTR th32DefaultHeapID; DWORD th32ModuleID; DWORD cntThreads; DWORD
// th32ParentProcessID; LONG pcPriClassBase; DWORD dwFlags; CHAR szExeFile[MAX_PATH]; } PROCESSENTRY32;
[PInvokeData("tlhelp32.h", MSDNShortId = "9e2f7345-52bf-4bfc-9761-90b0b374c727")]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
public struct PROCESSENTRY32
{
/// <summary>
@ -847,5 +895,23 @@ namespace Vanara.PInvoke
/// </summary>
public uint dwFlags;
}
/// <summary>Provides a <see cref="SafeHandle"/> to a snapshot that releases a created HSNAPSHOT instance at disposal using CloseHandle.</summary>
public class SafeHSNAPSHOT : SafeKernelHandle
{
/// <summary>Initializes a new instance of the <see cref="HSNAPSHOT"/> class and assigns an existing handle.</summary>
/// <param name="preexistingHandle">An <see cref="IntPtr"/> object that represents the pre-existing handle to use.</param>
/// <param name="ownsHandle">
/// <see langword="true"/> to reliably release the handle during the finalization phase; otherwise, <see langword="false"/> (not recommended).
/// </param>
public SafeHSNAPSHOT(IntPtr preexistingHandle, bool ownsHandle = true) : base(preexistingHandle, ownsHandle) { }
private SafeHSNAPSHOT() : base() { }
/// <summary>Performs an implicit conversion from <see cref="SafeHSNAPSHOT"/> to <see cref="HSNAPSHOT"/>.</summary>
/// <param name="h">The safe handle instance.</param>
/// <returns>The result of the conversion.</returns>
public static implicit operator HSNAPSHOT(SafeHSNAPSHOT h) => h.handle;
}
}
}

Some files were not shown because too many files have changed in this diff Show More