Solved

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

Posted on 2006-06-09
6
538 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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
SQL Help 27 57
.NET 2008 VB and C# 6 39
VB.NET 2008 Winforms Signing 13 32
PowerShell:  Convert parameter's friendly name to another name... hashtable perhaps? 2 29
Flash (http://en.wikipedia.org/wiki/Adobe_Flash) has evolved over the years to where it has become a masterful tool for displaying content screen.  It has excellent layout placement, UI precision as well as rendering capabilities. This, along with t…
In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

860 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