代码实现屏幕亮度最亮

什么名字呀 2017-08-29 05:34:02
如何用代码实现屏幕亮度最亮,setDeviceGammaRamp()这个不能达到要求,只能在目前亮度基础上实现调节暗,最亮就是目前亮度,所以应该如何实现调节屏幕亮度置最亮
...全文
380 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
zwfgdlc 2017-08-30
  • 打赏
  • 举报
回复
https://msdn.microsoft.com/en-us/library/dd692972(v=vs.85).aspx
BOOL SetMonitorBrightness(
  _In_  HANDLE hMonitor,
  _In_  DWORD dwNewBrightness
);
zwfgdlc 2017-08-30
  • 打赏
  • 举报
回复

	LPPHYSICAL_MONITOR pPhysicalMonitorArray = 0;
	DWORD dwNumberOfPhysicalMonitors;

	HMONITOR hMonitor = MonitorFromWindow(FindWindow(NULL, L"Program Manager"), MONITOR_DEFAULTTOPRIMARY);
	GetNumberOfPhysicalMonitorsFromHMONITOR(hMonitor, &dwNumberOfPhysicalMonitors);
	pPhysicalMonitorArray = (LPPHYSICAL_MONITOR)malloc(dwNumberOfPhysicalMonitors * sizeof(PHYSICAL_MONITOR));
	GetPhysicalMonitorsFromHMONITOR(hMonitor, dwNumberOfPhysicalMonitors, pPhysicalMonitorArray);

	DWORD dwMin = 0, dwMax = 0, dwCur = 0;
	GetMonitorBrightness(pPhysicalMonitorArray[0].hPhysicalMonitor, &dwMin, &dwCur, &dwMax);
	printf("MonitorBrightness: Min=%d, Max=%d, Cur=%d\n", dwMin, dwMax, dwCur);
	SetMonitorBrightness(pPhysicalMonitorArray[0].hPhysicalMonitor, 80);
	free(pPhysicalMonitorArray);
什么名字呀 2017-08-30
  • 打赏
  • 举报
回复
引用 3 楼 zwfgdlc 的回复:
https://msdn.microsoft.com/en-us/library/dd692972(v=vs.85).aspx
BOOL SetMonitorBrightness(
  _In_  HANDLE hMonitor,
  _In_  DWORD dwNewBrightness
);
HMONITOR hMonitor= NULL; DWORD cPhysicalMonitors; LPPHYSICAL_MONITOR pPhysicalMonitors= NULL; //HWND hWnd=GetDesktopWindow(); HWND hWnd = ::FindWindow(NULL,NULL); hMonitor= MonitorFromWindow(hWnd, MONITOR_DEFAULTTOPRIMARY); if (!GetNumberOfPhysicalMonitorsFromHMONITOR(hMonitor, &cPhysicalMonitors)) { return 1; } pPhysicalMonitors=(LPPHYSICAL_MONITOR)malloc(cPhysicalMonitors*sizeof(PHYSICAL_MONITOR)); if (pPhysicalMonitors==NULL) { return 1; } // Get the array.  if (!GetPhysicalMonitorsFromHMONITOR(hMonitor, cPhysicalMonitors, pPhysicalMonitors)) //获得的 pPhysicalMonitors句柄值为空,描述不为空 GetLastError(); return 1; } // Use the monitor handles .   if (!SetMonitorBrightness(pPhysicalMonitors, 100))              //无效监视器句柄 { DWORD D = GetLastError(); return 1; } // Close the monitor handles.   DestroyPhysicalMonitors(cPhysicalMonitors,pPhysicalMonitors); // Free the array.   free(pPhysicalMonitors);
什么名字呀 2017-08-30
  • 打赏
  • 举报
回复
HMONITOR hMonitor= NULL; DWORD cPhysicalMonitors; LPPHYSICAL_MONITOR pPhysicalMonitors= NULL; //HWND hWnd=GetDesktopWindow(); HWND hWnd = ::FindWindow(NULL,NULL); hMonitor= MonitorFromWindow(hWnd, MONITOR_DEFAULTTOPRIMARY); if (!GetNumberOfPhysicalMonitorsFromHMONITOR(hMonitor, &cPhysicalMonitors)) { return 1; } pPhysicalMonitors=(LPPHYSICAL_MONITOR)malloc(cPhysicalMonitors*sizeof(PHYSICAL_MONITOR)); if (pPhysicalMonitors==NULL) { return 1; } // Get the array.  if (!GetPhysicalMonitorsFromHMONITOR(hMonitor, cPhysicalMonitors, pPhysicalMonitors)) { GetLastError(); return 1; } // Use the monitor handles .   if (!SetMonitorBrightness(pPhysicalMonitors, 100)) //无效监视器句柄 { DWORD D = GetLastError(); return 1; } // Close the monitor handles.   DestroyPhysicalMonitors(cPhysicalMonitors,pPhysicalMonitors); // Free the array.   free(pPhysicalMonitors);
xiaohuh421 2017-08-29
  • 打赏
  • 举报
回复
显示器亮度, 是硬件决定的, 应该不会开放接口来设置吧. 你只能在物理显示器上设置的亮度值, 往下调.
赵4老师 2017-08-29
  • 打赏
  • 举报
回复
百度搜相关关键字。

64,654

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧