Elight.Utility/Other/ScreenUtils.cs
(开头部分) 3KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
#if NETFRAMEWORK || WINDOWS
using System;
using System.Runtime.InteropServices;
using System.Windows.Forms;
namespace Elight.Utility.Other
{
public class ScreenUtils
{
#region Dll引用
[DllImport("User32.dll", EntryPoint = "GetDC")]
private extern static IntPtr GetDC(IntPtr hWnd);
[DllImport("User32.dll", EntryPoint = "ReleaseDC")]
private extern static int ReleaseDC(IntPtr hWnd, IntPtr hDC);
[DllImport("gdi32.dll")]
public static extern int GetDeviceCaps(IntPtr hdc, int nIndex);
[DllImport("User32.dll")]
public static extern int GetSystemMetrics(int hWnd);
[DllImport("User32.dll")]
private static extern IntPtr MonitorFromPoint([In] System.Drawing.Point pt, [In] uint dwFlags);
[DllImport("Shcore.dll")]
private static extern IntPtr GetDpiForMonitor([In] IntPtr hmonitor, [In] DpiType dpiType, [Out] out uint dpiX, [Out] out uint dpiY);
#endregion
const int DESKTOPVERTRES = 117;
const int DESKTOPHORZRES = 118;
const int SM_CXSCREEN = 0;
const int SM_CYSCREEN = 1;
/// <summary>
/// 获取DPI缩放比例
/// </summary>
/// <param name="dpiscalex"></param>
/// <param name="dpiscaley"></param>
public static void GetDPIScale(ref float dpiscalex, ref float dpiscaley)
{
int x = GetSystemMetrics(SM_CXSCREEN);
int y = GetSystemMetrics(SM_CYSCREEN);
IntPtr hdc = GetDC(IntPtr.Zero);
int w = GetDeviceCaps(hdc, DESKTOPHORZRES);
int h = GetDeviceCaps(hdc, DESKTOPVERTRES);
ReleaseDC(IntPtr.Zero, hdc);
dpiscalex = (float)w / x;
dpiscaley = (float)h / y;
}
/// <summary>
/// 获取分辨率
/// </summary>
/// <param name="width">宽</param>
/// <param name="height">高</param>
private static void GetResolving(ref int width, ref int height)
{
后面还有 53 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。