Results 1 to 5 of 5

Thread: Restart windows from vb.net

  1. #1

    Thread Starter
    New Member
    Join Date
    Mar 2006
    Posts
    9

    Restart windows from vb.net

    Hi,
    I need to restart windows CE from within my application. Does anyone know how to do this? Im using vb.net compact.

    Thanks,

    Tim

  2. #2
    Fanatic Member Strider's Avatar
    Join Date
    Sep 2004
    Location
    Dublin, Ireland
    Posts
    612

    Re: Restart windows from vb.net

    This class will do it

    VB Code:
    1. Imports System.Runtime.InteropServices
    2.  
    3. Public Class DeviceReboot
    4.     <DllImport("coredll")> _
    5.     Private Shared Function SetSystemPowerState( _
    6.         ByVal psState As String, _
    7.         ByVal StateFlags As Integer, _
    8.         ByVal Options As Integer) As Integer
    9.     End Function
    10.  
    11.     Const POWER_STATE_ON As Integer = &H10000
    12.     Const POWER_STATE_OFF As Integer = &H20000
    13.     Const POWER_STATE_SUSPEND As Integer = &H200000
    14.     Const POWER_STATE_RESET As Integer = &H800000
    15.  
    16.     Public Sub New()
    17.  
    18.     End Sub
    19.  
    20.     Public Function Reboot()
    21.         Try
    22.             SetSystemPowerState(Nothing, POWER_STATE_RESET, 0)
    23.         Catch ex As Exception
    24.             Throw New Exception(ex.Message)
    25.         End Try
    26.     End Function
    27. End Class
    Barry


    Visual Studio .NET 2008/Visual Studio .NET 2005/Visual Studio .NET 2003
    .NET Framework 3.0 2.0 1.1/ASP.Net 3.0 2.0 1.1/Compact Framework 1.0

    SQL Server 2005/2000/SQL Server CE 2.0


    If you like, rate this post

    Compact Framework for Beginners

  3. #3

    Thread Starter
    New Member
    Join Date
    Mar 2006
    Posts
    9

    Re: Restart windows from vb.net

    cool. Sorted me again!

  4. #4
    Fanatic Member Strider's Avatar
    Join Date
    Sep 2004
    Location
    Dublin, Ireland
    Posts
    612

    Re: Restart windows from vb.net

    just a as a point to note.....

    the reboot worked fine for me on the devices we use Psion Workabout Pro,
    but i've also tried it on the PSC Falcon and the reboot option didnt work.

    i have other code to make this work if you are using PSC and the class posted above doesnt work
    Barry


    Visual Studio .NET 2008/Visual Studio .NET 2005/Visual Studio .NET 2003
    .NET Framework 3.0 2.0 1.1/ASP.Net 3.0 2.0 1.1/Compact Framework 1.0

    SQL Server 2005/2000/SQL Server CE 2.0


    If you like, rate this post

    Compact Framework for Beginners

  5. #5

    Thread Starter
    New Member
    Join Date
    Mar 2006
    Posts
    9

    Re: Restart windows from vb.net

    cheers. Worked fine on my device.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width