• C#计算屏幕的物理宽和高


                var mc = new ManagementClass("Win32_DesktopMonitor");
                double height = 0;
                double width = 0;
                foreach (var a in mc.GetInstances())
                {
                    string path;
                    Trace.WriteLine(path = a.Properties["PNPDeviceID"].Value.ToString());
                    var bytes = (byte[])Registry.LocalMachine.OpenSubKey(@"SYSTEMCurrentControlSetEnum" + path + @"Device Parameters").GetValue("EDID");
                    height = bytes[22];
                    width = bytes[21];
                    Trace.WriteLine("" + bytes[21].ToString());
                    Trace.WriteLine("" + bytes[22].ToString());
                }
                height = height * 10;
                width = width * 10;
                double x1 = SystemParameters.PrimaryScreenWidth;//得到屏幕整体宽度
                double y1 = SystemParameters.PrimaryScreenHeight;//得到屏幕整体高度

    要引用系统自带的Management.dll程序集,然后访问EDID的数据,EDID的数组中的22位和23位是屏幕的物理宽和高。

    多看书,少装逼!
  • 相关阅读:
    多线程
    多线程
    多线程
    多线程
    Java 基础
    异常
    多线程
    多线程
    多线程
    幂等性
  • 原文地址:https://www.cnblogs.com/R00R/p/14687875.html
Copyright © 2020-2023  润新知