Search code examples
c#windows-cemobile-devicesmotorola-emdk

How to shutdown/reboot a mobile device (Win CE 6.0) with EMDK 2.6?


I'm trying to shutdown/reboot my Motorola MC9190 with the EMDK 2.6, but I can't figure out how to achieve this. May someone point me in the right direction in which namespace I can find methods for this or post an example? The Helpfiles just offer me methods the reboot several parts like RF or WLAN :/

Thanks in advance.

PS: I can't use external components as a workaround!


Solution

  • I usually use this snippet, below you will see for both CE and WM (commented). You just need to call the ExitWindowsEx(2,0) for CE, and SetSystemPowerState(NULL; POWER_STATE_RESET, 0) for Windows Mobile.

    The following sample delays the reboot 48hrs.

    // REBOOT.cpp : Defines the entry point for the console application. //

    #include "stdafx.h"
    #include <windows.h>
    #include <commctrl.h>
    #include <Pm.h>
    
    int _tmain(int argc, _TCHAR* argv[])
    {
        SYSTEMTIME tSysTime;
        GetSystemTime(&tSysTime);
    
        if (tSysTime.wYear!= 2005)
        {
            int delay = 1000 *60 * 60 * 48;// 48 Hrs
            Sleep(delay);
    
            //windows Mobile
            //ExitWindowsEx(2,0);
    
            //windows CE
            return (int)SetSystemPowerState(NULL, POWER_STATE_RESET, 0);
    
        }
    
        return 0;
    }