Address: http://blog.sina.com.cn/s/blog_6215c3760100fc2s.html
Kerneliocontrol is an undisclosed function. Therefore, we need to declare that many undisclosed methods are used in the following example. Therefore, we need to declare them before use: # define ctl_code (devicetype, function, method, access) (devicetype) <16) | (ACCESS)
<14) | (function) <2) | (method ))
# Define file_device_hal 0x00000101
# Define method_buffered 0
# Define file_any_access 0
# Define Ioctl_hal_reboot Ctl_code (file_device_hal, 15, Method_buffered, File_any_access)
Extern "C" _ Declspec (dllimport) Bool Kerneliocontrol (
DWORD Dwiocontrolcode,
Lpvoid Lpinbuf,
DWORD Ninbufsize,
Lpvoid Lpoutbuf,
DWORD Noutbufsize,
Lpdword Lpbytesreturned );
Call:
Kerneliocontrol (ioctl_hal_reboot, Null, 0, Null, 0, Null );
// Supplement
Close (suspend)
Method 1:
// Virtual shut-down key
: Keybd_event (vk_off, 0, 0, 0 );
: Keybd_event (vk_off, 0, keyeventf_keyup, 0 );
Method 2: Call this function and shut down directly. Haha, be careful before calling it!
// Call the undisclosed function poweroffsystem ()
Extern "C" _ declspec (dllimport) void poweroffsystem ();
Soft Reset: the method mentioned at the beginning of the article.
// Soft reset the device
# Include
# Define ioctl_hal_reboot ctl_code (file_device_hal, 15, method_buffered, file_any_access)
Extern "C" _ declspec (dllimport) bool kerneliocontrol (
DWORD dwiocontrolcode,
Lpvoid lpinbuf,
DWORD ninbufsize,
Lpvoid lpoutbuf,
DWORD noutbufsize,
Lpdword lpbytesreturned );
Bool resetpocketpc ()
{
Return kerneliocontrol (ioctl_hal_reboot, null, 0, null, 0, null );
}
Hard reset)
// Note !!! Using this code will clear all user data in your Pocket PC,
// Do not use it illegally.
# Include
# 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 );
Bool hardresetpocketpc ()
{
Setcleanrebootflag ();
Return kerneliocontrol (ioctl_hal_reboot, null, 0, null, 0, null );
}
-------------------------------------------------------------
Close (suspend)
Method 1:
// Virtual shut-down key
: Keybd_event (vk_off, 0, 0, 0 );
: Keybd_event (vk_off, 0, keyeventf_keyup, 0 );
Method 2:
// Call the undisclosed function poweroffsystem ()
Extern "C" _ declspec (dllimport) void poweroffsystem ();
Soft Reset)
// Soft reset the device
# Include<Winioctl. h> 〉
# Define ioctl_hal_reboot ctl_code (file_device_hal, 15, method_buffered, file_any_access)
Extern "C" _ declspec (dllimport) bool kerneliocontrol (
DWORD dwiocontrolcode,
Lpvoid lpinbuf,
DWORD ninbufsize,
Lpvoid lpoutbuf,
DWORD noutbufsize,
Lpdword lpbytesreturned );
Bool resetdevice ()
{
Return kerneliocontrol (ioctl_hal_reboot, null, 0, null, 0, null );
}
Hard reset)
// Note !!! Using this code will clear all user data in your Pocket PC,
// Do not use it illegally.
# 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 );
Bool hardresetdevice ()
{
Setcleanrebootflag ();
Return kerneliocontrol (ioctl_hal_reboot, null, 0, null, 0, null );
}