- 利用C#重新启动PPC设备的源代码
- public partial class Form1 : Form
- {
- [DllImport("coredll.dll")]
- private extern static int KernelIoControl(int dwIoControlCode, IntPtr lpInBuf, int nInBufSize, IntPtr lpOutBuf, int nOutBufSize, int lpBytesReturned);
- private int CTL_CODE(int nDeviceType, int nFunc, int nMethod, int nAccess)
- {
- return (nDeviceType << 16) | (nAccess << 14) | (nFunc << 2) | nMethod;
- }
- private int ResetPocketPC()
- {
- const int FILE_DEVICE_HAL = 0x101;
- const int METHOD_BUFFERED = 0;
- const int FILE_ANY_ACCESS = 0;
- int nBytesReturned = 0;
- int nIOCTL_HAL_REBOOT;
- nIOCTL_HAL_REBOOT = CTL_CODE(FILE_DEVICE_HAL, 15, METHOD_BUFFERED, FILE_ANY_ACCESS);
- return KernelIoControl(nIOCTL_HAL_REBOOT,IntPtr.Zero, 0, IntPtr.Zero, 0, nBytesReturned);
- }
- public Form1()
- {
- InitializeComponent();
- }
- private void Form1_Load(object sender, EventArgs e)
- {
- }
- private void button1_Click(object sender, EventArgs e)
- {
- ResetPocketPC();
- }
- }
QQ:819543772
EMail:wuchunlei@163.com