Click to See Complete Forum and Search --> : How to write a method which can reset my Pocket PC (PDA) in VB .net


NTMT
March 29th, 2004, 10:58 PM
Hi all,

Can any one show me how to write a method which can reset my pocket PC(PDA) in VB .net

Thanks a lot:)

Mai Thoa

Craig Gemmill
March 29th, 2004, 11:48 PM
How ironic, I was just working on something using this code:

MSDN Sample (http://msdn.microsoft.com/mobility/prodtechinfo/devtools/netcf/FAQ/default.aspx#6.17)

'VB
Public Const FILE_DEVICE_HAL As Integer = &H101
Public Const METHOD_BUFFERED As Integer = 0
Public Const FILE_ANY_ACCESS As Integer = 0

Public 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 'CTL_CODE

<DllImport("Coredll.dll")> _
Public Shared Function KernelIoControl _
( _
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
End Function

Function ResetPocketPC() As Integer
Dim bytesReturned As Integer = 0
Dim IOCTL_HAL_REBOOT As Integer = 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 'ResetPocketPC

Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) _
Handles MyBase.Load
Dim r As DialogResult = MessageBox.Show( _
"Are you sure you want to reset?", _
"Test", _
MessageBoxButtons.YesNo, _
MessageBoxIcon.Question, _
MessageBoxDefaultButton.Button2)

If r = DialogResult.Yes Then
ResetPocketPC()
End If

End Sub 'Form1_Load


Keep in mind that you do need the .NETCF installed on the device.

NTMT
April 1st, 2004, 08:29 PM
Hi Craig,


I did it. Thanks a lot