2012-06-04 29 views
1

我想關閉/重新啓動與EMDK 2.6我的摩托羅拉MC9190,但我無法弄清楚如何實現這一點。有人可能會指出我在哪個命名空間的正確方向,我可以找到這個方法或張貼一個例子?在幫助文檔只要給我提供的方法重新啓動幾個部分如RF或WLAN:提前/如何使用EMDK 2.6關閉/重新啓動移動設備(Win CE 6.0)?

感謝。

PS:我不能使用外部元件作爲一種解決方法!

+1

我還沒有發現在EMDK 2.5這樣的選擇 - 我們使用http://pinvoke.net/default.aspx/coredll .KernelIoControl到warmboot –

+0

感謝您的信息。不幸的是,外部組件對我來說不是解決方案。 – Streuner

+3

KernelIoControl不是外部組件,它已經是操作系統的一部分。你只需要調用它。 – ctacke

回答

1

我通常使用這個片段中,下面你會看到兩個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; 
} 
3

這是我使用軟碼重置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); 
    } 
0

使用此代碼爲重啓

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); 
     } 
相關問題