ClassAssistance.Slave/Helper/Native/Impl/User32.cs

(完整代码) 1KB

using System;
using System.Runtime.InteropServices;
using System.Text;

namespace ClassAssistance.Slave.Helper.Native.Impl
{
    public sealed class User32 : DynamicNativeLibrary<User32>
    {
        public User32() : base("user32.dll") { }

        [UnmanagedFunctionPointer(CallingConvention.Winapi, CharSet = CharSet.Auto)]
        public delegate IntPtr dGetForegroundWindow();

        [UnmanagedFunctionPointer(CallingConvention.Winapi, CharSet = CharSet.Auto)]
        public delegate int dGetWindowThreadProcessId(IntPtr handle, out int processId);

        [UnmanagedFunctionPointer(CallingConvention.Winapi, CharSet = CharSet.Auto)]
        public delegate int dGetWindowText(IntPtr hWnd, StringBuilder lpString, int nMaxCount);

        public static dGetWindowText GetWindowText = 
            Instance.FindUmanagedFunction<dGetWindowText>("GetWindowTextW");

        public static dGetWindowThreadProcessId GetWindowThreadProcessId = 
            Instance.FindUmanagedFunction<dGetWindowThreadProcessId>("GetWindowThreadProcessId");

        public static dGetForegroundWindow GetForegroundWindow = 
            Instance.FindUmanagedFunction<dGetForegroundWindow>("GetForegroundWindow");
    }
}

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

AI 解读

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

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