How can I soft reset Smartphone 2002 device from code?
By Yaroslav Goncharov, April 29, 2003.
Question
How can I soft reset Smartphone 2002 from my program?
Answer
You can use KernelIoControl API function with IOCTL_HAL_REBOOT code. Copy and paste the following
code snippet to your program. Then you can use SoftResetDevice function to 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 SoftResetDevice()
{
return KernelIoControl(IOCTL_HAL_REBOOT, NULL, 0, NULL, 0, NULL);
}
There are 2 aspects connected with this method to consider:
-
KernelIoControl function is restricted by default. It means that on most devices you can use this function
in the privileged mode only. In the restricted mode you will get "Access is denied" error.
- This function call is device specific and depends on OEM implementation. The author tested this function
on HTC devices (including Orange SPV).
Related resources
Discuss
Discuss this QA.
Here you can write your comments and read comments of other developers.
|