MSDOTnet.org Forum Index
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

How to check the power supply

 
Post new topic   Reply to topic    MSDOTnet.org Forum Index -> Compact Framework
Author Message
Michael Meyer



Joined: 10 Feb 2008
Posts: 2

PostPosted: Sun Feb 10, 2008 4:43 pm    Post subject: How to check the power supply Reply with quote

Hi,

I am looking for a possibility to check the power supply of my PDA. I am
using the .netCF 2.0.

Regards

Michael

--
http://www.mchme.de

Archived from group: microsoft>public>dotnet>framework>compactframework
Back to top
View user's profile Send private message
Bjørn_Brox



Joined: 07 Jan 2008
Posts: 2

PostPosted: Sun Feb 10, 2008 4:54 pm    Post subject: Re: How to check the power supply Reply with quote

Michael Meyer skrev:
> Hi,
>
> I am looking for a possibility to check the power supply of my PDA. I am
> using the .netCF 2.0.
>
> Regards
>
> Michael
>
Define "check"?

You can read the BatteryLevel, BatteryState and such using
Microsoft.WindowsMobile.Status

--
Bjørn Brox
Back to top
View user's profile Send private message
Arun



Joined: 08 Aug 2007
Posts: 4

PostPosted: Mon Feb 11, 2008 1:45 pm    Post subject: Re: How to check the power supply Reply with quote

Hi Michael,

Managed code:
You have Microsoft.WindowsMobile.Status

BatteryLevel batteryLevel = SystemState.PowerBatteryStrength;
BatteryState batteryState = SystemState.PowerBatteryState;

string batteryLevelText;
switch (batteryLevel)
{
case BatteryLevel.VeryLow:
batteryLevelText = "Battery Level: Very Low";
break;
case BatteryLevel.Low:
batteryLevelText = "Battery Level: Low";
break;
case BatteryLevel.Medium:
batteryLevelText = "Battery Level: Medium";
break;
case BatteryLevel.High:
batteryLevelText = "Battery Level: High";
break;
case BatteryLevel.VeryHigh:
batteryLevelText = "Battery Level: Very High";
break;
}

string batteryStateText = "Battery State: ";
if ((batteryState & BatteryState.Normal) == BatteryState.Normal)
batteryStateText += "Normal";
if ((batteryState & BatteryState.NotPresent) ==
BatteryState.NotPresent)
batteryStateText += "Not Present";
if ((batteryState & BatteryState.Charging) == BatteryState.Charging)
batteryStateText += "Charging";
if ((batteryState & BatteryState.Low) == BatteryState.Low)
batteryStateText += "Low";
if ((batteryState & BatteryState.Critical) ==
BatteryState.ChargCriticaling)
batteryStateText += "Critical";

Ref: http://msdn2.microsoft.com/en-us/library/aa456240.aspx#yctiwy_snapi_part1_topic3

UnManaged:
[DllImport("coredll.dll", EntryPoint = "GetSystemPowerStatusEx",
SetLastError = true)]
private static extern bool
GetSystemPowerStatusEx(BatteryPowerStatus pStatus, bool flag);

Hope this helps,

Cheers,
Arun


On Feb 10, 2:54 am, Bjørn Brox wrote:
> Michael Meyer skrev:> Hi,
>
> > I am looking for a possibility to check the power supply of my PDA. I am
> > using the .netCF 2.0.
>
> > Regards
>
> > Michael
>
> Define "check"?
>
> You can read the BatteryLevel, BatteryState and such using
> Microsoft.WindowsMobile.Status
>
> --
> Bjørn Brox
Back to top
View user's profile Send private message
Michael Meyer



Joined: 10 Feb 2008
Posts: 2

PostPosted: Tue Feb 12, 2008 5:00 am    Post subject: Re: How to check the power supply Reply with quote

Arun schrieb:
> Hi Michael,
>
> Managed code:
> You have Microsoft.WindowsMobile.Status
>
> BatteryLevel batteryLevel = SystemState.PowerBatteryStrength;
> BatteryState batteryState = SystemState.PowerBatteryState;
>
> string batteryLevelText;
> switch (batteryLevel)
> {
> case BatteryLevel.VeryLow:
> batteryLevelText = "Battery Level: Very Low";
> break;
> case BatteryLevel.Low:
> batteryLevelText = "Battery Level: Low";
> break;
> case BatteryLevel.Medium:
> batteryLevelText = "Battery Level: Medium";
> break;
> case BatteryLevel.High:
> batteryLevelText = "Battery Level: High";
> break;
> case BatteryLevel.VeryHigh:
> batteryLevelText = "Battery Level: Very High";
> break;
> }
>
> string batteryStateText = "Battery State: ";
> if ((batteryState & BatteryState.Normal) == BatteryState.Normal)
> batteryStateText += "Normal";
> if ((batteryState & BatteryState.NotPresent) ==
> BatteryState.NotPresent)
> batteryStateText += "Not Present";
> if ((batteryState & BatteryState.Charging) == BatteryState.Charging)
> batteryStateText += "Charging";
> if ((batteryState & BatteryState.Low) == BatteryState.Low)
> batteryStateText += "Low";
> if ((batteryState & BatteryState.Critical) ==
> BatteryState.ChargCriticaling)
> batteryStateText += "Critical";
>
> Ref: http://msdn2.microsoft.com/en-us/library/aa456240.aspx#yctiwy_snapi_part1_topic3
>
> UnManaged:
> [DllImport("coredll.dll", EntryPoint = "GetSystemPowerStatusEx",
> SetLastError = true)]
> private static extern bool
> GetSystemPowerStatusEx(BatteryPowerStatus pStatus, bool flag);
>
> Hope this helps,
>
> Cheers,
> Arun
>
>
> On Feb 10, 2:54 am, Bjørn Brox wrote:
>> Michael Meyer skrev:> Hi,
>>
>>> I am looking for a possibility to check the power supply of my PDA. I am
>>> using the .netCF 2.0.
>>> Regards
>>> Michael
>> Define "check"?
>>
>> You can read the BatteryLevel, BatteryState and such using
>> Microsoft.WindowsMobile.Status
>>
>> --
>> Bjørn Brox
>

Thanks for your help.

Michael


--
http://www.mchme.de

Back to top
View user's profile Send private message
Display posts from previous:   
Related Topics:
Power Management and remoting Okay, here's a good question for you experts. I have a server that I want to have use power management - if the server has not been used for a while, it hibernates. The server already has code to add an event to the scheduler so that it can wake itself u

NIC Power Management features issue I need to enable the NIC Power Management features on Windows XP workstations (and later Windows Vista too...!!) so that I can use Wake On Lan I considered using a simple reg hack to do this, but before and after registry snapshots reveals

How to shorten startup time on low power machine? I've to run .net applications on a low power machine (366mhz and 96mb ram!). Unfortunately this application needs about 23 seconds to startup, which isn't acceptable. The app uses a custom library which in turn uses DirectX9 managed extensions. This libra

Check this out DataAdapter. Hi NG members, Has anyone out here tried to carry out some Stress test on Guys try this. Simple query with 1 or 2 joins Tables not having more than 1K records. Use da.Fill(ds) Bind a table to some grid. No fancy stuff --- You will noti

Best way t check/close a connection I am looking for suggestions on how to conditionaly check if a database connection has been opened and to close it if it is. For Example, I have a page that validates a querystring. If the query string is valid I open a connection to a database using an O
Post new topic   Reply to topic    MSDOTnet.org Forum Index -> Compact Framework All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group