简体   繁体   English

如何使用 EMDK 2.6 关闭/重启移动设备 (Win CE 6.0)?

[英]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.我正在尝试使用 EMDK 2.6 关闭/重新启动我的摩托罗拉 MC9190,但我不知道如何实现这一点。 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 :/帮助文件只是为我提供了重启 RF 或 WLAN 等几个部分的方法:/

Thanks in advance.提前致谢。

PS: I can't use external components as a workaround! PS:我不能使用外部组件作为解决方法!

This is the code I use to soft reset a Windows CE Device这是我用来软重置 Windows CE 设备的代码

    [DllImport("coredll.dll")]
    private static extern bool KernelIoControl(Int32 IoControlCode, IntPtr InputBuffer, Int32 InputBufferSize, byte[] OutputBuffer, Int32 OutputBufferSize, ref Int32 BytesReturned);
    private const uint FILE_DEVICE_HAL = 0x00000101;
    private const uint METHOD_BUFFERED = 0;
    private const uint FILE_ANY_ACCESS = 0;

    private static uint CTL_CODE(uint DeviceType, uint Function, uint Method, uint Access)
    {
        return ((DeviceType << 16) | (Access << 14) | (Function << 2) | Method);
    }

    public static void softReset()
    {
        byte[] OutputBuffer = new byte[256];
        Int32 OutputBufferSize, BytesReturned;
        OutputBufferSize = OutputBuffer.Length;
        BytesReturned = 0;

        Int32 IOCTL_HAL_REBOOT = (Int32)CTL_CODE(FILE_DEVICE_HAL, 15, METHOD_BUFFERED, FILE_ANY_ACCESS);

        KernelIoControl(IOCTL_HAL_REBOOT, IntPtr.Zero, 0, OutputBuffer, OutputBufferSize, ref BytesReturned);
    }

Use to this code for reboot使用此代码重新启动

[DllImport("coredll.dll")]
static extern int SetSystemPowerState(string psState, int StateFlags, int Options);
        const int POWER_FORCE = 4096;
        const int POWER_STATE_RESET = 0x00800000;


        private void SoftReset()
        {
            SetSystemPowerState(null, POWER_STATE_RESET, POWER_FORCE);
        }  

(include System.Runtime.InteropServices) (包括 System.Runtime.InteropServices)

I usually use this snippet, below you will see for both CE and WM (commented).我通常使用这个片段,下面你会看到 CE 和 WM(评论)。 You just need to call the ExitWindowsEx(2,0) for CE, and SetSystemPowerState(NULL; POWER_STATE_RESET, 0) for Windows Mobile.您只需要为 CE 调用 ExitWindowsEx(2,0),为 Windows Mobile 调用 SetSystemPowerState(NULL; POWER_STATE_RESET, 0)。

The following sample delays the reboot 48hrs.以下示例将重新启动延迟 48 小时。

// REBOOT.cpp : Defines the entry point for the console application. // REBOOT.cpp : 定义控制台应用程序的入口点。 // //

#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;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM