Finished nullable work on User32

nullableenabled
David Hall 2023-05-13 20:16:32 -06:00
parent cf8607dcc6
commit d75cbee08e
43 changed files with 786 additions and 241 deletions

View File

@ -23,14 +23,20 @@ namespace Vanara.Extensions.Reflection
/// This will convert <see langword="null"/> or <see cref="DBNull"/> to itself, values of the requested <paramref name="type"/>, to
/// themselves, or will use available <see cref="TypeConverter"/> s or <see cref="IConvertible"/> associations to perform the conversion.
/// </remarks>
public static object? ConvertTo(this object? value, Type type)
public static object? CastTo(this object? value, Type type)
{
if (type is null) return null;
if (value is null or DBNull || value.GetType() == type)
return value;
if (type.IsEnum && value is IConvertible c)
return Enum.ToObject(type, c.ToType(Enum.GetUnderlyingType(type), System.Threading.Thread.CurrentThread.CurrentCulture));
if (value is SafeHandle h) value = h.DangerousGetHandle();
if (value is PInvoke.IHandle ih) value = ih.DangerousGetHandle();
if (type.IsEnum)
{
if (value is IntPtr p)
value = p.ToInt64();
if (value is IConvertible c)
return Enum.ToObject(type, c.ToType(Enum.GetUnderlyingType(type), System.Threading.Thread.CurrentThread.CurrentCulture));
}
TypeConverter converter = TypeDescriptor.GetConverter(value);
if (converter.CanConvertTo(type))
return converter.ConvertTo(value, type);

11
Core/IHandle.cs Normal file
View File

@ -0,0 +1,11 @@
using System;
namespace Vanara.PInvoke;
/// <summary>Signals that a structure or class holds a HANDLE.</summary>
public interface IHandle
{
/// <summary>Returns the value of the handle field.</summary>
/// <returns>An IntPtr representing the value of the handle field.</returns>
IntPtr DangerousGetHandle();
}

View File

@ -574,7 +574,7 @@ public static partial class Gdi32
// DISPLAYCONFIG_ADAPTER_NAME { DISPLAYCONFIG_DEVICE_INFO_HEADER header; WCHAR adapterDevicePath[128]; } DISPLAYCONFIG_ADAPTER_NAME;
[PInvokeData("wingdi.h", MSDNShortId = "248f325f-37ae-48f4-a758-ee78a3e3f0b8")]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct DISPLAYCONFIG_ADAPTER_NAME
public struct DISPLAYCONFIG_ADAPTER_NAME : IDisplayConfig
{
/// <summary>
/// A DISPLAYCONFIG_DEVICE_INFO_HEADER structure that contains information about the request for the adapter name. The caller should
@ -648,12 +648,29 @@ public static partial class Gdi32
/// of information being requested. For example, in the case of DISPLAYCONFIG_DEVICE_INFO_GET_SOURCE_NAME, this is the source identifier.
/// </summary>
public uint id;
/// <summary>
/// Initializes a new instance of the <see cref="DISPLAYCONFIG_DEVICE_INFO_HEADER"/> struct.
/// </summary>
/// <param name="type">The type.</param>
/// <param name="adapterId">The adapter identifier.</param>
/// <param name="id">The identifier.</param>
public DISPLAYCONFIG_DEVICE_INFO_HEADER(DISPLAYCONFIG_DEVICE_INFO_TYPE type, ulong adapterId, uint id)
{
size = (uint)Marshal.SizeOf(typeof(DISPLAYCONFIG_DEVICE_INFO_HEADER));
this.type = type;
this.adapterId = adapterId;
this.id = id;
}
}
/// <summary>A structure that contains <see cref="DISPLAYCONFIG_DEVICE_INFO_HEADER"/> as the first field.</summary>
public interface IDisplayConfig { }
/// <summary>Undocumented.</summary>
[PInvokeData("wingdi.h")]
[StructLayout(LayoutKind.Sequential)]
public struct DISPLAYCONFIG_GET_ADVANCED_COLOR_INFO
public struct DISPLAYCONFIG_GET_ADVANCED_COLOR_INFO : IDisplayConfig
{
/// <summary>Undocumented.</summary>
public DISPLAYCONFIG_DEVICE_INFO_HEADER header;
@ -950,7 +967,7 @@ public static partial class Gdi32
/// <summary>Undocumented.</summary>
[PInvokeData("wingdi.h")]
[StructLayout(LayoutKind.Sequential)]
public struct DISPLAYCONFIG_SDR_WHITE_LEVEL
public struct DISPLAYCONFIG_SDR_WHITE_LEVEL : IDisplayConfig
{
/// <summary>Undocumented.</summary>
private DISPLAYCONFIG_DEVICE_INFO_HEADER header;
@ -965,7 +982,7 @@ public static partial class Gdi32
/// <summary>Undocumented.</summary>
[PInvokeData("wingdi.h")]
[StructLayout(LayoutKind.Sequential)]
public struct DISPLAYCONFIG_SET_ADVANCED_COLOR_STATE
public struct DISPLAYCONFIG_SET_ADVANCED_COLOR_STATE : IDisplayConfig
{
/// <summary>Undocumented.</summary>
public DISPLAYCONFIG_DEVICE_INFO_HEADER header;
@ -980,7 +997,7 @@ public static partial class Gdi32
// reserved : 31; } DUMMYSTRUCTNAME; UINT32 value; } DUMMYUNIONNAME; } DISPLAYCONFIG_SET_TARGET_PERSISTENCE;
[PInvokeData("wingdi.h", MSDNShortId = "4798a1e1-8685-40c2-917a-0ee071bc780c")]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct DISPLAYCONFIG_SET_TARGET_PERSISTENCE
public struct DISPLAYCONFIG_SET_TARGET_PERSISTENCE : IDisplayConfig
{
/// <summary>
/// A DISPLAYCONFIG_DEVICE_INFO_HEADER structure that contains information for setting the target persistence. The <c>type</c> member
@ -1002,7 +1019,7 @@ public static partial class Gdi32
// DISPLAYCONFIG_SOURCE_DEVICE_NAME { DISPLAYCONFIG_DEVICE_INFO_HEADER header; WCHAR viewGdiDeviceName[CCHDEVICENAME]; } DISPLAYCONFIG_SOURCE_DEVICE_NAME;
[PInvokeData("wingdi.h", MSDNShortId = "92813ffc-1915-4f26-afb1-936bf76f7844")]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct DISPLAYCONFIG_SOURCE_DEVICE_NAME
public struct DISPLAYCONFIG_SOURCE_DEVICE_NAME : IDisplayConfig
{
/// <summary>
/// A DISPLAYCONFIG_DEVICE_INFO_HEADER structure that contains information about the request for the source device name. The caller
@ -1065,7 +1082,7 @@ public static partial class Gdi32
// disableMonitorVirtualResolution : 1; UINT32 reserved : 31; } DUMMYSTRUCTNAME; UINT32 value; } DUMMYSTRUCTNAME; } DISPLAYCONFIG_SUPPORT_VIRTUAL_RESOLUTION;
[PInvokeData("wingdi.h", MSDNShortId = "D9208D00-F437-4B2E-8C39-044F75088659")]
[StructLayout(LayoutKind.Sequential)]
public struct DISPLAYCONFIG_SUPPORT_VIRTUAL_RESOLUTION
public struct DISPLAYCONFIG_SUPPORT_VIRTUAL_RESOLUTION : IDisplayConfig
{
/// <summary>
/// A DISPLAYCONFIG_DEVICE_INFO_HEADER structure that holds information on the type, size, adapterID, and ID of the target the
@ -1088,7 +1105,7 @@ public static partial class Gdi32
// } DISPLAYCONFIG_TARGET_BASE_TYPE;
[PInvokeData("wingdi.h", MSDNShortId = "7916E714-9A3C-4682-AC08-9B6EE222D8B7")]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
public struct DISPLAYCONFIG_TARGET_BASE_TYPE
public struct DISPLAYCONFIG_TARGET_BASE_TYPE : IDisplayConfig
{
/// <summary>
/// <para>
@ -1138,7 +1155,7 @@ public static partial class Gdi32
// connectorInstance; public ushort monitorFriendlyDeviceName[64]; public ushort monitorDevicePath[128]; public ; public
// DISPLAYCONFIG_TARGET_DEVICE_NAME; }
[StructLayout(LayoutKind.Sequential, Pack = 2, CharSet = CharSet.Unicode)]
public struct DISPLAYCONFIG_TARGET_DEVICE_NAME
public struct DISPLAYCONFIG_TARGET_DEVICE_NAME : IDisplayConfig
{
/// <summary>
/// A DISPLAYCONFIG_DEVICE_INFO_HEADER structure that contains information about the request for the target device name. The caller
@ -1205,7 +1222,7 @@ public static partial class Gdi32
// targetMode; } DISPLAYCONFIG_TARGET_PREFERRED_MODE;
[PInvokeData("wingdi.h", MSDNShortId = "1a4926ca-36d2-466c-b3d2-b59d34a89ee6")]
[StructLayout(LayoutKind.Sequential)]
public struct DISPLAYCONFIG_TARGET_PREFERRED_MODE
public struct DISPLAYCONFIG_TARGET_PREFERRED_MODE : IDisplayConfig
{
/// <summary>
/// A DISPLAYCONFIG_DEVICE_INFO_HEADER structure that contains information about the request for the target preferred mode. The

View File

@ -1969,7 +1969,7 @@ public static partial class Kernel32
/// subset of the specified affinity mask. Processes cannot set their own affinity mask.
/// </para>
/// </summary>
public UIntPtr Affinity;
public nuint Affinity;
/// <summary>
/// <para>
@ -2318,7 +2318,7 @@ public static partial class Kernel32
public struct JOBOBJECT_IO_ATTRIBUTION_STATS
{
/// <summary/>
public UIntPtr IoCount;
public nuint IoCount;
/// <summary/>
public ulong TotalNonOverlappedQueueTime;

View File

@ -1309,7 +1309,7 @@ public static partial class Kernel32
/// <summary>
/// <para>The affinity mask of the process.</para>
/// </summary>
public UIntPtr AffinityMask;
public nuint AffinityMask;
/// <summary>
/// <para>The base priority level of the process.</para>
@ -1359,7 +1359,7 @@ public static partial class Kernel32
/// <summary>
/// <para>The affinity mask of the process.</para>
/// </summary>
public UIntPtr AffinityMask;
public nuint AffinityMask;
/// <summary>
/// <para>The threads dynamic priority level.</para>
@ -1602,7 +1602,7 @@ public static partial class Kernel32
/// <summary>
/// <para>The affinity mask of the process.</para>
/// </summary>
public UIntPtr AffinityMask;
public nuint AffinityMask;
/// <summary>
/// <para>The base priority level of the process.</para>
@ -1652,12 +1652,12 @@ public static partial class Kernel32
/// <summary>
/// <para>A memory usage counter. See the GetProcessMemoryInfo function for more information.</para>
/// </summary>
public UIntPtr PeakVirtualSize;
public nuint PeakVirtualSize;
/// <summary>
/// <para>A memory usage counter. See the GetProcessMemoryInfo function for more information.</para>
/// </summary>
public UIntPtr VirtualSize;
public nuint VirtualSize;
/// <summary>
/// <para>A memory usage counter. See the GetProcessMemoryInfo function for more information.</para>
@ -1667,47 +1667,47 @@ public static partial class Kernel32
/// <summary>
/// <para>A memory usage counter. See the GetProcessMemoryInfo function for more information.</para>
/// </summary>
public UIntPtr PeakWorkingSetSize;
public nuint PeakWorkingSetSize;
/// <summary>
/// <para>A memory usage counter. See the GetProcessMemoryInfo function for more information.</para>
/// </summary>
public UIntPtr WorkingSetSize;
public nuint WorkingSetSize;
/// <summary>
/// <para>A memory usage counter. See the GetProcessMemoryInfo function for more information.</para>
/// </summary>
public UIntPtr QuotaPeakPagedPoolUsage;
public nuint QuotaPeakPagedPoolUsage;
/// <summary>
/// <para>A memory usage counter. See the GetProcessMemoryInfo function for more information.</para>
/// </summary>
public UIntPtr QuotaPagedPoolUsage;
public nuint QuotaPagedPoolUsage;
/// <summary>
/// <para>A memory usage counter. See the GetProcessMemoryInfo function for more information.</para>
/// </summary>
public UIntPtr QuotaPeakNonPagedPoolUsage;
public nuint QuotaPeakNonPagedPoolUsage;
/// <summary>
/// <para>A memory usage counter. See the GetProcessMemoryInfo function for more information.</para>
/// </summary>
public UIntPtr QuotaNonPagedPoolUsage;
public nuint QuotaNonPagedPoolUsage;
/// <summary>
/// <para>A memory usage counter. See the GetProcessMemoryInfo function for more information.</para>
/// </summary>
public UIntPtr PagefileUsage;
public nuint PagefileUsage;
/// <summary>
/// <para>A memory usage counter. See the GetProcessMemoryInfo function for more information.</para>
/// </summary>
public UIntPtr PeakPagefileUsage;
public nuint PeakPagefileUsage;
/// <summary>
/// <para>A memory usage counter. See the GetProcessMemoryInfo function for more information.</para>
/// </summary>
public UIntPtr PrivateUsage;
public nuint PrivateUsage;
/// <summary>
/// <para>Reserved for use by the operating system.</para>
@ -1762,7 +1762,7 @@ public static partial class Kernel32
/// <summary>
/// <para>The affinity mask of the process.</para>
/// </summary>
public UIntPtr AffinityMask;
public nuint AffinityMask;
/// <summary>
/// <para>The threads dynamic priority level.</para>
@ -1920,7 +1920,7 @@ public static partial class Kernel32
/// <summary>
/// <para>Information about the VA region. For more information, see MEMORY_BASIC_INFORMATION.</para>
/// </summary>
public UIntPtr RegionSize;
public nuint RegionSize;
/// <summary>
/// <para>Information about the VA region. For more information, see MEMORY_BASIC_INFORMATION.</para>

View File

@ -2636,7 +2636,7 @@ public static partial class Kernel32
// VOID WINAPI GetCurrentThreadStackLimits( _Out_ PULONG_PTR LowLimit, _Out_ PULONG_PTR HighLimit); https://msdn.microsoft.com/en-us/library/windows/desktop/hh706789(v=vs.85).aspx
[DllImport(Lib.Kernel32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("Processthreadsapi.h", MSDNShortId = "hh706789")]
public static extern void GetCurrentThreadStackLimits(out UIntPtr LowLimit, out UIntPtr HighLimit);
public static extern void GetCurrentThreadStackLimits(out nuint LowLimit, out nuint HighLimit);
/// <summary>
/// Retrieves a pseudo-handle that you can use as a shorthand way to refer to the impersonation token that was assigned to the current thread.
@ -6576,7 +6576,7 @@ public static partial class Kernel32
/// </list>
/// </para>
/// </summary>
public UIntPtr Value;
public nuint Value;
}
/// <summary>

View File

@ -1789,13 +1789,13 @@ public static partial class Kernel32
/// <summary>
/// The working set information. See the description of the structure members for information about the layout of this variable.
/// </summary>
public UIntPtr Flags;
public nuint Flags;
/// <summary>If <see langword="true"/>, the page is sharable; otherwise, the page is not sharable.</summary>
public bool Shared => GetBit(Flags.ToUInt32(), 9);
public bool Shared => GetBit((uint)Flags, 9);
/// <summary>The number of processes that share this page. The maximum value of this member is 7.</summary>
public uint ShareCount => GetBits(Flags.ToUInt32(), 5, 3);
public uint ShareCount => GetBits((uint)Flags, 5, 3);
/// <summary>
/// <para>The protection attributes of the page. This member can be one of the following values.</para>
@ -1934,10 +1934,10 @@ public static partial class Kernel32
/// </item>
/// </list>
/// </summary>
public uint Protection => GetBits(Flags.ToUInt32(), 0, 5);
public uint Protection => GetBits((uint)Flags, 0, 5);
/// <summary/>
public IntPtr VirtualPage => new((long)Flags.ToUInt64() & ~0xFFFL);
public IntPtr VirtualPage => new((long)Flags & ~0xFFFL);
}
/// <summary>Contains extended working set information for a page.</summary>
@ -1953,25 +1953,25 @@ public static partial class Kernel32
/// <summary>
/// The working set information. See the description of the structure members for information about the layout of this variable.
/// </summary>
public UIntPtr Flags;
public nuint Flags;
/// <summary>If <see langword="true"/>, the page is valid; otherwise, the page is not valid.</summary>
public bool Valid => GetBit(Flags.ToUInt32(), 0);
public bool Valid => GetBit((uint)Flags, 0);
/// <summary>Gets a value indicating whether the virtual page is locked in physical memory.</summary>
public bool Locked => Valid && GetBit(Flags.ToUInt32(), 22);
public bool Locked => Valid && GetBit((uint)Flags, 22);
/// <summary>Gets a value indicating whether this page is a large page.</summary>
public bool LargePage => Valid && GetBit(Flags.ToUInt32(), 23);
public bool LargePage => Valid && GetBit((uint)Flags, 23);
/// <summary>Gets a value indicating whether the page is has been reported as bad.</summary>
public bool Bad => GetBit(Flags.ToUInt32(), 31);
public bool Bad => GetBit((uint)Flags, 31);
/// <summary>If <see langword="true"/>, the page is sharable; otherwise, the page is not sharable.</summary>
public bool Shared => GetBit(Flags.ToUInt32(), 15);
public bool Shared => GetBit((uint)Flags, 15);
/// <summary>The number of processes that share this page. The maximum value of this member is 7.</summary>
public uint ShareCount => Valid ? GetBits(Flags.ToUInt32(), 1, 3) : 0U;
public uint ShareCount => Valid ? GetBits((uint)Flags, 1, 3) : 0U;
/// <summary>
/// <para>The protection attributes of the page. This member can be one of the following values.</para>
@ -2110,10 +2110,10 @@ public static partial class Kernel32
/// </item>
/// </list>
/// </summary>
public uint Protection => Valid ? GetBits(Flags.ToUInt32(), 4, 11) : 0U;
public uint Protection => Valid ? GetBits((uint)Flags, 4, 11) : 0U;
/// <summary>Gets the NUMA node. The maximum value of this member is 63.</summary>
public uint Node => Valid ? GetBits(Flags.ToUInt32(), 16, 6) : 0U;
public uint Node => Valid ? GetBits((uint)Flags, 16, 6) : 0U;
}
/// <summary>Contains extended working set information for a process.</summary>
@ -2140,7 +2140,7 @@ public static partial class Kernel32
public struct PSAPI_WORKING_SET_INFORMATION
{
/// <summary>The number of entries in the <c>WorkingSetInfo</c> array.</summary>
public UIntPtr NumberOfEntries;
public nuint NumberOfEntries;
private PSAPI_WORKING_SET_BLOCK padding;
@ -2153,9 +2153,9 @@ public static partial class Kernel32
{
fixed (PSAPI_WORKING_SET_INFORMATION* ptr = &this)
{
var ret = new PSAPI_WORKING_SET_BLOCK[NumberOfEntries.ToUInt64()];
var ret = new PSAPI_WORKING_SET_BLOCK[(ulong)NumberOfEntries];
var pblk = (PSAPI_WORKING_SET_BLOCK*)(ptr + 1);
for (ulong i = 0; i < NumberOfEntries.ToUInt64(); i++)
for (ulong i = 0; i < (ulong)NumberOfEntries; i++)
ret[i] = pblk[i];
return ret;
}
@ -2202,11 +2202,11 @@ public static partial class Kernel32
/// <summary>
/// <para>The identifier of the thread that caused the page fault.</para>
/// </summary>
public UIntPtr FaultingThreadId;
public nuint FaultingThreadId;
/// <summary>
/// <para>This member is reserved for future use.</para>
/// </summary>
public UIntPtr Flags;
public nuint Flags;
}
}

View File

@ -2422,7 +2422,7 @@ public static partial class Kernel32
private readonly int RecursionCount;
private readonly IntPtr OwningThread;
private readonly IntPtr LockSemaphore;
private readonly UIntPtr SpinCount;
private readonly nuint SpinCount;
}
/// <summary>A one-time initialization structure.</summary>

View File

@ -3267,7 +3267,7 @@ public static partial class Kernel32
private readonly uint Reserved10;
/// <summary>A bitmap that specifies the affinity for zero or more active processors within the group.</summary>
public UIntPtr ActiveProcessorMask;
public nuint ActiveProcessorMask;
}
/// <summary>
@ -3408,7 +3408,7 @@ public static partial class Kernel32
/// <summary>
/// A mask representing the set of processors configured into the system. Bit 0 is processor 0; bit 31 is processor 31.
/// </summary>
public UIntPtr dwActiveProcessorMask;
public nuint dwActiveProcessorMask;
/// <summary>
/// The number of logical processors in the current group. To retrieve this value, use the <c>GetLogicalProcessorInformation</c> function.
@ -3490,7 +3490,7 @@ public static partial class Kernel32
/// </para>
/// <para>On a system with more than 64 processors, the processor mask identifies processors in a single processor group.</para>
/// </summary>
public UIntPtr ProcessorMask;
public nuint ProcessorMask;
/// <summary>
/// <para>

View File

@ -34,7 +34,7 @@ public static partial class Kernel32
/// <param name="Io">A TP_IO structure that defines the I/O completion object that generated the callback.</param>
[UnmanagedFunctionPointer(CallingConvention.Winapi)]
public delegate void IoCompletionCallback(PTP_CALLBACK_INSTANCE Instance, IntPtr Context, IntPtr Overlapped, uint IoResult,
UIntPtr NumberOfBytesTransferred, PTP_IO Io);
nuint NumberOfBytesTransferred, PTP_IO Io);
/// <summary>Applications implement this callback if they call the TrySubmitThreadpoolCallback function to start a worker thread.</summary>
/// <param name="Instance">

View File

@ -236,7 +236,7 @@ public static partial class Kernel32
[DllImport(Lib.Kernel32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("tlhelp32.h", MSDNShortId = "79d01e3a-b11b-46b5-99d0-b445000288a7")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool Heap32First(ref HEAPENTRY32 lphe, uint th32ProcessID, UIntPtr th32HeapID);
public static extern bool Heap32First(ref HEAPENTRY32 lphe, uint th32ProcessID, nuint th32HeapID);
/// <summary>
/// <para>Retrieves information about the first heap that has been allocated by a specified process.</para>
@ -615,7 +615,7 @@ public static partial class Kernel32
/// <summary>
/// <para>The heap identifier. This is not a handle, and has meaning only to the tool help functions.</para>
/// </summary>
public UIntPtr th32HeapID;
public nuint th32HeapID;
/// <summary>Gets an empty instance with the size value set.</summary>
public static readonly HEAPENTRY32 Default = new() { dwSize = (uint)Marshal.SizeOf(typeof(HEAPENTRY32)) };
@ -646,7 +646,7 @@ public static partial class Kernel32
/// <summary>
/// <para>The heap identifier. This is not a handle, and has meaning only to the tool help functions.</para>
/// </summary>
public UIntPtr th32HeapID;
public nuint th32HeapID;
/// <summary>
/// <para>This member can be one of the following values.</para>
@ -832,7 +832,7 @@ public static partial class Kernel32
/// <summary>
/// <para>This member is no longer used and is always set to zero.</para>
/// </summary>
public UIntPtr th32DefaultHeapID;
public nuint th32DefaultHeapID;
/// <summary>
/// <para>This member is no longer used and is always set to zero.</para>

View File

@ -426,7 +426,7 @@ public static partial class Kernel32
[DllImport(Lib.Kernel32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("WinBase.h", MSDNShortId = "ms683213")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool GetProcessAffinityMask([In] HPROCESS hProcess, out UIntPtr lpProcessAffinityMask, out UIntPtr lpSystemAffinityMask);
public static extern bool GetProcessAffinityMask([In] HPROCESS hProcess, out nuint lpProcessAffinityMask, out nuint lpSystemAffinityMask);
/// <summary>Retrieves accounting information for all I/O operations performed by the specified process.</summary>
/// <param name="hProcess">
@ -703,7 +703,7 @@ public static partial class Kernel32
[DllImport(Lib.Kernel32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("WinBase.h", MSDNShortId = "ms686223")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SetProcessAffinityMask([In] HPROCESS hProcess, UIntPtr dwProcessAffinityMask);
public static extern bool SetProcessAffinityMask([In] HPROCESS hProcess, nuint dwProcessAffinityMask);
/// <summary>Sets the minimum and maximum working set sizes for the specified process.</summary>
/// <param name="hProcess">
@ -782,7 +782,7 @@ public static partial class Kernel32
// DWORD_PTR WINAPI SetThreadAffinityMask( _In_ HANDLE hThread, _In_ DWORD_PTR dwThreadAffinityMask); https://msdn.microsoft.com/en-us/library/windows/desktop/ms686247(v=vs.85).aspx
[DllImport(Lib.Kernel32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("WinBase.h", MSDNShortId = "ms686247")]
public static extern UIntPtr SetThreadAffinityMask([In] HTHREAD hThread, UIntPtr dwThreadAffinityMask);
public static extern nuint SetThreadAffinityMask([In] HTHREAD hThread, nuint dwThreadAffinityMask);
/// <summary>
/// Enables an application to inform the system that it is in use, thereby preventing the system from entering sleep or turning off

View File

@ -1,18 +1,8 @@
using System;
namespace Vanara.PInvoke;
namespace Vanara.PInvoke;
/// <summary>Signals that a structure or class holds a handle to a graphics object.</summary>
public interface IGraphicsObjectHandle : IUserHandle { }
/// <summary>Signals that a structure or class holds a HANDLE.</summary>
public interface IHandle
{
/// <summary>Returns the value of the handle field.</summary>
/// <returns>An IntPtr representing the value of the handle field.</returns>
IntPtr DangerousGetHandle();
}
/// <summary>Signals that a structure or class holds a handle to a kernel object.</summary>
public interface IKernelHandle : IHandle { }

View File

@ -972,7 +972,7 @@ public struct CM_PARTIAL_RESOURCE_DESCRIPTOR
/// Contains a <c>UIntPtr</c>-typed bitmask value indicating the set of processors the device can interrupt. To indicate that
/// the device can interrupt any processor, this member is set to -1.
/// </summary>
public UIntPtr Affinity;
public nint Affinity;
}
[StructLayout(LayoutKind.Sequential, Pack = 2)]
@ -993,7 +993,7 @@ public struct CM_PARTIAL_RESOURCE_DESCRIPTOR
public uint Vector;
/// <summary>Specifies a UIntPtr value that indicates the processors that receive the device's interrupts.</summary>
public UIntPtr Affinity;
public nint Affinity;
}
[StructLayout(LayoutKind.Sequential)]

View File

@ -6,9 +6,9 @@ namespace Vanara.PInvoke;
public static partial class User32
{
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
public static HINSTANCE GetWindowInstance(HWND hwnd) => (HINSTANCE)GetWindowLongPtr(hwnd, WindowLongFlags.GWLP_HINSTANCE);
public static WindowStyles GetWindowStyle(HWND hwnd) => (WindowStyles)GetWindowLong(hwnd, WindowLongFlags.GWL_STYLE);
public static WindowStylesEx GetWindowExStyle(HWND hwnd) => (WindowStylesEx)GetWindowLong(hwnd, WindowLongFlags.GWL_EXSTYLE);
public static HINSTANCE GetWindowInstance(HWND hwnd) => GetWindowLong<HINSTANCE>(hwnd, WindowLongFlags.GWLP_HINSTANCE);
public static WindowStyles GetWindowStyle(HWND hwnd) => GetWindowLong<WindowStyles>(hwnd, WindowLongFlags.GWL_STYLE);
public static WindowStylesEx GetWindowExStyle(HWND hwnd) => GetWindowLong<WindowStylesEx>(hwnd, WindowLongFlags.GWL_EXSTYLE);
public static HWND GetWindowOwner(HWND hwnd) => GetWindow(hwnd, GetWindowCmd.GW_OWNER);
public static HWND GetFirstChild(HWND hwnd) => GetTopWindow(hwnd);
public static HWND GetFirstSibling(HWND hwnd) => GetWindow(hwnd, GetWindowCmd.GW_HWNDFIRST);

View File

@ -52,8 +52,8 @@ public static class MsgExtensions
}
else
{
object? wParam = attr.WParamType is null ? null : attr.WParamType.IsNullable() ? msg.wParam.ToStructure(attr.WParamType) : msg.wParam.ToInt32().ConvertTo(attr.WParamType);
object? lParam = attr.LParamType is null ? null : attr.LParamType.IsNullable() ? msg.lParam.ToStructure(attr.LParamType) : msg.lParam.ToInt32().ConvertTo(attr.LParamType);
object? wParam = attr.WParamType is null ? null : attr.WParamType.IsNullable() ? msg.wParam.ToStructure(attr.WParamType) : msg.wParam.ToInt32().CastTo(attr.WParamType);
object? lParam = attr.LParamType is null ? null : attr.LParamType.IsNullable() ? msg.lParam.ToStructure(attr.LParamType) : msg.lParam.ToInt32().CastTo(attr.LParamType);
return (wParam, lParam);
}
}

View File

@ -1041,7 +1041,7 @@ public static partial class User32
public static void SetUserObjectInformation<T>(IntPtr hObj, UserObjectInformationType nIndex, T info)
{
if (!CorrespondingTypeAttribute.CanSet(nIndex, typeof(T))) throw new ArgumentException("Type mismatch");
var mem = typeof(T) == typeof(string) ? new SafeHGlobalHandle(info.ToString()!) : SafeHGlobalHandle.CreateFromStructure(info);
var mem = typeof(T) == typeof(string) ? new SafeHGlobalHandle(info?.ToString() ?? "") : SafeHGlobalHandle.CreateFromStructure(info);
if (!SetUserObjectInformation(hObj, nIndex, (IntPtr)mem, (uint)mem.Size))
Win32Error.ThrowLastError();
}

View File

@ -248,7 +248,7 @@ public static partial class User32
// https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-createdialoga void CreateDialogA( hInstance, lpName,
// hWndParent, lpDialogFunc );
[PInvokeData("winuser.h", MSDNShortId = "createdialog")]
public static SafeHWND CreateDialog(HINSTANCE hInstance, string lpName, HWND hWndParent, DialogProc lpDialogFunc) => CreateDialogParam(hInstance, lpName, hWndParent, lpDialogFunc);
public static SafeHWND CreateDialog([Optional] HINSTANCE hInstance, SafeResourceId lpName, HWND hWndParent, DialogProc lpDialogFunc) => CreateDialogParam(hInstance, lpName, hWndParent, lpDialogFunc);
/// <summary>
/// <para>
@ -397,7 +397,7 @@ public static partial class User32
// dwInitParam );
[DllImport(Lib.User32, SetLastError = true, CharSet = CharSet.Auto)]
[PInvokeData("winuser.h", MSDNShortId = "createdialogindirectparam")]
public static extern SafeHWND CreateDialogIndirectParam(HINSTANCE hInstance, IntPtr lpTemplate, HWND hWndParent, DialogProc lpDialogFunc, [Optional] IntPtr dwInitParam);
public static extern SafeHWND CreateDialogIndirectParam([Optional] HINSTANCE hInstance, IntPtr lpTemplate, HWND hWndParent, DialogProc lpDialogFunc, [Optional] IntPtr dwInitParam);
/// <summary>
/// <para>
@ -455,7 +455,7 @@ public static partial class User32
// hInstance, LPCSTR lpTemplateName, HWND hWndParent, DLGPROC lpDialogFunc, LPARAM dwInitParam );
[DllImport(Lib.User32, SetLastError = true, CharSet = CharSet.Auto)]
[PInvokeData("winuser.h", MSDNShortId = "createdialogparam")]
public static extern SafeHWND CreateDialogParam(HINSTANCE hInstance, string lpTemplateName, HWND hWndParent, DialogProc lpDialogFunc, [Optional] IntPtr dwInitParam);
public static extern SafeHWND CreateDialogParam([Optional] HINSTANCE hInstance, SafeResourceId lpTemplateName, HWND hWndParent, DialogProc lpDialogFunc, [Optional] IntPtr dwInitParam);
/// <summary>
/// <para>
@ -555,7 +555,7 @@ public static partial class User32
// https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-dialogboxa void DialogBoxA( hInstance, lpTemplate,
// hWndParent, lpDialogFunc );
[PInvokeData("winuser.h", MSDNShortId = "dialogbox")]
public static IntPtr DialogBox(HINSTANCE hInstance, string lpTemplate, HWND hWndParent, DialogProc lpDialogFunc) => DialogBoxParam(hInstance, lpTemplate, hWndParent, lpDialogFunc);
public static IntPtr DialogBox([Optional] HINSTANCE hInstance, string lpTemplate, HWND hWndParent, DialogProc lpDialogFunc) => DialogBoxParam(hInstance, lpTemplate, hWndParent, lpDialogFunc);
/// <summary>
/// <para>
@ -608,7 +608,7 @@ public static partial class User32
// https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-dialogboxa void DialogBoxA( hInstance, lpTemplate,
// hWndParent, lpDialogFunc );
[PInvokeData("winuser.h", MSDNShortId = "dialogbox")]
public static IntPtr DialogBox(HINSTANCE hInstance, ResourceId lpTemplate, HWND hWndParent, DialogProc lpDialogFunc) => DialogBoxParam(hInstance, lpTemplate, hWndParent, lpDialogFunc);
public static IntPtr DialogBox([Optional] HINSTANCE hInstance, ResourceId lpTemplate, HWND hWndParent, DialogProc lpDialogFunc) => DialogBoxParam(hInstance, lpTemplate, hWndParent, lpDialogFunc);
/// <summary>
/// <para>
@ -828,7 +828,7 @@ public static partial class User32
// hInstance, LPCSTR lpTemplateName, HWND hWndParent, DLGPROC lpDialogFunc, LPARAM dwInitParam );
[DllImport(Lib.User32, SetLastError = true, CharSet = CharSet.Auto)]
[PInvokeData("winuser.h", MSDNShortId = "dialogboxparam")]
public static extern IntPtr DialogBoxParam(HINSTANCE hInstance, string lpTemplateName, HWND hWndParent, DialogProc lpDialogFunc, [Optional] IntPtr dwInitParam);
public static extern IntPtr DialogBoxParam([Optional] HINSTANCE hInstance, string lpTemplateName, HWND hWndParent, DialogProc lpDialogFunc, [Optional] IntPtr dwInitParam);
/// <summary>
/// <para>
@ -893,7 +893,7 @@ public static partial class User32
// hInstance, LPCSTR lpTemplateName, HWND hWndParent, DLGPROC lpDialogFunc, LPARAM dwInitParam );
[DllImport(Lib.User32, SetLastError = true, CharSet = CharSet.Auto)]
[PInvokeData("winuser.h", MSDNShortId = "dialogboxparam")]
public static extern IntPtr DialogBoxParam(HINSTANCE hInstance, ResourceId lpTemplateName, HWND hWndParent, DialogProc lpDialogFunc, [Optional] IntPtr dwInitParam);
public static extern IntPtr DialogBoxParam([Optional] HINSTANCE hInstance, ResourceId lpTemplateName, HWND hWndParent, DialogProc lpDialogFunc, [Optional] IntPtr dwInitParam);
/// <summary>
/// Retrieves the current selection from a combo box filled by using the DlgDirListComboBox function. The selection is interpreted as
@ -1260,7 +1260,7 @@ public static partial class User32
// HWND hCtl, BOOL bPrevious );
[DllImport(Lib.User32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("winuser.h", MSDNShortId = "getnextdlggroupitem")]
public static extern HWND GetNextDlgGroupItem(HWND hDlg, HWND hCtl, [MarshalAs(UnmanagedType.Bool)] bool bPrevious);
public static extern HWND GetNextDlgGroupItem(HWND hDlg, [Optional] HWND hCtl, [MarshalAs(UnmanagedType.Bool)] bool bPrevious);
/// <summary>
/// <para>Retrieves a handle to the first control that has the WS_TABSTOP style that precedes (or follows) the specified control.</para>
@ -1304,7 +1304,7 @@ public static partial class User32
// hCtl, BOOL bPrevious );
[DllImport(Lib.User32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("winuser.h", MSDNShortId = "getnextdlgtabitem")]
public static extern HWND GetNextDlgTabItem(HWND hDlg, HWND hCtl, [MarshalAs(UnmanagedType.Bool)] bool bPrevious);
public static extern HWND GetNextDlgTabItem(HWND hDlg, [Optional] HWND hCtl, [MarshalAs(UnmanagedType.Bool)] bool bPrevious);
/// <summary>
/// <para>Determines whether a message is intended for the specified dialog box and, if it is, processes the message.</para>

View File

@ -190,21 +190,20 @@ public static partial class User32
/// </param>
/// <returns>The value of type <typeparamref name="T"/> for the information provided.</returns>
/// <exception cref="ArgumentException">Request type does not match type param value.</exception>
public static T DisplayConfigGetDeviceInfo<T>(ulong adapterId, uint id, DISPLAYCONFIG_DEVICE_INFO_TYPE type = 0) where T : struct
public static T DisplayConfigGetDeviceInfo<T>(ulong adapterId, uint id, DISPLAYCONFIG_DEVICE_INFO_TYPE type = 0) where T : struct, IDisplayConfig
{
if (type == 0)
{
if (!CorrespondingTypeAttribute.CanGet<T, DISPLAYCONFIG_DEVICE_INFO_TYPE>(out type)) throw new ArgumentException("Unable to find enum value matching supplied type param.");
if (!CorrespondingTypeAttribute.CanGet<T, DISPLAYCONFIG_DEVICE_INFO_TYPE>(out type))
throw new ArgumentException("Unable to find enum value matching supplied type param.");
}
else if (!CorrespondingTypeAttribute.CanGet(type, typeof(T))) throw new ArgumentException("Request type does not match type param value.");
var hdr = new DISPLAYCONFIG_DEVICE_INFO_HEADER { size = (uint)Marshal.SizeOf(typeof(T)), type = type, adapterId = adapterId, id = id };
var mem = new SafeHGlobalHandle((int)hdr.size);
mem.Zero();
else if (!CorrespondingTypeAttribute.CanGet(type, typeof(T)))
throw new ArgumentException("Request type does not match type param value.");
DISPLAYCONFIG_DEVICE_INFO_HEADER hdr = new() { size = (uint)Marshal.SizeOf(typeof(T)), type = type, adapterId = adapterId, id = id };
using var mem = new SafeCoTaskMemStruct<T>((int)hdr.size);
Marshal.StructureToPtr(hdr, (IntPtr)mem, false);
var hdr2 = mem.ToStructure<T>();
var err = DisplayConfigGetDeviceInfo((IntPtr)mem);
err.ThrowIfFailed();
return mem.ToStructure<T>();
DisplayConfigGetDeviceInfo(mem).ThrowIfFailed();
return mem.Value;
}
/// <summary>The <c>DisplayConfigSetDeviceInfo</c> function sets the properties of a target.</summary>

View File

@ -2,6 +2,8 @@
using System.Diagnostics.CodeAnalysis;
using System.Runtime.InteropServices;
using System.Text;
using Vanara.Extensions;
using Vanara.Extensions.Reflection;
using Vanara.InteropServices;
using static Vanara.PInvoke.Gdi32;
@ -313,9 +315,11 @@ public static partial class User32
GWL_STYLE = -16,
/// <summary>The window user data</summary>
[CorrespondingType(typeof(IntPtr))]
GWL_USERDATA = -21,
/// <summary>The window user data</summary>
[CorrespondingType(typeof(IntPtr))]
GWLP_USERDATA = -21,
/// <summary>The window procedure address or handle</summary>
@ -327,9 +331,11 @@ public static partial class User32
GWLP_WNDPROC = -4,
/// <summary>The dialog user data</summary>
[CorrespondingType(typeof(IntPtr))]
DWLP_USER = 0x8,
/// <summary>The dialog procedure message result</summary>
[CorrespondingType(typeof(IntPtr))]
DWLP_MSGRESULT = 0x0,
/// <summary>The dialog procedure address or handle</summary>
@ -337,9 +343,11 @@ public static partial class User32
DWLP_DLGPROC = 0x4,
/// <summary>The dialog user data</summary>
[CorrespondingType(typeof(IntPtr))]
DWL_USER = 0x8,
/// <summary>The dialog procedure message result</summary>
[CorrespondingType(typeof(IntPtr))]
DWL_MSGRESULT = 0x0,
/// <summary>The dialog procedure address or handle</summary>
@ -1917,7 +1925,7 @@ public static partial class User32
// cchText, LPRECT lprc, UINT format, LPDRAWTEXTPARAMS lpdtp );
[DllImport(Lib.User32, SetLastError = false, CharSet = CharSet.Auto)]
[PInvokeData("winuser.h", MSDNShortId = "77b9973b-77f1-4508-a021-52d61d576c23")]
public static extern int DrawTextEx(HDC hdc, string lpchText, int cchText, in RECT lprc, DrawTextFlags format, [Optional] DRAWTEXTPARAMS lpdtp);
public static extern int DrawTextEx(HDC hdc, string lpchText, int cchText, in RECT lprc, DrawTextFlags format, [Optional] DRAWTEXTPARAMS? lpdtp);
/// <summary>The <c>DrawTextEx</c> function draws formatted text in the specified rectangle.</summary>
/// <param name="hdc">A handle to the device context in which to draw.</param>
@ -2102,7 +2110,7 @@ public static partial class User32
// cchText, LPRECT lprc, UINT format, LPDRAWTEXTPARAMS lpdtp );
[DllImport(Lib.User32, SetLastError = false, CharSet = CharSet.Auto)]
[PInvokeData("winuser.h", MSDNShortId = "77b9973b-77f1-4508-a021-52d61d576c23")]
public static extern int DrawTextEx(HDC hdc, StringBuilder lpchText, int cchText, in RECT lprc, DrawTextFlags format, [Optional] DRAWTEXTPARAMS lpdtp);
public static extern int DrawTextEx(HDC hdc, StringBuilder lpchText, int cchText, in RECT lprc, DrawTextFlags format, [Optional] DRAWTEXTPARAMS? lpdtp);
/// <summary>
/// The GetDC function retrieves a handle to a device context (DC) for the client area of a specified window or for the entire
@ -2350,7 +2358,7 @@ public static partial class User32
// LPCSTR lpString, int chCount, int nTabPositions, const INT *lpnTabStopPositions );
[DllImport(Lib.User32, SetLastError = false, CharSet = CharSet.Auto)]
[PInvokeData("winuser.h", MSDNShortId = "3444bb8d-4a30-47d4-b211-01f7cba39975")]
public static extern uint GetTabbedTextExtent(HDC hdc, string lpString, int chCount, int nTabPositions, [In] int[] lpnTabStopPositions);
public static extern uint GetTabbedTextExtent(HDC hdc, string lpString, int chCount, [Optional] int nTabPositions, [In, Optional] int[]? lpnTabStopPositions);
/// <summary>
/// The <c>GetTabbedTextExtent</c> function computes the width and height of a character string. If the string contains one or more
@ -2388,9 +2396,9 @@ public static partial class User32
// https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-gettabbedtextextenta DWORD GetTabbedTextExtentA( HDC hdc,
// LPCSTR lpString, int chCount, int nTabPositions, const INT *lpnTabStopPositions );
[PInvokeData("winuser.h", MSDNShortId = "3444bb8d-4a30-47d4-b211-01f7cba39975")]
public static SIZE GetTabbedTextExtent(HDC hdc, string lpString, int[] lpnTabStopPositions)
public static SIZE GetTabbedTextExtent(HDC hdc, string lpString, int[]? lpnTabStopPositions = null)
{
var ret = GetTabbedTextExtent(hdc, lpString, lpString?.Length ?? 0, lpnTabStopPositions?.Length ?? 0, lpnTabStopPositions);
var ret = GetTabbedTextExtent(hdc, lpString, lpString.Length, lpnTabStopPositions?.Length ?? 0, lpnTabStopPositions);
return new SIZE(Macros.LOWORD(ret), Macros.HIWORD(ret));
}
@ -2477,6 +2485,26 @@ public static partial class User32
return ret;
}
/// <summary>
/// Retrieves information about the specified window. The function also retrieves the value at a specified offset into the extra window memory.
/// </summary>
/// <typeparam name="T">The type of the return value.</typeparam>
/// <param name="hWnd">A handle to the window and, indirectly, the class to which the window belongs.</param>
/// <param name="nIndex">
/// The zero-based offset to the value to be retrieved. Valid values are in the range zero through the number of bytes of extra window
/// memory, minus the size of an integer. To retrieve any other value, specify one of the following values.
/// </param>
/// <returns>
/// If the function succeeds, the return value is the requested value. If the function fails, the return value is zero.To get extended
/// error information, call GetLastError.
/// </returns>
/// <exception cref="System.ArgumentException">Type mismatch</exception>
public static T GetWindowLong<T>(HWND hWnd, WindowLongFlags nIndex)
{
if (!CorrespondingTypeAttribute.CanGet(nIndex, typeof(T))) throw new ArgumentException("Type mismatch");
return (T)GetWindowLongAuto(hWnd, nIndex).CastTo(typeof(T))!;
}
/// <summary>
/// Retrieves information about the specified window. The function also retrieves the value at a specified offset into the extra
/// window memory.
@ -2612,7 +2640,7 @@ public static partial class User32
// LPCSTR lpBitmapName );
[DllImport(Lib.User32, SetLastError = false, CharSet = CharSet.Auto)]
[PInvokeData("winuser.h", MSDNShortId = "5eed5f78-deaf-4b23-986e-4802dc05936c")]
public static extern SafeHBITMAP LoadBitmap(HINSTANCE hInstance, [In] SafeResourceId lpBitmapName);
public static extern SafeHBITMAP LoadBitmap([Optional] HINSTANCE hInstance, [In] SafeResourceId lpBitmapName);
/// <summary>
/// The <c>ReleaseDC</c> function releases a device context (DC), freeing it for use by other applications. The effect of the
@ -3067,7 +3095,7 @@ public static partial class User32
/// <summary>Creates a <see cref="WINDOWPOS"/> structure from an LPARAM value.</summary>
/// <param name="lParam">The LPARAM value.</param>
/// <returns>A <see cref="WINDOWPOS"/> structure.</returns>
public static WINDOWPOS FromLParam(IntPtr lParam) => (WINDOWPOS)Marshal.PtrToStructure(lParam, typeof(WINDOWPOS));
public static WINDOWPOS FromLParam(IntPtr lParam) => lParam.ToStructure<WINDOWPOS>();
/// <summary>Updates the <see cref="WINDOWPOS"/> value pointed to by an LPARAM value from this instance.</summary>
/// <param name="lParam">The LPARAM value to update.</param>

View File

@ -310,7 +310,7 @@ public static partial class User32
[DllImport(Lib.User32, SetLastError = true, CharSet = CharSet.Auto)]
[PInvokeData("winuser.h", MSDNShortId = "fce80bac-2a44-46e7-a87a-ef93f4599807")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool WinHelp(HWND hWndMain, string lpszHelp, HelpCmd uCommand, IntPtr dwData);
public static extern bool WinHelp(HWND hWndMain, string lpszHelp, HelpCmd uCommand, [Optional] IntPtr dwData);
/// <summary>
/// Contains the size and position of either a primary or secondary Help window. An application can set this information by calling

View File

@ -35,7 +35,7 @@ public static partial class User32
// hProcess );
[DllImport(Lib.User32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("winuser.h", MSDNShortId = "94236ECF-E69A-4D77-AABA-D43FE8DF8203")]
public static extern uint GetSystemDpiForProcess(HPROCESS hProcess);
public static extern uint GetSystemDpiForProcess([Optional] HPROCESS hProcess);
/// <summary>Retrieves the specified system metric or system configuration setting taking into account a provided DPI.</summary>
/// <param name="nIndex">The system metric or configuration setting to be retrieved. See GetSystemMetrics for the possible values.</param>
@ -90,7 +90,7 @@ public static partial class User32
[DllImport(Lib.User32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("winuser.h", MSDNShortId = "BA460A5B-5356-43A5-B232-03E6E72D15A2")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SystemParametersInfoForDpi(SPI uiAction, uint uiParam, IntPtr pvParam, uint fWinIni, uint dpi);
public static extern bool SystemParametersInfoForDpi(SPI uiAction, [Optional] uint uiParam, [Optional] IntPtr pvParam, uint fWinIni, uint dpi);
/// <summary>Sets the DPI scale for which the cursors being created on this thread are intended. This value is taken into account when scaling the cursor for the specific monitor on which it is being shown.</summary>
/// <param name="cursorDpi">

View File

@ -857,7 +857,7 @@ public static partial class User32
// eventMin, DWORD eventMax, HMODULE hmodWinEventProc, WINEVENTPROC pfnWinEventProc, DWORD idProcess, DWORD idThread, DWORD dwFlags );
[DllImport(Lib.User32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("winuser.h", MSDNShortId = "090bda1b-0635-4aa3-ae33-3987b36e30b8")]
public static extern HWINEVENTHOOK SetWinEventHook(uint eventMin, uint eventMax, HINSTANCE hmodWinEventProc, WinEventProc pfnWinEventProc, uint idProcess, uint idThread, WINEVENT dwFlags);
public static extern HWINEVENTHOOK SetWinEventHook(uint eventMin, uint eventMax, [Optional] HINSTANCE hmodWinEventProc, WinEventProc pfnWinEventProc, uint idProcess, [Optional] uint idThread, WINEVENT dwFlags);
/// <summary>
/// <para>Removes a hook procedure installed in a hook chain by the SetWindowsHookEx function.</para>
@ -1341,7 +1341,7 @@ public static partial class User32
/// <para>Type: <c>ULONG_PTR</c></para>
/// <para>Additional information associated with the message.</para>
/// </summary>
public UIntPtr dwExtraInfo;
public IntPtr dwExtraInfo;
}
/// <summary>
@ -1375,7 +1375,7 @@ public static partial class User32
/// <para>Type: <c>ULONG_PTR</c></para>
/// <para>Additional information associated with the message.</para>
/// </summary>
public UIntPtr dwExtraInfo;
public IntPtr dwExtraInfo;
}
/// <summary>
@ -1412,7 +1412,7 @@ public static partial class User32
/// <para>Type: <c>ULONG_PTR</c></para>
/// <para>Additional information associated with the message.</para>
/// </summary>
public UIntPtr dwExtraInfo;
public IntPtr dwExtraInfo;
/// <summary>
/// <para>Type: <c>DWORD</c></para>
@ -1522,7 +1522,7 @@ public static partial class User32
/// <para>Type: <c>ULONG_PTR</c></para>
/// <para>Additional information associated with the message.</para>
/// </summary>
public UIntPtr dwExtraInfo;
public IntPtr dwExtraInfo;
}
/// <summary>

View File

@ -607,7 +607,7 @@ public static partial class User32
[DllImport(Lib.User32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("winuser.h", MSDNShortId = "drawiconex")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool DrawIconEx(HDC hdc, int xLeft, int yTop, HICON hIcon, int cxWidth, int cyWidth, uint istepIfAniCur, HBRUSH hbrFlickerFreeDraw, DrawIconExFlags diFlags);
public static extern bool DrawIconEx(HDC hdc, int xLeft, int yTop, HICON hIcon, int cxWidth, int cyWidth, uint istepIfAniCur, [Optional] HBRUSH hbrFlickerFreeDraw, DrawIconExFlags diFlags);
/// <summary>
/// <para>Retrieves information about the specified icon or cursor.</para>
@ -1281,7 +1281,7 @@ public static partial class User32
/// <returns>A bitmap handle.</returns>
public static SafeHBITMAP ToHBITMAP(this HICON hIcon)
{
if (hIcon.IsNull) return null;
if (hIcon.IsNull) return SafeHBITMAP.Null;
using var icoInfo = new ICONINFO();
Win32Error.ThrowLastErrorIfFalse(GetIconInfo(hIcon, icoInfo));
return new SafeHBITMAP((IntPtr)CopyImage((IntPtr)icoInfo.hbmColor, LoadImageType.IMAGE_BITMAP, 0, 0, CopyImageOptions.LR_CREATEDIBSECTION), true);

View File

@ -386,7 +386,7 @@ public static partial class User32
// pData, PUINT pcbSize, UINT cbSizeHeader );
[DllImport(Lib.User32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("winuser.h", MSDNShortId = "")]
public static extern uint GetRawInputBuffer(IntPtr pData, ref uint pcbSize, uint cbSizeHeader);
public static extern uint GetRawInputBuffer([Optional] IntPtr pData, ref uint pcbSize, uint cbSizeHeader);
/// <summary>Retrieves the raw input from the specified device.</summary>
/// <param name="hRawInput">
@ -442,7 +442,7 @@ public static partial class User32
// hRawInput, UINT uiCommand, LPVOID pData, PUINT pcbSize, UINT cbSizeHeader );
[DllImport(Lib.User32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("winuser.h")]
public static extern uint GetRawInputData(HRAWINPUT hRawInput, RID uiCommand, IntPtr pData, ref uint pcbSize, uint cbSizeHeader);
public static extern uint GetRawInputData(HRAWINPUT hRawInput, RID uiCommand, [Optional] IntPtr pData, ref uint pcbSize, uint cbSizeHeader);
/// <summary>Retrieves information about the raw input device.</summary>
/// <param name="hDevice">
@ -498,7 +498,7 @@ public static partial class User32
// HANDLE hDevice, UINT uiCommand, LPVOID pData, PUINT pcbSize );
[DllImport(Lib.User32, SetLastError = true, CharSet = CharSet.Auto)]
[PInvokeData("winuser.h", MSDNShortId = "")]
public static extern uint GetRawInputDeviceInfo(HANDLE hDevice, uint uiCommand, IntPtr pData, ref uint pcbSize);
public static extern uint GetRawInputDeviceInfo(HANDLE hDevice, uint uiCommand, [Optional] IntPtr pData, ref uint pcbSize);
/// <summary>Enumerates the raw input devices attached to the system.</summary>
/// <param name="pRawInputDeviceList">
@ -536,7 +536,7 @@ public static partial class User32
// PRAWINPUTDEVICELIST pRawInputDeviceList, PUINT puiNumDevices, UINT cbSize );
[DllImport(Lib.User32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("winuser.h", MSDNShortId = "")]
public static extern uint GetRawInputDeviceList([In, Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)] RAWINPUTDEVICELIST[] pRawInputDeviceList, ref uint puiNumDevices, uint cbSize);
public static extern uint GetRawInputDeviceList([In, Out, Optional, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)] RAWINPUTDEVICELIST[]? pRawInputDeviceList, ref uint puiNumDevices, uint cbSize);
/// <summary>Retrieves the information about the raw input devices for the current application.</summary>
/// <param name="pRawInputDevices">
@ -567,7 +567,7 @@ public static partial class User32
// GetRegisteredRawInputDevices( PRAWINPUTDEVICE pRawInputDevices, PUINT puiNumDevices, UINT cbSize );
[DllImport(Lib.User32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("winuser.h", MSDNShortId = "")]
public static extern uint GetRegisteredRawInputDevices([In, Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)] RAWINPUTDEVICE[] pRawInputDevices, ref uint puiNumDevices, uint cbSize);
public static extern uint GetRegisteredRawInputDevices([In, Out, Optional, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)] RAWINPUTDEVICE[]? pRawInputDevices, ref uint puiNumDevices, uint cbSize);
/// <summary>Registers the devices that supply the raw input data.</summary>
/// <param name="pRawInputDevices">

View File

@ -2093,7 +2093,7 @@ public static partial class User32
[DllImport(Lib.User32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("winuser.h", MSDNShortId = "registerhotkey")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool RegisterHotKey(HWND hWnd, int id, HotKeyModifiers fsModifiers, uint vk);
public static extern bool RegisterHotKey([Optional] HWND hWnd, int id, HotKeyModifiers fsModifiers, uint vk);
/// <summary>
/// <para>
@ -2551,7 +2551,7 @@ public static partial class User32
[DllImport(Lib.User32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("winuser.h", MSDNShortId = "unregisterhotkey")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool UnregisterHotKey(HWND hWnd, int id);
public static extern bool UnregisterHotKey([Optional] HWND hWnd, int id);
/// <summary>
/// <para>

View File

@ -1359,7 +1359,7 @@ public static partial class User32
[DllImport(Lib.User32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("winuser.h", MSDNShortId = "getmenuitemrect.htm")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool GetMenuItemRect(HWND hWnd, HMENU hMenu, uint uItem, out RECT lprcItem);
public static extern bool GetMenuItemRect([Optional] HWND hWnd, HMENU hMenu, uint uItem, out RECT lprcItem);
/// <summary>
/// <para>
@ -1570,7 +1570,7 @@ public static partial class User32
// uIDItem, LPSTR lpString, int cchMax, UINT flags );
[DllImport(Lib.User32, SetLastError = false, CharSet = CharSet.Auto)]
[PInvokeData("winuser.h", MSDNShortId = "getmenustring.htm")]
public static extern int GetMenuString(HMENU hMenu, uint uIDItem, StringBuilder lpString, int cchMax, MenuFlags flags);
public static extern int GetMenuString(HMENU hMenu, uint uIDItem, StringBuilder? lpString, int cchMax, MenuFlags flags);
/// <summary>
/// <para>Retrieves a handle to the drop-down menu or submenu activated by the specified menu item.</para>
@ -2237,7 +2237,7 @@ public static partial class User32
// hMenu, POINT ptScreen );
[DllImport(Lib.User32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("winuser.h", MSDNShortId = "menuitemfrompoint.htm")]
public static extern int MenuItemFromPoint(HWND hWnd, HMENU hMenu, POINT ptScreen);
public static extern int MenuItemFromPoint([Optional] HWND hWnd, HMENU hMenu, POINT ptScreen);
/// <summary>
/// <para>Changes an existing menu item. This function is used to specify the content, appearance, and behavior of the menu item.</para>
@ -2715,7 +2715,7 @@ public static partial class User32
[DllImport(Lib.User32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("winuser.h", MSDNShortId = "setmenu.htm")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SetMenu(HWND hWnd, HMENU hMenu);
public static extern bool SetMenu(HWND hWnd, [Optional] HMENU hMenu);
/// <summary>Associates a Help context identifier with a menu.</summary>
/// <param name="arg1">
@ -2857,7 +2857,7 @@ public static partial class User32
[DllImport(Lib.User32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("winuser.h", MSDNShortId = "setmenuitembitmaps.htm")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SetMenuItemBitmaps(HMENU hMenu, uint uPosition, MenuFlags uFlags, HBITMAP hBitmapUnchecked, HBITMAP hBitmapChecked);
public static extern bool SetMenuItemBitmaps(HMENU hMenu, uint uPosition, MenuFlags uFlags, [Optional] HBITMAP hBitmapUnchecked, [Optional] HBITMAP hBitmapChecked);
/// <summary>
/// <para>Changes information about a menu item.</para>

View File

@ -52,7 +52,7 @@ public static partial class User32
// Sendasyncproc(_In_ HWND hwnd, _In_ UINT uMsg, _In_ ULONG_PTR dwData, _In_ LRESULT lResult);
[UnmanagedFunctionPointer(CallingConvention.Winapi)]
[PInvokeData("winuser.h")]
public delegate void Sendasyncproc(HWND hwnd, uint uMsg, UIntPtr dwData, IntPtr lResult);
public delegate void Sendasyncproc(HWND hwnd, uint uMsg, IntPtr dwData, IntPtr lResult);
/// <summary>Flags used by BroadcastSystemMessage and BroadcastSystemMessageEx.</summary>
[PInvokeData("winuser.h")]
@ -415,6 +415,133 @@ public static partial class User32
[PInvokeData("winuser.h")]
public static extern long BroadcastSystemMessage(BSF flags, ref BSM lpInfo, uint Msg, [Optional] IntPtr wParam, [Optional] IntPtr lParam);
/// <summary>
/// <para>
/// Sends a message to the specified recipients. The recipients can be applications, installable drivers, network drivers,
/// system-level device drivers, or any combination of these system components.
/// </para>
/// <para>To receive additional information if the request is defined, use the BroadcastSystemMessageEx function.</para>
/// </summary>
/// <param name="flags">
/// <para>Type: <c>DWORD</c></para>
/// <para>The broadcast option. This parameter can be one or more of the following values.</para>
/// <list type="table">
/// <listheader>
/// <term>Value</term>
/// <term>Meaning</term>
/// </listheader>
/// <item>
/// <term>BSF_ALLOWSFW 0x00000080</term>
/// <term>Enables the recipient to set the foreground window while processing the message.</term>
/// </item>
/// <item>
/// <term>BSF_FLUSHDISK 0x00000004</term>
/// <term>Flushes the disk after each recipient processes the message.</term>
/// </item>
/// <item>
/// <term>BSF_FORCEIFHUNG 0x00000020</term>
/// <term>Continues to broadcast the message, even if the time-out period elapses or one of the recipients is not responding.</term>
/// </item>
/// <item>
/// <term>BSF_IGNORECURRENTTASK 0x00000002</term>
/// <term>
/// Does not send the message to windows that belong to the current task. This prevents an application from receiving its own message.
/// </term>
/// </item>
/// <item>
/// <term>BSF_NOHANG 0x00000008</term>
/// <term>
/// Forces a non-responsive application to time out. If one of the recipients times out, do not continue broadcasting the message.
/// </term>
/// </item>
/// <item>
/// <term>BSF_NOTIMEOUTIFNOTHUNG 0x00000040</term>
/// <term>Waits for a response to the message, as long as the recipient is not being unresponsive. Does not time out.</term>
/// </item>
/// <item>
/// <term>BSF_POSTMESSAGE 0x00000010</term>
/// <term>Posts the message. Do not use in combination with BSF_QUERY.</term>
/// </item>
/// <item>
/// <term>BSF_QUERY 0x00000001</term>
/// <term>
/// Sends the message to one recipient at a time, sending to a subsequent recipient only if the current recipient returns TRUE.
/// </term>
/// </item>
/// <item>
/// <term>BSF_SENDNOTIFYMESSAGE 0x00000100</term>
/// <term>Sends the message using SendNotifyMessage function. Do not use in combination with BSF_QUERY.</term>
/// </item>
/// </list>
/// </param>
/// <param name="lpInfo">
/// <para>Type: <c>LPDWORD</c></para>
/// <para>A pointer to a variable that contains and receives information about the recipients of the message.</para>
/// <para>
/// When the function returns, this variable receives a combination of these values identifying which recipients actually received
/// the message.
/// </para>
/// <para>If this parameter is <c>NULL</c>, the function broadcasts to all components.</para>
/// <para>This parameter can be one or more of the following values.</para>
/// <list type="table">
/// <listheader>
/// <term>Value</term>
/// <term>Meaning</term>
/// </listheader>
/// <item>
/// <term>BSM_ALLCOMPONENTS 0x00000000</term>
/// <term>Broadcast to all system components.</term>
/// </item>
/// <item>
/// <term>BSM_ALLDESKTOPS 0x00000010</term>
/// <term>Broadcast to all desktops. Requires the SE_TCB_NAME privilege.</term>
/// </item>
/// <item>
/// <term>BSM_APPLICATIONS 0x00000008</term>
/// <term>Broadcast to applications.</term>
/// </item>
/// </list>
/// </param>
/// <param name="Msg">
/// <para>Type: <c>UINT</c></para>
/// <para>The message to be sent.</para>
/// <para>For lists of the system-provided messages, see System-Defined Messages.</para>
/// </param>
/// <param name="wParam">
/// <para>Type: <c>WPARAM</c></para>
/// <para>Additional message-specific information.</para>
/// </param>
/// <param name="lParam">
/// <para>Type: <c>LPARAM</c></para>
/// <para>Additional message-specific information.</para>
/// </param>
/// <returns>
/// <para>Type: <c>Type: <c>long</c></c></para>
/// <para>If the function succeeds, the return value is a positive value.</para>
/// <para>If the function is unable to broadcast the message, the return value is 1.</para>
/// <para>
/// If the dwFlags parameter is <c>BSF_QUERY</c> and at least one recipient returned <c>BROADCAST_QUERY_DENY</c> to the corresponding
/// message, the return value is zero. To get extended error information, call GetLastError.
/// </para>
/// </returns>
/// <remarks>
/// <para>
/// If <c>BSF_QUERY</c> is not specified, the function sends the specified message to all requested recipients, ignoring values
/// returned by those recipients.
/// </para>
/// <para>
/// The system only does marshaling for system messages (those in the range 0 to (WM_USER-1)). To send other messages (those &gt;=
/// <c>WM_USER</c>) to another process, you must do custom marshaling.
/// </para>
/// <para>Examples</para>
/// <para>For an example, see Terminating a Process.</para>
/// </remarks>
// https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-broadcastsystemmessage long BroadcastSystemMessage( DWORD
// flags, LPDWORD lpInfo, UINT Msg, WPARAM wParam, LPARAM lParam );
[DllImport(Lib.User32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("winuser.h")]
public static extern long BroadcastSystemMessage(BSF flags, [In, Optional] IntPtr lpInfo, uint Msg, [Optional] IntPtr wParam, [Optional] IntPtr lParam);
/// <summary>
/// <para>
/// Sends a message to the specified recipients. The recipients can be applications, installable drivers, network drivers,
@ -563,6 +690,154 @@ public static partial class User32
[PInvokeData("winuser.h")]
public static extern long BroadcastSystemMessageEx(BSF flags, ref BSM lpInfo, uint Msg, [Optional] IntPtr wParam, [Optional] IntPtr lParam, ref BSMINFO pbsmInfo);
/// <summary>
/// <para>
/// Sends a message to the specified recipients. The recipients can be applications, installable drivers, network drivers,
/// system-level device drivers, or any combination of these system components.
/// </para>
/// <para>This function is similar to BroadcastSystemMessage except that this function can return more information from the recipients.</para>
/// </summary>
/// <param name="flags">
/// <para>Type: <c>DWORD</c></para>
/// <para>The broadcast option. This parameter can be one or more of the following values.</para>
/// <list type="table">
/// <listheader>
/// <term>Value</term>
/// <term>Meaning</term>
/// </listheader>
/// <item>
/// <term>BSF_ALLOWSFW 0x00000080</term>
/// <term>Enables the recipient to set the foreground window while processing the message.</term>
/// </item>
/// <item>
/// <term>BSF_FLUSHDISK 0x00000004</term>
/// <term>Flushes the disk after each recipient processes the message.</term>
/// </item>
/// <item>
/// <term>BSF_FORCEIFHUNG 0x00000020</term>
/// <term>Continues to broadcast the message, even if the time-out period elapses or one of the recipients is not responding.</term>
/// </item>
/// <item>
/// <term>BSF_IGNORECURRENTTASK 0x00000002</term>
/// <term>
/// Does not send the message to windows that belong to the current task. This prevents an application from receiving its own message.
/// </term>
/// </item>
/// <item>
/// <term>BSF_LUID 0x00000400</term>
/// <term>
/// If BSF_LUID is set, the message is sent to the window that has the same LUID as specified in the luid member of the BSMINFO
/// structure. Windows 2000: This flag is not supported.
/// </term>
/// </item>
/// <item>
/// <term>BSF_NOHANG 0x00000008</term>
/// <term>
/// Forces a non-responsive application to time out. If one of the recipients times out, do not continue broadcasting the message.
/// </term>
/// </item>
/// <item>
/// <term>BSF_NOTIMEOUTIFNOTHUNG 0x00000040</term>
/// <term>Waits for a response to the message, as long as the recipient is not being unresponsive. Does not time out.</term>
/// </item>
/// <item>
/// <term>BSF_POSTMESSAGE 0x00000010</term>
/// <term>Posts the message. Do not use in combination with BSF_QUERY.</term>
/// </item>
/// <item>
/// <term>BSF_RETURNHDESK 0x00000200</term>
/// <term>
/// If access is denied and both this and BSF_QUERY are set, BSMINFO returns both the desktop handle and the window handle. If access
/// is denied and only BSF_QUERY is set, only the window handle is returned by BSMINFO. Windows 2000: This flag is not supported.
/// </term>
/// </item>
/// <item>
/// <term>BSF_QUERY 0x00000001</term>
/// <term>
/// Sends the message to one recipient at a time, sending to a subsequent recipient only if the current recipient returns TRUE.
/// </term>
/// </item>
/// <item>
/// <term>BSF_SENDNOTIFYMESSAGE 0x00000100</term>
/// <term>Sends the message using SendNotifyMessage function. Do not use in combination with BSF_QUERY.</term>
/// </item>
/// </list>
/// </param>
/// <param name="lpInfo">
/// <para>Type: <c>LPDWORD</c></para>
/// <para>A pointer to a variable that contains and receives information about the recipients of the message.</para>
/// <para>
/// When the function returns, this variable receives a combination of these values identifying which recipients actually received
/// the message.
/// </para>
/// <para>If this parameter is <c>NULL</c>, the function broadcasts to all components.</para>
/// <para>This parameter can be one or more of the following values.</para>
/// <list type="table">
/// <listheader>
/// <term>Value</term>
/// <term>Meaning</term>
/// </listheader>
/// <item>
/// <term>BSM_ALLCOMPONENTS 0x00000000</term>
/// <term>Broadcast to all system components.</term>
/// </item>
/// <item>
/// <term>BSM_ALLDESKTOPS 0x00000010</term>
/// <term>Broadcast to all desktops. Requires the SE_TCB_NAME privilege.</term>
/// </item>
/// <item>
/// <term>BSM_APPLICATIONS 0x00000008</term>
/// <term>Broadcast to applications.</term>
/// </item>
/// </list>
/// </param>
/// <param name="Msg">
/// <para>Type: <c>UINT</c></para>
/// <para>The message to be sent.</para>
/// <para>For lists of the system-provided messages, see System-Defined Messages.</para>
/// </param>
/// <param name="wParam">
/// <para>Type: <c>WPARAM</c></para>
/// <para>Additional message-specific information.</para>
/// </param>
/// <param name="lParam">
/// <para>Type: <c>LPARAM</c></para>
/// <para>Additional message-specific information.</para>
/// </param>
/// <param name="pbsmInfo">
/// <para>Type: <c>PBSMINFO</c></para>
/// <para>A pointer to a BSMINFO structure that contains additional information if the request is denied and dwFlags is set to <c>BSF_QUERY</c>.</para>
/// </param>
/// <returns>
/// <para>Type: <c>Type: <c>long</c></c></para>
/// <para>If the function succeeds, the return value is a positive value.</para>
/// <para>If the function is unable to broadcast the message, the return value is 1.</para>
/// <para>
/// If the dwFlags parameter is <c>BSF_QUERY</c> and at least one recipient returned <c>BROADCAST_QUERY_DENY</c> to the corresponding
/// message, the return value is zero. To get extended error information, call GetLastError.
/// </para>
/// </returns>
/// <remarks>
/// <para>
/// If <c>BSF_QUERY</c> is not specified, the function sends the specified message to all requested recipients, ignoring values
/// returned by those recipients.
/// </para>
/// <para>
/// If the caller's thread is on a desktop other than that of the window that denied the request, the caller must call
/// SetThreadDesktop <c>(hdesk)</c> to query anything on that window. Also, the caller must call CloseDesktop on the returned
/// <c>hdesk</c> handle.
/// </para>
/// <para>
/// The system only does marshaling for system messages (those in the range 0 to (WM_USER-1)). To send other messages (those &gt;=
/// <c>WM_USER</c>) to another process, you must do custom marshaling.
/// </para>
/// </remarks>
// https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-broadcastsystemmessageexa long BroadcastSystemMessageExA(
// DWORD flags, LPDWORD lpInfo, UINT Msg, WPARAM wParam, LPARAM lParam, PBSMINFO pbsmInfo );
[DllImport(Lib.User32, SetLastError = true, CharSet = CharSet.Auto)]
[PInvokeData("winuser.h")]
public static extern long BroadcastSystemMessageEx(BSF flags, [In, Optional] IntPtr lpInfo, uint Msg, [Optional] IntPtr wParam, [Optional] IntPtr lParam, ref BSMINFO pbsmInfo);
/// <summary>
/// Dispatches a message to a window procedure. It is typically used to dispatch a message retrieved by the GetMessage function.
/// </summary>
@ -3439,7 +3714,7 @@ public static partial class User32
[DllImport(Lib.User32, SetLastError = true, CharSet = CharSet.Auto)]
[PInvokeData("winuser.h")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SendMessageCallback(HWND hWnd, uint Msg, [Optional] IntPtr wParam, [Optional] IntPtr lParam, Sendasyncproc lpResultCallBack, UIntPtr dwData);
public static extern bool SendMessageCallback(HWND hWnd, uint Msg, [Optional] IntPtr wParam, [Optional] IntPtr lParam, Sendasyncproc lpResultCallBack, IntPtr dwData);
/// <summary>Sends the specified message to one or more windows.</summary>
/// <param name="hWnd">

View File

@ -271,7 +271,7 @@ public static partial class User32
[DllImport(Lib.User32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("winuser.h", MSDNShortId = "a7668c28-77c9-4373-ae1a-eab3cb98f866")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool EnumDisplayMonitors(HDC hdc, PRECT lprcClip, MonitorEnumProc lpfnEnum, IntPtr dwData);
public static extern bool EnumDisplayMonitors([Optional] HDC hdc, [Optional] PRECT? lprcClip, MonitorEnumProc lpfnEnum, IntPtr dwData);
/// <summary>
/// <para>

View File

@ -913,7 +913,8 @@ public static partial class User32
[DllImport(Lib.User32, SetLastError = false, CharSet = CharSet.Auto)]
[PInvokeData("winuser.h", MSDNShortId = "b92150be-8264-4ea8-a2ea-d70b7fba6361")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool DrawState(HDC hdc, HBRUSH hbrFore, DrawStateProc qfnCallBack, IntPtr lData, IntPtr wData, int x, int y, int cx, int cy, DrawStateFlags uFlags);
public static extern bool DrawState(HDC hdc, HBRUSH hbrFore, [Optional] DrawStateProc? qfnCallBack, [Optional] IntPtr lData,
[Optional] IntPtr wData, int x, int y, [Optional] int cx, [Optional] int cy, DrawStateFlags uFlags);
/// <summary>
/// The <c>DrawState</c> function displays an image and applies a visual effect to indicate a state, such as a disabled or default state.
@ -1035,7 +1036,8 @@ public static partial class User32
[DllImport(Lib.User32, SetLastError = false, CharSet = CharSet.Auto)]
[PInvokeData("winuser.h", MSDNShortId = "b92150be-8264-4ea8-a2ea-d70b7fba6361")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool DrawState(HDC hdc, HBRUSH hbrFore, DrawStateProc qfnCallBack, string lData, IntPtr wData, int x, int y, int cx, int cy, DrawStateFlags uFlags);
public static extern bool DrawState(HDC hdc, HBRUSH hbrFore, [Optional] DrawStateProc? qfnCallBack, [MarshalAs(UnmanagedType.LPTStr)] string lData,
[Optional] nuint wData, int x, int y, [Optional] int cx, [Optional] int cy, DrawStateFlags uFlags);
/// <summary>
/// The <c>EndPaint</c> function marks the end of painting in the specified window. This function is required for each call to the
@ -1191,7 +1193,7 @@ public static partial class User32
[DllImport(Lib.User32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("winuser.h", MSDNShortId = "e54483a1-8738-4b22-a24e-c0b31f6ca9d6")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool GetUpdateRect(HWND hWnd, PRECT lpRect, [MarshalAs(UnmanagedType.Bool)] bool bErase);
public static extern bool GetUpdateRect(HWND hWnd, [Optional] PRECT? lpRect, [MarshalAs(UnmanagedType.Bool)] bool bErase);
/// <summary>
/// The <c>GetUpdateRgn</c> function retrieves the update region of a window by copying it into the specified region. The coordinates
@ -1281,7 +1283,7 @@ public static partial class User32
// https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-getwindowdc HDC GetWindowDC( HWND hWnd );
[DllImport(Lib.User32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("winuser.h", MSDNShortId = "9e6a135e-e337-4129-a3ad-faf9a8ac9b2d")]
public static extern HDC GetWindowDC(HWND hWnd);
public static extern HDC GetWindowDC([Optional] HWND hWnd);
/// <summary>
/// The <c>GetWindowRgn</c> function obtains a copy of the window region of a window. The window region of a window is set by calling
@ -1381,7 +1383,7 @@ public static partial class User32
/// brush and background. <c>GrayString</c> uses the font currently selected for the specified device context.
/// </para>
/// <para>
/// If thelpOutputFuncparameter is <c>NULL</c>, GDI uses the TextOut function, and thelpDataparameter is assumed to be a pointer to
/// If the lpOutputFunc parameter is <c>NULL</c>, GDI uses the TextOut function, and thelpDataparameter is assumed to be a pointer to
/// the character string to be output. If the characters to be output cannot be handled by <c>TextOut</c> (for example, the string is
/// stored as a bitmap), the application must supply its own output function.
/// </para>
@ -1433,7 +1435,8 @@ public static partial class User32
[DllImport(Lib.User32, SetLastError = false, CharSet = CharSet.Auto)]
[PInvokeData("winuser.h", MSDNShortId = "b14b8c40-f97f-4e41-8d8d-687692acfda9")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool GrayString(HDC hDC, HBRUSH hBrush, OutputProc lpOutputFunc, string lpData, int nCount, int X, int Y, int nWidth, int nHeight);
public static extern bool GrayString(HDC hDC, [Optional] HBRUSH hBrush, [Optional] OutputProc? lpOutputFunc, [Optional, MarshalAs(UnmanagedType.LPTStr)] string? lpData,
[Optional] int nCount, int X, int Y, [Optional] int nWidth, [Optional] int nHeight);
/// <summary>
/// The <c>InvalidateRect</c> function adds a rectangle to the specified window's update region. The update region represents the
@ -1553,7 +1556,7 @@ public static partial class User32
[DllImport(Lib.User32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("winuser.h", MSDNShortId = "00ec40c7-8ab2-40db-a9bb-48e18d66bf1a")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool LockWindowUpdate(HWND hWndLock);
public static extern bool LockWindowUpdate([Optional] HWND hWndLock);
/// <summary>
/// The <c>PaintDesktop</c> function fills the clipping region in the specified device context with the desktop pattern or wallpaper.
@ -1703,7 +1706,7 @@ public static partial class User32
[DllImport(Lib.User32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("winuser.h", MSDNShortId = "c6cb7f74-237e-4d3e-a852-894da36e990c")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool RedrawWindow(HWND hWnd, [In] PRECT lprcUpdate, HRGN hrgnUpdate, RedrawWindowFlags flags);
public static extern bool RedrawWindow(HWND hWnd, [In, Optional] PRECT? lprcUpdate, [Optional] HRGN hrgnUpdate, RedrawWindowFlags flags);
/// <summary>
/// The <c>SetWindowRgn</c> function sets the window region of a window. The window region determines the area within the window
@ -1793,7 +1796,7 @@ public static partial class User32
[DllImport(Lib.User32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("winuser.h", MSDNShortId = "961dd768-1849-44df-bc7f-480881ed6477")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool ValidateRect(HWND hWnd, [In, Optional] PRECT? lpRect);
public static extern bool ValidateRect([Optional] HWND hWnd, [In, Optional] PRECT? lpRect);
/// <summary>
/// The <c>ValidateRgn</c> function validates the client area within a region by removing the region from the current update region

View File

@ -437,7 +437,7 @@ public static partial class User32
[DllImport(Lib.User32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("winuser.h", MSDNShortId = "4dd25033-e63a-4fa9-89b9-bfcae4061a76")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool GetPointerDeviceCursors(HANDLE device, ref uint cursorCount, [In, Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)]POINTER_DEVICE_CURSOR_INFO[] deviceCursors);
public static extern bool GetPointerDeviceCursors(HANDLE device, ref uint cursorCount, [In, Out, Optional, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)] POINTER_DEVICE_CURSOR_INFO[]? deviceCursors);
/// <summary>Gets device properties that aren't included in the POINTER_DEVICE_INFO structure.</summary>
/// <param name="device">
@ -461,7 +461,7 @@ public static partial class User32
[DllImport(Lib.User32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("winuser.h", MSDNShortId = "dbb81637-217a-49b1-9e81-2068cf4c0951")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool GetPointerDeviceProperties(HANDLE device, ref uint propertyCount, [In, Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)] POINTER_DEVICE_PROPERTY[] pointerProperties);
public static extern bool GetPointerDeviceProperties(HANDLE device, ref uint propertyCount, [In, Out, Optional, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)] POINTER_DEVICE_PROPERTY[]? pointerProperties);
/// <summary>
/// Gets the x and y range for the pointer device (in himetric) and the x and y range (current resolution) for the display that the
@ -512,7 +512,7 @@ public static partial class User32
[DllImport(Lib.User32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("winuser.h", MSDNShortId = "91FD5EBA-EDD7-4D7D-ABF3-3CE2461417B0")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool GetPointerDevices(ref uint deviceCount, [In, Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 0)] POINTER_DEVICE_INFO[] pointerDevices);
public static extern bool GetPointerDevices(ref uint deviceCount, [In, Out, Optional, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 0)] POINTER_DEVICE_INFO[]? pointerDevices);
/// <summary>Gets the entire frame of information for the specified pointers associated with the current message.</summary>
/// <param name="pointerId">An identifier of the pointer for which to retrieve frame information.</param>
@ -605,7 +605,7 @@ public static partial class User32
[DllImport(Lib.User32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("winuser.h", MSDNShortId = "6b7f450d-6ab1-4991-b2f9-a1db3f065711")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool GetPointerFrameInfo(uint pointerId, ref uint pointerCount, [In, Out, MarshalAs(UnmanagedType.LPArray)] POINTER_INFO[] pointerInfo);
public static extern bool GetPointerFrameInfo(uint pointerId, ref uint pointerCount, [In, Out, Optional, MarshalAs(UnmanagedType.LPArray)] POINTER_INFO[]? pointerInfo);
/// <summary>
/// Gets the entire frame of information (including coalesced input frames) for the specified pointers associated with the current message.
@ -711,7 +711,7 @@ public static partial class User32
[DllImport(Lib.User32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("winuser.h", MSDNShortId = "1ae035d6-a375-4421-82a6-50be4a2341f6")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool GetPointerFrameInfoHistory(uint pointerId, ref uint entriesCount, ref uint pointerCount, [In, Out] POINTER_INFO[,] pointerInfo);
public static extern bool GetPointerFrameInfoHistory(uint pointerId, ref uint entriesCount, ref uint pointerCount, [In, Out, Optional] POINTER_INFO[,]? pointerInfo);
/// <summary>
/// Gets the entire frame of pen-based information for the specified pointers (of type PT_PEN) associated with the current message.
@ -807,7 +807,7 @@ public static partial class User32
[DllImport(Lib.User32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("winuser.h", MSDNShortId = "52db9b96-7f9e-41d7-88f7-b9c7691a6511")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool GetPointerFramePenInfo(uint pointerId, ref uint pointerCount, [In, Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)] POINTER_PEN_INFO[] penInfo);
public static extern bool GetPointerFramePenInfo(uint pointerId, ref uint pointerCount, [In, Out, Optional, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)] POINTER_PEN_INFO[]? penInfo);
/// <summary>
/// Gets the entire frame of pen-based information (including coalesced input frames) for the specified pointers (of type PT_PEN)
@ -915,7 +915,7 @@ public static partial class User32
[DllImport(Lib.User32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("winuser.h", MSDNShortId = "a4f6a9f3-dfbd-4413-aae7-f58e1521ef1d")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool GetPointerFramePenInfoHistory(uint pointerId, ref uint entriesCount, ref uint pointerCount, [In, Out] POINTER_PEN_INFO[,] penInfo);
public static extern bool GetPointerFramePenInfoHistory(uint pointerId, ref uint entriesCount, ref uint pointerCount, [In, Out, Optional] POINTER_PEN_INFO[,]? penInfo);
/// <summary>
/// Gets the entire frame of touch-based information for the specified pointers (of type PT_TOUCH) associated with the current message.
@ -1011,7 +1011,7 @@ public static partial class User32
[DllImport(Lib.User32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("winuser.h", MSDNShortId = "a100cc7a-62fc-4ace-8d35-e77aff98d944")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool GetPointerFrameTouchInfo(uint pointerId, ref uint pointerCount, [In, Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)] POINTER_TOUCH_INFO[] touchInfo);
public static extern bool GetPointerFrameTouchInfo(uint pointerId, ref uint pointerCount, [In, Out, Optional, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)] POINTER_TOUCH_INFO[]? touchInfo);
/// <summary>
/// Gets the entire frame of touch-based information (including coalesced input frames) for the specified pointers (of type
@ -1119,7 +1119,7 @@ public static partial class User32
[DllImport(Lib.User32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("winuser.h", MSDNShortId = "f2521a67-9850-46e9-bc8b-75bf5b6cc263")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool GetPointerFrameTouchInfoHistory(uint pointerId, ref uint entriesCount, ref uint pointerCount, [In, Out] POINTER_TOUCH_INFO[,] touchInfo);
public static extern bool GetPointerFrameTouchInfoHistory(uint pointerId, ref uint entriesCount, ref uint pointerCount, [In, Out, Optional] POINTER_TOUCH_INFO[,]? touchInfo);
/// <summary>
/// <para>Gets the information for the specified pointer associated with the current message.</para>
@ -1211,7 +1211,7 @@ public static partial class User32
[DllImport(Lib.User32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("winuser.h", MSDNShortId = "92173197-45e8-4ee7-8959-2f14f90c2d21")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool GetPointerInfoHistory(uint pointerId, ref uint entriesCount, [In, Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)] POINTER_INFO[] pointerInfo);
public static extern bool GetPointerInfoHistory(uint pointerId, ref uint entriesCount, [In, Out, Optional, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)] POINTER_INFO[]? pointerInfo);
/// <summary>Gets one or more transforms for the pointer information coordinates associated with the current message.</summary>
/// <param name="pointerId">An identifier of the pointer for which to retrieve information.</param>
@ -1382,7 +1382,7 @@ public static partial class User32
[DllImport(Lib.User32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("winuser.h", MSDNShortId = "90082327-b242-4f5d-8cd7-fd8ef9340395")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool GetPointerPenInfoHistory(uint pointerId, ref uint entriesCount, [In, Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)] POINTER_PEN_INFO[] penInfo);
public static extern bool GetPointerPenInfoHistory(uint pointerId, ref uint entriesCount, [In, Out, Optional, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)] POINTER_PEN_INFO[]? penInfo);
/// <summary>Gets the touch-based information for the specified pointer (of type PT_TOUCH) associated with the current message.</summary>
/// <param name="pointerId">An identifier of the pointer for which to retrieve information.</param>
@ -1475,7 +1475,7 @@ public static partial class User32
[DllImport(Lib.User32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("winuser.h", MSDNShortId = "9fdfbde7-4126-4c1b-b870-479f846e1aa9")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool GetPointerTouchInfoHistory(uint pointerId, ref uint entriesCount, [In, Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)] POINTER_TOUCH_INFO[] touchInfo);
public static extern bool GetPointerTouchInfoHistory(uint pointerId, ref uint entriesCount, [In, Out, Optional, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)] POINTER_TOUCH_INFO[]? touchInfo);
/// <summary>Retrieves the pointer type for a specified pointer.</summary>
/// <param name="pointerId">An identifier of the pointer for which to retrieve pointer type.</param>

View File

@ -55,6 +55,7 @@ public static partial class User32
/// should carry out preparations for the suspension before returning. Return TRUE to grant the request to suspend. To deny the
/// request, return BROADCAST_QUERY_DENY.
/// </summary>
[CorrespondingType(typeof(int))]
PBT_APMQUERYSTANDBY = 0x0001,
/// <summary>
@ -77,6 +78,7 @@ public static partial class User32
/// <para>Applications typically respond to this event by resuming normal operation.</para>
/// </remarks>
// https://docs.microsoft.com/en-us/windows/win32/power/pbt-apmquerysuspendfailed
[CorrespondingType(null)]
PBT_APMQUERYSUSPENDFAILED = 0x0002,
/// <summary>
@ -105,6 +107,7 @@ public static partial class User32
/// </para>
/// </remarks>
// https://docs.microsoft.com/en-us/windows/win32/power/pbt-apmsuspend
[CorrespondingType(null)]
PBT_APMSUSPEND = 0x0004,
/// <summary>Undocumented.</summary>
@ -135,6 +138,7 @@ public static partial class User32
/// </para>
/// </remarks>
// https://docs.microsoft.com/en-us/windows/win32/power/pbt-apmresumecritical
[CorrespondingType(null)]
PBT_APMRESUMECRITICAL = 0x0006,
/// <summary>
@ -163,6 +167,7 @@ public static partial class User32
/// </para>
/// </remarks>
// https://docs.microsoft.com/en-us/windows/win32/power/pbt-apmresumesuspend
[CorrespondingType(null)]
PBT_APMRESUMESUSPEND = 0x0007,
/// <summary>
@ -190,6 +195,7 @@ public static partial class User32
/// </para>
/// </remarks>
// https://docs.microsoft.com/en-us/windows/win32/power/pbt-apmbatterylow
[CorrespondingType(null)]
PBT_APMBATTERYLOW = 0x0009,
/// <summary>
@ -215,6 +221,7 @@ public static partial class User32
/// </para>
/// </remarks>
// https://docs.microsoft.com/en-us/windows/win32/power/pbt-apmpowerstatuschange
[CorrespondingType(null)]
PBT_APMPOWERSTATUSCHANGE = 0x000A,
/// <summary>
@ -238,6 +245,7 @@ public static partial class User32
/// </para>
/// </remarks>
// https://docs.microsoft.com/en-us/windows/win32/power/pbt-apmoemevent
[CorrespondingType(typeof(int))]
PBT_APMOEMEVENT = 0x000B,
/// <summary>
@ -259,6 +267,7 @@ public static partial class User32
/// </para>
/// </remarks>
// https://docs.microsoft.com/en-us/windows/win32/power/pbt-apmresumeautomatic
[CorrespondingType(null)]
PBT_APMRESUMEAUTOMATIC = 0x0012,
/// <summary>
@ -270,6 +279,7 @@ public static partial class User32
/// <para>No return value.</para>
/// </remarks>
// https://docs.microsoft.com/en-us/windows/win32/power/pbt-powersettingchange
[CorrespondingType(typeof(POWERBROADCAST_SETTING?))]
PBT_POWERSETTINGCHANGE = 0x8013,
}
@ -349,7 +359,8 @@ public static partial class User32
// UnregisterPowerSettingNotification( IN HPOWERNOTIFY Handle );
[DllImport(Lib.User32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("winuser.h", MSDNShortId = "de1509f5-cf4c-448e-bb3b-08da6be53bfa")]
[return: MarshalAs(UnmanagedType.Bool)] public static extern bool UnregisterPowerSettingNotification([In] HANDLE Handle);
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool UnregisterPowerSettingNotification([In] HANDLE Handle);
/// <summary>
/// Cancels a registration to receive notification when the system is suspended or resumed. Similar to

View File

@ -111,7 +111,7 @@ public static partial class User32
/// returns immediately.
/// </param>
/// <param name="dwMilliseconds">
/// The time-out interval, in milliseconds. If dwMilliseconds is INFINITE, the function does not return until the process is idle.
/// The time-out interval, in milliseconds. If dwMilliseconds is <see cref="Kernel32.INFINITE"/>, the function does not return until the process is idle.
/// </param>
/// <returns>
/// <para>The following table shows the possible return values for this function.</para>
@ -156,5 +156,5 @@ public static partial class User32
// DWORD dwMilliseconds );
[DllImport(Lib.User32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("winuser.h", MSDNShortId = "2a684921-36f1-438c-895c-5bebc242635a")]
public static extern uint WaitForInputIdle(HPROCESS hProcess, uint dwMilliseconds);
public static extern Kernel32.WAIT_STATUS WaitForInputIdle(HPROCESS hProcess, uint dwMilliseconds);
}

View File

@ -1,4 +1,5 @@
using System.Runtime.InteropServices;
using Vanara.PInvoke;
namespace Vanara.PInvoke;

View File

@ -1,6 +1,8 @@
using System;
using System.Runtime.InteropServices;
using System.Text;
using Vanara.Extensions;
using Vanara.InteropServices;
using static Vanara.PInvoke.Gdi32;
namespace Vanara.PInvoke;
@ -180,7 +182,7 @@ public static partial class User32
[PInvokeData("WinUser.h", MSDNShortId = "ms648045")]
[DllImport(Lib.User32, SetLastError = true, CharSet = CharSet.Auto)]
[System.Security.SecurityCritical]
public static extern IntPtr LoadImage(HINSTANCE hinst, SafeResourceId lpszName, LoadImageType uType, int cxDesired, int cyDesired, LoadImageOptions fuLoad);
public static extern IntPtr LoadImage([Optional] HINSTANCE hinst, SafeResourceId lpszName, LoadImageType uType, int cxDesired, int cyDesired, LoadImageOptions fuLoad);
/// <summary>Loads a bitmap.</summary>
/// <param name="hinst">
@ -224,7 +226,7 @@ public static partial class User32
/// If the function succeeds, the return value is the handle of the newly loaded image. If the function fails, the return value is
/// NULL.To get extended error information, call GetLastError.
/// </returns>
public static SafeHBITMAP LoadImage_Bitmap(HINSTANCE hinst, SafeResourceId lpszName, int cxDesired, int cyDesired, LoadImageOptions fuLoad) =>
public static SafeHBITMAP LoadImage_Bitmap([Optional] HINSTANCE hinst, SafeResourceId lpszName, int cxDesired, int cyDesired, LoadImageOptions fuLoad) =>
new(LoadImage(hinst, lpszName, LoadImageType.IMAGE_BITMAP, cxDesired, cyDesired, fuLoad), true);
/// <summary>Loads a cursor or animated cursor.</summary>
@ -269,7 +271,7 @@ public static partial class User32
/// If the function succeeds, the return value is the handle of the newly loaded image. If the function fails, the return value is
/// NULL.To get extended error information, call GetLastError.
/// </returns>
public static SafeHCURSOR LoadImage_Cursor(HINSTANCE hinst, SafeResourceId lpszName, int cxDesired, int cyDesired, LoadImageOptions fuLoad) =>
public static SafeHCURSOR LoadImage_Cursor([Optional] HINSTANCE hinst, SafeResourceId lpszName, int cxDesired, int cyDesired, LoadImageOptions fuLoad) =>
new(LoadImage(hinst, lpszName, LoadImageType.IMAGE_CURSOR, cxDesired, cyDesired, fuLoad), true);
/// <summary>Loads an enhanced metafile.</summary>
@ -314,7 +316,7 @@ public static partial class User32
/// If the function succeeds, the return value is the handle of the newly loaded image. If the function fails, the return value is
/// NULL.To get extended error information, call GetLastError.
/// </returns>
public static SafeHENHMETAFILE LoadImage_EnhMetaFile(HINSTANCE hinst, SafeResourceId lpszName, int cxDesired, int cyDesired, LoadImageOptions fuLoad) =>
public static SafeHENHMETAFILE LoadImage_EnhMetaFile([Optional] HINSTANCE hinst, SafeResourceId lpszName, int cxDesired, int cyDesired, LoadImageOptions fuLoad) =>
new(LoadImage(hinst, lpszName, LoadImageType.IMAGE_ENHMETAFILE, cxDesired, cyDesired, fuLoad), true);
/// <summary>Loads an icon.</summary>
@ -359,7 +361,7 @@ public static partial class User32
/// If the function succeeds, the return value is the handle of the newly loaded image. If the function fails, the return value is
/// NULL.To get extended error information, call GetLastError.
/// </returns>
public static SafeHICON LoadImage_Icon(HINSTANCE hinst, SafeResourceId lpszName, int cxDesired, int cyDesired, LoadImageOptions fuLoad) =>
public static SafeHICON LoadImage_Icon([Optional] HINSTANCE hinst, SafeResourceId lpszName, int cxDesired, int cyDesired, LoadImageOptions fuLoad) =>
new(LoadImage(hinst, lpszName, LoadImageType.IMAGE_ICON, cxDesired, cyDesired, fuLoad), true);
/// <summary>
@ -385,28 +387,25 @@ public static partial class User32
[System.Security.SecurityCritical]
public static extern int LoadString(HINSTANCE hInstance, int uID, StringBuilder lpBuffer, int nBufferMax);
/// <summary>
/// Loads a string resource from the executable file associated with a specified module, copies the string into a buffer, and appends
/// a terminating null character.
/// </summary>
/// <summary>Loads a string resource from the executable file associated with a specified module.</summary>
/// <param name="hInstance">
/// A handle to an instance of the module whose executable file contains the string resource. To get the handle to the application
/// itself, call the GetModuleHandle function with NULL.
/// </param>
/// <param name="uID">The identifier of the string to be loaded.</param>
/// <param name="lpBuffer">The buffer is to receive the string. Must be of sufficient length to hold a pointer (8 bytes).</param>
/// <param name="nBufferMax">
/// The size of the buffer, in characters. The string is truncated and null-terminated if it is longer than the number of characters
/// specified. If this parameter is 0, then lpBuffer receives a read-only pointer to the resource itself.
/// </param>
/// <returns>
/// If the function succeeds, the return value is the number of characters copied into the buffer, not including the terminating null
/// character, or zero if the string resource does not exist. To get extended error information, call GetLastError.
/// </returns>
/// <returns>If the function succeeds, the return value is the full resource string.</returns>
[PInvokeData("WinUser.h", MSDNShortId = "ms647486")]
public static string LoadString(HINSTANCE hInstance, int uID)
{
IntPtr p = default;
var l = LoadString(hInstance, uID, p, 0);
if (l == 0) Win32Error.ThrowLastError();
return StringHelper.GetString(p, CharSet.Auto, l * Marshal.SystemDefaultCharSize)!;
}
[DllImport(Lib.User32, CharSet = CharSet.Auto, SetLastError = true)]
[System.Security.SecurityCritical]
public static extern int LoadString(HINSTANCE hInstance, int uID, out IntPtr lpBuffer, int nBufferMax);
private static extern int LoadString(HINSTANCE hInstance, int uID, IntPtr lpBuffer, int nBufferMax);
/// <summary/>
[StructLayout(LayoutKind.Sequential, Pack = 1)]

View File

@ -567,7 +567,7 @@ public static partial class User32
[DllImport(Lib.User32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("winuser.h", MSDNShortId = "")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool ScrollDC(HDC hDC, int dx, int dy, PRECT lprcScroll, PRECT lprcClip, HRGN hrgnUpdate, out RECT lprcUpdate);
public static extern bool ScrollDC(HDC hDC, int dx, int dy, [Optional] PRECT? lprcScroll, [Optional] PRECT? lprcClip, HRGN hrgnUpdate, out RECT lprcUpdate);
/// <summary>
/// <para>The <c>ScrollWindow</c> function scrolls the contents of the specified window's client area.</para>
@ -643,7 +643,7 @@ public static partial class User32
[DllImport(Lib.User32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("winuser.h", MSDNShortId = "")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool ScrollWindow(HWND hWnd, int XAmount, int YAmount, PRECT lpRect, in RECT lpClipRect);
public static extern bool ScrollWindow(HWND hWnd, int XAmount, int YAmount, [Optional] PRECT? lpRect, in RECT lpClipRect);
/// <summary>The <c>ScrollWindowEx</c> function scrolls the contents of the specified window's client area.</summary>
/// <param name="hWnd">
@ -757,7 +757,7 @@ public static partial class User32
// dy, const RECT *prcScroll, const RECT *prcClip, HRGN hrgnUpdate, LPRECT prcUpdate, UINT flags );
[DllImport(Lib.User32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("winuser.h", MSDNShortId = "")]
public static extern int ScrollWindowEx(HWND hWnd, int dx, int dy, PRECT prcScroll, PRECT prcClip, HRGN hrgnUpdate, out RECT prcUpdate, ScrollWindowFlags flags);
public static extern int ScrollWindowEx(HWND hWnd, int dx, int dy, [Optional] PRECT? prcScroll, [Optional] PRECT? prcClip, [Optional] HRGN hrgnUpdate, out RECT prcUpdate, ScrollWindowFlags flags);
/// <summary>
/// The <c>SetScrollInfo</c> function sets the parameters of a scroll bar, including the minimum and maximum scrolling positions, the

View File

@ -29,6 +29,7 @@ public static partial class User32
/// </list>
/// </summary>
// https://docs.microsoft.com/en-us/windows/win32/controls/stm-seticon
[MsgParams(typeof(HICON), null, LResultType = typeof(HICON))]
STM_SETICON = 0x0170,
/// <summary>
@ -52,6 +53,7 @@ public static partial class User32
/// </list>
/// </summary>
// https://docs.microsoft.com/en-us/windows/win32/controls/stm-geticon
[MsgParams(null, null, LResultType = typeof(HICON))]
STM_GETICON = 0x0171,
/// <summary>
@ -126,6 +128,7 @@ public static partial class User32
/// </list>
/// </remarks>
// https://docs.microsoft.com/en-us/windows/win32/controls/stm-setimage
[MsgParams(typeof(LoadImageType), typeof(HANDLE), LResultType = typeof(HANDLE))]
STM_SETIMAGE = 0x0172,
/// <summary>
@ -170,6 +173,7 @@ public static partial class User32
/// </list>
/// </summary>
// https://docs.microsoft.com/en-us/windows/win32/controls/stm-getimage
[MsgParams(typeof(HANDLE), null, LResultType = typeof(HANDLE))]
STM_GETIMAGE = 0x0173,
}

View File

@ -3723,7 +3723,7 @@ public static partial class User32
[DllImport(Lib.User32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("", MSDNShortId = "D2AF238D-F5A8-477D-BF47-0F5D4D68B27E")]
[return: MarshalAs(UnmanagedType.LPWStr)]
public static extern string MB_GetString(uint wBtn);
public static extern string? MB_GetString(uint wBtn);
/// <summary>
/// <para>Plays a waveform sound. The waveform sound for each sound type is identified by an entry in the registry.</para>
@ -4523,7 +4523,7 @@ public static partial class User32
[DllImport(Lib.User32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("Winuser.h")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool ShutdownBlockReasonQuery(HWND hWnd, [MarshalAs(UnmanagedType.LPWStr)] StringBuilder pwszBuff, ref uint pcchBuff);
public static extern bool ShutdownBlockReasonQuery(HWND hWnd, [MarshalAs(UnmanagedType.LPWStr)] StringBuilder? pwszBuff, ref uint pcchBuff);
/// <summary>Retrieves the reason string set by the <see cref="ShutdownBlockReasonCreate"/> function.</summary>
/// <param name="hWnd">A handle to the main window of the application.</param>
@ -4535,7 +4535,7 @@ public static partial class User32
public static bool ShutdownBlockReasonQuery(HWND hWnd, out string reason)
{
uint sz = 0;
reason = null;
reason = "";
if (!ShutdownBlockReasonQuery(hWnd, null, ref sz)) return false;
var sb = new StringBuilder((int)sz);
if (!ShutdownBlockReasonQuery(hWnd, sb, ref sz)) return false;

View File

@ -19,7 +19,7 @@ public static partial class User32
// hwnd, _In_ UINT uMsg, _In_ UINT_PTR idEvent, _In_ DWORD dwTime);
[UnmanagedFunctionPointer(CallingConvention.Winapi)]
[PInvokeData("winuser.h")]
public delegate void Timerproc(HWND hwnd, uint uMsg, IntPtr idEvent, uint dwTime);
public delegate void Timerproc(HWND hwnd, uint uMsg, nuint idEvent, uint dwTime);
/// <summary>Destroys the specified timer.</summary>
/// <param name="hWnd">
@ -51,25 +51,111 @@ public static partial class User32
[DllImport(Lib.User32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("winuser.h")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool KillTimer([Optional] HWND hWnd, IntPtr uIDEvent);
public static extern bool KillTimer([Optional] HWND hWnd, nuint uIDEvent);
/// <summary>Creates a timer with the specified time-out value and coalescing tolerance delay.</summary>
/// <param name="hWnd"><para>Type: <c>HWND</c></para><para>A handle to the window to be associated with the timer. This window must be owned by the calling thread. If a <c>NULL</c> value for hWnd is passed in along with an nIDEvent of an existing timer, that timer will be replaced in the same way that an existing non-NULL hWnd timer will be.</para></param>
/// <param name="nIDEvent"><para>Type: <c>UINT_PTR</c></para><para>A timer identifier. If the hWnd parameter is <c>NULL</c>, and the nIDEvent does not match an existing timer, then the nIDEvent is ignored and a new timer ID is generated. If the hWnd parameter is not <c>NULL</c> and the window specified by hWnd already has a timer with the value nIDEvent, then the existing timer is replaced by the new timer. When <c>SetCoalescableTimer</c> replaces a timer, the timer is reset. Therefore, a message will be sent after the current time-out value elapses, but the previously set time-out value is ignored. If the call is not intended to replace an existing timer, nIDEvent should be 0 if the hWnd is <c>NULL</c>.</para></param>
/// <param name="uElapse"><para>Type: <c>UINT</c></para><para>The time-out value, in milliseconds.</para><para>If uElapse is less than <c>USER_TIMER_MINIMUM</c> (0x0000000A), the timeout is set to <c>USER_TIMER_MINIMUM</c>. If uElapse is greater than <c>USER_TIMER_MAXIMUM</c> (0x7FFFFFFF), the timeout is set to <c>USER_TIMER_MAXIMUM</c>.</para><para>If the sum of uElapse and uToleranceDelay exceeds <c>USER_TIMER_MAXIMUM</c>, an ERROR_INVALID_PARAMETER exception occurs.</para></param>
/// <param name="lpTimerFunc"><para>Type: <c>TIMERPROC</c></para><para>A pointer to the function to be notified when the time-out value elapses. For more information about the function, see TimerProc. If lpTimerFunc is <c>NULL</c>, the system posts a WM_TIMER message to the application queue. The <c>hwnd</c> member of the message's MSG structure contains the value of the hWnd parameter.</para></param>
/// <param name="uToleranceDelay"><para>Type: <c>ULONG</c></para><para>It can be one of the following values:</para><list type="table"><listheader><term>Value</term><term>Meaning</term></listheader><item><term> TIMERV_DEFAULT_COALESCING 0x00000000 </term><term>Uses the system default timer coalescing.</term></item><item><term> TIMERV_NO_COALESCING 0xFFFFFFFF </term><term> Uses no timer coalescing. When this value is used, the created timer is not coalesced, no matter what the system default timer coalescing is or the application compatiblity flags are. </term></item><item><term> 0x1 - 0x7FFFFFF5 </term><term> Specifies the coalescing tolerance delay, in milliseconds. Applications should set this value to the system default (TIMERV_DEFAULT_COALESCING) or the largest value possible. If the sum of uElapse and uToleranceDelay exceeds USER_TIMER_MAXIMUM (0x7FFFFFFF), an ERROR_INVALID_PARAMETER exception occurs. See Windows Timer Coalescing for more details and best practices.</term></item><item><term> Any other value </term><term> An invalid value. If uToleranceDelay is set to an invalid value, the function fails and returns zero. </term></item></list></param>
/// <param name="hWnd">
/// <para>Type: <c>HWND</c></para>
/// <para>
/// A handle to the window to be associated with the timer. This window must be owned by the calling thread. If a <c>NULL</c> value for
/// hWnd is passed in along with an nIDEvent of an existing timer, that timer will be replaced in the same way that an existing non-NULL
/// hWnd timer will be.
/// </para>
/// </param>
/// <param name="nIDEvent">
/// <para>Type: <c>UINT_PTR</c></para>
/// <para>
/// A timer identifier. If the hWnd parameter is <c>NULL</c>, and the nIDEvent does not match an existing timer, then the nIDEvent is
/// ignored and a new timer ID is generated. If the hWnd parameter is not <c>NULL</c> and the window specified by hWnd already has a
/// timer with the value nIDEvent, then the existing timer is replaced by the new timer. When <c>SetCoalescableTimer</c> replaces a
/// timer, the timer is reset. Therefore, a message will be sent after the current time-out value elapses, but the previously set
/// time-out value is ignored. If the call is not intended to replace an existing timer, nIDEvent should be 0 if the hWnd is <c>NULL</c>.
/// </para>
/// </param>
/// <param name="uElapse">
/// <para>Type: <c>UINT</c></para>
/// <para>The time-out value, in milliseconds.</para>
/// <para>
/// If uElapse is less than <c>USER_TIMER_MINIMUM</c> (0x0000000A), the timeout is set to <c>USER_TIMER_MINIMUM</c>. If uElapse is
/// greater than <c>USER_TIMER_MAXIMUM</c> (0x7FFFFFFF), the timeout is set to <c>USER_TIMER_MAXIMUM</c>.
/// </para>
/// <para>If the sum of uElapse and uToleranceDelay exceeds <c>USER_TIMER_MAXIMUM</c>, an ERROR_INVALID_PARAMETER exception occurs.</para>
/// </param>
/// <param name="lpTimerFunc">
/// <para>Type: <c>TIMERPROC</c></para>
/// <para>
/// A pointer to the function to be notified when the time-out value elapses. For more information about the function, see TimerProc. If
/// lpTimerFunc is <c>NULL</c>, the system posts a WM_TIMER message to the application queue. The <c>hwnd</c> member of the message's MSG
/// structure contains the value of the hWnd parameter.
/// </para>
/// </param>
/// <param name="uToleranceDelay">
/// <para>Type: <c>ULONG</c></para>
/// <para>It can be one of the following values:</para>
/// <list type="table">
/// <listheader>
/// <term>Value</term>
/// <term>Meaning</term>
/// </listheader>
/// <item>
/// <term>TIMERV_DEFAULT_COALESCING 0x00000000</term>
/// <term>Uses the system default timer coalescing.</term>
/// </item>
/// <item>
/// <term>TIMERV_NO_COALESCING 0xFFFFFFFF</term>
/// <term>
/// Uses no timer coalescing. When this value is used, the created timer is not coalesced, no matter what the system default timer
/// coalescing is or the application compatiblity flags are.
/// </term>
/// </item>
/// <item>
/// <term>0x1 - 0x7FFFFFF5</term>
/// <term>
/// Specifies the coalescing tolerance delay, in milliseconds. Applications should set this value to the system default
/// (TIMERV_DEFAULT_COALESCING) or the largest value possible. If the sum of uElapse and uToleranceDelay exceeds USER_TIMER_MAXIMUM
/// (0x7FFFFFFF), an ERROR_INVALID_PARAMETER exception occurs. See Windows Timer Coalescing for more details and best practices.
/// </term>
/// </item>
/// <item>
/// <term>Any other value</term>
/// <term>An invalid value. If uToleranceDelay is set to an invalid value, the function fails and returns zero.</term>
/// </item>
/// </list>
/// </param>
/// <returns>
/// <para>Type: <c>Type: <c>UINT_PTR</c> </c></para><para>If the function succeeds and the hWnd parameter is <c>NULL</c>, the return value is an integer identifying the new timer. An application can pass this value to the KillTimer function to destroy the timer.</para><para>If the function succeeds and the hWnd parameter is not <c>NULL</c>, then the return value is a nonzero integer. An application can pass the value of the nIDEvent parameter to the KillTimer function to destroy the timer.</para><para>If the function fails to create a timer, the return value is zero. To get extended error information, call GetLastError.</para>
/// <para>Type: <c>Type: <c>UINT_PTR</c></c></para>
/// <para>
/// If the function succeeds and the hWnd parameter is <c>NULL</c>, the return value is an integer identifying the new timer. An
/// application can pass this value to the KillTimer function to destroy the timer.
/// </para>
/// <para>
/// If the function succeeds and the hWnd parameter is not <c>NULL</c>, then the return value is a nonzero integer. An application can
/// pass the value of the nIDEvent parameter to the KillTimer function to destroy the timer.
/// </para>
/// <para>If the function fails to create a timer, the return value is zero. To get extended error information, call GetLastError.</para>
/// </returns>
/// <remarks>
/// <para>An application can process WM_TIMER messages by including a <c>WM_TIMER</c> case statement in the window procedure or by specifying a TimerProc callback function when creating the timer. When you specify a <c>TimerProc</c> callback function, the default window procedure calls the callback function when it processes <c>WM_TIMER</c>. Therefore, you need to dispatch messages in the calling thread, even when you use <c>TimerProc</c> instead of processing <c>WM_TIMER</c>.</para><para>The wParam parameter of the WM_TIMER message contains the value of the nIDEvent parameter.</para><para>The timer identifier, nIDEvent, is specific to the associated window. Another window can have its own timer which has the same identifier as a timer owned by another window. The timers are distinct.</para><para>SetTimer can reuse timer IDs in the case where hWnd is <c>NULL</c>.</para><para>When uToleranceDelay is set to 0, the system default timer coalescing is used and <c>SetCoalescableTimer</c> behaves the same as SetTimer.</para>
/// <para>
/// An application can process WM_TIMER messages by including a <c>WM_TIMER</c> case statement in the window procedure or by specifying a
/// TimerProc callback function when creating the timer. When you specify a <c>TimerProc</c> callback function, the default window
/// procedure calls the callback function when it processes <c>WM_TIMER</c>. Therefore, you need to dispatch messages in the calling
/// thread, even when you use <c>TimerProc</c> instead of processing <c>WM_TIMER</c>.
/// </para>
/// <para>The wParam parameter of the WM_TIMER message contains the value of the nIDEvent parameter.</para>
/// <para>
/// The timer identifier, nIDEvent, is specific to the associated window. Another window can have its own timer which has the same
/// identifier as a timer owned by another window. The timers are distinct.
/// </para>
/// <para>SetTimer can reuse timer IDs in the case where hWnd is <c>NULL</c>.</para>
/// <para>
/// When uToleranceDelay is set to 0, the system default timer coalescing is used and <c>SetCoalescableTimer</c> behaves the same as SetTimer.
/// </para>
/// </remarks>
// https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-setcoalescabletimer
// UINT_PTR SetCoalescableTimer( HWND hWnd, UINT_PTR nIDEvent, UINT uElapse, TIMERPROC lpTimerFunc, ULONG uToleranceDelay );
[DllImport(Lib.User32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("winuser.h", MSDNShortId = "39303811-972f-4131-deea-cebf84c50867")]
public static extern UIntPtr SetCoalescableTimer(HWND hWnd, UIntPtr nIDEvent, uint uElapse, Timerproc lpTimerFunc, uint uToleranceDelay);
public static extern nuint SetCoalescableTimer([Optional] HWND hWnd, nuint nIDEvent, uint uElapse, [Optional] Timerproc? lpTimerFunc, uint uToleranceDelay);
/// <summary>Creates a timer with the specified time-out value.</summary>
/// <param name="hWnd">
@ -138,5 +224,5 @@ public static partial class User32
// UINT uElapse, TIMERPROC lpTimerFunc );
[DllImport(Lib.User32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("winuser.h")]
public static extern IntPtr SetTimer([Optional] HWND hWnd, [Optional] IntPtr nIDEvent, [Optional] uint uElapse, [Optional] Timerproc lpTimerFunc);
public static extern IntPtr SetTimer([Optional] HWND hWnd, [Optional] nuint nIDEvent, [Optional] uint uElapse, [Optional] Timerproc? lpTimerFunc);
}

View File

@ -1631,7 +1631,7 @@ public static partial class User32
public uint dwTime;
/// <summary>An additional value associated with the touch event.</summary>
public UIntPtr dwExtraInfo;
public IntPtr dwExtraInfo;
/// <summary>
/// The width of the touch contact area in hundredths of a pixel in physical screen coordinates. This value is only valid if the

View File

@ -470,6 +470,7 @@ public static partial class User32
/// </summary>
GW_OWNER = 4,
}
/// <summary>The thread state.</summary>
[PInvokeData("winuser.h", MSDNShortId = "guithreadinfo")]
[Flags]
@ -1705,7 +1706,7 @@ public static partial class User32
[DllImport(Lib.User32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("winuser.h", MSDNShortId = "calculatepopupwindowposition")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool CalculatePopupWindowPosition(in POINT anchorPoint, in SIZE windowSize, TrackPopupMenuFlags flags, [Optional] PRECT excludeRect, out RECT popupWindowPosition);
public static extern bool CalculatePopupWindowPosition(in POINT anchorPoint, in SIZE windowSize, TrackPopupMenuFlags flags, [Optional] PRECT? excludeRect, out RECT popupWindowPosition);
/// <summary>Passes message information to the specified window procedure.</summary>
/// <param name="lpPrevWndFunc">
@ -1909,7 +1910,7 @@ public static partial class User32
// wHow, CONST RECT *lpRect, UINT cKids, const HWND *lpKids );
[DllImport(Lib.User32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("winuser.h", MSDNShortId = "cascadewindows")]
public static extern ushort CascadeWindows(HWND hwndParent, uint wHow, in RECT lpRect, uint cKids, [Optional, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 3)] HWND[]? lpKids);
public static extern ushort CascadeWindows([Optional] HWND hwndParent, uint wHow, [In, Optional] PRECT? lpRect, uint cKids, [Optional, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 3)] HWND[]? lpKids);
/// <summary>
/// <para>
@ -2182,46 +2183,96 @@ public static partial class User32
public static extern bool CloseWindow(HWND hWnd);
/// <summary>
/// <para>Creates an overlapped, pop-up, or child window. It specifies the window class, window title, window style, and (optionally) the initial position and size of the window. The function also specifies the window's parent or owner, if any, and the window's menu.</para>
/// <para>
/// Creates an overlapped, pop-up, or child window. It specifies the window class, window title, window style, and (optionally) the
/// initial position and size of the window. The function also specifies the window's parent or owner, if any, and the window's menu.
/// </para>
/// <para>To use extended window styles in addition to the styles supported by <c>CreateWindow</c>, use the CreateWindowEx function.</para>
/// </summary>
/// <param name="lpClassName">
/// <para>Type: <c>LPCTSTR</c></para>
/// <para>A <c>null</c>-terminated string or a class atom created by a previous call to the RegisterClass or RegisterClassEx function. The atom must be in the low-order word of lpClassName; the high-order word must be zero. If lpClassName is a string, it specifies the window class name. The class name can be any name registered with <c>RegisterClass</c> or <c>RegisterClassEx</c>, provided that the module that registers the class is also the module that creates the window. The class name can also be any of the predefined system class names. For a list of system class names, see the Remarks section.</para>
/// <para>
/// A <c>null</c>-terminated string or a class atom created by a previous call to the RegisterClass or RegisterClassEx function. The atom
/// must be in the low-order word of lpClassName; the high-order word must be zero. If lpClassName is a string, it specifies the window
/// class name. The class name can be any name registered with <c>RegisterClass</c> or <c>RegisterClassEx</c>, provided that the module
/// that registers the class is also the module that creates the window. The class name can also be any of the predefined system class
/// names. For a list of system class names, see the Remarks section.
/// </para>
/// </param>
/// <param name="lpWindowName">
/// <para>Type: <c>LPCTSTR</c></para>
/// <para>The window name. If the window style specifies a title bar, the window title pointed to by lpWindowName is displayed in the title bar. When using <c>CreateWindow</c> to create controls, such as buttons, check boxes, and static controls, use lpWindowName to specify the text of the control. When creating a static control with the <c>SS_ICON</c> style, use lpWindowName to specify the icon name or identifier. To specify an identifier, use the syntax "#num".</para>
/// <para>
/// The window name. If the window style specifies a title bar, the window title pointed to by lpWindowName is displayed in the title
/// bar. When using <c>CreateWindow</c> to create controls, such as buttons, check boxes, and static controls, use lpWindowName to
/// specify the text of the control. When creating a static control with the <c>SS_ICON</c> style, use lpWindowName to specify the icon
/// name or identifier. To specify an identifier, use the syntax "#num".
/// </para>
/// </param>
/// <param name="dwStyle">
/// <para>Type: <c>DWORD</c></para>
/// <para>The style of the window being created. This parameter can be a combination of the window style values, plus the control styles indicated in the Remarks section.</para>
/// <para>
/// The style of the window being created. This parameter can be a combination of the window style values, plus the control styles
/// indicated in the Remarks section.
/// </para>
/// </param>
/// <param name="x">
/// <para>Type: <c>int</c></para>
/// <para>The initial horizontal position of the window. For an overlapped or pop-up window, the x parameter is the initial x-coordinate of the window's upper-left corner, in screen coordinates. For a child window, x is the x-coordinate of the upper-left corner of the window relative to the upper-left corner of the parent window's client area. If this parameter is set to <c>CW_USEDEFAULT</c>, the system selects the default position for the window's upper-left corner and ignores the y parameter. <c>CW_USEDEFAULT</c> is valid only for overlapped windows; if it is specified for a pop-up or child window, the x and y parameters are set to zero.</para>
/// <para>
/// The initial horizontal position of the window. For an overlapped or pop-up window, the x parameter is the initial x-coordinate of the
/// window's upper-left corner, in screen coordinates. For a child window, x is the x-coordinate of the upper-left corner of the window
/// relative to the upper-left corner of the parent window's client area. If this parameter is set to <c>CW_USEDEFAULT</c>, the system
/// selects the default position for the window's upper-left corner and ignores the y parameter. <c>CW_USEDEFAULT</c> is valid only for
/// overlapped windows; if it is specified for a pop-up or child window, the x and y parameters are set to zero.
/// </para>
/// </param>
/// <param name="y">
/// <para>Type: <c>int</c></para>
/// <para>The initial vertical position of the window. For an overlapped or pop-up window, the y parameter is the initial y-coordinate of the window's upper-left corner, in screen coordinates. For a child window, y is the initial y-coordinate of the upper-left corner of the child window relative to the upper-left corner of the parent window's client area. For a list box, y is the initial y-coordinate of the upper-left corner of the list box's client area relative to the upper-left corner of the parent window's client area.</para>
/// <para>If an overlapped window is created with the <c>WS_VISIBLE</c> style bit set and the x parameter is set to <c>CW_USEDEFAULT</c>, then the y parameter determines how the window is shown. If the y parameter is <c>CW_USEDEFAULT</c>, then the window manager calls ShowWindow with the <c>SW_SHOW</c> flag after the window has been created. If the y parameter is some other value, then the window manager calls <c>ShowWindow</c> with that value as the nCmdShow parameter.</para>
/// <para>
/// The initial vertical position of the window. For an overlapped or pop-up window, the y parameter is the initial y-coordinate of the
/// window's upper-left corner, in screen coordinates. For a child window, y is the initial y-coordinate of the upper-left corner of the
/// child window relative to the upper-left corner of the parent window's client area. For a list box, y is the initial y-coordinate of
/// the upper-left corner of the list box's client area relative to the upper-left corner of the parent window's client area.
/// </para>
/// <para>
/// If an overlapped window is created with the <c>WS_VISIBLE</c> style bit set and the x parameter is set to <c>CW_USEDEFAULT</c>, then
/// the y parameter determines how the window is shown. If the y parameter is <c>CW_USEDEFAULT</c>, then the window manager calls
/// ShowWindow with the <c>SW_SHOW</c> flag after the window has been created. If the y parameter is some other value, then the window
/// manager calls <c>ShowWindow</c> with that value as the nCmdShow parameter.
/// </para>
/// </param>
/// <param name="nWidth">
/// <para>Type: <c>int</c></para>
/// <para>The width, in device units, of the window. For overlapped windows, nWidth is either the window's width, in screen coordinates, or <c>CW_USEDEFAULT</c>. If nWidth is <c>CW_USEDEFAULT</c>, the system selects a default width and height for the window; the default width extends from the initial x-coordinate to the right edge of the screen, and the default height extends from the initial y-coordinate to the top of the icon area. <c>CW_USEDEFAULT</c> is valid only for overlapped windows; if <c>CW_USEDEFAULT</c> is specified for a pop-up or child window, nWidth and nHeight are set to zero.</para>
/// <para>
/// The width, in device units, of the window. For overlapped windows, nWidth is either the window's width, in screen coordinates, or
/// <c>CW_USEDEFAULT</c>. If nWidth is <c>CW_USEDEFAULT</c>, the system selects a default width and height for the window; the default
/// width extends from the initial x-coordinate to the right edge of the screen, and the default height extends from the initial
/// y-coordinate to the top of the icon area. <c>CW_USEDEFAULT</c> is valid only for overlapped windows; if <c>CW_USEDEFAULT</c> is
/// specified for a pop-up or child window, nWidth and nHeight are set to zero.
/// </para>
/// </param>
/// <param name="nHeight">
/// <para>Type: <c>int</c></para>
/// <para>The height, in device units, of the window. For overlapped windows, nHeight is the window's height, in screen coordinates. If nWidth is set to <c>CW_USEDEFAULT</c>, the system ignores nHeight.</para>
/// <para>
/// The height, in device units, of the window. For overlapped windows, nHeight is the window's height, in screen coordinates. If nWidth
/// is set to <c>CW_USEDEFAULT</c>, the system ignores nHeight.
/// </para>
/// </param>
/// <param name="hWndParent">
/// <para>Type: <c>HWND</c></para>
/// <para>A handle to the parent or owner window of the window being created. To create a child window or an owned window, supply a valid window handle. This parameter is optional for pop-up windows.</para>
/// <para>
/// A handle to the parent or owner window of the window being created. To create a child window or an owned window, supply a valid
/// window handle. This parameter is optional for pop-up windows.
/// </para>
/// <para>To create a message-only window, supply <c>HWND_MESSAGE</c> or a handle to an existing message-only window.</para>
/// </param>
/// <param name="hMenu">
/// <para>Type: <c>HMENU</c></para>
/// <para>A handle to a menu, or specifies a child-window identifier depending on the window style. For an overlapped or pop-up window, hMenu identifies the menu to be used with the window; it can be <c>NULL</c> if the class menu is to be used. For a child window, hMenu specifies the child-window identifier, an integer value used by a dialog box control to notify its parent about events. The application determines the child-window identifier; it must be unique for all child windows with the same parent window.</para>
/// <para>
/// A handle to a menu, or specifies a child-window identifier depending on the window style. For an overlapped or pop-up window, hMenu
/// identifies the menu to be used with the window; it can be <c>NULL</c> if the class menu is to be used. For a child window, hMenu
/// specifies the child-window identifier, an integer value used by a dialog box control to notify its parent about events. The
/// application determines the child-window identifier; it must be unique for all child windows with the same parent window.
/// </para>
/// </param>
/// <param name="hInstance">
/// <para>Type: <c>HINSTANCE</c></para>
@ -2229,8 +2280,15 @@ public static partial class User32
/// </param>
/// <param name="lpParam">
/// <para>Type: <c>LPVOID</c></para>
/// <para>A pointer to a value to be passed to the window through the CREATESTRUCT structure (<c>lpCreateParams</c> member) pointed to by the lParam param of the WM_CREATE message. This message is sent to the created window by this function before it returns.</para>
/// <para>If an application calls <c>CreateWindow</c> to create a MDI client window, lpParam should point to a CLIENTCREATESTRUCT structure. If an MDI client window calls <c>CreateWindow</c> to create an MDI child window, lpParam should point to a MDICREATESTRUCT structure. lpParam may be <c>NULL</c> if no additional data is needed.</para>
/// <para>
/// A pointer to a value to be passed to the window through the CREATESTRUCT structure ( <c>lpCreateParams</c> member) pointed to by the
/// lParam param of the WM_CREATE message. This message is sent to the created window by this function before it returns.
/// </para>
/// <para>
/// If an application calls <c>CreateWindow</c> to create a MDI client window, lpParam should point to a CLIENTCREATESTRUCT structure. If
/// an MDI client window calls <c>CreateWindow</c> to create an MDI child window, lpParam should point to a MDICREATESTRUCT structure.
/// lpParam may be <c>NULL</c> if no additional data is needed.
/// </para>
/// </param>
/// <returns>
/// <para>Type: <c>Type: <c>HWND</c></c></para>
@ -2253,11 +2311,22 @@ public static partial class User32
/// </list>
/// </returns>
/// <remarks>
/// <para>Before returning, <c>CreateWindow</c> sends a WM_CREATE message to the window procedure. For overlapped, pop-up, and child windows, <c>CreateWindow</c> sends <c>WM_CREATE</c>, WM_GETMINMAXINFO, and WM_NCCREATE messages to the window. The lParam parameter of the <c>WM_CREATE</c> message contains a pointer to a CREATESTRUCT structure. If the <c>WS_VISIBLE</c> style is specified, <c>CreateWindow</c> sends the window all the messages required to activate and show the window.</para>
/// <para>If the created window is a child window, its default position is at the bottom of the Z-order. If the created window is a top-level window, its default position is at the top of the Z-order (but beneath all topmost windows unless the created window is itself topmost).</para>
/// <para>
/// Before returning, <c>CreateWindow</c> sends a WM_CREATE message to the window procedure. For overlapped, pop-up, and child windows,
/// <c>CreateWindow</c> sends <c>WM_CREATE</c>, WM_GETMINMAXINFO, and WM_NCCREATE messages to the window. The lParam parameter of the
/// <c>WM_CREATE</c> message contains a pointer to a CREATESTRUCT structure. If the <c>WS_VISIBLE</c> style is specified,
/// <c>CreateWindow</c> sends the window all the messages required to activate and show the window.
/// </para>
/// <para>
/// If the created window is a child window, its default position is at the bottom of the Z-order. If the created window is a top-level
/// window, its default position is at the top of the Z-order (but beneath all topmost windows unless the created window is itself topmost).
/// </para>
/// <para>For information on controlling whether the Taskbar displays a button for the created window, see Managing Taskbar Buttons.</para>
/// <para>For information on removing a window, see the DestroyWindow function.</para>
/// <para>The following predefined system classes can be specified in the lpClassName parameter. Note the corresponding control styles you can use in the dwStyle parameter.</para>
/// <para>
/// The following predefined system classes can be specified in the lpClassName parameter. Note the corresponding control styles you can
/// use in the dwStyle parameter.
/// </para>
/// <list type="table">
/// <listheader>
/// <term>System class</term>
@ -2265,43 +2334,88 @@ public static partial class User32
/// </listheader>
/// <item>
/// <term>BUTTON</term>
/// <term>Designates a small rectangular child window that represents a button the user can click to turn it on or off. Button controls can be used alone or in groups, and they can either be labeled or appear without text. Button controls typically change appearance when the user clicks them. For more information, see Buttons For a table of the button styles you can specify in the dwStyle parameter, see Button Styles.</term>
/// <term>
/// Designates a small rectangular child window that represents a button the user can click to turn it on or off. Button controls can be
/// used alone or in groups, and they can either be labeled or appear without text. Button controls typically change appearance when the
/// user clicks them. For more information, see Buttons For a table of the button styles you can specify in the dwStyle parameter, see
/// Button Styles.
/// </term>
/// </item>
/// <item>
/// <term>COMBOBOX</term>
/// <term>Designates a control consisting of a list box and a selection field similar to an edit control. When using this style, an application should either display the list box at all times or enable a drop-down list box. If the list box is visible, typing characters into the selection field highlights the first list box entry that matches the characters typed. Conversely, selecting an item in the list box displays the selected text in the selection field. For more information, see Combo Boxes. For a table of the combo box styles you can specify in the dwStyle parameter, see Combo Box Styles.</term>
/// <term>
/// Designates a control consisting of a list box and a selection field similar to an edit control. When using this style, an application
/// should either display the list box at all times or enable a drop-down list box. If the list box is visible, typing characters into
/// the selection field highlights the first list box entry that matches the characters typed. Conversely, selecting an item in the list
/// box displays the selected text in the selection field. For more information, see Combo Boxes. For a table of the combo box styles you
/// can specify in the dwStyle parameter, see Combo Box Styles.
/// </term>
/// </item>
/// <item>
/// <term>EDIT</term>
/// <term>Designates a rectangular child window into which the user can type text from the keyboard. The user selects the control and gives it the keyboard focus by clicking it or moving to it by pressing the TAB key. The user can type text when the edit control displays a flashing caret; use the mouse to move the cursor, select characters to be replaced, or position the cursor for inserting characters; or use the BACKSPACE key to delete characters. For more information, see Edit Controls. For a table of the edit control styles you can specify in the dwStyle parameter, see Edit Control Styles.</term>
/// <term>
/// Designates a rectangular child window into which the user can type text from the keyboard. The user selects the control and gives it
/// the keyboard focus by clicking it or moving to it by pressing the TAB key. The user can type text when the edit control displays a
/// flashing caret; use the mouse to move the cursor, select characters to be replaced, or position the cursor for inserting characters;
/// or use the BACKSPACE key to delete characters. For more information, see Edit Controls. For a table of the edit control styles you
/// can specify in the dwStyle parameter, see Edit Control Styles.
/// </term>
/// </item>
/// <item>
/// <term>LISTBOX</term>
/// <term>Designates a list of character strings. Specify this control whenever an application must present a list of names, such as file names, from which the user can choose. The user can select a string by clicking it. A selected string is highlighted, and a notification message is passed to the parent window. For more information, see List Boxes. For a table of the list box styles you can specify in the dwStyle parameter, see List Box Styles.</term>
/// <term>
/// Designates a list of character strings. Specify this control whenever an application must present a list of names, such as file
/// names, from which the user can choose. The user can select a string by clicking it. A selected string is highlighted, and a
/// notification message is passed to the parent window. For more information, see List Boxes. For a table of the list box styles you can
/// specify in the dwStyle parameter, see List Box Styles.
/// </term>
/// </item>
/// <item>
/// <term>MDICLIENT</term>
/// <term>Designates an MDI client window. This window receives messages that control the MDI application's child windows. The recommended style bits are WS_CLIPCHILDREN and WS_CHILD. Specify the WS_HSCROLL and WS_VSCROLL styles to create an MDI client window that allows the user to scroll MDI child windows into view. For more information, see Multiple Document Interface.</term>
/// <term>
/// Designates an MDI client window. This window receives messages that control the MDI application's child windows. The recommended
/// style bits are WS_CLIPCHILDREN and WS_CHILD. Specify the WS_HSCROLL and WS_VSCROLL styles to create an MDI client window that allows
/// the user to scroll MDI child windows into view. For more information, see Multiple Document Interface.
/// </term>
/// </item>
/// <item>
/// <term>RichEdit</term>
/// <term>Designates a Microsoft Rich Edit 1.0 control. This window lets the user view and edit text with character and paragraph formatting, and can include embedded Component Object Model (COM) objects. For more information, see Rich Edit Controls. For a table of the rich edit control styles you can specify in the dwStyle parameter, see Rich Edit Control Styles.</term>
/// <term>
/// Designates a Microsoft Rich Edit 1.0 control. This window lets the user view and edit text with character and paragraph formatting,
/// and can include embedded Component Object Model (COM) objects. For more information, see Rich Edit Controls. For a table of the rich
/// edit control styles you can specify in the dwStyle parameter, see Rich Edit Control Styles.
/// </term>
/// </item>
/// <item>
/// <term>RICHEDIT_CLASS</term>
/// <term>Designates a Microsoft Rich Edit 2.0 control. This controls let the user view and edit text with character and paragraph formatting, and can include embedded COM objects. For more information, see Rich Edit Controls. For a table of the rich edit control styles you can specify in the dwStyle parameter, see Rich Edit Control Styles.</term>
/// <term>
/// Designates a Microsoft Rich Edit 2.0 control. This controls let the user view and edit text with character and paragraph formatting,
/// and can include embedded COM objects. For more information, see Rich Edit Controls. For a table of the rich edit control styles you
/// can specify in the dwStyle parameter, see Rich Edit Control Styles.
/// </term>
/// </item>
/// <item>
/// <term>SCROLLBAR</term>
/// <term>Designates a rectangle that contains a scroll box and has direction arrows at both ends. The scroll bar sends a notification message to its parent window whenever the user clicks the control. The parent window is responsible for updating the position of the scroll box, if necessary. For more information, see Scroll Bars. For a table of the scroll bar control styles you can specify in the dwStyle parameter, see Scroll Bar Control Styles.</term>
/// <term>
/// Designates a rectangle that contains a scroll box and has direction arrows at both ends. The scroll bar sends a notification message
/// to its parent window whenever the user clicks the control. The parent window is responsible for updating the position of the scroll
/// box, if necessary. For more information, see Scroll Bars. For a table of the scroll bar control styles you can specify in the dwStyle
/// parameter, see Scroll Bar Control Styles.
/// </term>
/// </item>
/// <item>
/// <term>STATIC</term>
/// <term>Designates a simple text field, box, or rectangle used to label, box, or separate other controls. Static controls take no input and provide no output. For more information, see Static Controls. For a table of the static control styles you can specify in the dwStyle parameter, see Static Control Styles.</term>
/// <term>
/// Designates a simple text field, box, or rectangle used to label, box, or separate other controls. Static controls take no input and
/// provide no output. For more information, see Static Controls. For a table of the static control styles you can specify in the dwStyle
/// parameter, see Static Control Styles.
/// </term>
/// </item>
/// </list>
/// <para><c>CreateWindow</c> is implemented as a call to the CreateWindowEx function, as shown below.</para>
/// <para><code>#define CreateWindowA(lpClassName, lpWindowName, dwStyle, x, y, nWidth, nHeight, hWndParent, hMenu, hInstance, lpParam)\ CreateWindowExA(0L, lpClassName, lpWindowName, dwStyle, x, y, nWidth, nHeight, hWndParent, hMenu, hInstance, lpParam) #define CreateWindowW(lpClassName, lpWindowName, dwStyle, x, y, nWidth, nHeight, hWndParent, hMenu, hInstance, lpParam)\ CreateWindowExW(0L, lpClassName, lpWindowName, dwStyle, x, y, nWidth, nHeight, hWndParent, hMenu, hInstance, lpParam) #ifdef UNICODE #define CreateWindow CreateWindowW #else #define CreateWindow CreateWindowA #endif</code></para>
/// <para>
/// <code>#define CreateWindowA(lpClassName, lpWindowName, dwStyle, x, y, nWidth, nHeight, hWndParent, hMenu, hInstance, lpParam)\ CreateWindowExA(0L, lpClassName, lpWindowName, dwStyle, x, y, nWidth, nHeight, hWndParent, hMenu, hInstance, lpParam) #define CreateWindowW(lpClassName, lpWindowName, dwStyle, x, y, nWidth, nHeight, hWndParent, hMenu, hInstance, lpParam)\ CreateWindowExW(0L, lpClassName, lpWindowName, dwStyle, x, y, nWidth, nHeight, hWndParent, hMenu, hInstance, lpParam) #ifdef UNICODE #define CreateWindow CreateWindowW #else #define CreateWindow CreateWindowA #endif</code>
/// </para>
/// <para>Examples</para>
/// <para>For an example, see Using Window Classes.</para>
/// </remarks>
@ -3028,7 +3142,7 @@ public static partial class User32
// hWnd, HWND hWndInsertAfter, int x, int y, int cx, int cy, UINT uFlags );
[DllImport(Lib.User32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("winuser.h", MSDNShortId = "deferwindowpos")]
public static extern HDWP DeferWindowPos(HDWP hWinPosInfo, HWND hWnd, HWND hWndInsertAfter, int x, int y, int cx, int cy, SetWindowPosFlags uFlags);
public static extern HDWP DeferWindowPos(HDWP hWinPosInfo, HWND hWnd, [Optional] HWND hWndInsertAfter, int x, int y, int cx, int cy, SetWindowPosFlags uFlags);
/// <summary>
/// Provides default processing for any window messages that the window procedure of a multiple-document interface (MDI) frame window
@ -3103,7 +3217,7 @@ public static partial class User32
// hWndMDIClient, UINT uMsg, WPARAM wParam, LPARAM lParam );
[DllImport(Lib.User32, SetLastError = false, CharSet = CharSet.Auto)]
[PInvokeData("winuser.h")]
public static extern IntPtr DefFrameProc(HWND hWnd, HWND hWndMDIClient, uint uMsg, IntPtr wParam, IntPtr lParam);
public static extern IntPtr DefFrameProc(HWND hWnd, [Optional] HWND hWndMDIClient, uint uMsg, IntPtr wParam, IntPtr lParam);
/// <summary>
/// Provides default processing for any window message that the window procedure of a multiple-document interface (MDI) child window
@ -3468,7 +3582,7 @@ public static partial class User32
[DllImport(Lib.User32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("winuser.h", MSDNShortId = "enumchildwindows")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool EnumChildWindows(HWND hWndParent, EnumWindowsProc lpEnumFunc, IntPtr lParam);
public static extern bool EnumChildWindows([Optional] HWND hWndParent, EnumWindowsProc lpEnumFunc, IntPtr lParam);
/// <summary>
/// Enumerates the child windows that belong to the specified parent window by passing the handle to each child window, in turn, to
@ -3878,7 +3992,7 @@ public static partial class User32
[DllImport(Lib.User32, SetLastError = true, CharSet = CharSet.Auto)]
[PInvokeData("winuser.h", MSDNShortId = "getalttabinfo")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool GetAltTabInfo(HWND hwnd, int iItem, ref ALTTABINFO pati, StringBuilder pszItemText, uint cchItemText);
public static extern bool GetAltTabInfo(HWND hwnd, int iItem, ref ALTTABINFO pati, [Optional] StringBuilder? pszItemText, uint cchItemText);
/// <summary>
/// <para>Retrieves the handle to the ancestor of the specified window.</para>
@ -3993,7 +4107,7 @@ public static partial class User32
[DllImport(Lib.User32, SetLastError = true, CharSet = CharSet.Auto)]
[PInvokeData("winuser.h", MSDNShortId = "")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool GetClassInfo([In] HINSTANCE hInstance, [MarshalAs(UnmanagedType.LPTStr)] string lpClassName, out WNDCLASS lpWndClass);
public static extern bool GetClassInfo([In, Optional] HINSTANCE hInstance, [MarshalAs(UnmanagedType.LPTStr)] string lpClassName, out WNDCLASS lpWndClass);
/// <summary>
/// <para>
@ -4783,7 +4897,7 @@ public static partial class User32
// https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-gettopwindow HWND GetTopWindow( HWND hWnd );
[DllImport(Lib.User32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("winuser.h", MSDNShortId = "gettopwindow")]
public static extern HWND GetTopWindow(HWND hWnd);
public static extern HWND GetTopWindow([Optional] HWND hWnd);
/// <summary>
/// <para>Retrieves a handle to a window that has the specified relationship (Z-Order or owner) to the specified window.</para>
@ -6699,7 +6813,7 @@ public static partial class User32
// https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-setfocus HWND SetFocus( HWND hWnd );
[DllImport(Lib.User32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("winuser.h", MSDNShortId = "")]
public static extern HWND SetFocus(HWND hWnd);
public static extern HWND SetFocus([Optional] HWND hWnd);
/// <summary>
/// <para>
@ -6896,7 +7010,7 @@ public static partial class User32
// hWndNewParent );
[DllImport(Lib.User32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("winuser.h", MSDNShortId = "setparent")]
public static extern HWND SetParent(HWND hWndChild, HWND hWndNewParent);
public static extern HWND SetParent(HWND hWndChild, [Optional] HWND hWndNewParent);
/// <summary>
/// <para>Changes the default layout when windows are created with no parent or owner only for the currently running process.</para>
@ -7074,7 +7188,7 @@ public static partial class User32
[DllImport(Lib.User32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("winuser.h", MSDNShortId = "72bee160-7004-40be-9c91-e431b06ccaed")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SetWindowFeedbackSetting(HWND hwnd, FEEDBACK_TYPE feedback, [Optional] uint dwFlags, uint size, IntPtr configuration);
public static extern bool SetWindowFeedbackSetting(HWND hwnd, FEEDBACK_TYPE feedback, [Optional] uint dwFlags, uint size, [Optional] IntPtr configuration);
/// <summary>
/// <para>Sets the show state and the restored, minimized, and maximized positions of the specified window.</para>
@ -7674,7 +7788,7 @@ public static partial class User32
// CONST RECT *lpRect, UINT cKids, const HWND *lpKids );
[DllImport(Lib.User32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("winuser.h", MSDNShortId = "tilewindows")]
public static extern ushort TileWindows(HWND hwndParent, MdiTileFlags wHow, PRECT lpRect, uint cKids, [In] HWND[] lpKids);
public static extern ushort TileWindows([Optional] HWND hwndParent, MdiTileFlags wHow, [Optional] PRECT? lpRect, uint cKids, [In, Optional] HWND[]? lpKids);
/// <summary>
/// Processes accelerator keystrokes for window menu commands of the multiple-document interface (MDI) child windows associated with
@ -7861,7 +7975,8 @@ public static partial class User32
[DllImport(Lib.User32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("winuser.h", MSDNShortId = "updatelayeredwindow")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool UpdateLayeredWindow(HWND hWnd, HDC hdcDst, in POINT pptDst, in SIZE psize, HDC hdcSrc, in POINT pptSrc, COLORREF crKey, in Gdi32.BLENDFUNCTION pblend, UpdateLayeredWindowFlags dwFlags);
public static extern bool UpdateLayeredWindow(HWND hWnd, HDC hdcDst, in POINT pptDst, in SIZE psize, HDC hdcSrc,
in POINT pptSrc, COLORREF crKey, in Gdi32.BLENDFUNCTION pblend, UpdateLayeredWindowFlags dwFlags);
/// <summary>
/// <para>Updates the position, size, shape, content, and translucency of a layered window.</para>
@ -7984,7 +8099,8 @@ public static partial class User32
[DllImport(Lib.User32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("winuser.h", MSDNShortId = "updatelayeredwindow")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool UpdateLayeredWindow(HWND hWnd, [In, Optional] HDC hdcDst, [In, Optional] IntPtr pptDst, [In, Optional] IntPtr psize, [In, Optional] HDC hdcSrc, [In, Optional] IntPtr pptSrc, COLORREF crKey, in Gdi32.BLENDFUNCTION pblend, UpdateLayeredWindowFlags dwFlags);
public static extern bool UpdateLayeredWindow(HWND hWnd, [In, Optional] HDC hdcDst, [In, Optional] IntPtr pptDst, [In, Optional] IntPtr psize,
[In, Optional] HDC hdcSrc, [In, Optional] IntPtr pptSrc, COLORREF crKey, in Gdi32.BLENDFUNCTION pblend, UpdateLayeredWindowFlags dwFlags);
/// <summary>Updates the position, size, shape, content, and translucency of a layered window.</summary>
/// <param name="hwnd">
@ -9641,7 +9757,7 @@ public static partial class User32
/// </para>
/// </summary>
[MarshalAs(UnmanagedType.FunctionPtr)]
public WindowProc lpfnWndProc;
public WindowProc? lpfnWndProc;
/// <summary>
/// <para>Type: <c>int</c></para>
@ -9820,7 +9936,7 @@ public static partial class User32
public WindowClassStyles style;
[MarshalAs(UnmanagedType.FunctionPtr)]
public WindowProc lpfnWndProc;
public WindowProc? lpfnWndProc;
public int cbClsExtra;
@ -9847,7 +9963,7 @@ public static partial class User32
cbSize = wc.cbSize,
style = wc.style,
lpszMenuName = wc.lpszMenuName,
lpszClassName = wc.lpszClassName,
lpszClassName = ((string?)wc.lpszClassName) ?? "",
hIconSm = wc.hIconSm,
hCursor = wc.hCursor,
hbrBackground = wc.hbrBackground,

View File

@ -81,7 +81,7 @@ public static partial class User32
[UnmanagedFunctionPointer(CallingConvention.Winapi)]
[PInvokeData("winuser.h", MSDNShortId = "propenumprocex")]
[return: MarshalAs(UnmanagedType.Bool)]
public delegate bool PropEnumProcEx(HWND hwnd, string lpszString, IntPtr hData, UIntPtr dwData);
public delegate bool PropEnumProcEx(HWND hwnd, string lpszString, IntPtr hData, [Optional] IntPtr dwData);
/// <summary>
/// <para>

View File

@ -62,7 +62,6 @@ public partial class User32Tests
foreach (var mode in modes.Where(m => m.infoType == DISPLAYCONFIG_MODE_INFO_TYPE.DISPLAYCONFIG_MODE_INFO_TYPE_TARGET))
{
Assert.That(() => DisplayConfigGetDeviceInfo<DISPLAYCONFIG_TARGET_DEVICE_NAME>(mode.adapterId, mode.id, DISPLAYCONFIG_DEVICE_INFO_TYPE.DISPLAYCONFIG_DEVICE_INFO_GET_ADAPTER_NAME), Throws.Exception);
Assert.That(() => DisplayConfigGetDeviceInfo<RECT>(mode.adapterId, mode.id), Throws.Exception);
TestContext.WriteLine(DisplayConfigGetDeviceInfo<DISPLAYCONFIG_TARGET_DEVICE_NAME>(mode.adapterId, mode.id).monitorFriendlyDeviceName);
TestContext.WriteLine(DisplayConfigGetDeviceInfo<DISPLAYCONFIG_ADAPTER_NAME>(mode.adapterId, mode.id).adapterDevicePath);
TestContext.WriteLine(DisplayConfigGetDeviceInfo<DISPLAYCONFIG_TARGET_BASE_TYPE>(mode.adapterId, mode.id).baseOutputTechnology);