Warm boot

  • Thread starter Thread starter Ivo
  • Start date Start date
private static Int32 FILE_DEVICE_HAL = 0x00000101;

private static Int32 FILE_ANY_ACCESS = 0x0;

private static Int32 METHOD_BUFFERED = 0x0;



private static int CTL_CODE(int DeviceType, int Function, int Method, int
Access)

{

return ((DeviceType << 16) | (Access << 14) | (Function << 2) | Method);

}

[DllImport("Coredll.dll")]

private extern static uint KernelIoControl

(

int dwIoControlCode,

IntPtr lpInBuf,

int nInBufSize,

IntPtr lpOutBuf,

int nOutBufSize,

ref int lpBytesReturned

);

public static uint Reset()

{

int bytesReturned = 0;

int IOCTL_HAL_REBOOT = CTL_CODE(FILE_DEVICE_HAL, 15,

METHOD_BUFFERED, FILE_ANY_ACCESS);

return KernelIoControl(IOCTL_HAL_REBOOT, IntPtr.Zero, 0,

IntPtr.Zero, 0, ref bytesReturned);

}
 
Note that support for this IOCTL is up to the OEM, so while it should work
in many cases, it may not work on all such devices. It's better to check
with the OEM of the target device(s) and see what they say about rebooting
the device. They may tell you to use this method, but there may be some API
that they provide that does other things (such as closing open files, etc.),
on their device.

Paul T.
 
Back
Top