C# Windows CE 6.0背光亮度控制

C# Windows CE 6.0背光亮度控制,c#,compact-framework,embedded,C#,Compact Framework,Embedded,我搜索了一下互联网,找到了一个解决方案,如何将设备亮度从C#code更改。它看起来像: [DllImport("coredll.dll", SetLastError = true)] [return: MarshalAs(UnmanagedType.Bool)] private static extern bool EventModify(IntPtr hEvent, [In, MarshalAs(UnmanagedType.U4)] int dEvent); [Dll

我搜索了一下互联网,找到了一个解决方案,如何将设备亮度从C#code更改。它看起来像:

[DllImport("coredll.dll", SetLastError = true)]
    [return: MarshalAs(UnmanagedType.Bool)]
    private static extern bool EventModify(IntPtr hEvent, [In, MarshalAs(UnmanagedType.U4)] int dEvent);

    [DllImport("coredll.Dll")]
    private static extern IntPtr CreateEvent(IntPtr lpEventAttributes, bool bManualReset, bool bInitialState, string lpName);

    [DllImport("coredll.Dll")]
    [return: MarshalAs(UnmanagedType.Bool)]
    private static extern bool CloseHandle(IntPtr hObject);

    private static bool SetEvent(IntPtr hEvent)
    {
        return EventModify(hEvent, (int)EventFlags.SET);
    }

    private void SetBacklightValue(string name, int v)
    {
        RegistryKey key = Registry.CurrentUser.OpenSubKey(@"ControlPanel\Backlight", true);
        if (key != null)
        {
            key.SetValue(name, v);
            key.Close();
        }
    }

    enum EventFlags
    {
        PULSE = 1,
        RESET = 2,
        SET = 3
    }

    private static void RaiseBackLightChangeEvent()
    {
        IntPtr hBackLightEvent = CreateEvent(IntPtr.Zero, false, false, "BackLightChangeEvent");
        if (hBackLightEvent != IntPtr.Zero)
        {
            bool result = SetEvent(hBackLightEvent);
            CloseHandle(hBackLightEvent);
        }

    }
注册表中的亮度值已成功更改。在我断开设备与PC的连接(或连接)后,亮度也会改变。但不是在设定实际值的时候。 我可能遗漏了什么(RaiseBackLightChangeEvent工作正常,没有错误)。Mb我需要引起一些其他事件?或者,如果没有,我如何模拟设备电源状态的变化而不实际改变它?或者如何强制注册表中的系统更新值?
谢谢你的帮助

背光控制不是标准化的,它因设备而异。在某些设备中,更改注册表就足够了,在其他设备中,您需要触发“命名事件”(您可以使用OpenNetcf),甚至对于那些您仍然需要知道事件名称的设备。对于其他设备,没有这样做的方法。我想您最好的选择是联系目标设备的制造商,询问他们如何处理此问题的详细信息