AutoPatientInfoRecorder/src/AntdUI/Lib/Vanara/Shared/Handles.cs

(开头部分) 14KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

// THIS FILE IS PART OF Vanara PROJECT
// THE Vanara PROJECT IS AN OPENSOURCE LIBRARY LICENSED UNDER THE MIT License.
// COPYRIGHT (C) dahall. ALL RIGHTS RESERVED.
// GITHUB: https://github.com/dahall/Vanara

using Microsoft.Win32.SafeHandles;
using System;
using System.Diagnostics;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

namespace Vanara.PInvoke
{
    /// <summary>Signals that a structure or class holds a handle to a synchronization 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 synchronization object.</summary>
    public interface IKernelHandle : IHandle { }

    /// <summary>Signals that a structure or class holds a handle to a synchronization object.</summary>
    public interface IUserHandle : IHandle { }

    /// <summary>Provides a handle to a Windows cursor.</summary>
    [StructLayout(LayoutKind.Sequential), DebuggerDisplay("{handle}")]
    public struct HCURSOR : IGraphicsObjectHandle
    {
        private readonly IntPtr handle;

        /// <summary>Initializes a new instance of the <see cref="HCURSOR"/> struct.</summary>
        /// <param name="preexistingHandle">An <see cref="IntPtr"/> object that represents the pre-existing handle to use.</param>
        public HCURSOR(IntPtr preexistingHandle) => handle = preexistingHandle;

        /// <summary>Returns an invalid handle by instantiating a <see cref="HCURSOR"/> object with <see cref="IntPtr.Zero"/>.</summary>
        public static HCURSOR NULL => new HCURSOR(IntPtr.Zero);

        /// <summary>Gets a value indicating whether this instance is a null handle.</summary>
        public bool IsNull => handle == IntPtr.Zero;

        /// <summary>Performs an explicit conversion from <see cref="HCURSOR"/> to <see cref="IntPtr"/>.</summary>
        /// <param name="h">The handle.</param>
        /// <returns>The result of the conversion.</returns>
        public static explicit operator IntPtr(HCURSOR h) => h.handle;

        /// <summary>Performs an implicit conversion from <see cref="IntPtr"/> to <see cref="HCURSOR"/>.</summary>
        /// <param name="h">The pointer to a handle.</param>
        /// <returns>The result of the conversion.</returns>
        public static implicit operator HCURSOR(IntPtr h) => new HCURSOR(h);

        /// <summary>Implements the operator !=.</summary>
        /// <param name="h1">The first handle.</param>
        /// <param name="h2">The second handle.</param>
        /// <returns>The result of the operator.</returns>
后面还有 243 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。