Restart a pocket pc

On December 24, 2008, in Programming, by Mike Hudson

If you own a pocket pc or smartphone, you will know how annoying it is to have to fiddle around with the stylus in order to perform a soft reset on the device.

Well using this code you can create an application which resets your device at the click of an icon.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
Private 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, ByRef lpBytesReturned As Integer) As Integer
Private Function CTL_CODE(ByVal DeviceType As Integer, _
ByVal Func As Integer, _ ByVal Method As Integer, _
ByVal Access As Integer) As Integer
Return (DeviceType << 16) Or (Access << 14) Or (Func << 2) Or Method
End Function
Private Function ResetPocketPC() As Integer
Const FILE_DEVICE_HAL As Integer = &H101
Const METHOD_BUFFERED As Integer = 0
Const FILE_ANY_ACCESS As Integer = 0
Dim bytesReturned As Integer = 0
Dim IOCTL_HAL_REBOOT As Integer
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, bytesReturned)
End Function
Sub Main()
ResetPocketPC()
End Sub
Tagged with:  

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!