-
ASP.net教程之c# 多种方法调整屏幕亮度
Github: https://github.com/CHNMaxGor/AjustScreenBrightness
方法一: 使用网上常说的 Gdi32.dll 下的 SetDeviceGammaRamp (修改系统Gamma)
DllImport("gdi32.dll")] public static extern bool GetDeviceGammaRamp(IntPtr hDC, ref RAMP lpRamp);[DllImport("gdi32.dll")] public static extern bool SetDeviceGammaRamp(IntPtr hDC, ref RAMP lpRamp);方法二: 使用MSDN上的 dxva2.dll SetMonitorBrightness
1 [DllImport("dxva2.dll")] 2 public static extern bool GetNumberOfPhysicalMonitorsFromHMONITOR(IntPtr hMonitor, ref uint pdwNumberOfPhysicalMonitors); 3 4 [DllImport("dxva2.dll")] 5 public static extern bool GetPhysicalMonitorsFromHMONITOR(IntPtr hMonitor, 6 uint dwPhysicalMonitorArraySize, [Out] PhysicalMonitor[] pPhysicalMonitorArray); 7 8 [DllImport("dxva2.dll")] 9 public static extern bool DestroyPhysicalMonitors(uint dwPhysicalMonitorArraySize, 10 [Out] PhysicalMonitor[] pPhysicalMonitorArray); 11 12 [DllImport("dxva2.dll")] 13 public static extern bool GetMonitorTechnologyType(IntPtr hMonitor, 14 ref McDisplayTechnologyType pdtyDisplayTechnologyType); 15 16 [DllImport("dxva2.dll")] 17 public static extern bool GetMonitorCapabilities(IntPtr hMonitor, ref uint pdwMonitorCapabilities, 18 ref uint pdwSupportedColorTemperatures); 19 20 [DllImport("dxva2.dll")] 21 public static extern bool SetMonitorBrightness(IntPtr hMonitor, short brightness); 22 23 [DllImport("dxva2.dll")] 24 public static extern bool SetMonitorContrast(IntPtr hMonitor, short contrast); 25 26 [DllImport("dxva2.dll")] 27 public static extern bool GetMonitorBrightness(IntPtr hMonitor, ref short pdwMinimumBrightness, 28 ref short pdwCurrentBrightness, ref short pdwMaximumBrightness); 29 30 [DllImport("dxva2.dll")] 31 public static extern bool GetMonitorContrast(IntPtr hMonitor, ref short pwdMinimumContrast, 32 ref short pwdCurrentContrast, ref short pwdMaximumContrast);
方法三: 使用 C:\Windows\System32\DriverStore\FileRepository\igdlh64.inf_amd64_neutral_3daeca3838e011e0\igfxDHLib.dll (这是驱动的文件,不同机器有自己对应的驱动文件)
DataHandlerClass _cls = new DataHandlerClass(); _CUI_COLOR_DEVICES _screenModel = default(_CUI_COLOR_DEVICES); public AjustScreenByIgfxDHLib() { CUI_SUPPORTED_CONFIG cui_SUPPORTED_CONFIG = default(CUI_SUPPORTED_CONFIG); uint num = _cls.get_SupportedConfig(ref cui_SUPPORTED_CONFIG); var id = cui_SUPPORTED_CONFIG.DeviceConfig[0].DispDev[0]; uint[] array = new uint[3]; var a = _cls.get_GetDeviceList(id, array); _screenModel.ulDevices = array[0]; _screenModel.Device = new _CUI_COLOR_INFO[3]; _screenModel.Device[0].Brightness.color = _COLOR_TYPE.NumColors; _screenModel.Device[0].Contrast.color = _COLOR_TYPE.NumColors; _screenModel.Device[0].Gamma.color = _COLOR_TYPE.NumColors; _screenModel.Command = _CUI_COLOR_COMMAND.GET_COLOR; _cls.get_color(_screenModel.ulDevices, ref _screenModel); }
注意事项
该方法使用时请注意好参数的范围,比如说把对比度设置太低时屏幕会完全黑掉 什么都看不到,然后你就不能直接把对比度调回来了.
栏目列表
最新更新
如何使用OS模块中的stat方法
Python os 模块
seek() 方法
python打开文件实例1
Python写入文件
什么是流?
文件操作如何进制逐行读取
Python相对路径
with创建临时运行环境
Python文件操作
.Net Standard(.Net Core)实现获取配置信息
Linux PXE + Kickstart 自动装机
Shell 编程 基础
Shell 编程 条件语句
CentOS8-网卡配置及详解
Linux中LVM逻辑卷管理
1.数码相框-相框框架分析(1)
Ubuntu armhf 版本国内源
Linux中raid磁盘阵列
搭建简易网站
access教程之Access简介
mysql 安装了最新版本8.x版本后的报错:
Mysql空间数据&空间索引(spatial)
如何远程连接SQL Server数据库的图文教程
复制SqlServer数据库的方法
搜索sql语句
sql中返回参数的值
sql中生成查询的模糊匹配字符串
数据定义功能
数据操作功能