Pregunta

Mi HTC HD2 no puede ser reiniciado desde OS, simplemente cerró. Así que quiero escribir un pequeño programa para hacer eso.

¿Es posible mediante programación reinicio del dispositivo Windows Mobile 6.x usando C #?

¿Fue útil?

Solución

Se debe utilizar la API ExitWindowsEx documentado. IOCTL sólo debe utilizarse en las plataformas que carecen de la llamada a la función ExitWindowsEx (Pocket PC 2000, 2002 y 2003). Vea la MSDN doc para más información.

[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);
}

Otros consejos

SOFT RESET / restablecimiento de hardware

géneros codice tagore

Creo que esto le ayudará a: restablecimiento de hardware de Windows Mobile Device ..Still este método no es "clara código C #", ya que utiliza interoperabilidad, pero funciona, por lo que puede resolver su problema.
Para blanda Restablecer:

[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);
}

(aunque no he utilizado este método myself..see aquí )

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top