不迎不送,来去自便,无茶无酒,谈笑随缘

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::
  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

posted on 2009-01-04 17:24  wude  阅读(133)  评论(0编辑  收藏  举报