Performing a Hard Reset through Software in C++
CESD-D-0007
Applies To:
- Windows CE 2.11
- Windows CE 3.0
- Windows CE 4.x .net
Overview:
For the majority of users performing a Hard Reset involves powering down the
device, removing all battery cells and leaving the device uninitialised for
several minutes.
This article outlines a programmatic approach to Hard Resetting a Handheld PC
by using software.
More Info:
The code below demonstrates how to flush the RAM contents and reinitialise
a Windows CE hard boot using C++
#include <windows.h>
#include <winioctl.h>
#define IOCTL_HAL_REBOOT CTL_CODE(FILE_DEVICE_HAL, 15, METHOD_BUFFERED, FILE_ANY_ACCESS)
extern "C" __declspec(dllimport)void SetCleanRebootFlag(void);
extern "C" __declspec(dllimport) BOOL KernelIoControl(
DWORD dwIoControlCode,
LPVOID lpInBuf,
DWORD nInBufSize,
LPVOID lpOutBuf,
DWORD nOutBufSize,
LPDWORD lpBytesReturned);
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPTSTR lpCmdLine, int
nCmdShow)
{
SetCleanRebootFlag();
KernelIoControl(IOCTL_HAL_REBOOT,
NULL, 0, NULL, 0, NULL);
return
0;
}
Acknowledgements:
With thanks to Monica Erdody for assisting us with this article.
|