?
Solved

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

Posted on 2006-06-09
6
Medium Priority
?
543 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:James Atkin
  • 3
  • 2
5 Comments
 
LVL 9

Accepted Solution

by:
lojk earned 2000 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:James Atkin
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:James Atkin
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:James Atkin
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

Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

Question has a verified solution.

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

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:…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
Integration Management Part 2
Suggested Courses
Course of the Month13 days, 8 hours left to enroll

749 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