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
[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# 多种方法调整屏幕亮度的更多相关文章
- Android 播放电影时滑动屏幕调整屏幕亮度(转)
(转自:http://blog.csdn.net/piaozhiye/article/details/6544450) 发现有一些主流的播放器播放电影时可以通过滑动屏幕调整屏幕亮度,其实实现起来也很容 ...
- 【转】Windows Phone 调整屏幕亮度的简单实现
之前看到以及其它应用都有调节屏幕亮度的功能,还以为MS有相关的API,就去MSDN找了下,但是怎么都找不到.今天突然想到做自定义MessageBox时,由于要突出弹出框部分,所以会改变LayoutRo ...
- Mint linux中调整屏幕亮度的方法
/********************************************************************* * Author : Samson * Date ...
- Unity shader学习之屏幕后期效果之调整屏幕亮度,饱和度,对比度
Unity的屏幕后期处理效果,使用MonoBehaviour.OnRenderImage来实现. 转载请注明出处:http://www.cnblogs.com/jietian331/p/7228063 ...
- centos调整屏幕亮度
笔记本安装centos6.5后亮度无法通过键盘快捷键调节,可以通过安装软件来调节. 安装:yum install xgamma 设置亮度:xgamma -gamma n( 0.1 < n < ...
- 解决ubuntu无法调整和保存屏幕亮度的问题
整理自解决ubuntu无法调整和保存屏幕亮度的问题 ubuntu无法调整屏幕亮度,对笔记本来说很耗电,同时也很刺眼,因为它是默认以最大亮度来工作的. 所谓的调整,方法为下面的其中一种: 1.Fn+左右 ...
- Android开发调节屏幕亮度
在播放器,我们经常看到这样的设计,即,在用户的特定部分将能够滑动屏幕向上或向下调整屏幕的亮度,上下滑动的某一部分将能够调整播放音量.并以滑动的进程可以进行调整,以玩. 如今,我不得不说一下亮度调节. ...
- iOS获取屏幕亮度及设置
平常很少有功能点需要调整屏幕亮度,但是也会有一些特殊场景,类似支付宝微信的二维码提供扫描时会使屏幕程序高亮状态,查了下资料做了一下简单记录: 获取当前屏幕的亮度 CGFloat value = [UI ...
- Win8.1屏幕亮度自动调节关闭方法
细心的朋友会发现,Win8.1系统的笔记本屏幕亮度有时候,会根据外界光线亮度以及温度自动调节屏幕亮度,尽管看似比较智能,但有时候我们并不希望笔记本屏幕亮度受光线影响,忽暗忽亮.如果我们希望Win8笔记 ...
随机推荐
- 关于loadrunner使用web_add_header添加HTTP信息头(比如Content-Type,token等)和使用
关于loadrunner使用web_add_header添加HTTP信息头(比如Content-Type,token等)和使用 1.web_add_header添加HTTP信息头(比如Content- ...
- 重温《STL源码剖析》笔记 第二章
源码之前,了无秘密. --侯杰 第二章:空间配置器 allocator SGI特殊的空间配置器,std::alloc SGI是以malloc()和free()完成内存的配置与释放. SGI设计了双层级 ...
- Selenium自动化测试-unittest单元测试框架
一.Pyhon工作原理-- 核心概念:test case, testsuite, TestLoder,TextTestRunner,TextTestResult, test fixture TestC ...
- Java NIO Channel通道
原文链接:http://tutorials.jenkov.com/java-nio/channels.html Java NIO Channel通道和流非常相似,主要有以下几点区别: 通道可以读也可以 ...
- HTML基础篇(标签和属性整--已剔除不被浏览器支持的部分)
行内元素有:a b span img input select strong 块级元素有:div ul ol li dl dt dd h1 h2 h3 h4…p HTML 参考手册- (HTML5 标 ...
- PHP Simple HTML DOM解析器使用入门
http://www.cnphp.info/php-simple-html-dom-parser-intro.html 一直以来使用php解析html文档树都是一个难题.Simple HTML DOM ...
- python 3.6 lxml标准库lxml的安装及etree的使用注意
据我所知,python 3.5之后的lxml模块里面不再包含etree,那么要怎么解决这个问题呢? lxml模块下的etree函数的使用问题,部分lxml模块不再支持etree方法,因此只能想办法下载 ...
- Java 读书笔记 (十三) for each 循环
JDK 1.5引进了一种新的循环类型,被称为foreach循环或者加强型循环,它能在不使用下标的情况下遍历数组. 实例: public class TestArray{ public static v ...
- 比较集合List<T>集合,前后多了哪些数据,少了哪些数据Except
1.少了哪些数据 private List<int> GetRoleIdListReduce(List<int> roleIdListOld, List<int> ...
- 数据保存策略(Retention Policies)
数据保存策略(Retention Policies) InfluxDB没有提供直接删除Points的方法,但是它提供了Retention Policies.主要用于指定数据的保留时间:当数据超过了指定 ...