SetPowerRequirement (advapi32)
Last changed: -130.149.176.185

.
Summary
Set Power Requirement for specified device

C# Signature:

using System.Runtime.InteropServices;
[DllImport("coredll.dll", SetLastError=true)]
static extern int SetPowerRequirement(string DeviceName, DevicePowerState State, uint dwDeviceFlags, string Name, ulong Reserved);

VB Signature:

Declare Function SetPowerRequirement Lib "coredll.dll" Alias "SetPowerRequirement" (ByVal DeviceName As String, ByVal state As DevicePowerState, ByVal dwDeviceFlags As UInteger, ByVal name As String, ByVal Reserved As ULong) As Integer

User-Defined Types:

C#

    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
     }

VB

    Friend Enum DevicePowerState As Integer
    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
    End Enum

Alternative Managed API:

Do you know one? Please contribute it!

Notes:

POWER_NAME parameter needs to be defined; please help!

Seems to be 1

Tips & Tricks:

Please add some!

Sample Code:

public static void setBackLightOn()
{    
    try
    {
        unsafe
        {  
          SetPowerRequirement("BKL1:",DevicePowerState.D0,POWER_NAME,null,0);
        }
    }
    catch ( Exception ex )
    {
        String str = ex.Message;
    }
}

Documentation