Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / Mobile / WinMobile

How to programmatically warm boot a Windows CE device

5.00/5 (4 votes)
13 Jan 2015CPOL1 min read 19.6K  
Simple way to warm boot a Windows CE device

Happiness is a Warm Boot

As the Beatles famously sang, happiness is a warm boot (or something to that effect, after a fashion). Sometimes you need to revel in this type of happiness with a handheld device.

Do you want to go the Hard Way, or the Easy Way?

There are two ways to warm boot a Windows CE device: You can do it manually, using the device, by simultaneously pressing eleven different keys (you will have to use one of your toes - I find that it's too easy to "fat toe" the device if you use your big toe, so I recommend the "this-little-piggy-went-whee-whee-whee-all-the-way-home" toe) while holding your breath and spelling "Sit on a potato pan Otis" backwards in a French accent as you are wearing a grey-green wig, OR! ... you can do it programatically.

Note: Contrary to unpopular opinion, it is not the "this-little-piggy-went-wee-wee-all-the-way-home" toe.

I find it considerably more convenient to do it programatically. You can do so in three easy steps:

0) Add a submenu item, perhaps to a Help menu, named WarmBoot

1) Add these declarations to the form:

C#
[System.Runtime.InteropServices.DllImport("coredll.dll")]
private static extern Int32 SetSystemPowerState(Char[] psState, Int32 StateFlags, Int32 Options);

2) Add the following code to the menu item's click event.

C#
private void menuItemHELP_WarmBoot_Click(object sender, EventArgs e)
{
    const int POWER_STATE_RESET = 0x800000;
    SetSystemPowerState(null, POWER_STATE_RESET, 0);
}

Voila! You can now warm boot until the cows come home (by which time you'll probably be heading home, too, and for the same reason the little dogies do).

Note: This code was adapted from here

I say adapted (not "stolen") because that code won't compile, as the C# code there doesn't seem to have been tested. To get it to compile, it needs to be "private static extern Int32 SetSystemPowerState(Char[] psState, Int32 StateFlags, Int32 Options);" (needs "static extern") and "SetSystemPowerState(null, POWER_STATE_RESET, 0);" (null, not nothing)

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)