<< Click to Display Table of Contents >> Não permitir desligar display |
![]() ![]() ![]() |
public class Teste
{
[DllImport("CoreDll.DLL", SetLastError = true)]
static extern IntPtr SetPowerRequirement(string DeviceName, DevicePowerState State, uint dwDeviceFlags, string Name, ulong Reserved);
[DllImport("CoreDll.DLL", SetLastError = true)]
public static extern uint ReleasePowerRequirement(IntPtr hPowerReq);
private static IntPtr s_hBacklightReq = IntPtr.Zero;
public enum DevicePowerState : int
{
Unspecified = -1,
D0 = 0, // Full On: full power, full functionality
D1, // Low Power On: fully functional at low power/performance
D2, // Standby: partially powered with automatic wake
D3, // Sleep: partially powered with device initiated wake
D4, // Off: unpowered
}
void SetBacklightRequirement(bool fBacklightOn)
{
// The name of the backlight device.
uint POWER_FORCE = 1;
if (fBacklightOn)
{
if (s_hBacklightReq == IntPtr.Zero)
{
// Turn the backlight D2 = partially powered
s_hBacklightReq = SetPowerRequirement("BKL1:", DevicePowerState.D2, POWER_FORCE, null, 0);
}
}
else
{
if (s_hBacklightReq != IntPtr.Zero)
{
ReleasePowerRequirement(s_hBacklightReq);
s_hBacklightReq = IntPtr.Zero;
}
}
}
public void ManterSempreLigado()
{
SetBacklightRequirement(true);
}
public void Restaurar()
{
SetBacklightRequirement(false);
}
}
Veja também