Click here to Skip to main content
15,886,664 members
Articles / Mobile Apps / Windows Mobile
Tip/Trick

How to programmatically warm boot a Windows CE device

Rate me:
Please Sign up or sign in to vote.
5.00/5 (4 votes)
13 Jan 2015CPOL1 min read 19K   4   3
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)


Written By
Founder Across Time & Space
United States United States
I am in the process of morphing from a software developer into a portrayer of Mark Twain. My monologue (or one-man play, entitled "The Adventures of Mark Twain: As Told By Himself" and set in 1896) features Twain giving an overview of his life up till then. The performance includes the relating of interesting experiences and humorous anecdotes from Twain's boyhood and youth, his time as a riverboat pilot, his wild and woolly adventures in the Territory of Nevada and California, and experiences as a writer and world traveler, including recollections of meetings with many of the famous and powerful of the 19th century - royalty, business magnates, fellow authors, as well as intimate glimpses into his home life (his parents, siblings, wife, and children).

Peripatetic and picaresque, I have lived in eight states; specifically, besides my native California (where I was born and where I now again reside) in chronological order: New York, Montana, Alaska, Oklahoma, Wisconsin, Idaho, and Missouri.

I am also a writer of both fiction (for which I use a nom de plume, "Blackbird Crow Raven", as a nod to my Native American heritage - I am "½ Cowboy, ½ Indian") and nonfiction, including a two-volume social and cultural history of the U.S. which covers important events from 1620-2006: http://www.lulu.com/spotlight/blackbirdcraven

Comments and Discussions

 
QuestionWow Pin
Chris Maunder13-Jan-15 14:22
cofounderChris Maunder13-Jan-15 14:22 
AnswerRe: Wow Pin
B. Clay Shannon13-Jan-15 14:42
professionalB. Clay Shannon13-Jan-15 14:42 
GeneralRe: Wow Pin
trkchk14-Jan-15 6:13
trkchk14-Jan-15 6:13 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.