RegistryKey CUser = Registry.CurrentUser;
RegistryKey Backlight = CUser.OpenSubKey("ControlPanel\\Backlight", true);
return (int)Backlight.GetValue("Brightness", RegistryValueKind.DWord);
public static void SetBackLightValue(string strValue)
RegistryKey hkcu = Registry.CurrentUser;
RegistryKey Backlight = hkcu.OpenSubKey("ControlPanel\\Backlight", true);
Backlight.SetValue("Brightness", strValue, RegistryValueKind.DWord);
catch (Exception ex)
System.Diagnostics.Debug.WriteLine(ex.Message);
public static bool ReloadBackLight()
bool ret = false;
IntPtr scanEvent = NativeWin.CreateEvent(IntPtr.Zero, false, false, "BackLightChangeEvent");
if (scanEvent == null)
throw new Exception("CreateEvent失败");
NativeWin.EventModify(scanEvent, EventFlags.SET);
NativeWin.CloseHandle(scanEvent);
ret = true;
return ret;
partial class NativeWin
[DllImport("coredll.dll", SetLastError = true, CharSet = CharSet.Auto)]
internal static extern IntPtr CreateEvent(IntPtr lpEventAttributes, [In, MarshalAs(UnmanagedType.Bool)] bool bManualReset, [In, MarshalAs(UnmanagedType.Bool)] bool bIntialState, [In, MarshalAs(UnmanagedType.BStr)] string lpName);
[DllImport("coredll.dll", SetLastError = true, CharSet = CharSet.Auto)]
[return: MarshalAs(UnmanagedType.Bool)]
internal static extern bool CloseHandle(IntPtr hObject);
[DllImport("coredll.dll", SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
internal static extern bool EventModify(IntPtr hEvent, [In, MarshalAs(UnmanagedType.U4)] EventFlags dEvent);
enum EventFlags : int
PULSE = 1,
RESET = 2,
SET = 3
wince
中的背光灯控制 要控制背光灯就必须知道相关设置,以下是
wince
中背光灯的设置。在BL_ReadRegistry函数中被读取。[HKEY_CURRENT_USER/ControlPanel/BackLight] "ACTimeout"=dword:0000012c ; 外
<br />应用
调节
亮度
常用的方法有如下两种:<br />一、利用IOCTL:<br />在背光驱动的IOCTL里面增加
调节
背光
亮度
的IOCTL,如下:<br />case IOCTL_BACKLIGHT_ADJUST:<br /> //获取应用传递过来的参数<br /> //
调节
PWM值<br />case IOCTL_BACKLIGHT_GETLEVEL://这个主要用来查询当前背光
亮度
。<br /> //传送出背光的当前
亮度
。<br />在应用程序里面通过deviceiocontrol 传递个参
; *****************************************************************************************************; *** This file is provided to configure the defaults for Contrast and Backlight settings.
有2种方法,一是直接调用API,二是修改
注册表
直接调用API,需要设备厂家的手册,或者查看
注册表
的 HKEY_LOCAL_MACHINE\\Drivers\\BuiltIn\\BackLite 项
修改
注册表
,
注册表
的键值也是不同的,根据设备来定
废话不多说,直接上代码
注册表
方式
using Microsoft.Win32;
using