Search code examples
c#windows-ce

How to Poweroff /suspend WinCE 6 device from C#


I have been doing few programming in WinCE 6 device for sometime now.For one of my requirement I want to suspend the device after some time . I m not sure how to do it.

If its PC , I know this works

Process.Start("shutdown","/s /t 0");

Not Sure for WinCE devices .Thanks .

Device: WinCE ,using C#


Solution

  • There's is no command line support to shutdown the WindowCE. you can use PInvoke the core.dll and call P/Invoke ExitWindowsEx

    [Flags]
    public enum ExitFlags
    {
      Reboot = 0x02,
      PowerOff = 0x08
    }
    
    [DllImport("coredll")]
    public static extern int ExitWindowsEx(ExitFlags flags, int reserved);
    
    ...
    
    ExitWindowsEx(ExitFlags.PowerOff, 0);
    

    ----- Updated ---------

    Try with GwesPowerOffSystem it's for WinCE 5.0. This is exactly what you are looking for. It's in the same core dll file.