Thursday, January 1, 2009

iMateBuddy - Soft Reset and Timer for Windows Mobile 5.0

Introduction


I always wanted to try out the windows mobile programming\ projects that had shipped with the Visual Studio 2003. And some time back I got this opportunity when I bought my first windows mobile, a i-mate PDAL with Windows Mobile 5.0 OS and hence the name "iMateBuddy".

To start with, there were two features that are common in normal mobiles, which I didn't find in Windows Mobile 5.0. One was a Soft Reset for a mobile and second is a Timer application. So I went ahead and created my own windows mobile application using VS 2008 with above two features.

Download Code - 1.5MB



Description



Timer is simple up timer with precision in thousand milliseconds. Its implemented using the Timer class from the System.Windows.Forms namespace.
Reset features resets the mobile which other wise requires to be done by pressing and holding the power button. For this the coredll.dll is imported using [DllImport("coredll.dll")] and its
KernelIoControl() methode is called with IOCTL_HAL_REBOOT code passed as the parameter.

const int FILE_DEVICE_HAL = 0x101;
const int METHOD_BUFFERED = 0;
const int FILE_ANY_ACCESS = 0;
int bytesReturned = 0;
int IOCTL_HAL_REBOOT;
IOCTL_HAL_REBOOT = CTL_CODE(FILE_DEVICE_HAL, 15, METHOD_BUFFERED, FILE_ANY_ACCESS);
return KernelIoControl(IOCTL_HAL_REBOOT, IntPtr.Zero, 0, IntPtr.Zero, 0, ref bytesReturned);

The solution consists of the main Smart Device project and a Smart Device CAB project. The CAB project generates the .CAB file which is setup file to install the app in the mobile device. On installation, setup copies a shortcut in the 'Programs' and the 'Startup' menu.

Future Scope

Futher I'm planning to add another feature which I find missing in Windows Mobile 5.0, from the normal symbian mobiles, which is "Location Info". For this I have googled around a bit but didn't find a complete solution. One possible solution is to get the cell tower info using api mentioned in the article - http://social.msdn.microsoft.com/Forums/en-US/windowsmobiledev/thread/279ca64f-5768-4c7d-9f44-6794e173fa91. But it doesn't give all the information. I'll keep looking for a better solution and post an update.

Please let me know if anybody has a solution for getting the mobile's "Location Info" or any other suggestions\ comments about this application.

s.a.w