重新启动PPC设备(C#)

来源:互联网 发布:淘宝规则小卖家死 编辑:程序博客网 时间:2024/05/01 04:48
  1. 利用C#重新启动PPC设备的源代码
  2. public partial class Form1 : Form
  3.     {
  4.         [DllImport("coredll.dll")]
  5.         private extern static int KernelIoControl(int dwIoControlCode, IntPtr lpInBuf, int nInBufSize, IntPtr lpOutBuf, int nOutBufSize, int lpBytesReturned);
  6.         private int CTL_CODE(int nDeviceType, int nFunc, int nMethod, int nAccess) 
  7.         {
  8.             return (nDeviceType << 16) | (nAccess << 14) | (nFunc << 2) | nMethod;
  9.         }
  10.         private int ResetPocketPC()
  11.         {
  12.             const int FILE_DEVICE_HAL = 0x101;
  13.             const int METHOD_BUFFERED = 0;
  14.             const int FILE_ANY_ACCESS = 0;
  15.             int nBytesReturned = 0;
  16.             int nIOCTL_HAL_REBOOT;
  17.             nIOCTL_HAL_REBOOT = CTL_CODE(FILE_DEVICE_HAL, 15, METHOD_BUFFERED, FILE_ANY_ACCESS);
  18.             return KernelIoControl(nIOCTL_HAL_REBOOT,IntPtr.Zero, 0, IntPtr.Zero, 0, nBytesReturned);
  19.         }
  20.         public Form1()
  21.         {
  22.             InitializeComponent();
  23.         }
  24.         private void Form1_Load(object sender, EventArgs e)
  25.         {
  26.         }
  27.         private void button1_Click(object sender, EventArgs e)
  28.         {
  29.             ResetPocketPC();
  30.         }
  31.     }

 

QQ:819543772

EMail:wuchunlei@163.com

原创粉丝点击