Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2006-06-09
6
Medium Priority
?
542 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 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

Tech or Treat!

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

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

Summary Displaying images in RichTextBox is a common requirement with limited solutions available. Pasting through clipboard or embedding into RTF content only support static images.  This article describes how to insert Windows control objects int…
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:…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…

636 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