Feb 1 2009

Resetting the Device

Category: Windows Mobile | WindowsJoel Ivory Johnson @ 16:11

I was looking through the Windows Mobile Team Blog for something and came across a bit of code that I thought would be useful to some for resetting a device.  Here's the code:

[DllImport("Coredll.dll")]
extern static int KernelIoControl(
 
int dwIoControlCode,
  IntPtr lpInBuf,
 
int nInBufSize,
  IntPtr lpOutBuf,
 
int nOutBufSize ,
 
ref int
lpBytesReturned
);

[DllImport("Coredll.dll")]

 

extern static void SetCleanRebootFlag();


public
 void HardReset()
{
   int
IOCTL_HAL_REBOOT = 0x101003C;
  
int
bytesReturned = 0;
   SetCleanRebootFlag();
  
KernelIoControl(IOCTL_HAL_REBOOT, IntPtr.Zero, 0, IntPtr.Zero, 0, ref
bytesReturned );
}

Tags:

Comments

1.
Murali Murali says:

I used this API once and it caused some unknown exception and it asked me to send the debug information to Microsoft.
Then I found another simple API to call

ExitWindowsEx(int dwFlags, int dwReason)
available in aygshell.dll.

This is very simple function call.

msdn.microsoft.com/.../aa376868(VS.85).aspx