Last Updated:

Windows Mobile Application Development

Windows Mobile Application Development

Mobile and compact devices are becoming increasingly popular in our society. Each of us faces them every day. Of course, each of us has a mobile phone, handheld computers or other high-tech devices.

All of these devices have different mobile platforms. There are such well-known platforms as Windows MobileMiPhoneBlackBerrySymbian OSAndroidMaemoOpenMoko, etc. They all have different histories, advantages and disadvantages.

This article focuses on developing applications for Windows Mobile. Here we will talk about the various nuances of creating and testing user applications for different types of devices.

1. Development
Tools 2. Creating Windows Mobile Applications for Windows Mobile Devices Using MS Visual Studio .NET
2.1 UI
2.2 Communication
2.3 P/Invoke and Native Interop
2.4 Debugging
3. Deployment and Installation
4. Security model for Windows Mobile 5 and Windows Mobile 6




Platforms such as Windows MobileBlackBerryiPhone are quite "closed" and limited to either their own devices (BlackBerry, iPhone) or the complexity of development. Among the other problems of the above-mentioned platforms is the limited API. Even the Java mobile platform has some drawbacks, such as a large number of limitations; very different APIs; Device-specific code The Symbian and Windows Mobile platforms are better from this perspective as they support a wider range of devices and their APIs provide more capabilities.

The common problem here is also that there are many platforms out there. Speaking of OpenSource and cross-platform solutions, it should be said that they are still developing and have not yet become widespread.

In this article, we will focus on the Windows Mobile platform.

Microsoft released its first platform for embedded devices in the late 90s. In 2002, the Windows CE.NET platform appeared. And then Pocket PCs were released on the Windows CE 3.0 platform and above. Further development of wireless communication technologies made it possible to combine a telephone and a personal computer. This is how pocket PC 2002 Phone Edition appeared, which supports GSM, GPRS, Bluetooth and wireless access to the HS network. At the same time, another concept of the device was being developed, which was very similar to the aforementioned, but was closer to a telephone than to a personal computer. This device was named SmartPhone 2002. The fundamental difference between a smartphone and a Pocket PC is that the PDA has a touch screen, and the smartphone has only control buttons. They also had different applications and maintained different standards and technologies.

The Windows Mobile platform is more related to smartphones, communicators and small personal devices. The Windows CE and Windows Embedded platforms are typically used in a variety of industrial hardware.

Now we have Windows Mobile 5 and Windows Mobile 6 and Windows Mobile 7 will be released soon. Modern devices based on Windows Mobile Pocket PC; have processors of 500-600 MHz and RAM 64-128 MB, which is a lot for such devices.

1. Development Tools


There are several models for developing an application for Windows Mobile:

  • Win32 API
  • MFC
  • .NET Compact Framework.

Microsoft Co provides developers with all the necessary tools to develop applications for PDAs, Pocket PCs; and a smartphone.

Here are some tips for choosing a different type of code.

  • Use your own code to maximize performance, work directly with hardware, and minimize system resource requirements.
  • Use Managed Code to develop GUI-centric applications whose main requirements are development and time-to-market. Managed code is also good for easily working with web services.
  • Use server-side code to work with different devices through a single code base, as well as if you have a wide stable communication channel with the device.

Below are overviews of existing development tools for PDAs, PDAs, and smartphones.

eMbedded Visual C ++ 4.0

The Microsoft eMbedded Visual C++ 4.0 development environment is designed to create applications for devices running the Windows CE .NET 4.2 operating system, as well as (with Service Pack 3) for PDAs and smartphones running Windows Mobile 2003 Second Edition. The eMbedded Visual C++ 4.0 development environment is good for creating native code for mobile and embedded devices running Windows CE .NET 4.2. It allows a developer to debug in a timely manner to diagnose unhandled exceptions, attach processes to a process for advanced debugging, and interact with the emulator.

Visual Studio .NET and SDP Features

The Smart Device Programming (SDP) features of the Visual Studio .NET 2003 integrated development environment (2005, 2008) enable you to create applications that use the capabilities of the Microsoft .NET Compact Framework. In this way, a developer can create distributed mobile data processing systems that work in both connected and non-persistent scenarios. Extensive class library. The .NET Compact Framework makes application development much faster than using traditional development tools.

Visual Studio .NET enables you to create applications for Pocket PC 2002 devices and (with the appropriate SDK) Pocket PC 2003, 2005, and 2003, 2005 smartphones using the same tools as for desktop application development. The .NET Compact Framework library is installed with Visual Studio .NET. This library is specifically designed for devices with limited resources. Developers can also use the new C# and Visual Basic .NET languages for mobile and embedded applications. They are good at working with web services and ADO.NET technologies.

ASP .NET Mobile Controls extend the functionality of SDP and the .NET Compact Framework. They enable you to use the capabilities of the .NET Compact Framework and Visual Studio .NET to develop mobile Web applications by delivering data to a variety of mobile devices by using ASP.NET technology. This approach allows you to create a single mobile web application in the Visual Studio .NET environment, which will automatically render data for display on various devices: mobile phones, smartphones, PDAs, PDAs. The integrated development environment (IDE) enables you to create mobile web applications by simply dragging and dropping controls onto forms.

The ASP.NET system does not install components on the client device. Server-side logic is used to adapt the formatting to specific browsers. It generates information in Wireless Markup Language (WML), HTML, and Compact HTML (cHTML) formats.

Microsoft SQL Server

Microsoft SQL Server Compact Edition (SQL Server CE) is a compact database for rapid development of applications that extend the capabilities of working with corporate data through the use of mobile devices. SQL Server CE is a tool that simplifies mobile application development by supporting SQL syntax and using a SQL Server-compatible application interface and API model.

SQL Server CE provides a core set of relational database features, such as an optimized query processor; Support for transactions and heterogeneous data types — with unpretentious requirements for system resources. Remote data access and merge replication provide reliable delivery of information from SQL Server databases, the ability to work offline with information and then synchronize with the server. SQL Server CE is suitable for systems with mobile devices and wireless networks.

SQL Server CE is designed to integrate with the .NET Compact Framework using Visual Studio .NET. Simplifies the development of database applications on mobile and embedded devices. The new SQL Server CE data provider for code management in the Common Language Runtime helps you develop extensible applications that can work offline with information in non-persistent scenarios.

Microsoft .NET SqlClient provides APIs for running .NET Framework and .NET Compact Framework applications. For shared Windows systems, Microsoft SqlClient with SQL Server and SqlServerCe for Microsoft SQL Server Compact Edition for Compact Framework databases are used.

The SqlClient namespace exists in both versions. In this way, we can interact:

  • Use the .NET Compact Framework SqlClient to access SQL Server from a device on the desktop.
  • Use the .NET Compact Framework SqlServerCe to access SQL Server Compact Edition directly on the device.

Working with databases on a device is similar to working on the desktop. SQL uses a TCP/IP connection to access SQLServer in the desktop, so you do not have to install SQL Server Compact Edition on the device.

All mentioned models are implemented on desktop systems. So the experience of their application can be used in the development of programs for Windows Mobile. Using the Win32 API, we quickly get compact code, and we can also use it to develop drivers and system components. Using MFC, we have extensions to the API functions as well as a constructor for developing the interface. And with the Compact Framework, we have a well-designed interface, automatic garbage collection, XML support, and more. There's also an even more stripped-down version, the Micro Framework, where there are fewer SDK features.

After installing the SDK for MS Visual Studio, new build configurations appear, as well as new features for building for these platforms. Suit also contains an emulator for developing and testing software without a physical connection between the device and the computer.

Because many Windows Mobile-based devices have an ARM processor, you can also compile modules using other compilers. : AVR32, ARM (RealView), GNUARM, IAR Systems.

2. Creating Windows Mobile applications for Windows Mobile devices using MS Visual Studio .NET


The Visual Studio development environment, together with the Compact Framework, enables you to develop applications using an extensive graphical interface, databases, archiving and encryption tools, USB, Serial, Bluetooth, and wireless networking and telephony. All of this is provided by the SDK, as well as libraries and header files from Platform Builder.

2.1 User interface

Thanks to the presence of a good designer in VS and SDK, we can easily develop a graphical interface for mobile applications in the same way as for desktop applications. The only difference is in the sets of graphics components for the desktop and for Windows Mobile. There is also a difference between the components of the Smartphone and Pocket PC versions, because the Pocket PC has a touch screen, while the SmartPhone does not. Therefore, the development of an interface for a smartphone is more complicated. This should be taken into account when developing software for both platforms.

It's also worth noting here that the software created for pocket PC doesn't run on the SmartPhone platform as long as the opposite is possible — as long as the moment when some special smartphone feature is invoked.

Naturally, many of the graphics components, as well as most of the features of the full-size Framework, have been removed from the Windows Mobile SDK to reduce the size of the SDK on the device side. Only the bare essentials remain. But performance and memory capacity are increasing, so the number of features included in the SDK is getting bigger. So the difference between Compact Framework 1.0 and 2.0 is huge. Version 1.0 was very limited.

In general, developing a GUI using the C# Code Framework is similar to developing a regular Win32 application in C#.

It is also possible to develop a graphical interface using an assembly of 3D rendering engines. These are such as GAPI (Game API), OPENGL ES (Embedded System), OPENVG (Vector Graphics) and other projects. Of course, this is quite a time-consuming process, since it is very important to write the optimal code due to the relatively low performance of mobile devices.

2.2 Communication

To enable date mobile devices to have a wide range of communication capabilities. They have access to a wireless high-speed network using the 802.11 WiFi Connection standard. They also use IrDa, Bluetooth, and a USB host/client. While the use of Irda is gradually declining, the protocols and standards of Bluetooth, WiFi, Edge, GSM, and USB are increasingly being used.

Microsoft provides the following APIs:

  • The ActiveSync API provides functionality for working with synchronization services, file filters, and more.
  • The Bluetooth API provides functionality for wireless access to mobile and peripheral devices.
  • Connection Manager API is used to automate the connection process, manage network connectivity. Devices use a connection manager to establish a connection, as well as to inform about the intended connection (for example, the Internet).
  • The Object Exchange (OBEX) API provides functionality for working with an efficient, compact binary protocol suitable for devices with disabilities.
  • The Remote API (RAPI) provides functions for managing and remotely invoking methods on a device side. The following functions are available: access to the registry, files, databases and various device configurations from the Desktop system. The most important option is rPC, where we simply call the "CeRapiInvoke()" method on the desktop side, pass the name of the DLL on the device side and the name of the function in that DLL, and then simply call that method.
  • API объектной модели Pocket Outlook предоставляет функции для работы с объектами Pocket Outlook. Он предоставляет интерфейсы для синхронизации и доступа к объектам: Задача, Календарь, Контакты.
  • Telephony API (TAPI) включает:
    • Assisted API
    • Extended API
    • Phone API
    • SIM Manager API
    • Short Message Service (SMS) API
    • Telephony Service Provider (TSP) API
    • Wireless Application Protocol (WAP) API.

Also, mobile devices have the ability to work with serial (USB) ports. Many devices have multiple COM ports. Usually the first 3-5 of them are reserved for IrDa, Bluetooth, SerialPort and others. Other ports are available to the user. Some devices have a USB host function, in other words, USB On-The-Go (OTG) devices that can serve as both a USB client and a USB host. To do this, the device must have the necessary hardware and software (device driver).

A device driver is a driver that is an intermediate layer between the HOST driver and the application layer. Such a driver provides a "Streaming Interface Driver" and should contain features such as:

  • XXX_Init
  • XXX_Open
  • XXX_Close
  • XXX_Write
  • XXX_Read
  • XXX_IOControl

Here, "XXX" is replaced by "Prefix" (e.g. "COM", "DSK").

This prefix is registered in the registry when the driver is registered with the system. For more information about the device driver interface, contact MSDN.

Also, the developer can use such APIs that are not related to communication:

  • API Device Configuration
  • File and Application Management API
  • Game API
  • Home Screen API
  • HTML Control API
  • Shell API
  • Speech Recognizer API
  • Vibrate API
  • Voice recorder management API.

2.3 P/Invoke and Native Interop

As far as the Compact Framework contains basic functions and methods, from the full

Framework we have such functionality as:

  • XML Serialization
  • Cryptography
  • Security
  • Reflection
  • Interop Services, etc.

Of course, Platform Invoke calls are available. For this purpose—as with the full framework—we use functions and attributes from the System.Runtime.InteropServices namespace and the DllImport attribute to describe the functions that will be called from unmanaged code.

However, the functionality of these methods is limited. So, the Marshal class has PtrToStructure, GetComInterfaceForObject, Copy(), and Read() functions, but, for example, it does not have a function such as GetDelegateForFunctionPointer(). So it's impossible to do Marshaling with Delegate alone. Only the GetFunctionPointerForDelegate function is available. If we want to pass a pointer to a function from managed code, we have to get it to the FunctionPointer and only then pass it to the unmanaged code to call it from there. Also, we can't pass some objects because the Compact Framework can't read sizeOf() for some objects. Therefore, we often have to pass only data of Blitable types and arrays of these types (Int, byte, char, but not bool), and pass and receive classes and structures using IntPtr. Of course, this is due to the desire to increase their productivity. therefore we recommend that you use the primary types for marshaling and the "gchandle" class to store the object in the process memory and make that memory "visible" to unmanaged code

Of course, the performance of P/Invoke the number of calls from a C# application to a C++ DLL is almost half that of the performance of method calls between C++ DLLs. However, the performance of devices increases, and it becomes possible to use such calls.

2.4 Debugging

MS Visual Studio allows you to debug applications under

Windows Mobile is exactly the same as for desktop applications. We have an emulator, a device emulator manager, and other features like breakpoints, threads, a tracking panel, etc.

However, you cannot debug by using native and managed code at the same time. Therefore, you can run both C++ and managed projects. It's the same with Attach to Process. It is possible to attach to processes on the device (or emulator) side. ActiveSync is required to provide communication between the device and the system, it is installed along with the SDK. You can also connect the emulator to your computer by using ActiveSync. We get almost complete emulation of Windows Mobile devices. There are emulators of smartphones and handheld computers (or Pocket PC Phone Edition). However, only one Windows Mobile device can be connected to your computer at a time. Therefore, debugging on two devices at the same time, which, for example, interact in some way, is very difficult. Of course, we are talking only about debugging the applications we have developed, and not about applications and services of the system. For this debugging, we need a complete build of the system created with Platform Builder (in recent versions of Platform Builder it is included in Visual Studio). We can also create our own SDK for the Visual Studio platform and Windows CE.

The emulator also allows you to simulate a GSM network connection and GPS support. Allows you to test and develop a wide range of applications without having a physical device in your hands.

Speaking of debugging with IDA, we have to mention that version 5.1 already has the ability to debug with this interactive disassembler using their plugin that is installed on the device.

When the SDK appears in Visual Studio, an option such as "Deploy" appears. Now in the context menu of the project there is an option "Expand", in addition to "Build", "Clear", "Debug". After selecting this option, the DLL or .exe file created in the current configuration is transferred to the device. A new column also appears in Configuration Manager, in which not only "Build" but also "Deploy" is available in some configuration settings. Deploying .NET projects transfers not only the module, but also the assemblies that depend on it (dependencies).

3. Deployment and Installation

The development of applications for Windows Mobile also involves their assembly and the creation of an installation package. To do this, in Windows Mobile there is such a thing as a Cabinet file (.cab). It's a regular archive, but it's also an installation package (a kind of MSI package). It is built using Cab Wizard (cabwiz.exefrom MS VisualStudio (or from the command line). This utility creates a processor-specific ".cab" file. The WinCEApplicationManager transmits and runs the CAB on the device so that the user can install the application by following the instructions that appear on the device's screen. You can also create an MSI Setup project that includes a .cab file by using Visual Studio. This package will run on the user's computer and then pass the CAB installation to the device to continue the installation process.

On the device side there is a special uninstall manager. You must attach a configuration .ini file to the .cab file. This .ini file includes settings to control the installation process, such as the path, the name of the shortcut to create, the minimum OS version to install the application, and other parameters written using special syntax. It is also possible to include your own DLL in the CAB file to extend the installation capabilities. This DLL contains functions such as "Installer_AfterInstall", "Installer_BeforeInstall", "Installer_AfterUnInstall", "Installer_BeforeUnInstall", the code of these functions will be executed on the device side at certain points in the installation or uninstallation process.

When developing a CAB installation, you can attach files, various resources, built-in modules, add information to the registry. They are designated as "Project Result. Therefore, after creating a CAB file, you do not need to reset anything: it will collect all the included projects and files and collect them into an archive.

4. Security Model for Windows Mobile 5 and Windows Mobile 6

Windows Mobile-based devices receive, send, and analyze potentially sensitive information that should be protected from insecure applications. To protect your device, unknown applications are disabled, access to some APIs is restricted, and some parts of the registry are not allowed to be modified. Devices can be marked as "trusted" and "unreliable," and the system uses this information to prevent unauthorized apps from running and restrict their access to the system. Access to the system via RAPI (Remote API) via ActiveSync may also be restricted. Security certificates Security rights are used for executable modules (EXE, DLL) and for CAB files.

Protection against threats and risks

The following settings help protect devices:

  • Strict password protection.
  • PIN protection.
  • Devices damage deleted information to prevent access to it (WM 6).
  • Devices damage deleted information on memory cards to prevent access to it (WM 6).
  • Storage encryption and the extended encryption standard for SSL (WM 6).
  • Use your own certificates.
  • Device detection via Bluetooth can be protected (smartphone WM 6).
  • 2 multi-level application launch system (single-tier and two-level access).
  • There is no macro support, so viruses can cause a lot of harm.

Running apps is based on permissions. Windows Mobile devices use the following models:

  • Privileged
  • Ordinary
  • Blocked

Privileged applications have the widest access. They have access to any API, entry in protected areas of the registry and full access to the system.

Most applications have a normal model. They don't have access to a trusted API and they don't have full control over the system.

The application cannot be launched at all if it has a status of "Blocked". This means that it is not signed with the appropriate certificate or the user has disabled the appropriate system warning from running.

The situation is similar with Cab files. Executable modules with a status of Normal can run privileged DLLs, but then they will run as Normal. However, privileged executable modules cannot run modules with a status of Normal.