重新啟動PDA OS

  • 2619
  • 0

重新啟動PDA OS,就如同按下Reset鍵的功能,另一種講法叫暖開機Warn boot

重新啟動PDA OS,就如同按下Reset鍵的功能,另一種講法叫暖開機Warn boot

首先import 一DLL

        [DllImport("coredll.dll")]
        private static extern bool KernelIoControl(int IoControlCode, IntPtr InputBuffer, int InputBufferSize, IntPtr OutputBuffer, int OutputBufferSize, ref int BytesReturned);

 

        /// <summary>
        /// IOCTL Code
        /// </summary>
        /// <param name="a_DeviceType">The device type</param>
        /// <param name="a_Access">The access check value</param>  
        /// <param name="a_Func">Function to perform</param>
        /// <param name="a_Method">The method code for how the buffers are passed</param>        
        /// <returns></returns>

        private static int CTL_CODE(int a_DeviceType, int a_Func, int a_Method, int a_Access)
        {
            return (a_DeviceType << 16) | (a_Access << 14) | (a_Func << 2) | a_Method;
        }


// Warn boot
        public static bool ResetPocketPC()
        {
            const int l_FILE_DEVICE_HAL = 0x101;
            const int l_METHOD_BUFFERED = 0;
            const int l_FILE_ANY_ACCESS = 0;

            int l_bytesReturned = 0;
            int l_IOCTL_HAL_REBOOT;

            l_IOCTL_HAL_REBOOT = CTL_CODE(l_FILE_DEVICE_HAL, 15, l_METHOD_BUFFERED, l_FILE_ANY_ACCESS);
            return KernelIoControl(l_IOCTL_HAL_REBOOT, IntPtr.Zero, 0, IntPtr.Zero, 0, ref l_bytesReturned);
        }

直接叫用ResetPocketPC()就可了

參考資料http://msdn.microsoft.com/zh-tw/library/ms172519(VS.80).aspx