Solved

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

Posted on 2006-06-09
6
535 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
Comment Utility
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
Comment Utility
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
Comment Utility
I have just checked the response from ResetPocketPC() and it is NOT returning True....
0
 
LVL 9

Expert Comment

by:lojk
Comment Utility
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
Comment Utility
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Recently while returning home from work my wife (another .NET developer) was murmuring something. On further poking she said that she has been assigned a task where she has to serialize and deserialize objects and she is afraid of serialization. Wha…
For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

772 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

15 Experts available now in Live!

Get 1:1 Help Now