using Microsoft.Win32.SafeHandles; using System; using System.Diagnostics; using System.Runtime.InteropServices; namespace Vanara.PInvoke; /// Provides a handle to an accelerator table. [StructLayout(LayoutKind.Sequential), DebuggerDisplay("{handle}")] public struct HACCEL : IUserHandle { private readonly IntPtr handle; /// Initializes a new instance of the struct. /// An object that represents the pre-existing handle to use. public HACCEL(IntPtr preexistingHandle) => handle = preexistingHandle; /// Returns an invalid handle by instantiating a object with . public static HACCEL NULL => new(IntPtr.Zero); /// Gets a value indicating whether this instance is a null handle. public bool IsNull => handle == IntPtr.Zero; /// Performs an explicit conversion from to . /// The handle. /// The result of the conversion. public static explicit operator IntPtr(HACCEL h) => h.handle; /// Performs an implicit conversion from to . /// The pointer to a handle. /// The result of the conversion. public static implicit operator HACCEL(IntPtr h) => new(h); /// Implements the operator ! which returns if the handle is invalid. /// The instance. /// The result of the operator. public static bool operator !(HACCEL hMem) => hMem.IsNull; /// Implements the operator !=. /// The first handle. /// The second handle. /// The result of the operator. public static bool operator !=(HACCEL h1, HACCEL h2) => !(h1 == h2); /// Implements the operator ==. /// The first handle. /// The second handle. /// The result of the operator. public static bool operator ==(HACCEL h1, HACCEL h2) => h1.Equals(h2); /// public override bool Equals(object obj) => obj is HACCEL h && handle == h.handle; /// public override int GetHashCode() => handle.GetHashCode(); /// public IntPtr DangerousGetHandle() => handle; } /// Provides a generic handle. [StructLayout(LayoutKind.Sequential), DebuggerDisplay("{handle}")] public struct HANDLE : IHandle { private readonly IntPtr handle; /// Initializes a new instance of the struct. /// An object that represents the pre-existing handle to use. public HANDLE(IntPtr preexistingHandle) => handle = preexistingHandle; /// Returns an invalid handle by instantiating a object with . public static HANDLE NULL => new(IntPtr.Zero); /// Gets a value indicating whether this instance is a null handle. public bool IsNull => handle == IntPtr.Zero; /// Performs an explicit conversion from to . /// The handle. /// The result of the conversion. public static explicit operator IntPtr(HANDLE h) => h.handle; /// Performs an implicit conversion from to . /// The pointer to a handle. /// The result of the conversion. public static implicit operator HANDLE(IntPtr h) => new(h); /// Performs an implicit conversion from to . /// The pointer to a handle. /// The result of the conversion. public static implicit operator HANDLE(SafeHandle h) => new(h.DangerousGetHandle()); /// Implements the operator ! which returns if the handle is invalid. /// The instance. /// The result of the operator. public static bool operator !(HANDLE hMem) => hMem.IsNull; /// Implements the operator !=. /// The first handle. /// The second handle. /// The result of the operator. public static bool operator !=(HANDLE h1, HANDLE h2) => !(h1 == h2); /// Implements the operator ==. /// The first handle. /// The second handle. /// The result of the operator. public static bool operator ==(HANDLE h1, HANDLE h2) => h1.Equals(h2); /// public override bool Equals(object obj) => obj is HANDLE h && handle == h.handle; /// public override int GetHashCode() => handle.GetHashCode(); /// public IntPtr DangerousGetHandle() => handle; } /// Provides a handle to a bitmap. [StructLayout(LayoutKind.Sequential), DebuggerDisplay("{handle}")] public struct HBITMAP : IGraphicsObjectHandle { private readonly IntPtr handle; /// Initializes a new instance of the struct. /// An object that represents the pre-existing handle to use. public HBITMAP(IntPtr preexistingHandle) => handle = preexistingHandle; /// Returns an invalid handle by instantiating a object with . public static HBITMAP NULL => new(IntPtr.Zero); /// Gets a value indicating whether this instance is a null handle. public bool IsNull => handle == IntPtr.Zero; /// Performs an explicit conversion from to . /// The handle. /// The result of the conversion. public static explicit operator IntPtr(HBITMAP h) => h.handle; /// Performs an implicit conversion from to . /// The pointer to a handle. /// The result of the conversion. public static implicit operator HBITMAP(IntPtr h) => new(h); /// Performs an implicit conversion from to . /// The pointer to a GDI handle. /// The result of the conversion. public static implicit operator HBITMAP(HGDIOBJ h) => new((IntPtr)h); /// Implements the operator ! which returns if the handle is invalid. /// The instance. /// The result of the operator. public static bool operator !(HBITMAP hMem) => hMem.IsNull; /// Implements the operator !=. /// The first handle. /// The second handle. /// The result of the operator. public static bool operator !=(HBITMAP h1, HBITMAP h2) => !(h1 == h2); /// Implements the operator ==. /// The first handle. /// The second handle. /// The result of the operator. public static bool operator ==(HBITMAP h1, HBITMAP h2) => h1.Equals(h2); /// public override bool Equals(object obj) => obj is HBITMAP h && handle == h.handle; /// public override int GetHashCode() => handle.GetHashCode(); /// public IntPtr DangerousGetHandle() => handle; } /// Provides a handle to drawing brush. [StructLayout(LayoutKind.Sequential), DebuggerDisplay("{handle}")] public struct HBRUSH : IGraphicsObjectHandle { private readonly IntPtr handle; /// Initializes a new instance of the struct. /// An object that represents the pre-existing handle to use. public HBRUSH(IntPtr preexistingHandle) => handle = preexistingHandle; /// Returns an invalid handle by instantiating a object with . public static HBRUSH NULL => new(IntPtr.Zero); /// Gets a value indicating whether this instance is a null handle. public bool IsNull => handle == IntPtr.Zero; /// Performs an explicit conversion from to . /// The handle. /// The result of the conversion. public static explicit operator IntPtr(HBRUSH h) => h.handle; /// Performs an implicit conversion from to . /// The pointer to a handle. /// The result of the conversion. public static implicit operator HBRUSH(IntPtr h) => new(h); /// Performs an implicit conversion from to . /// The pointer to a GDI handle. /// The result of the conversion. public static implicit operator HBRUSH(HGDIOBJ h) => new((IntPtr)h); /// Performs an implicit conversion from to . /// The color index. /// The result of the conversion. public static implicit operator HBRUSH(SystemColorIndex i) => new((IntPtr)i); /// Implements the operator ! which returns if the handle is invalid. /// The instance. /// The result of the operator. public static bool operator !(HBRUSH hMem) => hMem.IsNull; /// Implements the operator !=. /// The first handle. /// The second handle. /// The result of the operator. public static bool operator !=(HBRUSH h1, HBRUSH h2) => !(h1 == h2); /// Implements the operator ==. /// The first handle. /// The second handle. /// The result of the operator. public static bool operator ==(HBRUSH h1, HBRUSH h2) => h1.Equals(h2); /// public override bool Equals(object obj) => obj is HBRUSH h && handle == h.handle; /// public override int GetHashCode() => handle.GetHashCode(); /// public IntPtr DangerousGetHandle() => handle; } /// Provides a handle to a color space. [StructLayout(LayoutKind.Sequential), DebuggerDisplay("{handle}")] public struct HCOLORSPACE : IGraphicsObjectHandle { private readonly IntPtr handle; /// Initializes a new instance of the struct. /// An object that represents the pre-existing handle to use. public HCOLORSPACE(IntPtr preexistingHandle) => handle = preexistingHandle; /// Returns an invalid handle by instantiating a object with . public static HCOLORSPACE NULL => new(IntPtr.Zero); /// Gets a value indicating whether this instance is a null handle. public bool IsNull => handle == IntPtr.Zero; /// Performs an explicit conversion from to . /// The handle. /// The result of the conversion. public static explicit operator IntPtr(HCOLORSPACE h) => h.handle; /// Performs an implicit conversion from to . /// The pointer to a handle. /// The result of the conversion. public static implicit operator HCOLORSPACE(IntPtr h) => new(h); /// Performs an implicit conversion from to . /// The pointer to a GDI handle. /// The result of the conversion. public static implicit operator HCOLORSPACE(HGDIOBJ h) => new((IntPtr)h); /// Implements the operator ! which returns if the handle is invalid. /// The instance. /// The result of the operator. public static bool operator !(HCOLORSPACE hMem) => hMem.IsNull; /// Implements the operator !=. /// The first handle. /// The second handle. /// The result of the operator. public static bool operator !=(HCOLORSPACE h1, HCOLORSPACE h2) => !(h1 == h2); /// Implements the operator ==. /// The first handle. /// The second handle. /// The result of the operator. public static bool operator ==(HCOLORSPACE h1, HCOLORSPACE h2) => h1.Equals(h2); /// public override bool Equals(object obj) => obj is HCOLORSPACE h && handle == h.handle; /// public override int GetHashCode() => handle.GetHashCode(); /// public IntPtr DangerousGetHandle() => handle; } /// Provides a handle to cursor. [StructLayout(LayoutKind.Sequential), DebuggerDisplay("{handle}")] public struct HCURSOR : IGraphicsObjectHandle { private readonly IntPtr handle; /// Initializes a new instance of the struct. /// An object that represents the pre-existing handle to use. public HCURSOR(IntPtr preexistingHandle) => handle = preexistingHandle; /// Returns an invalid handle by instantiating a object with . public static HCURSOR NULL => new(IntPtr.Zero); /// Gets a value indicating whether this instance is a null handle. public bool IsNull => handle == IntPtr.Zero; /// Performs an explicit conversion from to . /// The handle. /// The result of the conversion. public static explicit operator IntPtr(HCURSOR h) => h.handle; /// Performs an implicit conversion from to . /// The pointer to a handle. /// The result of the conversion. public static implicit operator HCURSOR(IntPtr h) => new(h); /// Performs an implicit conversion from to . /// The pointer to a GDI handle. /// The result of the conversion. public static implicit operator HCURSOR(HGDIOBJ h) => new((IntPtr)h); /// Implements the operator ! which returns if the handle is invalid. /// The instance. /// The result of the operator. public static bool operator !(HCURSOR hMem) => hMem.IsNull; /// Implements the operator !=. /// The first handle. /// The second handle. /// The result of the operator. public static bool operator !=(HCURSOR h1, HCURSOR h2) => !(h1 == h2); /// Implements the operator ==. /// The first handle. /// The second handle. /// The result of the operator. public static bool operator ==(HCURSOR h1, HCURSOR h2) => h1.Equals(h2); /// public override bool Equals(object obj) => obj is HCURSOR h && handle == h.handle; /// public override int GetHashCode() => handle.GetHashCode(); /// public IntPtr DangerousGetHandle() => handle; } /// Provides a handle to a graphic device context. [StructLayout(LayoutKind.Sequential), DebuggerDisplay("{handle}")] public struct HDC : IHandle { private readonly IntPtr handle; /// Initializes a new instance of the struct. /// An object that represents the pre-existing handle to use. public HDC(IntPtr preexistingHandle) => handle = preexistingHandle; /// Returns an invalid handle by instantiating a object with . public static HDC NULL => new(IntPtr.Zero); /// Gets a value indicating whether this instance is a null handle. public bool IsNull => handle == IntPtr.Zero; /// Performs an explicit conversion from to . /// The handle. /// The result of the conversion. public static explicit operator IntPtr(HDC h) => h.handle; /// Performs an implicit conversion from to . /// The pointer to a handle. /// The result of the conversion. public static implicit operator HDC(IntPtr h) => new(h); /// Implements the operator ! which returns if the handle is invalid. /// The instance. /// The result of the operator. public static bool operator !(HDC hMem) => hMem.IsNull; /// Implements the operator !=. /// The first handle. /// The second handle. /// The result of the operator. public static bool operator !=(HDC h1, HDC h2) => !(h1 == h2); /// Implements the operator ==. /// The first handle. /// The second handle. /// The result of the operator. public static bool operator ==(HDC h1, HDC h2) => h1.Equals(h2); /// public override bool Equals(object obj) => obj is HDC h && handle == h.handle; /// public override int GetHashCode() => handle.GetHashCode(); /// public IntPtr DangerousGetHandle() => handle; } /// Provides a handle to a desktop. [StructLayout(LayoutKind.Sequential), DebuggerDisplay("{handle}")] public struct HDESK : IKernelHandle { private readonly IntPtr handle; /// Initializes a new instance of the struct. /// An object that represents the pre-existing handle to use. public HDESK(IntPtr preexistingHandle) => handle = preexistingHandle; /// Returns an invalid handle by instantiating a object with . public static HDESK NULL => new(IntPtr.Zero); /// Gets a value indicating whether this instance is a null handle. public bool IsNull => handle == IntPtr.Zero; /// Performs an explicit conversion from to . /// The handle. /// The result of the conversion. public static explicit operator IntPtr(HDESK h) => h.handle; /// Performs an implicit conversion from to . /// The pointer to a handle. /// The result of the conversion. public static implicit operator HDESK(IntPtr h) => new(h); /// Implements the operator ! which returns if the handle is invalid. /// The instance. /// The result of the operator. public static bool operator !(HDESK hMem) => hMem.IsNull; /// Implements the operator !=. /// The first handle. /// The second handle. /// The result of the operator. public static bool operator !=(HDESK h1, HDESK h2) => !(h1 == h2); /// Implements the operator ==. /// The first handle. /// The second handle. /// The result of the operator. public static bool operator ==(HDESK h1, HDESK h2) => h1.Equals(h2); /// public override bool Equals(object obj) => obj is HDESK h && handle == h.handle; /// public override int GetHashCode() => handle.GetHashCode(); /// public IntPtr DangerousGetHandle() => handle; } /// Provides a handle to a DPA. [StructLayout(LayoutKind.Sequential), DebuggerDisplay("{handle}")] public struct HDPA : IKernelHandle { private readonly IntPtr handle; /// Initializes a new instance of the struct. /// An object that represents the pre-existing handle to use. public HDPA(IntPtr preexistingHandle) => handle = preexistingHandle; /// Returns an invalid handle by instantiating a object with . public static HDPA NULL => new(IntPtr.Zero); /// Gets a value indicating whether this instance is a null handle. public bool IsNull => handle == IntPtr.Zero; /// Performs an explicit conversion from to . /// The handle. /// The result of the conversion. public static explicit operator IntPtr(HDPA h) => h.handle; /// Performs an implicit conversion from to . /// The pointer to a handle. /// The result of the conversion. public static implicit operator HDPA(IntPtr h) => new(h); /// Implements the operator ! which returns if the handle is invalid. /// The instance. /// The result of the operator. public static bool operator !(HDPA hMem) => hMem.IsNull; /// Implements the operator !=. /// The first handle. /// The second handle. /// The result of the operator. public static bool operator !=(HDPA h1, HDPA h2) => !(h1 == h2); /// Implements the operator ==. /// The first handle. /// The second handle. /// The result of the operator. public static bool operator ==(HDPA h1, HDPA h2) => h1.Equals(h2); /// public override bool Equals(object obj) => obj is HDPA h && handle == h.handle; /// public override int GetHashCode() => handle.GetHashCode(); /// public IntPtr DangerousGetHandle() => handle; } /// Provides a handle to a Windows drop operation. [StructLayout(LayoutKind.Sequential), DebuggerDisplay("{handle}")] public struct HDROP : IShellHandle { private readonly IntPtr handle; /// Initializes a new instance of the struct. /// An object that represents the pre-existing handle to use. public HDROP(IntPtr preexistingHandle) => handle = preexistingHandle; /// Returns an invalid handle by instantiating a object with . public static HDROP NULL => new(IntPtr.Zero); /// Gets a value indicating whether this instance is a null handle. public bool IsNull => handle == IntPtr.Zero; /// Performs an explicit conversion from to . /// The handle. /// The result of the conversion. public static explicit operator IntPtr(HDROP h) => h.handle; /// Performs an implicit conversion from to . /// The pointer to a handle. /// The result of the conversion. public static implicit operator HDROP(IntPtr h) => new(h); /// Implements the operator ! which returns if the handle is invalid. /// The instance. /// The result of the operator. public static bool operator !(HDROP hMem) => hMem.IsNull; /// Implements the operator !=. /// The first handle. /// The second handle. /// The result of the operator. public static bool operator !=(HDROP h1, HDROP h2) => !(h1 == h2); /// Implements the operator ==. /// The first handle. /// The second handle. /// The result of the operator. public static bool operator ==(HDROP h1, HDROP h2) => h1.Equals(h2); /// public override bool Equals(object obj) => obj is HDROP h && handle == h.handle; /// public override int GetHashCode() => handle.GetHashCode(); /// public IntPtr DangerousGetHandle() => handle; } /// Provides a handle to a DSA. [StructLayout(LayoutKind.Sequential), DebuggerDisplay("{handle}")] public struct HDSA : IKernelHandle { private readonly IntPtr handle; /// Initializes a new instance of the struct. /// An object that represents the pre-existing handle to use. public HDSA(IntPtr preexistingHandle) => handle = preexistingHandle; /// Returns an invalid handle by instantiating a object with . public static HDSA NULL => new(IntPtr.Zero); /// Gets a value indicating whether this instance is a null handle. public bool IsNull => handle == IntPtr.Zero; /// Performs an explicit conversion from to . /// The handle. /// The result of the conversion. public static explicit operator IntPtr(HDSA h) => h.handle; /// Performs an implicit conversion from to . /// The pointer to a handle. /// The result of the conversion. public static implicit operator HDSA(IntPtr h) => new(h); /// Implements the operator ! which returns if the handle is invalid. /// The instance. /// The result of the operator. public static bool operator !(HDSA hMem) => hMem.IsNull; /// Implements the operator !=. /// The first handle. /// The second handle. /// The result of the operator. public static bool operator !=(HDSA h1, HDSA h2) => !(h1 == h2); /// Implements the operator ==. /// The first handle. /// The second handle. /// The result of the operator. public static bool operator ==(HDSA h1, HDSA h2) => h1.Equals(h2); /// public override bool Equals(object obj) => obj is HDSA h && handle == h.handle; /// public override int GetHashCode() => handle.GetHashCode(); /// public IntPtr DangerousGetHandle() => handle; } /// Provides a handle to a deferred windows position. [StructLayout(LayoutKind.Sequential), DebuggerDisplay("{handle}")] public struct HDWP : IUserHandle { private readonly IntPtr handle; /// Initializes a new instance of the struct. /// An object that represents the pre-existing handle to use. public HDWP(IntPtr preexistingHandle) => handle = preexistingHandle; /// Returns an invalid handle by instantiating a object with . public static HDWP NULL => new(IntPtr.Zero); /// Gets a value indicating whether this instance is a null handle. public bool IsNull => handle == IntPtr.Zero; /// Performs an explicit conversion from to . /// The handle. /// The result of the conversion. public static explicit operator IntPtr(HDWP h) => h.handle; /// Performs an implicit conversion from to . /// The pointer to a handle. /// The result of the conversion. public static implicit operator HDWP(IntPtr h) => new(h); /// Implements the operator ! which returns if the handle is invalid. /// The instance. /// The result of the operator. public static bool operator !(HDWP hMem) => hMem.IsNull; /// Implements the operator !=. /// The first handle. /// The second handle. /// The result of the operator. public static bool operator !=(HDWP h1, HDWP h2) => !(h1 == h2); /// Implements the operator ==. /// The first handle. /// The second handle. /// The result of the operator. public static bool operator ==(HDWP h1, HDWP h2) => h1.Equals(h2); /// public override bool Equals(object obj) => obj is HDWP h && handle == h.handle; /// public override int GetHashCode() => handle.GetHashCode(); /// public IntPtr DangerousGetHandle() => handle; } /// Provides a handle to an enhanced metafile. [StructLayout(LayoutKind.Sequential), DebuggerDisplay("{handle}")] public struct HENHMETAFILE : IHandle { private readonly IntPtr handle; /// Initializes a new instance of the struct. /// An object that represents the pre-existing handle to use. public HENHMETAFILE(IntPtr preexistingHandle) => handle = preexistingHandle; /// Returns an invalid handle by instantiating a object with . public static HENHMETAFILE NULL => new(IntPtr.Zero); /// Gets a value indicating whether this instance is a null handle. public bool IsNull => handle == IntPtr.Zero; /// Performs an explicit conversion from to . /// The handle. /// The result of the conversion. public static explicit operator IntPtr(HENHMETAFILE h) => h.handle; /// Performs an implicit conversion from to . /// The pointer to a handle. /// The result of the conversion. public static implicit operator HENHMETAFILE(IntPtr h) => new(h); /// Implements the operator ! which returns if the handle is invalid. /// The instance. /// The result of the operator. public static bool operator !(HENHMETAFILE hMem) => hMem.IsNull; /// Implements the operator !=. /// The first handle. /// The second handle. /// The result of the operator. public static bool operator !=(HENHMETAFILE h1, HENHMETAFILE h2) => !(h1 == h2); /// Implements the operator ==. /// The first handle. /// The second handle. /// The result of the operator. public static bool operator ==(HENHMETAFILE h1, HENHMETAFILE h2) => h1.Equals(h2); /// public override bool Equals(object obj) => obj is HENHMETAFILE h && handle == h.handle; /// public override int GetHashCode() => handle.GetHashCode(); /// public IntPtr DangerousGetHandle() => handle; } /// Provides a handle to a sync event. [StructLayout(LayoutKind.Sequential), DebuggerDisplay("{handle}")] public struct HEVENT : ISyncHandle { private readonly IntPtr handle; /// Initializes a new instance of the struct. /// An object that represents the pre-existing handle to use. public HEVENT(IntPtr preexistingHandle) => handle = preexistingHandle; /// Returns an invalid handle by instantiating a object with . public static HEVENT NULL => new(IntPtr.Zero); /// Gets a value indicating whether this instance is a null handle. public bool IsNull => handle == IntPtr.Zero; /// Performs an explicit conversion from to . /// The handle. /// The result of the conversion. public static explicit operator IntPtr(HEVENT h) => h.handle; /// Performs an implicit conversion from to . /// The pointer to a handle. /// The result of the conversion. public static implicit operator HEVENT(IntPtr h) => new(h); /// Implements the operator ! which returns if the handle is invalid. /// The instance. /// The result of the operator. public static bool operator !(HEVENT hMem) => hMem.IsNull; /// Implements the operator !=. /// The first handle. /// The second handle. /// The result of the operator. public static bool operator !=(HEVENT h1, HEVENT h2) => !(h1 == h2); /// Implements the operator ==. /// The first handle. /// The second handle. /// The result of the operator. public static bool operator ==(HEVENT h1, HEVENT h2) => h1.Equals(h2); /// public override bool Equals(object obj) => obj is HEVENT h && handle == h.handle; /// public override int GetHashCode() => handle.GetHashCode(); /// public IntPtr DangerousGetHandle() => handle; } /// Provides a handle to a file. [StructLayout(LayoutKind.Sequential), DebuggerDisplay("{handle}")] public struct HFILE : ISyncHandle { private readonly IntPtr handle; /// Initializes a new instance of the struct. /// An object that represents the pre-existing handle to use. public HFILE(IntPtr preexistingHandle) => handle = preexistingHandle; /// Returns an invalid handle by instantiating a object with . public static HFILE NULL => new(IntPtr.Zero); /// Gets a value indicating whether this instance is a null handle. public bool IsNull => handle == IntPtr.Zero; /// Represents an invalid handle. public static readonly HFILE INVALID_HANDLE_VALUE = new IntPtr(-1); /// Gets a value indicating whether this instance is an invalid handle (INVALID_HANDLE_VALUE). public bool IsInvalid => handle == INVALID_HANDLE_VALUE; /// Performs an implicit conversion from to . /// The pointer to a handle. /// The result of the conversion. public static implicit operator HFILE(SafeFileHandle h) => new(h?.DangerousGetHandle() ?? IntPtr.Zero); /// Performs an explicit conversion from to . /// The handle. /// The result of the conversion. public static explicit operator IntPtr(HFILE h) => h.handle; /// Performs an implicit conversion from to . /// The pointer to a handle. /// The result of the conversion. public static implicit operator HFILE(IntPtr h) => new(h); /// Implements the operator ! which returns if the handle is invalid. /// The instance. /// The result of the operator. public static bool operator !(HFILE hMem) => hMem.IsNull; /// Implements the operator !=. /// The first handle. /// The second handle. /// The result of the operator. public static bool operator !=(HFILE h1, HFILE h2) => !(h1 == h2); /// Implements the operator ==. /// The first handle. /// The second handle. /// The result of the operator. public static bool operator ==(HFILE h1, HFILE h2) => h1.Equals(h2); /// public override bool Equals(object obj) => obj is HFILE h && handle == h.handle; /// public override int GetHashCode() => handle.GetHashCode(); /// public IntPtr DangerousGetHandle() => handle; } /// Provides a handle to a font. [StructLayout(LayoutKind.Sequential), DebuggerDisplay("{handle}")] public struct HFONT : IGraphicsObjectHandle { private readonly IntPtr handle; /// Initializes a new instance of the struct. /// An object that represents the pre-existing handle to use. public HFONT(IntPtr preexistingHandle) => handle = preexistingHandle; /// Returns an invalid handle by instantiating a object with . public static HFONT NULL => new(IntPtr.Zero); /// Gets a value indicating whether this instance is a null handle. public bool IsNull => handle == IntPtr.Zero; /// Performs an explicit conversion from to . /// The handle. /// The result of the conversion. public static explicit operator IntPtr(HFONT h) => h.handle; /// Performs an implicit conversion from to . /// The pointer to a handle. /// The result of the conversion. public static implicit operator HFONT(IntPtr h) => new(h); /// Performs an implicit conversion from to . /// The pointer to a GDI handle. /// The result of the conversion. public static implicit operator HFONT(HGDIOBJ h) => new((IntPtr)h); /// Implements the operator ! which returns if the handle is invalid. /// The instance. /// The result of the operator. public static bool operator !(HFONT hMem) => hMem.IsNull; /// Implements the operator !=. /// The first handle. /// The second handle. /// The result of the operator. public static bool operator !=(HFONT h1, HFONT h2) => !(h1 == h2); /// Implements the operator ==. /// The first handle. /// The second handle. /// The result of the operator. public static bool operator ==(HFONT h1, HFONT h2) => h1.Equals(h2); /// public override bool Equals(object obj) => obj is HFONT h && handle == h.handle; /// public override int GetHashCode() => handle.GetHashCode(); /// public IntPtr DangerousGetHandle() => handle; } /// Provides a handle to a graphic device object. [StructLayout(LayoutKind.Sequential), DebuggerDisplay("{handle}")] public struct HGDIOBJ : IGraphicsObjectHandle { private readonly IntPtr handle; /// Initializes a new instance of the struct. /// An object that represents the pre-existing handle to use. public HGDIOBJ(IntPtr preexistingHandle) => handle = preexistingHandle; /// Returns an invalid handle by instantiating a object with . public static HGDIOBJ NULL => new(IntPtr.Zero); /// Gets a value indicating whether this instance is a null handle. public bool IsNull => handle == IntPtr.Zero; /// Performs an explicit conversion from to . /// The handle. /// The result of the conversion. public static explicit operator IntPtr(HGDIOBJ h) => h.handle; /// Performs an implicit conversion from to . /// The pointer to a handle. /// The result of the conversion. public static implicit operator HGDIOBJ(IntPtr h) => new(h); /// Performs an implicit conversion from to . /// The pointer to a handle. /// The result of the conversion. public static implicit operator HGDIOBJ(HBITMAP h) => new((IntPtr)h); /// Performs an implicit conversion from to . /// The pointer to a handle. /// The result of the conversion. public static implicit operator HGDIOBJ(HBRUSH h) => new((IntPtr)h); /// Performs an implicit conversion from to . /// The pointer to a handle. /// The result of the conversion. public static implicit operator HGDIOBJ(HCOLORSPACE h) => new((IntPtr)h); /// Performs an implicit conversion from to . /// The pointer to a handle. /// The result of the conversion. public static implicit operator HGDIOBJ(HCURSOR h) => new((IntPtr)h); /// Performs an implicit conversion from to . /// The pointer to a handle. /// The result of the conversion. public static implicit operator HGDIOBJ(HFONT h) => new((IntPtr)h); /// Performs an implicit conversion from to . /// The pointer to a handle. /// The result of the conversion. public static implicit operator HGDIOBJ(HPALETTE h) => new((IntPtr)h); /// Performs an implicit conversion from to . /// The pointer to a handle. /// The result of the conversion. public static implicit operator HGDIOBJ(HPEN h) => new((IntPtr)h); /// Performs an implicit conversion from to . /// The pointer to a handle. /// The result of the conversion. public static implicit operator HGDIOBJ(HRGN h) => new((IntPtr)h); /// Implements the operator ! which returns if the handle is invalid. /// The instance. /// The result of the operator. public static bool operator !(HGDIOBJ hMem) => hMem.IsNull; /// Implements the operator !=. /// The first handle. /// The second handle. /// The result of the operator. public static bool operator !=(HGDIOBJ h1, HGDIOBJ h2) => !(h1 == h2); /// Implements the operator ==. /// The first handle. /// The second handle. /// The result of the operator. public static bool operator ==(HGDIOBJ h1, HGDIOBJ h2) => h1.Equals(h2); /// public override bool Equals(object obj) => obj is HGDIOBJ h && handle == h.handle; /// public override int GetHashCode() => handle.GetHashCode(); /// public IntPtr DangerousGetHandle() => handle; } /// Provides a handle to an icon. [StructLayout(LayoutKind.Sequential), DebuggerDisplay("{handle}")] public struct HICON : IUserHandle { private readonly IntPtr handle; /// Initializes a new instance of the struct. /// An object that represents the pre-existing handle to use. public HICON(IntPtr preexistingHandle) => handle = preexistingHandle; /// Returns an invalid handle by instantiating a object with . public static HICON NULL => new(IntPtr.Zero); /// Gets a value indicating whether this instance is a null handle. public bool IsNull => handle == IntPtr.Zero; /// Performs an explicit conversion from to . /// The handle. /// The result of the conversion. public static explicit operator IntPtr(HICON h) => h.handle; /// Performs an implicit conversion from to . /// The pointer to a handle. /// The result of the conversion. public static implicit operator HICON(IntPtr h) => new(h); /// Implements the operator ! which returns if the handle is invalid. /// The instance. /// The result of the operator. public static bool operator !(HICON hMem) => hMem.IsNull; /// Implements the operator !=. /// The first handle. /// The second handle. /// The result of the operator. public static bool operator !=(HICON h1, HICON h2) => !(h1 == h2); /// Implements the operator ==. /// The first handle. /// The second handle. /// The result of the operator. public static bool operator ==(HICON h1, HICON h2) => h1.Equals(h2); /// public override bool Equals(object obj) => obj is HICON h && handle == h.handle; /// public override int GetHashCode() => handle.GetHashCode(); /// public IntPtr DangerousGetHandle() => handle; } /// Provides a handle to a Windows image list. [StructLayout(LayoutKind.Sequential), DebuggerDisplay("{handle}")] public struct HIMAGELIST : IShellHandle { private readonly IntPtr handle; /// Initializes a new instance of the struct. /// An object that represents the pre-existing handle to use. public HIMAGELIST(IntPtr preexistingHandle) => handle = preexistingHandle; /// Returns an invalid handle by instantiating a object with . public static HIMAGELIST NULL => new(IntPtr.Zero); /// Gets a value indicating whether this instance is a null handle. public bool IsNull => handle == IntPtr.Zero; /// Performs an explicit conversion from to . /// The handle. /// The result of the conversion. public static explicit operator IntPtr(HIMAGELIST h) => h.handle; /// Performs an implicit conversion from to . /// The pointer to a handle. /// The result of the conversion. public static implicit operator HIMAGELIST(IntPtr h) => new(h); /// Implements the operator ! which returns if the handle is invalid. /// The instance. /// The result of the operator. public static bool operator !(HIMAGELIST hMem) => hMem.IsNull; /// Implements the operator !=. /// The first handle. /// The second handle. /// The result of the operator. public static bool operator !=(HIMAGELIST h1, HIMAGELIST h2) => !(h1 == h2); /// Implements the operator ==. /// The first handle. /// The second handle. /// The result of the operator. public static bool operator ==(HIMAGELIST h1, HIMAGELIST h2) => h1.Equals(h2); /// public override bool Equals(object obj) => obj is HIMAGELIST h && handle == h.handle; /// public override int GetHashCode() => handle.GetHashCode(); /// public IntPtr DangerousGetHandle() => handle; } /// Provides a handle to a module or library instance. [StructLayout(LayoutKind.Sequential), DebuggerDisplay("{handle}")] public struct HINSTANCE : IKernelHandle { private readonly IntPtr handle; /// Initializes a new instance of the struct. /// An object that represents the pre-existing handle to use. public HINSTANCE(IntPtr preexistingHandle) => handle = preexistingHandle; /// Returns an invalid handle by instantiating a object with . public static HINSTANCE NULL => new(IntPtr.Zero); /// Gets a value indicating whether this instance is a null handle. public bool IsNull => handle == IntPtr.Zero; /// Performs an explicit conversion from to . /// The handle. /// The result of the conversion. public static explicit operator IntPtr(HINSTANCE h) => h.handle; /// Performs an implicit conversion from to . /// The pointer to a handle. /// The result of the conversion. public static implicit operator HINSTANCE(IntPtr h) => new(h); /// Implements the operator ! which returns if the handle is invalid. /// The instance. /// The result of the operator. public static bool operator !(HINSTANCE hMem) => hMem.IsNull; /// Implements the operator !=. /// The first handle. /// The second handle. /// The result of the operator. public static bool operator !=(HINSTANCE h1, HINSTANCE h2) => !(h1 == h2); /// Implements the operator ==. /// The first handle. /// The second handle. /// The result of the operator. public static bool operator ==(HINSTANCE h1, HINSTANCE h2) => h1.Equals(h2); /// public override bool Equals(object obj) => obj is HINSTANCE h && handle == h.handle; /// public override int GetHashCode() => handle.GetHashCode(); /// public IntPtr DangerousGetHandle() => handle; } /// Provides a handle to a Windows registry key. [StructLayout(LayoutKind.Sequential), DebuggerDisplay("{handle}")] public struct HKEY : IKernelHandle { private readonly IntPtr handle; /// Initializes a new instance of the struct. /// An object that represents the pre-existing handle to use. public HKEY(IntPtr preexistingHandle) => handle = preexistingHandle; /// Returns an invalid handle by instantiating a object with . public static HKEY NULL => new(IntPtr.Zero); /// Gets a value indicating whether this instance is a null handle. public bool IsNull => handle == IntPtr.Zero; /// /// Registry entries subordinate to this key define types (or classes) of documents and the properties associated with those types. /// Shell and COM applications use the information stored under this key. /// public static readonly HKEY HKEY_CLASSES_ROOT = new(new IntPtr(unchecked((int)0x80000000))); /// /// Contains information about the current hardware profile of the local computer system. The information under HKEY_CURRENT_CONFIG /// describes only the differences between the current hardware configuration and the standard configuration. Information about the /// standard hardware configuration is stored under the Software and System keys of HKEY_LOCAL_MACHINE. /// public static readonly HKEY HKEY_CURRENT_CONFIG = new(new IntPtr(unchecked((int)0x80000005))); /// /// Registry entries subordinate to this key define the preferences of the current user. These preferences include the settings of /// environment variables, data about program groups, colors, printers, network connections, and application preferences. This key /// makes it easier to establish the current user's settings; the key maps to the current user's branch in HKEY_USERS. In /// HKEY_CURRENT_USER, software vendors store the current user-specific preferences to be used within their applications. Microsoft, /// for example, creates the HKEY_CURRENT_USER\Software\Microsoft key for its applications to use, with each application creating its /// own subkey under the Microsoft key. /// public static readonly HKEY HKEY_CURRENT_USER = new(new IntPtr(unchecked((int)0x80000001))); /// public static readonly HKEY HKEY_DYN_DATA = new(new IntPtr(unchecked((int)0x80000006))); /// /// Registry entries subordinate to this key define the physical state of the computer, including data about the bus type, system /// memory, and installed hardware and software. It contains subkeys that hold current configuration data, including Plug and Play /// information (the Enum branch, which includes a complete list of all hardware that has ever been on the system), network logon /// preferences, network security information, software-related information (such as server names and the location of the server), /// and other system information. /// public static readonly HKEY HKEY_LOCAL_MACHINE = new(new IntPtr(unchecked((int)0x80000002))); /// /// Registry entries subordinate to this key allow you to access performance data. The data is not actually stored in the registry; /// the registry functions cause the system to collect the data from its source. /// public static readonly HKEY HKEY_PERFORMANCE_DATA = new(new IntPtr(unchecked((int)0x80000004))); /// /// Registry entries subordinate to this key define the default user configuration for new users on the local computer and the user /// configuration for the current user. /// public static readonly HKEY HKEY_USERS = new(new IntPtr(unchecked((int)0x80000003))); /// Performs an explicit conversion from to . /// The handle. /// The result of the conversion. public static explicit operator IntPtr(HKEY h) => h.handle; /// Performs an implicit conversion from to . /// The pointer to a handle. /// The result of the conversion. public static implicit operator HKEY(IntPtr h) => new(h); /// Performs an implicit conversion from to . /// The pointer to a handle. /// The result of the conversion. public static implicit operator HKEY(SafeRegistryHandle h) => new(h.DangerousGetHandle()); /// Implements the operator ! which returns if the handle is invalid. /// The instance. /// The result of the operator. public static bool operator !(HKEY hMem) => hMem.IsNull; /// Implements the operator !=. /// The first handle. /// The second handle. /// The result of the operator. public static bool operator !=(HKEY h1, HKEY h2) => !(h1 == h2); /// Implements the operator ==. /// The first handle. /// The second handle. /// The result of the operator. public static bool operator ==(HKEY h1, HKEY h2) => h1.Equals(h2); /// public override bool Equals(object obj) => obj is HKEY h && handle == h.handle; /// public override int GetHashCode() => handle.GetHashCode(); /// public IntPtr DangerousGetHandle() => handle; } /// Provides a handle to a menu. [StructLayout(LayoutKind.Sequential), DebuggerDisplay("{handle}")] public struct HMENU : IUserHandle { private readonly IntPtr handle; /// Initializes a new instance of the struct. /// An object that represents the pre-existing handle to use. public HMENU(IntPtr preexistingHandle) => handle = preexistingHandle; /// Returns an invalid handle by instantiating a object with . public static HMENU NULL => new(IntPtr.Zero); /// Gets a value indicating whether this instance is a null handle. public bool IsNull => handle == IntPtr.Zero; /// Performs an explicit conversion from to . /// The handle. /// The result of the conversion. public static explicit operator IntPtr(HMENU h) => h.handle; /// Performs an implicit conversion from to . /// The pointer to a handle. /// The result of the conversion. public static implicit operator HMENU(IntPtr h) => new(h); /// Implements the operator ! which returns if the handle is invalid. /// The instance. /// The result of the operator. public static bool operator !(HMENU hMem) => hMem.IsNull; /// Implements the operator !=. /// The first handle. /// The second handle. /// The result of the operator. public static bool operator !=(HMENU h1, HMENU h2) => !(h1 == h2); /// Implements the operator ==. /// The first handle. /// The second handle. /// The result of the operator. public static bool operator ==(HMENU h1, HMENU h2) => h1.Equals(h2); /// public override bool Equals(object obj) => obj is HMENU h && handle == h.handle; /// public override int GetHashCode() => handle.GetHashCode(); /// public IntPtr DangerousGetHandle() => handle; } /// Provides a handle to a metafile. [StructLayout(LayoutKind.Sequential), DebuggerDisplay("{handle}")] public struct HMETAFILE : IHandle { private readonly IntPtr handle; /// Initializes a new instance of the struct. /// An object that represents the pre-existing handle to use. public HMETAFILE(IntPtr preexistingHandle) => handle = preexistingHandle; /// Returns an invalid handle by instantiating a object with . public static HMETAFILE NULL => new(IntPtr.Zero); /// Gets a value indicating whether this instance is a null handle. public bool IsNull => handle == IntPtr.Zero; /// Performs an explicit conversion from to . /// The handle. /// The result of the conversion. public static explicit operator IntPtr(HMETAFILE h) => h.handle; /// Performs an implicit conversion from to . /// The pointer to a handle. /// The result of the conversion. public static implicit operator HMETAFILE(IntPtr h) => new(h); /// Implements the operator ! which returns if the handle is invalid. /// The instance. /// The result of the operator. public static bool operator !(HMETAFILE hMem) => hMem.IsNull; /// Implements the operator !=. /// The first handle. /// The second handle. /// The result of the operator. public static bool operator !=(HMETAFILE h1, HMETAFILE h2) => !(h1 == h2); /// Implements the operator ==. /// The first handle. /// The second handle. /// The result of the operator. public static bool operator ==(HMETAFILE h1, HMETAFILE h2) => h1.Equals(h2); /// public override bool Equals(object obj) => obj is HMETAFILE h && handle == h.handle; /// public override int GetHashCode() => handle.GetHashCode(); /// public IntPtr DangerousGetHandle() => handle; } /// Provides a handle to a monitor. [StructLayout(LayoutKind.Sequential), DebuggerDisplay("{handle}")] public struct HMONITOR : IKernelHandle { private readonly IntPtr handle; /// Initializes a new instance of the struct. /// An object that represents the pre-existing handle to use. public HMONITOR(IntPtr preexistingHandle) => handle = preexistingHandle; /// Returns an invalid handle by instantiating a object with . public static HMONITOR NULL => new(IntPtr.Zero); /// Gets a value indicating whether this instance is a null handle. public bool IsNull => handle == IntPtr.Zero; /// Performs an explicit conversion from to . /// The handle. /// The result of the conversion. public static explicit operator IntPtr(HMONITOR h) => h.handle; /// Performs an implicit conversion from to . /// The pointer to a handle. /// The result of the conversion. public static implicit operator HMONITOR(IntPtr h) => new(h); /// Implements the operator ! which returns if the handle is invalid. /// The instance. /// The result of the operator. public static bool operator !(HMONITOR hMem) => hMem.IsNull; /// Implements the operator !=. /// The first handle. /// The second handle. /// The result of the operator. public static bool operator !=(HMONITOR h1, HMONITOR h2) => !(h1 == h2); /// Implements the operator ==. /// The first handle. /// The second handle. /// The result of the operator. public static bool operator ==(HMONITOR h1, HMONITOR h2) => h1.Equals(h2); /// public override bool Equals(object obj) => obj is HMONITOR h && handle == h.handle; /// public override int GetHashCode() => handle.GetHashCode(); /// public IntPtr DangerousGetHandle() => handle; } /// Provides a handle to a palette. [StructLayout(LayoutKind.Sequential), DebuggerDisplay("{handle}")] public struct HPALETTE : IGraphicsObjectHandle { private readonly IntPtr handle; /// Initializes a new instance of the struct. /// An object that represents the pre-existing handle to use. public HPALETTE(IntPtr preexistingHandle) => handle = preexistingHandle; /// Returns an invalid handle by instantiating a object with . public static HPALETTE NULL => new(IntPtr.Zero); /// Gets a value indicating whether this instance is a null handle. public bool IsNull => handle == IntPtr.Zero; /// Performs an explicit conversion from to . /// The handle. /// The result of the conversion. public static explicit operator IntPtr(HPALETTE h) => h.handle; /// Performs an implicit conversion from to . /// The pointer to a handle. /// The result of the conversion. public static implicit operator HPALETTE(IntPtr h) => new(h); /// Performs an implicit conversion from to . /// The pointer to a GDI handle. /// The result of the conversion. public static implicit operator HPALETTE(HGDIOBJ h) => new((IntPtr)h); /// Implements the operator ! which returns if the handle is invalid. /// The instance. /// The result of the operator. public static bool operator !(HPALETTE hMem) => hMem.IsNull; /// Implements the operator !=. /// The first handle. /// The second handle. /// The result of the operator. public static bool operator !=(HPALETTE h1, HPALETTE h2) => !(h1 == h2); /// Implements the operator ==. /// The first handle. /// The second handle. /// The result of the operator. public static bool operator ==(HPALETTE h1, HPALETTE h2) => h1.Equals(h2); /// public override bool Equals(object obj) => obj is HPALETTE h && handle == h.handle; /// public override int GetHashCode() => handle.GetHashCode(); /// public IntPtr DangerousGetHandle() => handle; } /// Provides a handle to a drawing pen. [StructLayout(LayoutKind.Sequential), DebuggerDisplay("{handle}")] public struct HPEN : IGraphicsObjectHandle { private readonly IntPtr handle; /// Initializes a new instance of the struct. /// An object that represents the pre-existing handle to use. public HPEN(IntPtr preexistingHandle) => handle = preexistingHandle; /// Returns an invalid handle by instantiating a object with . public static HPEN NULL => new(IntPtr.Zero); /// Gets a value indicating whether this instance is a null handle. public bool IsNull => handle == IntPtr.Zero; /// Performs an explicit conversion from to . /// The handle. /// The result of the conversion. public static explicit operator IntPtr(HPEN h) => h.handle; /// Performs an implicit conversion from to . /// The pointer to a handle. /// The result of the conversion. public static implicit operator HPEN(IntPtr h) => new(h); /// Performs an implicit conversion from to . /// The pointer to a GDI handle. /// The result of the conversion. public static implicit operator HPEN(HGDIOBJ h) => new((IntPtr)h); /// Implements the operator ! which returns if the handle is invalid. /// The instance. /// The result of the operator. public static bool operator !(HPEN hMem) => hMem.IsNull; /// Implements the operator !=. /// The first handle. /// The second handle. /// The result of the operator. public static bool operator !=(HPEN h1, HPEN h2) => !(h1 == h2); /// Implements the operator ==. /// The first handle. /// The second handle. /// The result of the operator. public static bool operator ==(HPEN h1, HPEN h2) => h1.Equals(h2); /// public override bool Equals(object obj) => obj is HPEN h && handle == h.handle; /// public override int GetHashCode() => handle.GetHashCode(); /// public IntPtr DangerousGetHandle() => handle; } /// Provides a handle to a process. [StructLayout(LayoutKind.Sequential), DebuggerDisplay("{handle}")] public struct HPROCESS : ISyncHandle { private readonly IntPtr handle; /// Initializes a new instance of the struct. /// An object that represents the pre-existing handle to use. public HPROCESS(IntPtr preexistingHandle) => handle = preexistingHandle; /// Returns an invalid handle by instantiating a object with . public static HPROCESS NULL => new(IntPtr.Zero); /// Gets a value indicating whether this instance is a null handle. public bool IsNull => handle == IntPtr.Zero; /// Performs an explicit conversion from to . /// The handle. /// The result of the conversion. public static explicit operator IntPtr(HPROCESS h) => h.handle; /// Performs an implicit conversion from to . /// The pointer to a handle. /// The result of the conversion. public static implicit operator HPROCESS(IntPtr h) => new(h); /// Performs an implicit conversion from to . /// The pointer to a handle. /// The result of the conversion. public static implicit operator HPROCESS(Process h) => new(h.Handle); /// Implements the operator ! which returns if the handle is invalid. /// The instance. /// The result of the operator. public static bool operator !(HPROCESS hMem) => hMem.IsNull; /// Implements the operator !=. /// The first handle. /// The second handle. /// The result of the operator. public static bool operator !=(HPROCESS h1, HPROCESS h2) => !(h1 == h2); /// Implements the operator ==. /// The first handle. /// The second handle. /// The result of the operator. public static bool operator ==(HPROCESS h1, HPROCESS h2) => h1.Equals(h2); /// public override bool Equals(object obj) => obj is HPROCESS h && handle == h.handle; /// public override int GetHashCode() => handle.GetHashCode(); /// public IntPtr DangerousGetHandle() => handle; } /// Provides a handle to a Windows property sheet. [StructLayout(LayoutKind.Sequential), DebuggerDisplay("{handle}")] public struct HPROPSHEET : IUserHandle { private readonly IntPtr handle; /// Initializes a new instance of the struct. /// An object that represents the pre-existing handle to use. public HPROPSHEET(IntPtr preexistingHandle) => handle = preexistingHandle; /// Returns an invalid handle by instantiating a object with . public static HPROPSHEET NULL => new(IntPtr.Zero); /// Gets a value indicating whether this instance is a null handle. public bool IsNull => handle == IntPtr.Zero; /// Performs an explicit conversion from to . /// The handle. /// The result of the conversion. public static explicit operator IntPtr(HPROPSHEET h) => h.handle; /// Performs an implicit conversion from to . /// The pointer to a handle. /// The result of the conversion. public static implicit operator HPROPSHEET(IntPtr h) => new(h); /// Implements the operator ! which returns if the handle is invalid. /// The instance. /// The result of the operator. public static bool operator !(HPROPSHEET hMem) => hMem.IsNull; /// Implements the operator !=. /// The first handle. /// The second handle. /// The result of the operator. public static bool operator !=(HPROPSHEET h1, HPROPSHEET h2) => !(h1 == h2); /// Implements the operator ==. /// The first handle. /// The second handle. /// The result of the operator. public static bool operator ==(HPROPSHEET h1, HPROPSHEET h2) => h1.Equals(h2); /// public override bool Equals(object obj) => obj is HPROPSHEET h && handle == h.handle; /// public override int GetHashCode() => handle.GetHashCode(); /// public IntPtr DangerousGetHandle() => handle; } /// Provides a handle to a property sheet page. [StructLayout(LayoutKind.Sequential), DebuggerDisplay("{handle}")] public struct HPROPSHEETPAGE : IUserHandle { private readonly IntPtr handle; /// Initializes a new instance of the struct. /// An object that represents the pre-existing handle to use. public HPROPSHEETPAGE(IntPtr preexistingHandle) => handle = preexistingHandle; /// Returns an invalid handle by instantiating a object with . public static HPROPSHEETPAGE NULL => new(IntPtr.Zero); /// Gets a value indicating whether this instance is a null handle. public bool IsNull => handle == IntPtr.Zero; /// Performs an explicit conversion from to . /// The handle. /// The result of the conversion. public static explicit operator IntPtr(HPROPSHEETPAGE h) => h.handle; /// Performs an implicit conversion from to . /// The pointer to a handle. /// The result of the conversion. public static implicit operator HPROPSHEETPAGE(IntPtr h) => new(h); /// Implements the operator ! which returns if the handle is invalid. /// The instance. /// The result of the operator. public static bool operator !(HPROPSHEETPAGE hMem) => hMem.IsNull; /// Implements the operator !=. /// The first handle. /// The second handle. /// The result of the operator. public static bool operator !=(HPROPSHEETPAGE h1, HPROPSHEETPAGE h2) => !(h1 == h2); /// Implements the operator ==. /// The first handle. /// The second handle. /// The result of the operator. public static bool operator ==(HPROPSHEETPAGE h1, HPROPSHEETPAGE h2) => h1.Equals(h2); /// public override bool Equals(object obj) => obj is HPROPSHEETPAGE h && handle == h.handle; /// public override int GetHashCode() => handle.GetHashCode(); /// public IntPtr DangerousGetHandle() => handle; } /// Provides a handle to a drawing region. [StructLayout(LayoutKind.Sequential), DebuggerDisplay("{handle}")] public struct HRGN : IGraphicsObjectHandle { private readonly IntPtr handle; /// Initializes a new instance of the struct. /// An object that represents the pre-existing handle to use. public HRGN(IntPtr preexistingHandle) => handle = preexistingHandle; /// Returns an invalid handle by instantiating a object with . public static HRGN NULL => new(IntPtr.Zero); /// Gets a value indicating whether this instance is a null handle. public bool IsNull => handle == IntPtr.Zero; /// Performs an explicit conversion from to . /// The handle. /// The result of the conversion. public static explicit operator IntPtr(HRGN h) => h.handle; /// Performs an implicit conversion from to . /// The pointer to a handle. /// The result of the conversion. public static implicit operator HRGN(IntPtr h) => new(h); /// Performs an implicit conversion from to . /// The pointer to a GDI handle. /// The result of the conversion. public static implicit operator HRGN(HGDIOBJ h) => new((IntPtr)h); /// Implements the operator ! which returns if the handle is invalid. /// The instance. /// The result of the operator. public static bool operator !(HRGN hMem) => hMem.IsNull; /// Implements the operator !=. /// The first handle. /// The second handle. /// The result of the operator. public static bool operator !=(HRGN h1, HRGN h2) => !(h1 == h2); /// Implements the operator ==. /// The first handle. /// The second handle. /// The result of the operator. public static bool operator ==(HRGN h1, HRGN h2) => h1.Equals(h2); /// public override bool Equals(object obj) => obj is HRGN h && handle == h.handle; /// public override int GetHashCode() => handle.GetHashCode(); /// public IntPtr DangerousGetHandle() => handle; } /// Provides a handle to a file mapping object. [StructLayout(LayoutKind.Sequential), DebuggerDisplay("{handle}")] public struct HSECTION : IHandle { private readonly IntPtr handle; /// Initializes a new instance of the struct. /// An object that represents the pre-existing handle to use. public HSECTION(IntPtr preexistingHandle) => handle = preexistingHandle; /// Returns an invalid handle by instantiating a object with . public static HSECTION NULL => new(IntPtr.Zero); /// Gets a value indicating whether this instance is a null handle. public bool IsNull => handle == IntPtr.Zero; /// Performs an explicit conversion from to . /// The handle. /// The result of the conversion. public static explicit operator IntPtr(HSECTION h) => h.handle; /// Performs an implicit conversion from to . /// The pointer to a handle. /// The result of the conversion. public static implicit operator HSECTION(IntPtr h) => new(h); /// Implements the operator ! which returns if the handle is invalid. /// The instance. /// The result of the operator. public static bool operator !(HSECTION hMem) => hMem.IsNull; /// Implements the operator !=. /// The first handle. /// The second handle. /// The result of the operator. public static bool operator !=(HSECTION h1, HSECTION h2) => !(h1 == h2); /// Implements the operator ==. /// The first handle. /// The second handle. /// The result of the operator. public static bool operator ==(HSECTION h1, HSECTION h2) => h1.Equals(h2); /// public override bool Equals(object obj) => obj is HSECTION h && handle == h.handle; /// public override int GetHashCode() => handle.GetHashCode(); /// public IntPtr DangerousGetHandle() => handle; } /// Provides a handle to a blocking task. [StructLayout(LayoutKind.Sequential), DebuggerDisplay("{handle}")] public struct HTASK : IHandle { private readonly IntPtr handle; /// Initializes a new instance of the struct. /// An object that represents the pre-existing handle to use. public HTASK(IntPtr preexistingHandle) => handle = preexistingHandle; /// Returns an invalid handle by instantiating a object with . public static HTASK NULL => new(IntPtr.Zero); /// Gets a value indicating whether this instance is a null handle. public bool IsNull => handle == IntPtr.Zero; /// Performs an explicit conversion from to . /// The handle. /// The result of the conversion. public static explicit operator IntPtr(HTASK h) => h.handle; /// Performs an implicit conversion from to . /// The pointer to a handle. /// The result of the conversion. public static implicit operator HTASK(IntPtr h) => new(h); /// Implements the operator ! which returns if the handle is invalid. /// The instance. /// The result of the operator. public static bool operator !(HTASK hMem) => hMem.IsNull; /// Implements the operator !=. /// The first handle. /// The second handle. /// The result of the operator. public static bool operator !=(HTASK h1, HTASK h2) => !(h1 == h2); /// Implements the operator ==. /// The first handle. /// The second handle. /// The result of the operator. public static bool operator ==(HTASK h1, HTASK h2) => h1.Equals(h2); /// public override bool Equals(object obj) => obj is HTASK h && handle == h.handle; /// public override int GetHashCode() => handle.GetHashCode(); /// public IntPtr DangerousGetHandle() => handle; } /// Provides a handle to a Windows theme. [StructLayout(LayoutKind.Sequential), DebuggerDisplay("{handle}")] public struct HTHEME : IHandle { private readonly IntPtr handle; /// Initializes a new instance of the struct. /// An object that represents the pre-existing handle to use. public HTHEME(IntPtr preexistingHandle) => handle = preexistingHandle; /// Returns an invalid handle by instantiating a object with . public static HTHEME NULL => new(IntPtr.Zero); /// Gets a value indicating whether this instance is a null handle. public bool IsNull => handle == IntPtr.Zero; /// Performs an explicit conversion from to . /// The handle. /// The result of the conversion. public static explicit operator IntPtr(HTHEME h) => h.handle; /// Performs an implicit conversion from to . /// The pointer to a handle. /// The result of the conversion. public static implicit operator HTHEME(IntPtr h) => new(h); /// Implements the operator ! which returns if the handle is invalid. /// The instance. /// The result of the operator. public static bool operator !(HTHEME hMem) => hMem.IsNull; /// Implements the operator !=. /// The first handle. /// The second handle. /// The result of the operator. public static bool operator !=(HTHEME h1, HTHEME h2) => !(h1 == h2); /// Implements the operator ==. /// The first handle. /// The second handle. /// The result of the operator. public static bool operator ==(HTHEME h1, HTHEME h2) => h1.Equals(h2); /// public override bool Equals(object obj) => obj is HTHEME h && handle == h.handle; /// public override int GetHashCode() => handle.GetHashCode(); /// public IntPtr DangerousGetHandle() => handle; } /// Provides a handle to a thread. [StructLayout(LayoutKind.Sequential), DebuggerDisplay("{handle}")] public struct HTHREAD : ISyncHandle { private readonly IntPtr handle; /// Initializes a new instance of the struct. /// An object that represents the pre-existing handle to use. public HTHREAD(IntPtr preexistingHandle) => handle = preexistingHandle; /// Returns an invalid handle by instantiating a object with . public static HTHREAD NULL => new(IntPtr.Zero); /// Gets a value indicating whether this instance is a null handle. public bool IsNull => handle == IntPtr.Zero; /// Performs an explicit conversion from to . /// The handle. /// The result of the conversion. public static explicit operator IntPtr(HTHREAD h) => h.handle; /// Performs an implicit conversion from to . /// The pointer to a handle. /// The result of the conversion. public static implicit operator HTHREAD(IntPtr h) => new(h); /// Implements the operator ! which returns if the handle is invalid. /// The instance. /// The result of the operator. public static bool operator !(HTHREAD hMem) => hMem.IsNull; /// Implements the operator !=. /// The first handle. /// The second handle. /// The result of the operator. public static bool operator !=(HTHREAD h1, HTHREAD h2) => !(h1 == h2); /// Implements the operator ==. /// The first handle. /// The second handle. /// The result of the operator. public static bool operator ==(HTHREAD h1, HTHREAD h2) => h1.Equals(h2); /// public override bool Equals(object obj) => obj is HTHREAD h && handle == h.handle; /// public override int GetHashCode() => handle.GetHashCode(); /// public IntPtr DangerousGetHandle() => handle; } /// Provides a handle to a Windows thumbnail. [StructLayout(LayoutKind.Sequential), DebuggerDisplay("{handle}")] public struct HTHUMBNAIL : IShellHandle { private readonly IntPtr handle; /// Initializes a new instance of the struct. /// An object that represents the pre-existing handle to use. public HTHUMBNAIL(IntPtr preexistingHandle) => handle = preexistingHandle; /// Returns an invalid handle by instantiating a object with . public static HTHUMBNAIL NULL => new(IntPtr.Zero); /// Gets a value indicating whether this instance is a null handle. public bool IsNull => handle == IntPtr.Zero; /// Performs an explicit conversion from to . /// The handle. /// The result of the conversion. public static explicit operator IntPtr(HTHUMBNAIL h) => h.handle; /// Performs an implicit conversion from to . /// The pointer to a handle. /// The result of the conversion. public static implicit operator HTHUMBNAIL(IntPtr h) => new(h); /// Implements the operator ! which returns if the handle is invalid. /// The instance. /// The result of the operator. public static bool operator !(HTHUMBNAIL hMem) => hMem.IsNull; /// Implements the operator !=. /// The first handle. /// The second handle. /// The result of the operator. public static bool operator !=(HTHUMBNAIL h1, HTHUMBNAIL h2) => !(h1 == h2); /// Implements the operator ==. /// The first handle. /// The second handle. /// The result of the operator. public static bool operator ==(HTHUMBNAIL h1, HTHUMBNAIL h2) => h1.Equals(h2); /// public override bool Equals(object obj) => obj is HTHUMBNAIL h && handle == h.handle; /// public override int GetHashCode() => handle.GetHashCode(); /// public IntPtr DangerousGetHandle() => handle; } /// Provides a handle to an access token. [StructLayout(LayoutKind.Sequential), DebuggerDisplay("{handle}")] public struct HTOKEN : IKernelHandle { private readonly IntPtr handle; /// Initializes a new instance of the struct. /// An object that represents the pre-existing handle to use. public HTOKEN(IntPtr preexistingHandle) => handle = preexistingHandle; /// Returns an invalid handle by instantiating a object with . public static HTOKEN NULL => new(IntPtr.Zero); /// Gets a value indicating whether this instance is a null handle. public bool IsNull => handle == IntPtr.Zero; /// Performs an explicit conversion from to . /// The handle. /// The result of the conversion. public static explicit operator IntPtr(HTOKEN h) => h.handle; /// Performs an implicit conversion from to . /// The pointer to a handle. /// The result of the conversion. public static implicit operator HTOKEN(IntPtr h) => new(h); /// Implements the operator ! which returns if the handle is invalid. /// The instance. /// The result of the operator. public static bool operator !(HTOKEN hMem) => hMem.IsNull; /// Implements the operator !=. /// The first handle. /// The second handle. /// The result of the operator. public static bool operator !=(HTOKEN h1, HTOKEN h2) => !(h1 == h2); /// Implements the operator ==. /// The first handle. /// The second handle. /// The result of the operator. public static bool operator ==(HTOKEN h1, HTOKEN h2) => h1.Equals(h2); /// public override bool Equals(object obj) => obj is HTOKEN h && handle == h.handle; /// public override int GetHashCode() => handle.GetHashCode(); /// public IntPtr DangerousGetHandle() => handle; } /// Provides a handle to a windows station. [StructLayout(LayoutKind.Sequential), DebuggerDisplay("{handle}")] public struct HWINSTA : IKernelHandle { private readonly IntPtr handle; /// Initializes a new instance of the struct. /// An object that represents the pre-existing handle to use. public HWINSTA(IntPtr preexistingHandle) => handle = preexistingHandle; /// Returns an invalid handle by instantiating a object with . public static HWINSTA NULL => new(IntPtr.Zero); /// Gets a value indicating whether this instance is a null handle. public bool IsNull => handle == IntPtr.Zero; /// Performs an explicit conversion from to . /// The handle. /// The result of the conversion. public static explicit operator IntPtr(HWINSTA h) => h.handle; /// Performs an implicit conversion from to . /// The pointer to a handle. /// The result of the conversion. public static implicit operator HWINSTA(IntPtr h) => new(h); /// Implements the operator ! which returns if the handle is invalid. /// The instance. /// The result of the operator. public static bool operator !(HWINSTA hMem) => hMem.IsNull; /// Implements the operator !=. /// The first handle. /// The second handle. /// The result of the operator. public static bool operator !=(HWINSTA h1, HWINSTA h2) => !(h1 == h2); /// Implements the operator ==. /// The first handle. /// The second handle. /// The result of the operator. public static bool operator ==(HWINSTA h1, HWINSTA h2) => h1.Equals(h2); /// public override bool Equals(object obj) => obj is HWINSTA h && handle == h.handle; /// public override int GetHashCode() => handle.GetHashCode(); /// public IntPtr DangerousGetHandle() => handle; } /// Provides a handle to a window or dialog. [StructLayout(LayoutKind.Sequential), DebuggerDisplay("{handle}")] public struct HWND : IUserHandle { private readonly IntPtr handle; /// Initializes a new instance of the struct. /// An object that represents the pre-existing handle to use. public HWND(IntPtr preexistingHandle) => handle = preexistingHandle; /// Returns an invalid handle by instantiating a object with . public static HWND NULL => new(IntPtr.Zero); /// Gets a value indicating whether this instance is a null handle. public bool IsNull => handle == IntPtr.Zero; /// /// Places the window at the bottom of the Z order. If the hWnd parameter identifies a topmost window, the window loses its topmost /// status and is placed at the bottom of all other windows. /// public static HWND HWND_BOTTOM = new IntPtr(1); /// /// Used by SendMessage and PostMessage to send a message to all top-level windows in the system, including disabled or /// invisible unowned windows, overlapped windows, and pop-up windows; but the message is not sent to child windows. /// public static HWND HWND_BROADCAST = new IntPtr(0xffff); /// Use as parent in CreateWindow or CreateWindowEx call to indicate a message-only window. public static HWND HWND_MESSAGE = new IntPtr(-3); /// /// Places the window above all non-topmost windows (that is, behind all topmost windows). This flag has no effect if the window is /// already a non-topmost window. /// public static HWND HWND_NOTOPMOST = new IntPtr(-2); /// Places the window at the top of the Z order. public static HWND HWND_TOP = new IntPtr(0); /// Places the window above all non-topmost windows. The window maintains its topmost position even when it is deactivated. public static HWND HWND_TOPMOST = new IntPtr(-1); /// Performs an explicit conversion from to . /// The handle. /// The result of the conversion. public static explicit operator IntPtr(HWND h) => h.handle; /// Performs an implicit conversion from to . /// The pointer to a handle. /// The result of the conversion. public static implicit operator HWND(IntPtr h) => new(h); /// Implements the operator ! which returns if the handle is invalid. /// The instance. /// The result of the operator. public static bool operator !(HWND hMem) => hMem.IsNull; /// Implements the operator !=. /// The first handle. /// The second handle. /// The result of the operator. public static bool operator !=(HWND h1, HWND h2) => !(h1 == h2); /// Implements the operator ==. /// The first handle. /// The second handle. /// The result of the operator. public static bool operator ==(HWND h1, HWND h2) => h1.Equals(h2); /// public override bool Equals(object obj) => obj is HWND h && handle == h.handle; /// public override int GetHashCode() => handle.GetHashCode(); /// public IntPtr DangerousGetHandle() => handle; } /// Provides a pointer to an access control entry. [StructLayout(LayoutKind.Sequential), DebuggerDisplay("{handle}")] public struct PACE : ISecurityObject { private readonly IntPtr handle; /// Initializes a new instance of the struct. /// An object that represents the pre-existing handle to use. public PACE(IntPtr preexistingHandle) => handle = preexistingHandle; /// Returns an invalid handle by instantiating a object with . public static PACE NULL => new(IntPtr.Zero); /// Gets a value indicating whether this instance is a null handle. public bool IsNull => handle == IntPtr.Zero; /// Performs an explicit conversion from to . /// The handle. /// The result of the conversion. public static explicit operator IntPtr(PACE h) => h.handle; /// Performs an implicit conversion from to . /// The pointer to a handle. /// The result of the conversion. public static implicit operator PACE(IntPtr h) => new(h); /// Implements the operator ! which returns if the handle is invalid. /// The instance. /// The result of the operator. public static bool operator !(PACE hMem) => hMem.IsNull; /// Implements the operator !=. /// The first handle. /// The second handle. /// The result of the operator. public static bool operator !=(PACE h1, PACE h2) => !(h1 == h2); /// Implements the operator ==. /// The first handle. /// The second handle. /// The result of the operator. public static bool operator ==(PACE h1, PACE h2) => h1.Equals(h2); /// public override bool Equals(object obj) => obj is PACE h && handle == h.handle; /// public override int GetHashCode() => handle.GetHashCode(); /// public IntPtr DangerousGetHandle() => handle; } /// Provides a handle to an access control list. [StructLayout(LayoutKind.Sequential), DebuggerDisplay("{handle}")] public struct PACL : ISecurityObject { private readonly IntPtr handle; /// Initializes a new instance of the struct. /// An object that represents the pre-existing handle to use. public PACL(IntPtr preexistingHandle) => handle = preexistingHandle; /// Returns an invalid handle by instantiating a object with . public static PACL NULL => new(IntPtr.Zero); /// Gets a value indicating whether this instance is a null handle. public bool IsNull => handle == IntPtr.Zero; /// Performs an explicit conversion from to . /// The handle. /// The result of the conversion. public static explicit operator IntPtr(PACL h) => h.handle; /// Performs an implicit conversion from to . /// The pointer to a handle. /// The result of the conversion. public static implicit operator PACL(IntPtr h) => new(h); /// Implements the operator ! which returns if the handle is invalid. /// The instance. /// The result of the operator. public static bool operator !(PACL hMem) => hMem.IsNull; /// Implements the operator !=. /// The first handle. /// The second handle. /// The result of the operator. public static bool operator !=(PACL h1, PACL h2) => !(h1 == h2); /// Implements the operator ==. /// The first handle. /// The second handle. /// The result of the operator. public static bool operator ==(PACL h1, PACL h2) => h1.Equals(h2); /// public override bool Equals(object obj) => obj is PACL h && handle == h.handle; /// public override int GetHashCode() => handle.GetHashCode(); /// public IntPtr DangerousGetHandle() => handle; } /// Provides a handle to a security descriptor. [StructLayout(LayoutKind.Sequential), DebuggerDisplay("{handle}")] public struct PSECURITY_DESCRIPTOR : ISecurityObject { private readonly IntPtr handle; /// Initializes a new instance of the struct. /// An object that represents the pre-existing handle to use. public PSECURITY_DESCRIPTOR(IntPtr preexistingHandle) => handle = preexistingHandle; /// Returns an invalid handle by instantiating a object with . public static PSECURITY_DESCRIPTOR NULL => new(IntPtr.Zero); /// Gets a value indicating whether this instance is a null handle. public bool IsNull => handle == IntPtr.Zero; /// Performs an explicit conversion from to . /// The handle. /// The result of the conversion. public static explicit operator IntPtr(PSECURITY_DESCRIPTOR h) => h.handle; /// Performs an implicit conversion from to . /// The pointer to a handle. /// The result of the conversion. public static implicit operator PSECURITY_DESCRIPTOR(IntPtr h) => new(h); /// Implements the operator ! which returns if the handle is invalid. /// The instance. /// The result of the operator. public static bool operator !(PSECURITY_DESCRIPTOR hMem) => hMem.IsNull; /// Implements the operator !=. /// The first handle. /// The second handle. /// The result of the operator. public static bool operator !=(PSECURITY_DESCRIPTOR h1, PSECURITY_DESCRIPTOR h2) => !(h1 == h2); /// Implements the operator ==. /// The first handle. /// The second handle. /// The result of the operator. public static bool operator ==(PSECURITY_DESCRIPTOR h1, PSECURITY_DESCRIPTOR h2) => h1.Equals(h2); /// public override bool Equals(object obj) => obj is PSECURITY_DESCRIPTOR h && handle == h.handle; /// public override int GetHashCode() => handle.GetHashCode(); /// public IntPtr DangerousGetHandle() => handle; } /// Provides a handle to a security identifier. [StructLayout(LayoutKind.Sequential), DebuggerDisplay("{handle}")] public struct PSID : ISecurityObject { private readonly IntPtr handle; /// Initializes a new instance of the struct. /// An object that represents the pre-existing handle to use. public PSID(IntPtr preexistingHandle) => handle = preexistingHandle; /// Returns an invalid handle by instantiating a object with . public static PSID NULL => new(IntPtr.Zero); /// Gets a value indicating whether this instance is a null handle. public bool IsNull => handle == IntPtr.Zero; /// Performs an explicit conversion from to . /// The handle. /// The result of the conversion. public static explicit operator IntPtr(PSID h) => h.handle; /// Performs an implicit conversion from to . /// The pointer to a handle. /// The result of the conversion. public static implicit operator PSID(IntPtr h) => new(h); /// Implements the operator ! which returns if the handle is invalid. /// The instance. /// The result of the operator. public static bool operator !(PSID hMem) => hMem.IsNull; /// Implements the operator !=. /// The first handle. /// The second handle. /// The result of the operator. public static bool operator !=(PSID h1, PSID h2) => !(h1 == h2); /// Implements the operator ==. /// The first handle. /// The second handle. /// The result of the operator. public static bool operator ==(PSID h1, PSID h2) => h1.Equals(h2); /// public override bool Equals(object obj) => obj is PSID h && handle == h.handle; /// public override int GetHashCode() => handle.GetHashCode(); /// public IntPtr DangerousGetHandle() => handle; }