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);
}

  

注意事项 该方法使用时请注意好参数的范围,比如说把对比度设置太低时屏幕会完全黑掉 什么都看不到,然后你就不能直接把对比度调回来了.

转载于:https://www.cnblogs.com/MaxGorGor/p/10522682.html

c# 多种方法调整屏幕亮度相关推荐

  1. 调整屏幕亮度,调整字体大小

    在我们开发项目的过程中,常常会遇到这样的功能,比如调整亮度,或者调整当前屏幕的字体大小, 其实这样的功能很好实现, 具体代码如下: 一.声明成员变量 1 { 2 UIView *_view; 3 BO ...

  2. 如何使用注册表在Win10中调整屏幕亮度

    在这篇文章中,笔者将教大家如何在Win10中使用注册表调整屏幕亮度,值得注意的是,有一些台式机或者一体机,它们的显示器具有自己的亮度控制,因此对于本文给出的方法,你需要合适的显示器和合适的驱动程序,如 ...

  3. Win7系统专业版调整屏幕亮度的详细教程--win7w.com

    win7专业版修改调整屏幕亮度教程.很多win7用户都反映想要调整屏幕亮度的时候却找不到相关功能键,这要怎么办呢?win7专业版屏幕亮度究竟该如何进行修改调整呢?有遇到同样问题的小伙伴可以参照下面wi ...

  4. Win7笔记本如何调整屏幕亮度

    长期使用电脑的时候会因为视觉疲劳感觉屏幕亮度过高,需要对其调整来缓解.PC用户方法很简单,只需在显示器上点击按钮进行调整即可,那么Win7笔记本如何调整屏幕亮度?其实Win7系统本身有考虑到这个问题, ...

  5. win7电脑台式机如何调整屏幕亮度

    Win7台式电脑调整屏幕亮度方法: 1. 在电脑桌面空白鼠标右键,选择"屏幕分辨率". 2. 在屏幕分辨率界面找到并选择"高级设置". 3. 打开高级设置后,根 ...

  6. SHELL脚本之编写脚本实现调整屏幕亮度的脚本

    SHELL脚本之编写脚本实现调整屏幕亮度的脚本 Ubuntu系统没有自动调节亮度的功能,本人发现了一个命令行调节的方法 wanboo@wanboo-ubuntu:~/文档/shell脚本$ xrand ...

  7. 【微信小程序系列:二】小程序常用功能:跳转地图、扫一扫、人脸识别、拍照、拨打电话、调整屏幕亮度、文字可复制、监听截屏...

    一.先言: (- ̄▽ ̄)-,hello,微信小程序系列第二篇,介绍下小程序里的前端常用功能api,可以快速copy使用~ 二.文字可复制: 小程序页面里的文字默认是没有长按复制功能的,需要套个标签来实 ...

  8. Android调整屏幕亮度和改变屏幕亮度调整模式的代码

    最近有一个调整屏幕亮度的需求,在网上找了各种代码,心乱如麻.不是长篇大论说源码的,就是只言片语就上代码的,关键是代码还不能直接用. 这里面确实是有一些坑,在这里我会把可以用的代码写出来,并且告诉大家坑 ...

  9. iphone自适应屏幕亮度_如何在iPhone或iPad上调整屏幕亮度

    iphone自适应屏幕亮度 Khamosh Pathak Khamosh Pathak Your iPhone or iPad is pretty good at automatically adju ...

最新文章

  1. (chap6 Http首部) 响应首部字段 ServerVaryWWW-Authenticate
  2. C++Primer Plus (第六版)阅读笔记 + 源码分析【第四章:复合类型】
  3. 致盗窃,抄袭有三AI内容以及不可理喻的读者
  4. MYSQL和ORACLE时区设置比较
  5. 过拟合解决方法python_《python深度学习》笔记---4.4、过拟合与欠拟合(解决过拟合常见方法)...
  6. modbus软件开发实战指南_C++核心准则?GSL:指南支持库
  7. python prettytable表格列数太多_excel列数太多了怎么办
  8. 2.word转换为pdf
  9. MATLAB 句柄函数记录——多变量
  10. STL模板之vector与sort的使用
  11. XILINX FPGA数字信号处理——3、数字的表示和运算的实现
  12. Scrapy爬虫项目的创建及案例
  13. 地震数据插值之深度学习方法
  14. macOS 应用程序dmg 已损坏无法打开解决办法
  15. 布料仿真先导2-带阻尼的单个小球单摆下的拉格朗日方程列些和matlab仿真
  16. 【开发日志-已归档】2021-08
  17. Opencv 统计灰度图所有灰度值
  18. JS实战应用之做LOL领图标任务~
  19. Show, Attend, and Tell | a PyTorch Tutorial to Image Captioning代码调试(跑通)
  20. FQDN是什么?DNS又是什么?NNTP又是什么

热门文章

  1. 4873: [Shoi2017]寿司餐厅
  2. ML之FE:基于波士顿房价数据集利用LightGBM算法进行模型预测然后通过3σ原则法(计算残差标准差)寻找测试集中的异常值/异常样本
  3. 【Python画图】Matplotlib中fig、ax、plt的区别及其用法(入门)
  4. R 语言 fig() 用法
  5. 阿里巴巴计划分拆中国万网赴美上市
  6. django 验证和授权系统
  7. 圣诞节诗歌-最美的礼物—赞美之泉
  8. 离散数学 集合 思维导图
  9. python 职业技能大赛备赛(2)
  10. TypeScript type 和 interface区别