http://windowsmobiledn.com/qa-how-can-i-soft-reset-pocket-pc-device/
[code]
#include <winioctl.h>
void SoftReset();
extern "C" __declspec(dllimport) BOOL KernelIoControl(DWORD dwIoControlCode, LPVOID lpInBuf, DWORD nInBufSize, LPVOID lpOutBuf, DWORD nOutBufSize, LPDWORD lpBytesReturned);
static void ResetWithExitWindows()
{
HMODULE hModule = ::LoadLibrary(TEXT("aygshell.dll"));
typedef BOOL (*ExitWindowsExFunction)(UINT uFlags, DWORD dwReserved);
ExitWindowsExFunction f = (ExitWindowsExFunction)::GetProcAddress(hModule, TEXT("ExitWindowsEx"));
#ifndef EWX_REBOOT
#define EWX_REBOOT 2
#endif
f(EWX_REBOOT, 0);
FreeLibrary(hModule);
}
static void ResetWithSetSystemPowerState()
{
typedef DWORD (*SetSystemPowerStateFunction)(LPCWSTR pwsSystemState, DWORD StateFlags, DWORD Options);
HMODULE hModule = ::LoadLibrary(TEXT("Coredll.dll"));
SetSystemPowerStateFunction f = (SetSystemPowerStateFunction)
::GetProcAddress(hModule, TEXT("SetSystemPowerState"));
#ifndef POWER_STATE_RESET
#define POWER_STATE_RESET DWORD(0x00800000)
#endif
if(NULL, POWER_STATE_RESET, 0);
::FreeLibrary(hModule);
}
static void ResetWithKernelIoControl()
{
#ifndef IOCTL_HAL_REBOOT
#define IOCTL_HAL_REBOOT CTL_CODE(FILE_DEVICE_HAL, 15, METHOD_BUFFERED, FILE_ANY_ACCESS)
#endif
KernelIoControl(IOCTL_HAL_REBOOT, NULL, 0, NULL, 0, NULL);
}
void SoftReset()
{
OSVERSIONINFO vi;
memset(&vi, 0, sizeof(vi));
vi.dwOSVersionInfoSize = sizeof(vi);
VERIFY(GetVersionEx(&vi));
if (vi.dwMajorVersion >= 5) {
ResetWithExitWindows();
} else if (vi.dwMajorVersion==4 && vi.dwMinorVersion>=20) {
ResetWithSetSystemPowerState();
} else {
ResetWithKernelIoControl();
}
}
[/code]
[code]
#include <winioctl.h>
void SoftReset();
extern "C" __declspec(dllimport) BOOL KernelIoControl(DWORD dwIoControlCode, LPVOID lpInBuf, DWORD nInBufSize, LPVOID lpOutBuf, DWORD nOutBufSize, LPDWORD lpBytesReturned);
static void ResetWithExitWindows()
{
HMODULE hModule = ::LoadLibrary(TEXT("aygshell.dll"));
typedef BOOL (*ExitWindowsExFunction)(UINT uFlags, DWORD dwReserved);
ExitWindowsExFunction f = (ExitWindowsExFunction)::GetProcAddress(hModule, TEXT("ExitWindowsEx"));
#ifndef EWX_REBOOT
#define EWX_REBOOT 2
#endif
f(EWX_REBOOT, 0);
FreeLibrary(hModule);
}
static void ResetWithSetSystemPowerState()
{
typedef DWORD (*SetSystemPowerStateFunction)(LPCWSTR pwsSystemState, DWORD StateFlags, DWORD Options);
HMODULE hModule = ::LoadLibrary(TEXT("Coredll.dll"));
SetSystemPowerStateFunction f = (SetSystemPowerStateFunction)
::GetProcAddress(hModule, TEXT("SetSystemPowerState"));
#ifndef POWER_STATE_RESET
#define POWER_STATE_RESET DWORD(0x00800000)
#endif
if(NULL, POWER_STATE_RESET, 0);
::FreeLibrary(hModule);
}
static void ResetWithKernelIoControl()
{
#ifndef IOCTL_HAL_REBOOT
#define IOCTL_HAL_REBOOT CTL_CODE(FILE_DEVICE_HAL, 15, METHOD_BUFFERED, FILE_ANY_ACCESS)
#endif
KernelIoControl(IOCTL_HAL_REBOOT, NULL, 0, NULL, 0, NULL);
}
void SoftReset()
{
OSVERSIONINFO vi;
memset(&vi, 0, sizeof(vi));
vi.dwOSVersionInfoSize = sizeof(vi);
VERIFY(GetVersionEx(&vi));
if (vi.dwMajorVersion >= 5) {
ResetWithExitWindows();
} else if (vi.dwMajorVersion==4 && vi.dwMinorVersion>=20) {
ResetWithSetSystemPowerState();
} else {
ResetWithKernelIoControl();
}
}
[/code]
'Windows > MFC' 카테고리의 다른 글
HOWTO: Change Default Font in WM6 (0) | 2013.10.02 |
---|---|
IT trend 2010 (0) | 2013.10.02 |
unread sms, email (0) | 2013.10.02 |
Windows Mobile 6.1: Disable Internet Explorer 6 (0) | 2013.10.02 |
Changing the System Font & Adding Korean Support (0) | 2013.10.02 |