|
using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
namespace BeeMobile
{
/// <summary>
/// Represents a functionality to reset the whole device.
/// </summary>
public class ResetDevice
{
private const uint FILE_DEVICE_HAL = 0x00000101;
private const uint METHOD_BUFFERED = 0;
private const uint FILE_ANY_ACCESS = 0;
private static uint CTL_CODE(uint DeviceType, uint Function, uint Method, uint Access)
{
return ((DeviceType << 16) | (Access << 14) | (Function << 2) | Method);
}
[DllImport("Coredll.dll")]
private extern static uint KernelIoControl
(
uint dwIoControlCode,
IntPtr lpInBuf,
uint nInBufSize,
IntPtr lpOutBuf,
uint nOutBufSize,
ref uint lpBytesReturned
);
/// <summary>
/// Reset device.
/// </summary>
/// <returns></returns>
public static uint ResetPocketPC()
{
uint bytesReturned = 0;
uint IOCTL_HAL_REBOOT = CTL_CODE(FILE_DEVICE_HAL, 15,
METHOD_BUFFERED, FILE_ANY_ACCESS);
return KernelIoControl(IOCTL_HAL_REBOOT, IntPtr.Zero, 0,
IntPtr.Zero, 0, ref bytesReturned);
}
//public void ResetDevice()
//{
// DialogResult r = MessageBox.Show
// (
// "Are you sure you want to reset?",
// "Test",
// MessageBoxButtons.YesNo,
// MessageBoxIcon.Question,
// MessageBoxDefaultButton.Button2
// );
// if (r == DialogResult.Yes)
// {
// ResetPocketPC();
// }
//}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
I work for Bee Mobile.
Web site: http://beemobile4.net
Facebook site: http://facebook.com/BeeMobile
YouTube Channel: http://youtube.com/beemobile4dotnet