添加链接
link之家
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
#region 屏幕亮度
[DllImport("dxva2.dll")]
public static extern bool SetMonitorBrightness(IntPtr hMonitor, short brightness);
[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 GetNumberOfPhysicalMonitorsFromHMONITOR(IntPtr hMonitor,
    ref uint pdwNumberOfPhysicalMonitors);
[DllImport("dxva2.dll")]
public static extern bool GetPhysicalMonitorsFromHMONITOR(IntPtr hMonitor,
    uint dwPhysicalMonitorArraySize, [Out] PhysicalMonitor[] pPhysicalMonitorArray);
[DllImport("user32.dll")]
public static extern IntPtr MonitorFromWindow([In] IntPtr hwnd, uint dwFlags);
#endregion
/// <summary>
/// 物理常量
/// </summary>
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct PhysicalMonitor
    public IntPtr hPhysicalMonitor;
    [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 128)]
    public string szPhysicalMonitorDescription;
/// <summary>
/// 设置屏幕亮度
/// </summary>
/// <param name="handle">所在屏幕窗口的句柄</param>
/// <param name="brightness">亮度</param>
/// <returns></returns>
public static bool SetBrightness(IntPtr handle, short brightness)
    if (handle == IntPtr.Zero)
        return false;
    uint pdwNumberOfPhysicalMonitors = uint.MinValue;
    //获取屏幕所在的屏幕设备
    var hMonitor = MonitorFromWindow(handle, 1);
    GetNumberOfPhysicalMonitorsFromHMONITOR(hMonitor, ref pdwNumberOfPhysicalMonitors);
    var screen = new PhysicalMonitor[pdwNumberOfPhysicalMonitors];
    GetPhysicalMonitorsFromHMONITOR(hMonitor, pdwNumberOfPhysicalMonitors, screen);
    return screen.Length <= 0 ? false : SetMonitorBrightness(screen[0].hPhysicalMonitor, brightness);
/// <summary>
/// 得到屏幕亮度参数
/// </summary>
/// <param name="handle">所在屏幕窗口的句柄</param>
/// <param name="minBrightness">最小亮度</param>
/// <param name="currentBrightness">当前亮度</param>
/// <param name="maxBrightness">最大亮度</param>
/// <returns></returns>
public static bool GetBrightness(IntPtr handle, ref short minBrightness,
    ref short currentBrightness,
    ref short maxBrightness)
    if (handle == IntPtr.Zero)
        return false;
    uint pdwNumberOfPhysicalMonitors = uint.MinValue;
    //获取屏幕所在的屏幕设备
    var hMonitor = MonitorFromWindow(handle, 1);
    GetNumberOfPhysicalMonitorsFromHMONITOR(hMonitor, ref pdwNumberOfPhysicalMonitors);
    var screen = new PhysicalMonitor[pdwNumberOfPhysicalMonitors];
    GetPhysicalMonitorsFromHMONITOR(hMonitor, pdwNumberOfPhysicalMonitors, screen);
    return screen.Length <= 0 ? false : GetMonitorBrightness(screen[0].hPhysicalMonitor, ref minBrightness,
        ref currentBrightness,
        ref maxBrightness);
DialogTool.SetBrightness(this.Handle, 45);
short minBrightness = 0;
short currentBrightness = 0;
short maxBrightness = 0;
DialogTool.GetBrightness(this.Handle,
    ref minBrightness,
    ref currentBrightness,
    ref maxBrightness);
Trace.WriteLine($"最小:{minBrightness},当前亮度:{currentBrightness},最大亮度:{maxBrightness}");
C#读取和调节屏幕亮度,注意是亮度,不是对比度! ObjectQuery query = new ObjectQuery("SELECT * FROM WmiMonitorBrightness");//读取 new Object[] { UInt32.MaxValue, targetBrightness });//设置
[code="java"]WindowManager.LayoutParams lp = getWindow().getAttributes(); lp.screenBrightness = 1.0f; getWindow().setAttributes(lp); [/code]
Github:https://github.com/CHNMaxGor/AjustScreenBrightness 方法一: 使用网上常说的 Gdi32.dll 下的 SetDeviceGammaRamp (修改系统Gamma) DllImport("gdi32.dll")] public static extern bool GetDeviceGammaRamp(In...
private void GetScreenLight() ManagementScope scope = new ManagementScope("\\\\.\\ROOT\\WMI"); //create object query ObjectQuery query = new ObjectQuery("SELECT * FROM WmiMonitorBrightness");
SetBrightness(int.Parse(statics));//参数是亮度参数 [DllImport("gdi32.dll")] private unsafe static extern bool SetDeviceGammaRamp(Int32 hdc, void* ramp); private static bool initialized = fa...
try { IPowerManager power = IPowerManager.Stub.asInterface( ServiceManager.getService("power")); if (power != null) { power.setB...
win32project1_ffmpeg_dxva2.zip是一个开源的Win32工程,使用了FFmpeg和DXVA2技术。FFmpeg是一个开放源代码的跨平台音视频处理框架,它支持大量的音视频格式,包括了编解码、解码、流媒体传输等功能。DXVA2是DirectX Video Acceleration 2,是一种硬件加速技术,可以提高视频解码的效率和播放的流畅性。 这个工程基于FFmpeg和DXVA2技术,实现了一个简单的视频播放器。使用DXVA2技术可以加速视频的解码,解决了传统软件解码的卡顿和占用CPU资源的问题。同时,使用FFmpeg作为音视频框架,可以支持大量的媒体格式,实现多种媒体文件的播放。 这个工程源代码开放,可以通过Visual Studio进行编译和调试。对于需要实现视频播放的开发者,可以使用这个工程作为参考,了解视频播放的相关知识和技术,实现更高效、稳定的视频播放器。
CSDN-Ada助手: 恭喜你写出了关于nacos注册中心单机启动的博客,很详细,让人受益匪浅。接下来,我建议你可以探讨一下nacos注册中心的集群搭建和使用技巧,这对于实际应用场景会更有帮助。希望你能一直保持这样的创作热情,继续分享你的经验和知识。 CSDN 会根据你创作的前四篇博客的质量,给予优秀的博主博客红包奖励。请关注 https://bbs.csdn.net/forums/csdnnews?typeId=116148 看奖励名单。 mac 启动sentinel CSDN-Ada助手: 恭喜你写了第三篇博客,标题很有吸引力呢!看到你对mac启动sentinel的分享,我也学到了不少。下一步建议可以考虑分享一些sentinel的实际应用案例,或者深入探讨一些sentinel的高级用法,这样可以让读者更加了解这个工具的实际价值。期待你的下一篇文章! CSDN 正在通过评论红包奖励优秀博客,请看红包流:https://bbs.csdn.net/?type=4&header=0&utm_source=ada,我们会奖励持续创作和学习的博主,请看:https://bbs.csdn.net/forums/csdnnews?typeId=116148