问题描述
我正在寻找一种调节显示器亮度的方法,该显示器通过HDMI连接到装有Windows IoT核心版的Dragonboard 410c。我读到DCC / CI可以通过HDMI控制亮度,已经在Windows 10计算机上使用称为“ Monitorian”的开源工具进行了测试,该工具可以正常工作。这个工具是用C#编写的,但是依赖于“ DllImport”,我完全没有经验。所以问题是,是否有可能以某种方式控制我的UWP代码的亮度?
为Monitorian使用Windows 10 IoT核心API移植工具
Parsing Users\Dev\Desktop\mon\Monitorian.exe
Unbehandelte Ausnahme: System.DllNotFoundException: Die DLL "sqlite.Interop.dll": Das angegebene Modul wurde nicht gefunden. (Ausnahme von HRESULT: 0x8007007E) kann nicht geladen werden.
bei System.Data.sqlite.UnsafeNativeMethods.sqlite3_config_none(sqliteConfigOpsEnum op)
bei System.Data.sqlite.sqlite3.StaticIsInitialized()
bei System.Data.sqlite.sqliteLog.Initialize()
bei System.Data.sqlite.sqliteConnection..ctor(String connectionString,Boolean parseViaFramework)
bei System.Data.sqlite.sqliteConnection..ctor(String connectionString)
bei IoTAPIPortingTool.Program.ProcessLines(String[] lines,Boolean isUAP,String filename,StringBuilder outputBuilder) in C:\Users\Dev\Desktop\iot-utilities-master\IoTAPIPortingTool\Program.cs:Zeile 213.
bei IoTAPIPortingTool.Program.Main(String[] args) in C:\Users\Dev\Desktop\iot-utilities-master\IoTAPIPortingTool\Program.cs:Zeile 498.
解决方法
Fork Monitorian项目,它在GitHub中,并且已经有P / Invoke您正在寻找!
检查一下:
https://github.com/emoacht/Monitorian/search?q=dllimport
Brightness functions随时可用:
[DllImport("Dxva2.dll",SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
private static extern bool GetMonitorBrightness(
SafePhysicalMonitorHandle hMonitor,out uint pdwMinimumBrightness,out uint pdwCurrentBrightness,out uint pdwMaximumBrightness);
[DllImport("Dxva2.dll",SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
private static extern bool SetMonitorBrightness(
SafePhysicalMonitorHandle hMonitor,uint dwNewBrightness);
如果有任何更改,您也可以重新使用应用程序上的Monitorian.Core项目。
正如其他人所说,P / Invoke并不困难,而且现在您有了一个很好的例子。
注意事项:但是不确定在UWP下这些API的可用性。
编辑:
不支持UWP:
支持的最低客户端Windows Vista [仅桌面应用]
然后尝试另一种方式呢?
Host WinRT XAML controls in desktop apps (XAML Islands)
编辑:
物联网下没有什么Win32支持列表,而是有一个工具:
Windows 10 IoT Core API Porting Tool
Windows 10 IoT核心版仅支持Windows早期版本上可用的Win32和.NET API外围区域的子集。该工具将扫描您的二进制文件,并为您提供这些二进制文件不可用的API的报告,并为可能的替换提供建议。这不仅有助于估计IoT Core的端口成本,而且可以一路为您提供帮助。
因此,请尝试一下它的内容。