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

Streuner picture Streuner · Jun 4, 2012 · Viewed 10.7k times · Source

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!

Answer

montelof picture montelof · Jun 26, 2012

This is the code I use to soft reset a Windows CE Device

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