42Gears Speaks
24Nov/092

Can Microsoft get back its Mojo with Windows Mobile 7?

There have been speculations as to whether Microsoft will remain an important player in the mobile phone market with their Windows Mobile operating system. Numerous news articles and blog posts have “declared” the imminent death of Windows Mobile. This article lists a few reasons why these speculations might not eventually turn out to be true.

It is generally agreed that Windows Mobile has problems. We can compare it to Windows Vista which was not accepted very well by the market. Microsoft came back with Windows 7 which has turned out to be successful even after Vista’s debacle. They have learned from the problems and fixed them in Windows 7. Though the desktop and mobile platforms belong to different worlds, we must recognize the approach Microsoft took. The point is; Microsoft can certainly fix what is currently broken in Windows Mobile.

Microsoft rules desktop OS market with over 90% market share and it will make sense if Microsoft uses it to their advantage in mobile space as well.

Windows Mobile also rules the rugged handheld device market. Companies have tried various alternatives, including free “Linux” and failed. They went back to using Windows Mobile based devices for their day-to-day business activities related to mobility. For anything more than email access, companies still prefer Windows Mobile.

Windows Mobile is built on a solid platform. People have been cribbing about its “bad” and outdated “look and feel”. But this “look and feel” was a well-thought-of decision when Windows Mobile or Pocket PC (as it was called earlier) was designed. Microsoft did not want anyone to put any effort in learning how to use their new operating system. Infact, almost no learning was required if you already knew how to use Windows on the PC. They added a Start button on Windows Mobile taskbar!

WM 7 screenshots are available on the internet like here. Not sure if they are true, but if they are real, then surely MS is up to something great. The release has been delayed and MS had to release a stop-gap WM 6.5 version which has received fairly good reviews. WM 6.5 might hold-off the attack till WM 7 starts the counter attack.

iPhone and new devices running Android have tasted initial success by having a nice “look and feel” and jazziness. Their next challenge would be to get better integrated with the desktop environment, where Windows has complete domination. You think its going to be easy! Nope. That is where they will struggle. Microsoft has already solved that problem; the only thing they have to do is to “modernize” the look and feel of their operating system (WM) and they will be good.

It remains to be seen if Microsoft will really get their Mojo back with the release of WM 7. Until then let’s see what the industry analysts write about Microsoft’s departure from the mobile arena.

42Gears develops mobile device management tools for enterprises. Read more information about our products here.


11Oct/090

Simulating key presses in your program with keybd_event function

Out of need or curiosity you might want to know how to send key presses from your native application. The core of the solution involves calling keybd_event() function which has the following prototype.

VOID keybd_event(BYTE bVk, BYTE bScan, DWORD dwFlags, DWORD dwExtraInfo);

bVk is the virtual-key code of the character. bScan is the hardware scan code. dwFlags is an important field. If KEYEVENTF_KEYUP is specified in dwFlags field, the key is being released. If not specified, the key is being pressed.

Here is a function which simulates pressing of alphanumeric characters. See winuser.h for all available virtual key codes.

void SendStringKeys(char* pszChars)
{
while (*pszChars != NULL)
{
if ( (*pszChars >= 'A') && (*pszChars <= 'Z') )
keybd_event(VK_SHIFT, 0, KEYEVENTF_SILENT, 0);

keybd_event(toupper(*pszChars), 0, KEYEVENTF_SILENT, 0);
keybd_event(toupper(*pszChars), 0, KEYEVENTF_KEYUP|KEYEVENTF_SILENT, 0);

if ( (*pszChars >= 'A') && (*pszChars <= 'Z') )
keybd_event(VK_SHIFT, 0, KEYEVENTF_KEYUP|KEYEVENTF_SILENT, 0);

pszChars++;
}
}

And here is an example of how to call SendStringKeys function.

int _tmain(int argc, _TCHAR* argv[])
{
SendStringKeys("Hello World.");
return 0;
}

Go to Home


5Oct/090

Determining IP Address of a Windows Mobile device

Code to determine IP addresses of adapters on a Windows Mobile device, using IPHelper APIs.

Add Iphlpapi.lib to linker settings.

#include "Iphlpapi.h"

PIP_ADAPTER_INFO pinfo = NULL;
ULONG OutBufLen = 0;
DWORD dwRet = GetAdaptersInfo(NULL, &OutBufLen);
if (dwRet == ERROR_BUFFER_OVERFLOW)
{
pinfo = (PIP_ADAPTER_INFO)malloc(OutBufLen);
dwRet = GetAdaptersInfo(pinfo,&OutBufLen);
while (pinfo != NULL)
{
if (dwRet==ERROR_SUCCESS)
{
PIP_ADDR_STRING pAddressList = &(pinfo->IpAddressList);
do
{
printf(pAddressList->IpAddress.String);
pAddressList = pAddressList->Next;
} while (pAddressList != NULL);
}
pinfo = pinfo->Next;
}
free(pinfo);
}

Go to Home


3Oct/090

[Article Posted] Businesses! Are your mobile devices working for you?

Read the full article here.

Go to Home


26Sep/090

Debugging CeRAPIInvoke Calls

RAPI (Remote API) dlls are loaded by rapiclnt.exe on the Windows Mobile device when CeRapiInvoke API is called by the desktop application. CeRapiInvoke is a general-purpose API to remotely execute a function on a Windows Mobile device that is connected to the desktop over ActiveSync.

To debug your RAPI dll, do the following.

1. Launch Visual Studio and Open the RAPI dll project (.sln, .vcproj) in debug mode.

2. Go to Debug Menu and click on Attach to process menu item.

3. On the transport screen (see below), change the transport selection to Smart Device.
rapiclnt.exe running on the device

Attach to rapiclnt.exe on the device

Attach to rapiclnt.exe on the device

4. On the above screen, select rapiclnt.exe and click on Attach button. This step makes rapiclnt.exe and all modules loaded by it debuggable as long as debugging information is available to the debugger.

5. Now locate the function that you want to debug in source files and insert the breakpoint (or use DebugBreak function) at an appropriate location. You will see the inactive breakpoint icon. It means this module is not currently loaded. Thats okay as we know we have not yet called the function from the desktop application. When the function is eventually called, it will result in loading of the RAPI dll by rapiclnt.exe.

6. Now start the desktop side application. As CeRapiInvoke API is called, breakpoints will become active and you will see the control breaking at the first breakpoint.

From here onwards you can just debug the dll as you would debug normal applications.

Note: If you want debug both desktop application and RAPI dll, you should open the two projects in separate instances of Visual Studio IDE.

Go to Home


16Sep/090

Windows Mobile Shortcuts

Shortcuts makes it easy for users to launch applications. Shortcut files have “.lnk” extension and they take up very little storage space. Shortcuts contain information about the application to launch along with any parameter information. They are really handy if predetermined values need to be passed to the application as command line parameters.

How to create a Shortcut on the device

- Run Microsoft ActiveSync on your desktop and establish connection with the PDA.
- Right-click on the ActiveSync icon on the desktop Windows taskbar and Click Explore. This will bringup a window showing contents of Mobile Device folder
- Now goto the folder where the executable resides
- Rightclick on the file (say ABC.exe) and a menu pops up. Select Create Shortcut menu item
- This will generate a shortcut (.lnk) file with the name like “Shortcut to ABC.exe”
- You can rename the shortcut to anything that you like
- Move or copy the shortcut if you want it anywhere else on the device

How shortcuts work (Tech stuff for developers)

This section describes the format of a shortcut file. Simply copy the .lnk file to the desktop and open it in your favorite text editor. I use Notepad. The content in the .lnk file will have the following format.

xx#”\{APPLICATION_PATH}{OPTIONAL PARAMETERS}”

where xx is number of characters in the above text excluding xx#.

For e.g.

18#”\Windows\abc.exe”

where 18 is the count of characters after pound character (#) and \Windows\abc.exe is the target application.

To create a shortcut from your application use SHCreateShortcut API.

Sample Code: (Courtesy MSDN)

BOOL SHCreateShortcutExample()
{
// Create a shortcut called myAppShortcut.lnk,
// that links to the target file in \\, named myApp.exe.
// Place the shortcut in the folder \Windows.
return SHCreateShortcut(TEXT("\\Windows\\myAppShortcut.lnk"), TEXT("\\myApp.exe"));
}

Go to Home


16Sep/090

How to find Phone Signal Strength in Windows Mobile?

There is no API to determine the current signal strength of the phone radio on a Windows Mobile Phone Device. But as it changes the status is updated in the registry at the following location.

[HKEY_LOCAL_MACHINE\System\State\Phone]

“Signal Strength” value represents the signal value (0-100). The operating system uses this value to show the bars on the taskbar representing the current signal strength.

You might want to know in your application when the signal strength changes. Your application can poll the registry but polling is a resource intensive operation and should be avoided. Instead you can use RegistryNotifyCallback function provided by State and Notifications Broker mechanism. This powerful feature is available since WM 5.0 and gives applications an easy way to get notified when status of registry value changes.

Visit the following link for more information and sample code.
http://msdn.microsoft.com/en-us/library/ms894764.aspx

Native programmers should check out snapi.h file in the WM SDK. It gives more information about the bitmasks of various registry values.

Go to Home


1Sep/090

Starter’s Guide to Windows Mobile Development

Information in this post is for developers who are new to windows mobile application development and have no clue on where to start.

Languages:

You can choose from the following available languages.

  • Visual C# and Visual Basic for Managed programming. Managed applications require .net compact framework runtime to be installed on the device. It's a virtual machine on which common language runtime (CLR) instructions execute in a platform independent way. (Remember Java!!!). C# is most commonly used of these two. Sample code availability on the web is also more for C#.
  • Native programming with Visual C++ using Win32 APIs or MFC (Microsoft Foundation Classes). Although managed programming is easier, it does not have support for everything. Besides managed programs have slower execution times than their native counterparts. Note that execution speed has contextual importance. BTW our product SureLock Studio is completely developed in Visual C++ but we use test applications written in C# and VB.NET.

Required Development Tools and SDKs:

  • Microsoft Visual Studio (Professional or Team Edition): De facto tool for developing applications for Windows Mobile 5 and later. It supports programming in Visual C++, Visual C# and Visual Basic.
  • Latest Windows Mobile SDK.
  • Embedded Visual C++: EVC++ was tool for development applications for Windows Mobile devices before WM 5.0. It is still available for download and is completely free. You can only write managed applications with it. Note that you must install latest service pack and SDK.

Additional Tools:

  • Device Emulator Manager: Great way to test applications on various Emulators installed on the desktop PC. You can perform different operations like launching emulators instances, simulating cradle insert/remove, shutdown, saving/clearing state etc. Device Emulator Manager ships as part of Visual Studio
  • Emulator Images: Device Emulator uses the actual emulator OS images for execution. These emulator images come along with SDK.
  • Device Security Manager: Useful when your first Windows Mobile application is not allowed to execute on the device configured with security policies. You can change the security settings and add/remove certificates on the device. Device Security Manager also comes as part of with Visual Studio 2008.

Go to Home


1Sep/090

Windows CE and Windows Mobile for starters

Many a times I find myself in discussions on the history of Windows CE and Windows Mobile operating systems. Besides, if you have just started to work with Windows Mobile or Windows CE, its good to be aware of origins and basics of these operating systems.

Following is an attempt to sort those questions out. So here we go!

  • Microsoft launched Windows CE (code named Pegasus) in 1996
  • Previous attempts from Microsoft – WinPad (Win16) and Pulsar (Win32) projects (both canceled), Teams joined and became Pegasus.
  • Windows CE (now known as Windows Embedded) is a functionally scaled-down Windows operating system. It means it does lots of things like the desktop Windows but not all.
  • Designed from scratch for requirements of embedded and handheld devices (memory, CPU and power constraints). Although Windows CE has some functionality similar to desktop Windows but they are implemented completely differently.
  • CE kernel can run in under 1MB RAM
  • Windows CE is a highly customizable operating system. OEMs can pick and choose features or add new ones to their devices as per the requirements. For e.g. one Windows CE device can be a handheld with a display and a keyboard and another one can be a headless device without any display or keyboard.
  • Multithreading Support: Multithreading gives an illusion to running applications that all the system resources are available to it at all times. The illusion is a result of some intelligent time-sharing (also known as Scheduling) implemented in the operating system.
  • Pre-emptive scheduling between different priority levels and round-robin policy within a level.
  • Processor Support: Windows CE is supported on x86, ARM, SH3 ad MIPS based processors.
  • Difference between Windows Mobile and Windows CE: Windows Mobile is built on top of Windows CE kernel and subsystems. It is targeted at handheld devices with specific hardware and software features. OEMs are required to following strict guidelines (software and hardware) for developing their devices.
  • Windows CE supports Unicode only.

More later...

Go to Home


18Aug/090

Launching Calendar, Tasks and Contacts applications

If you have used Remote Window option in Remote Manager tool in SureLock Studio, you would have noticed that \windows\poutlook.exe is the executable that is responsible for showing calendar, tasks and contacts windows. There are no 3 different applications. How is this achieved?

Well...all the magic occurs by way of commandline parameter. Parameter passed to poutlook.exe determines which of the above three will be launched. Here are the parameters:

To launch Contacts application:

\windows\poutlook.exe contacts

To launch Calendar application:

\windows\poutlook.exe calendar

To launch Tasks application:

\windows\poutlook.exe tasks

If you want to launch any of the above in a device locked down by SureLock, then you must specify
proper parameter in application entry screen in SureLock Studio. Launching \windows\poutlook.exe without any parameter will not do anything.

Launch Calendar application (Change parameter for tasks and contacts)

Launch Calendar application (Change parameter for tasks and contacts)

Go to Home