• Mobile 重启设备


     这里有三种方式可以重启Mobile 设备

      SetSystemPowerState 

    SetSystemPowerState
    [DllImport("Coredll.dll")]
    public static extern int SetSystemPowerState(string psState, SystemPowerStateFlags StateFlags, uint Options);

    public const uint POWER_FORCE = 0x00001000;
    public enum SystemPowerStateFlags : uint
    {
        POWER_STATE_ON          
    = 0x00010000,  // on state
        POWER_STATE_OFF         = 0x00020000,  // no power, full off
        POWER_STATE_CRITICAL    = 0x00040000,  // critical off
        POWER_STATE_BOOT        = 0x00080000,  // boot state
        POWER_STATE_IDLE        = 0x00100000,  // idle state
        POWER_STATE_SUSPEND     = 0x00200000,  // suspend state
        POWER_STATE_UNATTENDED  = 0x00400000,  // Unattended state.
        POWER_STATE_RESET       = 0x00800000,  // reset state
        POWER_STATE_USERIDLE    = 0x01000000,  // user idle state
        POWER_STATE_BACKLIGHTON = 0x02000000,  // device scree backlight on
        POWER_STATE_PASSWORD    = 0x10000000   // This state is password protected.
    } 

    调用 

    NativeMethods.SetSystemPowerState(null, NativeMethods.SystemPowerStateFlags.POWER_STATE_RESET, NativeMethods.POWER_FORCE);


     ExitWindowsEx

    ExitWindowsEx
    [DllImport("aygshell.dll")]
    public static extern bool ExitWindowsEx(ExitWindowsExFlags uFlags, int dwReserved);
            
    public enum ExitWindowsExFlags : uint
    {
        EWX_REBOOT 
    = 2,
        
    // This flag is not supported on a Windows Mobile-based Pocket PC.
        EWX_POWEROFF = 8
    }

    调用

    NativeMethods.ExitWindowsEx(NativeMethods.ExitWindowsExFlags.EWX_REBOOT, 0);


     KernelIoControl

    KernelIoControl
    public const uint FILE_DEVICE_HAL = 0x00000101;
    public const uint METHOD_BUFFERED = 0;
    public const uint FILE_ANY_ACCESS = 0;

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

    [DllImport(
    "Coredll.dll")]
    public extern static bool KernelIoControl
    (
        
    uint dwIoControlCode,
        IntPtr lpInBuf,
        
    uint nInBufSize,
        IntPtr lpOutBuf,
        
    uint nOutBufSize,
        
    ref uint lpBytesReturned
    );

    private bool ResetPocketPC()
    {
        
    uint bytesReturned = 0;
        
    uint IOCTL_HAL_REBOOT = CTL_CODE(FILE_DEVICE_HAL, 15, METHOD_BUFFERED, FILE_ANY_ACCESS);
        
    return KernelIoControl(IOCTL_HAL_REBOOT, IntPtr.Zero, 0, IntPtr.Zero, 0ref bytesReturned);
    }

       

     
  • 相关阅读:
    ZOJ2913Bus Pass(BFS+set)
    HDU1242 Rescue(BFS+优先队列)
    转(havel 算法)
    ZOJ3761(并查集+树的遍历)
    ZOJ3578(Matrix)
    HDU1505
    ZOJ3574(归并排序求逆数对)
    VUE-脚手架搭建
    VUE脚手架搭建
    VUE-node.js
  • 原文地址:https://www.cnblogs.com/Lisen/p/1623873.html
Copyright © 2020-2023  润新知