Frage

Ihr HTC HD2 kann nicht von OS neu gestartet werden, nur herunterzufahren. Also habe ich ein kleines Programm, das zu tun, schreiben will.

Ist es möglich, programmatisch Neustart Windows Mobile 6.x-Gerät mit C #?

War es hilfreich?

Lösung

Sie sollten die dokumentierten ExitWindowsEx API verwenden. IOCTL sollte nur auf Plattformen verwendet werden, um den ExitWindowsEx Funktionsaufruf fehlen (Pocket PC 2000, 2002 und 2003). Sehen Sie sich die MSDN doc für weitere Informationen.

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

Andere Tipps

SOFT RESET / HARD RESET

Gattungen codice tagore

Ich denke, das wird Ihnen helfen: Hard Reset Windows Mobile Device ..Still diese Methode „clear c # -Code“ nicht, weil es Interop verwendet, aber es funktioniert, so dass es Ihr Problem lösen kann.
Für weich 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 i diese Methode nicht myself..see verwendet hier )

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top