We help IT Professionals succeed at work.

backlight

mk39
mk39 asked
on
Hi,

Is there any way to change backlight turn off time using programming(Preferred  c# or vb.net other c++ can be used too)? I guess, may be it is changed using registry info.

Manually, it is done by:

Setting > Backlight (Battery Power and External Power)

Thank you
Comment
Watch Question

Most Valuable Expert 2011
Top Expert 2015

Commented:

Author

Commented:
I tried it, but it is not changing time for backlight. Please help me to change backlight time.

Thank  you
public void SetBrightness(int level)
{

RegistryKey key = Registry.CurrentUser.CreateSubKey("ControlPanel\\Backlight");
key.SetValue("ACBrightNess", level);            
key.SetValue("BrightNess",level);

CoreDLL.SendEvent("BackLightChangeEvent");
}
public static class CoreDLL {
        [DllImport("CoreDll.dll")] private static extern IntPtr CreateEvent(
            string lpEventAttributes, bool bManualReset, bool bInitialState, string lpName);

        private enum EventModification {
            Pulse = 1,
            Reset = 2,
            Set = 3
        }

        [DllImport("coredll.dll")] private static extern Int32 EventModify(
            IntPtr hEvent, EventModification mod);

        [DllImport("coredll.dll")] private static extern Int32 CloseHandle(IntPtr h);

        public static void SendEvent(string evtName) {
            IntPtr evt = CreateEvent(null, false, true, evtName);
            if (evt == IntPtr.Zero) throw new InvalidOperationException("Failed to create event");
            try {
                EventModify(evt, EventModification.Pulse);
            } finally {
                CloseHandle(evt);
            }
        }
    }

Author

Commented:
After changing registry, why you have used
CoreDLL.SendEvent("BackLightChangeEvent");

Is it necessary?
 
Than you
To referesh the settings

Author

Commented:
What should be namespace for CoreDLL?
its gonna be a class in your existing class. So whatever your classname is. ClassName.CoreDLL.SendEvent

Author

Commented:
sorry, silly question, I got it
thanks
no problem

Author

Commented:
I tried it, I can see change in registry but it is not applied as it is changed.

How can I force it to apply immediately?

Thank you