I have been using PDAs since late 2002 and my first device was a Packard Bell PDA, equipped with Pocket PC 2001. I then moved to the Windows Mobile world and ever since I have been saving more and more personal information to my device. I currently use an HTC Touch Cruise and one thing that annoys me is the fact that I cannot directly lock down my phone without shutting it or waiting for my "prompt for password" timer to expire. I could definitely lock the keys but that is for accidental key press (or screen in my case). So I decided to take things in my own hands (oh no). After an hour or so I ended up with a tiny .NET Compact Framework 3.5 utility with no UI. The application simply calls a native function to lock the device and prompt the user to enter a PIN, assuming you have assigned one. The function is called SHDeviceLockAndPrompt() and you can find it in "aygshell.dll". So here is our code:

static class Program
    {
        [DllImport("aygshell.dll")]
        public extern static IntPtr SHDeviceLockAndPrompt();
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [MTAThread]
        static void Main()
        {
            SHDeviceLockAndPrompt();
        }
    }

You can get the utility compiled and ready for installation and the source code from my SkyDrive public share:
http://cid-28159fd1410e3d28.skydrive.live.com/embedrowdetail.aspx/DeviceLockWM

Just to clarify, I take no responsibility for any issues that might arise by using this utility. If you are having problems do drop me a line and I will try to help if I can, but this is provided as it is with no guarantees.

Advertisements