Windows Mobile 6.5 comes with a 'lock' mechanism just like any other mobile device .This feature has been available since Pocket PC days, although the mechanism was a little different. Though this built in locking feature was available, many companies and users had to build their own locking feature as no direct API/Handle was available for granular control of locking and timing.
Most of the cases, these locks are not password protected by users, and the sole intention of locking is to prevent any unwitting access to applications on Today screen.
Now, there are situations where the device is locked and the user warm boots the device. Under certain conditions when the device warm boots, the OS takes the user back to the locked state. Though unlocking the device is as simple as sliding the button (as shown in picture)
If not in all the cases, there are some cases where some start up applications run on a warm boot and come on top of today screen (controlled by its Z-index), eventually to find the focus being stolen by unseen lock screen hidden behind this app. Now the user is bogged under the real 'dead lock' scenario, he can neither close the app on top of the screen nor unlock the device, a catch-22 situation.
To avert such situation any start up app should ensure that the device is either programmatically unlocked and stay behind the lock screen. I couldn't find the way of keeping the app being the lock screen, but definitely found of way of unlocking the device..courtesy the Remote Spy tool shipped with VS.NET 2005+ onwards.
This tool helps in trapping all hte messages an open windows goes through. A quick look at the editor showed that lock runs under the name of "ConfettiLockScreen". By sending the right messages in right order simulates a 'slide' event and voila... unlocks the device.
[DllImport("coredll.dll", EntryPoint = "SendMessage")]
extern public static Int32 SendMessage(
IntPtr hWnd, // handle to destination window
uint Msg, // message
uint wParam, // first message parameter
uint lParam); // second message parameter
[DllImport("coredll.dll", EntryPoint = "FindWindow")]
extern public static IntPtr FindWindow(string className,
IntPtr hwnd = FindWindow("ConfettiLockScreen", null);
if (hwnd != null && hwnd != IntPtr.Zero)
SendMessage(hwnd, 0x00000111, 0x00004076, 0 ); //WM_COMMAND
SendMessage(hwnd, 0x00000008, 0, 0); //WM_KILLFOCUS
SendMessage(hwnd, 0x00000281, 0, 0xC000000F); //WM_IME_SETCONTEXT
SendMessage(hwnd, 0x00000282, 0, 0x00000001); //WM_IME_NOTIFY
MessageBox.Show("Could not get handle to lock object");