Reboot a device

This blog entry (courtesy of Robert Levy) shows how to programatically reset a device:-

Here is the VB.NET equivalent:-

Declare Function KernelIoControl Lib “coredll.dll” (ByVal dwIoControlCode As Integer, ByVal lpInBuf As IntPtr, ByVal nInBufSize As Integer, ByVal lpOutBuf As IntPtr, ByVal nOutBufSize As Integer, ByVal lpBytesReturned As Integer) As Integer

Declare Sub SetCleanRebootFlag Lib “coredll.dll” ()


Public Sub HardReset()

Dim IOCTL_HAL_REBOOT As Integer = &H101003C

Dim bytesReturned As Integer = 0


KernelIoControl(IOCTL_HAL_REBOOT, IntPtr.Zero, 0, IntPtr.Zero, 0, bytesReturned)

End Sub


To perform only a soft-reset exclude the call to SetCleanRebootFlag (Thank’s to Alex Feinman for highlighting this in a recent newsgroup post)

By Peter Foot

Microsoft Windows Development MVP