program.cs

来自「windows mobile 6.0 on Motolola Q*** s re」· CS 代码 · 共 34 行

CS
34
字号
using System;
using System.Runtime.InteropServices;
using System.Windows.Forms;

namespace WMReboot
{
    class Program
    {
        public const string AppName = "WMReboot";
        public const string AppVer = "1.0";

        public const int IOCTL_HAL_REBOOT = 0x101003c;

        [DllImport("coredll.dll", CharSet = CharSet.Auto, SetLastError = true)]
        public static extern int KernelIoControl(int dwIoControlCode, IntPtr lpInBuf, int nInBufSize, IntPtr lpOutBuf, int nOutBufSize, ref int lpBytesReturned);

        static void Main(string[] args)
        {
            DialogResult result = MessageBox.Show("Are you sure you want to reboot?", string.Format("{0} v{1}", AppName, AppVer), MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1);

            if (result == DialogResult.Yes)
            {
                Reboot();
            }
        }

        static private void Reboot()
        {
            int bytesReturned = 0;
            KernelIoControl(0x101003c, IntPtr.Zero, 0, IntPtr.Zero, 0, ref bytesReturned);
        }
    }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?