【问题标题】:How to shutdown/reboot a mobile device (Win CE 6.0) with EMDK 2.6?如何使用 EMDK 2.6 关闭/重启移动设备(Win CE 6.0)?
【发布时间】:2012-06-04 07:37:52
【问题描述】:

我正在尝试使用 EMDK 2.6 关闭/重新启动我的摩托罗拉 MC9190,但我不知道如何实现这一点。有人可以指出我可以在哪个命名空间中找到方法或发布示例的正确方向吗?帮助文件只是为我提供了重启 RF 或 WLAN 等几个部分的方法:/

提前致谢。

PS:我不能使用外部组件作为解决方法!

【问题讨论】:

  • 我在 EMDK 2.5 中没有找到这样的选项 - 我们使用 pinvoke.net/default.aspx/coredll.KernelIoControl 进行热启动
  • 感谢您的信息。不幸的是,外部组件对我来说不是解决方案。
  • KernelIoControl 不是外部组件,它已经是操作系统的一部分。你只需要调用它。
  • 我不熟悉这个调用。效果很好!如果您将其发布为答案,我将接受它:)

标签: c# windows-ce mobile-devices motorola-emdk


【解决方案1】:

这是我用来软重置 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);
    }

【讨论】:

    【解决方案2】:

    使用此代码重新启动

    [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);
            }  
    

    (包括 System.Runtime.InteropServices)

    【讨论】:

      【解决方案3】:

      我通常使用这个 sn-p,下面你会看到 CE 和 WM(已注释)。您只需要为 CE 调用 ExitWindowsEx(2,0),为 Windows Mobile 调用 SetSystemPowerState(NULL; POWER_STATE_RESET, 0)。

      以下示例将重启延迟 48 小时。

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

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-11-24
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多