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

 [DllImport("dxva2.dll")]
public static extern bool GetNumberOfPhysicalMonitorsFromHMONITOR(IntPtr hMonitor, ref uint pdwNumberOfPhysicalMonitors); [DllImport("dxva2.dll")]
public static extern bool GetPhysicalMonitorsFromHMONITOR(IntPtr hMonitor,
uint dwPhysicalMonitorArraySize, [Out] PhysicalMonitor[] pPhysicalMonitorArray); [DllImport("dxva2.dll")]
public static extern bool DestroyPhysicalMonitors(uint dwPhysicalMonitorArraySize,
[Out] PhysicalMonitor[] pPhysicalMonitorArray); [DllImport("dxva2.dll")]
public static extern bool GetMonitorTechnologyType(IntPtr hMonitor,
ref McDisplayTechnologyType pdtyDisplayTechnologyType); [DllImport("dxva2.dll")]
public static extern bool GetMonitorCapabilities(IntPtr hMonitor, ref uint pdwMonitorCapabilities,
ref uint pdwSupportedColorTemperatures); [DllImport("dxva2.dll")]
public static extern bool SetMonitorBrightness(IntPtr hMonitor, short brightness); [DllImport("dxva2.dll")]
public static extern bool SetMonitorContrast(IntPtr hMonitor, short contrast); [DllImport("dxva2.dll")]
public static extern bool GetMonitorBrightness(IntPtr hMonitor, ref short pdwMinimumBrightness,
ref short pdwCurrentBrightness, ref short pdwMaximumBrightness); [DllImport("dxva2.dll")]
public static extern bool GetMonitorContrast(IntPtr hMonitor, ref short pwdMinimumContrast,
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);
}

  

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

c# 多种方法调整屏幕亮度的更多相关文章

  1. Android 播放电影时滑动屏幕调整屏幕亮度(转)

    (转自:http://blog.csdn.net/piaozhiye/article/details/6544450) 发现有一些主流的播放器播放电影时可以通过滑动屏幕调整屏幕亮度,其实实现起来也很容 ...

  2. 【转】Windows Phone 调整屏幕亮度的简单实现

    之前看到以及其它应用都有调节屏幕亮度的功能,还以为MS有相关的API,就去MSDN找了下,但是怎么都找不到.今天突然想到做自定义MessageBox时,由于要突出弹出框部分,所以会改变LayoutRo ...

  3. Mint linux中调整屏幕亮度的方法

    /*********************************************************************  * Author  : Samson  * Date   ...

  4. Unity shader学习之屏幕后期效果之调整屏幕亮度,饱和度,对比度

    Unity的屏幕后期处理效果,使用MonoBehaviour.OnRenderImage来实现. 转载请注明出处:http://www.cnblogs.com/jietian331/p/7228063 ...

  5. centos调整屏幕亮度

    笔记本安装centos6.5后亮度无法通过键盘快捷键调节,可以通过安装软件来调节. 安装:yum install xgamma 设置亮度:xgamma -gamma n( 0.1 < n < ...

  6. 解决ubuntu无法调整和保存屏幕亮度的问题

    整理自解决ubuntu无法调整和保存屏幕亮度的问题 ubuntu无法调整屏幕亮度,对笔记本来说很耗电,同时也很刺眼,因为它是默认以最大亮度来工作的. 所谓的调整,方法为下面的其中一种: 1.Fn+左右 ...

  7. Android开发调节屏幕亮度

    在播放器,我们经常看到这样的设计,即,在用户的特定部分将能够滑动屏幕向上或向下调整屏幕的亮度,上下滑动的某一部分将能够调整播放音量.并以滑动的进程可以进行调整,以玩. 如今,我不得不说一下亮度调节. ...

  8. iOS获取屏幕亮度及设置

    平常很少有功能点需要调整屏幕亮度,但是也会有一些特殊场景,类似支付宝微信的二维码提供扫描时会使屏幕程序高亮状态,查了下资料做了一下简单记录: 获取当前屏幕的亮度 CGFloat value = [UI ...

  9. Win8.1屏幕亮度自动调节关闭方法

    细心的朋友会发现,Win8.1系统的笔记本屏幕亮度有时候,会根据外界光线亮度以及温度自动调节屏幕亮度,尽管看似比较智能,但有时候我们并不希望笔记本屏幕亮度受光线影响,忽暗忽亮.如果我们希望Win8笔记 ...

随机推荐

  1. Python 处理时间的模块

    1.由日期格式转化为字符串格式的函数为: datetime.datetime.strftime().date() 2.由字符串格式转化为日期格式的函数为: datetime.datetime.strp ...

  2. SpringCloud实战-Hystrix请求熔断与服务降级

    我们知道大量请求会阻塞在Tomcat服务器上,影响其它整个服务.在复杂的分布式架构的应用程序有很多的依赖,都会不可避免地在某些时候失败.高并发的依赖失败时如果没有隔离措施,当前应用服务就有被拖垮的风险 ...

  3. 通过数据流处理-微信小程序生成临时二维码

    1.小程序代码 onLoad: function (options) { var that = this api.Login(function (login) { var codeModel = ne ...

  4. 【转】mysql 中int类型字段unsigned和signed的区别

    转自https://www.cnblogs.com/wangzhongqiu/p/6424827.html 用法: mysql> CREATE TABLE t ( a INT UNSIGNED, ...

  5. 【手记】解决启动SQL Server Management Studio 17时报Cannot find one of more components...的问题

    刚装好SSMS 17.1准备体验,弹出: 一番搜索,普遍办法都是安装VS2015独立shell.删除某个注册表项什么的,没用,首先这个shell我是装了的,然后也没有那个注册表项.我自己尝试过重装sh ...

  6. Loadrunner 11 中Run-Time Setting详细参数说明

    .General/Run Logic :用来设置运行脚本迭代的次数,迭代次数只对run部分的脚本迭代次数有影响,对init和End部分无印象.一般设置未1~3次,只会影响在单位时间内客户端想服务器提交 ...

  7. JavaScript的数据类型问题总结

    一    JS中有哪些数据类型? -- 共 6 种数据类型,其中 5 种基本数据类型Undefined,Null,Boolean,Number和 String,1 种复杂数据类型Object.因为EC ...

  8. localStorage和sessionStorage区别(包括同源的定义)

    localStorage和sessionStorage一样都是用来存储客户端临时信息的对象. 他们均只能存储字符串类型的对象(虽然规范中可以存储其他原生类型的对象,但是目前为止没有浏览器对其进行实现) ...

  9. Linux 上一些常用命令

    切换权限: sudo chown -R 权限名: 文件 tar -zcvf 文件夹.tar 文件夹--exclude=要过滤的文件夹路径 重启crontab :service crond restar ...

  10. JAVAEE——Mybatis第二天:输入和输出映射、动态sql、关联查询、Mybatis整合spring、Mybatis逆向工程

    1. 学习计划 1.输入映射和输出映射 a) 输入参数映射 b) 返回值映射 2.动态sql a) If标签 b) Where标签 c) Sql片段 d) Foreach标签 3.关联查询 a) 一对 ...