G
gwatts
Hi,
I just did a great deal of searching to figure out that the device
name for the backlight is BKL1: (I've appended code if you want to keep
it on with the power manager). But it occurs to me that the backlight
device name is arbitrary. I'm just lucky my phone used the same name
(right?). Further, this must hold true for all devices. I'm curious.
How do I find out the names of all the devices known to my smartphone's
OS?
Cheers,
Gordon.
P.S. Code showing how to turn it on/off can be found
here:http://www.peterfoot.net/KeepYourSmartphoneBacklightOn.aspx (in
VB), Or in C# the code I ended up writing:
[DllImport("coredll.dll")]
static extern bool PowerPolicyNotify(
UInt32 dwMessage,
UInt32 dwData
);
[DllImport("coredll.dll", SetLastError = true,
CharSet=CharSet.Unicode)]
static extern IntPtr SetPowerRequirement(
string device_name,
CEDEVICE_POWER_STATE DeviceState,
UInt32 DeviceFlags,
string pvSystemState,
UInt32 StateFlags);
enum CEDEVICE_POWER_STATE : int
{
PwrDeviceUnspecified = -1,
D0 = 0, // Full on
D1, // Low power on, fully functional at low
D2, // Standby: partially owered with automatic wake
D3, // Sleep: partially powered with device initaited wake
D4, // Off: Unpowered.
PwrDeviceMaximum
}
public const int POWER_NAME = 0x00000001;
Code:
private IntPtr _power_hold;
On:
_power_hold = SetPowerRequirement("BKL1:",
CEDEVICE_POWER_STATE.D0,
POWER_NAME, null, 0);
Off: (should do error checking!)
ReleasePowerRequirement(_power_hold);
I just did a great deal of searching to figure out that the device
name for the backlight is BKL1: (I've appended code if you want to keep
it on with the power manager). But it occurs to me that the backlight
device name is arbitrary. I'm just lucky my phone used the same name
(right?). Further, this must hold true for all devices. I'm curious.
How do I find out the names of all the devices known to my smartphone's
OS?
Cheers,
Gordon.
P.S. Code showing how to turn it on/off can be found
here:http://www.peterfoot.net/KeepYourSmartphoneBacklightOn.aspx (in
VB), Or in C# the code I ended up writing:
[DllImport("coredll.dll")]
static extern bool PowerPolicyNotify(
UInt32 dwMessage,
UInt32 dwData
);
[DllImport("coredll.dll", SetLastError = true,
CharSet=CharSet.Unicode)]
static extern IntPtr SetPowerRequirement(
string device_name,
CEDEVICE_POWER_STATE DeviceState,
UInt32 DeviceFlags,
string pvSystemState,
UInt32 StateFlags);
enum CEDEVICE_POWER_STATE : int
{
PwrDeviceUnspecified = -1,
D0 = 0, // Full on
D1, // Low power on, fully functional at low
D2, // Standby: partially owered with automatic wake
D3, // Sleep: partially powered with device initaited wake
D4, // Off: Unpowered.
PwrDeviceMaximum
}
public const int POWER_NAME = 0x00000001;
Code:
private IntPtr _power_hold;
On:
_power_hold = SetPowerRequirement("BKL1:",
CEDEVICE_POWER_STATE.D0,
POWER_NAME, null, 0);
Off: (should do error checking!)
ReleasePowerRequirement(_power_hold);