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

  

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

最新文章

  1. 12月13日上午Smarty模版原理
  2. WPF之自定义控件
  3. VS使用的一些备忘东西
  4. 对ADC(DAC)的线性度(INL和DNL)的一点理解 [转]
  5. nginx的ngx_http_request_t结构体
  6. MVC下判断PC和移动端
  7. highchars
  8. 优秀js插件收藏
  9. JQuery的鼠标滚动事件
  10. unity中的委托
  11. [node] node 版本更新
  12. javascript实现小鸟飞行轨迹
  13. LeetCode之“动态规划”:Best Time to Buy and Sell Stock I && II && III && IV
  14. java异常和错误相关
  15. git体验
  16. 怎么在Vue的某个组件中根据组件tag标签名获取到对应的VueComponent实例呢
  17. paginate()出来的数据怎样循环插入数据?
  18. python-迭代器、生成器、内置函数及面向过程编程
  19. C# 控制左右声道
  20. Python图形开发之PIL

热门文章

  1. 团队项目第二阶段个人进展——Day10
  2. python_形参何时影响实参
  3. linux基础命令用法
  4. Linux Ubuntu 16.04 初次安装使用总结zzz
  5. Graphviz--图形绘制工具
  6. Java系列2 --- 你真的知道Java的String对象么?
  7. Android SlidingMenu 使用详解
  8. ubuntu16.04开机循环输入密码无法进入桌面的解决办法
  9. Python logger /logging
  10. grpc.go