Herlaai Windows Mobile 6.x toestel programmaties met C #
-
26-09-2019 - |
Vra
My HTC HD2 kan nie weer begin vanaf OS, net gesluit. So ek wil 'n klein program te skryf om dit te doen.
Is dit moontlik om programmaties herlaai Windows Mobile 6.x toestel met behulp van C #?
Oplossing
Jy moet die gedokumenteer ExitWindowsEx
API te gebruik. IOCTL
moet slegs gebruik word op platforms wat nie oor die ExitWindowsEx funksie oproep (Pocket PC 2000, 2002, en 2003). Sien die MSDN doc vir meer inligting.
[DllImport("aygshell.dll", SetLastError=""true"")]
[return: MarshalAs(UnmanagedType.Bool)]
static extern bool ExitWindowsEx([MarshalAs(UnmanagedType.U4)]uint dwFlags, [MarshalAs(UnmanagedType.U4)]uint dwReserved);
enum ExitWindowsAction : uint
{
EWX_LOGOFF = 0,
EWX_SHUTDOWN = 1,
EWX_REBOOT = 2,
EWX_FORCE = 4,
EWX_POWEROFF = 8
}
void rebootDevice()
{
ExitWindowsEx(ExitWindowsAction.EWX_REBOOT, 0);
}
Ander wenke
SOFT RESET / hard reset
genera Codice Tagore Ek dink dit sal jou help om: Hard Reset Windows Mobile Device ..Still hierdie metode is nie "n duidelike c # kode", omdat dit gebruik maak van Interop, maar dit werk, so dit jou probleem kan oplos.
Vir sagte reset:
[DllImport("coredll.dll", SetLastError=true)]
private static extern bool KernelIoControl(int dwIoControlCode, byte[] inBuf, int inBufSize, byte[] outBuf, int outBufSize, ref int bytesReturned);
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);
}
public static void softReset()
{
uint bytesReturned = 0;
uint IOCTL_HAL_REBOOT = CTL_CODE(FILE_DEVICE_HAL, 15, METHOD_BUFFERED, FILE_ANY_ACCESS);
KernelIoControl(IOCTL_HAL_REBOOT, IntPtr.Zero, 0, IntPtr.Zero, 0, ref bytesReturned);
}
(tho ek nie gebruik het hierdie metode myself..see hier )