【问题标题】:Get status of night light mode in Windows 10在 Windows 10 中获取夜灯模式的状态
【发布时间】:2017-09-06 12:39:25
【问题描述】:
【问题讨论】:
标签:
c#
windows-10
desktop-duplication
【解决方案1】:
你可以查看
的输出
GetDeviceGammaRamp
来自 Win API 的函数。将输出与夜灯 ON 和 OFF 进行比较,您应该可以检测到它。
或者您可以尝试监视此 Reg 键的更改
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\CloudStore\Store\Cache\DefaultAccount\$$windows.data.bluelightreduction.settings\Current
【解决方案2】:
此方法适用于 Windows 10 版本 2004
private static bool IsNightLightEnabled()
{
const string BlueLightReductionStateKey = @"SOFTWARE\Microsoft\Windows\CurrentVersion\CloudStore\Store\DefaultAccount\Current\default$windows.data.bluelightreduction.bluelightreductionstate\windows.data.bluelightreduction.bluelightreductionstate";
using (var key = Registry.CurrentUser.OpenSubKey(BlueLightReductionStateKey))
{
var data = key?.GetValue("Data");
if (data is null)
return false;
var byteData = (byte[])data;
return byteData.Length > 24 && byteData[23] == 0x10 && byteData[24] == 0x00;
}
}
【解决方案3】:
我想我找到了反映当前夜灯状态的注册表项。
[HKEY_CURRENT_USER\Control Panel\Quick Actions\Control Center\QuickActionsStateCapture]
"Toggles"="Toggles,...,Microsoft.QuickAction.BlueLightReduction:true,..."
虽然它不是很可靠,因为我认为它要求这个特定的切换应该是可见的......