Skip to main content
 首页 » 编程设计

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

2024年02月20日11mfrbuaa

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

提前致谢。

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

请您参考如下方法:

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