Hintergrundbeleuchtung

08/09/2007 - 08:33 von klaudiusz.bk | Report spam
Hallo
Ich schreibe ein c#-Programm, das die GPS-Daten auf meinem MDA II
Compact aufzeichnet. Weil das MDA in der Hosentasche bleiben soll,
muss ich die Beleuchtung ausschalten. Ich habe mit
[DllImport("coredll.dll", SetLastError = true)]
private static extern IntPtr SetPowerRequirement(string pvDevice,
PowerState eviceState,
uint DeviceFlags,
IntPtr pvSystemState,
uint StateFlags);
und dann:
SetPowerRequirement("BKL1:", D0, 1, IntPtr.Zero, 0);
versucht, leider ohne Erfolg.
Kennt jemand eine Lösung für mein Problem.
Gruß und danke
Klaudiusz
 

Lesen sie die antworten

#1 Frank Dzaebel
08/09/2007 - 09:51 | Warnen spam
Hallo Klaudiusz,

ist hier nicht das richtige Forum für CF.

Ich schreibe ein c#-Programm, das die GPS-Daten auf meinem MDA II
Compact aufzeichnet. Weil das MDA in der Hosentasche bleiben soll,
muss ich die Beleuchtung ausschalten.



Ich *vermute*, es könnte mit folgendem gehen:

private void button1_Click(object sender, EventArgs e)
{
PowerPolicyNotify(PPN.UNATTENDEDMODE, 1);
int ret = SetSystemPowerState(null, Power_State.SUSPEND, Power.FORCE);
}

#region SetSystemPowerState

[DllImport("coredll.dll")]
private static extern bool PowerPolicyNotify(PPN dwMessage, int dwData);

[DllImport("coredll.dll")]
static extern int SetSystemPowerState(string psState,
Power_State StateFlags, Power Options);

///
<summary>http://msdn2.microsoft.com/en-us/li...ummary>
public enum PPN
{
/// <summary>Reserved. Set dwData to zero.</summary>
REEVALUATESTATE = 0x0001,

/// <summary>Reserved. Set dwData to zero.</summary>
POWERCHANGE = 0x0002,

/// <summary>Reserved. Set dwData to zero.</summary>
SUSPENDKEYPRESSED = 0x0004,

/// <summary>Reserved. Set dwData to zero.</summary>
SUSPENDKEYRELEASED = 0x0005,

/// <summary>Reserved. Set dwData to zero.</summary>
APPBUTTONPRESSED = 0x0006,

/// <summary>Reserved. Set dwData to zero.</summary>
POWERBUTTONPRESSED = PPN.SUSPENDKEYPRESSED,

/// <summary>Set dwData to 1 or 0</summary>
UNATTENDEDMODE = 0x0003,

/// <summary>Reserved. Set dwData to zero.
/// These values are only revelant for OEM-
/// modified power management.</summary>
OEMBASE = 0x10000
}

public enum Power_State
{
/// <summary>Highest functional level and highest
/// power consumption.</summary>
ON = 0x00010000,

/// <summary>All devices are off. Resuming from
/// this state results in a cold boot. You can use
/// this state to prepare a device for shipping
/// without depleting the battery.</summary>
OFF = 0x00020000,

/// <summary>Battery is critically low. Carry out
/// required system maintenance, then dump power to
/// devices and put DRAM into a self-refresh state.
/// Resuming from this state results in a cold boot.</summary>
CRITICAL = 0x00040000,

/// <summary>System is in the process of booting.</summary>
BOOT = 0x00080000,

/// <summary>No devices are in use and there is no user
/// interaction. All devices should enter a low-power
/// state as well as a low-power system mode. You can
/// use this as an alternative to suspending the
/// system if the power saved from the low-power
/// mode is satisfactory.</summary>
IDLE = 0x00100000,

/// <summary>Suspend the OS and ultimately call
/// OEMPowerOff.</summary>
SUSPEND = 0x00200000,

/// <summary></summary>
UNATTENDED = 0x00400000,

/// <summary>Flush files, shut down devices and call
/// KernelIoControl.</summary>
RESET = 0x00800000,
USERIDLE = 0x01000000,
PASSWORD = 0x10000000
}

public enum Power
{
/// <summary></summary>
NAME = 0x00000001,
/// <summary></summary>
FORCE = 0x00001000,
/// <summary>Macht einen Watson Dump</summary>
DUMPDW = 0x00002000
}

#endregion


ciao Frank
Dipl.Inf. Frank Dzaebel [MCP/MVP C#]
http://Dzaebel.NET

Ähnliche fragen