Solved

Is it possible to force Windows CE to reboot from an application?

Posted on 2006-06-09
6
536 Views
Last Modified: 2008-03-17
Hi all,

I want to write a simple app that forces Windows CE 5.0 to reboot?

Any ideas?

Thanks,

James
0
Comment
Question by:jatkin
  • 3
  • 2
6 Comments
 
LVL 9

Accepted Solution

by:
lojk earned 500 total points
ID: 16886699
Straight from the MSDN...

ms-help://MS.VSCC.v80/MS.MSDN.v80/MS.VisualStudio.v80.en/dv_fxnetcf/html/3bff44fb-ce3b-4fbb-9233-d50d77bbf78c.htm

 
Private Const FILE_DEVICE_HAL As Integer = &H101
Private Const METHOD_BUFFERED As Integer = 0
Private Const FILE_ANY_ACCESS As Integer = 0

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

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 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

Private Sub ResetDevice()
    Dim msg As String
    Dim title As String
    Dim style As MsgBoxStyle
    Dim response As MsgBoxResult
    msg = "Are you sure you want to reset the device?"
    style = MsgBoxStyle.DefaultButton2 Or _
       MsgBoxStyle.Question Or MsgBoxStyle.YesNo
    title = "Device Reset"
    response = MsgBox(msg, style, title)
    If response = MsgBoxResult.Yes Then   ' User chose Yes.
       ResetPocketPC()
    End If

End Sub

 
0
 
LVL 4

Author Comment

by:jatkin
ID: 16892616
Hi,

Thanks for the response...
I have compiled the above and it creates an application that runs ok, but when I say 'Yes' it does nothing :-(
Any ideas?
If it helps, it is running on an Arcom Viper running Windows CE 5.0

Thanks,

James
0
 
LVL 4

Author Comment

by:jatkin
ID: 16892669
I have just checked the response from ResetPocketPC() and it is NOT returning True....
0
 
LVL 9

Expert Comment

by:lojk
ID: 16894034
hmm dont know, worked great when tested on the vs2005 Device Emulator, didnt fancy running it on my PDA for testing though...

ResetPocketPC returns an integer value, true is usually -1 so i doubt it would ever return 'true'. What does it actually return?

perhaps...

    If response = MsgBoxResult.Yes Then   ' User chose Yes.
msgbox (       ResetPocketPC())
    End If

might yield a clue..
0
 
LVL 4

Author Comment

by:jatkin
ID: 17056653
The information from lojk looks like it should work fine.
I currently have no way to test it, but I think it is a good answer...

Thanks...

James
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

912 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now