Develop for Windows Mobile 5.0 with Visual Studio 2005
Microsoft EMEA Home
| Site Map
Search Microsoft.com for:
Go The Beta Experience
Develop for Windows Mobile 5.0 with Visual Studio 2005 Published: September 4, 2005 By David Goon
On This Page Introduction Getting Started with Windows Mobile 5.0 Developmnet Windows Mobile 5.0 Productivity APIs
Introduction Windows Mobile 5.0, the latest Microsoft operating system for mobile devices, was launched on the 11th of May 2005 at the Mobile and Embedded Developers Conference, Las Vegas, USA. It represents a significant step forwards with emphasis on increased user productivity, great multimedia support and increased options for OEMs and operators to differentiate their device offerings. The new operating system brings with it a whole slew of new API’s and interfaces that make application development simpler and more powerful. However, the best news of all is the arrival of an integrated development platform providing all the tools necessary to target this new release – Visual Studio 2005. Although Visual Studio 2005 is currently in Beta you can use it to develop Windows Mobile 5.0 applications and even take them to market. This article will explore: ●
Getting started with Windows Mobile 5.0 development
http://www.microsoft.com/emea/msdn/betaexperience/nlarchive/issue_3/develop_for_windows_mobile_5_with_visual_studio_2005.aspx (1 of 6)19-10-2005 0:58:43
Develop for Windows Mobile 5.0 with Visual Studio 2005 ●
What Windows Mobile 5.0 brings in terms of new Productivity APIs
●
What Windows Mobile 5.0 brings in terms of new Multimedia APIs
Windows Mobile 5.0 also introduces new managed libraries that work with .NET Compact Framework programs in addition to the expected Win32 API sets. Developers using C# or VB.NET can use these libraries from applications based on either version 1.0 or version 2.0 of the Compact Framework. This article will describe these new libraries but will not cover libraries that are part of the Compact Framework itself. By the end of the article, you should have a basic understanding of the new features available for your use in developing the next killer mobile application. As Visual Studio 2005 is still a Beta product at this time, information provided in this article is subject to change. However, Windows Mobile 5.0 is a released product and information is accurate at the time of writing. Top of page
Getting Started with Windows Mobile 5.0 Development Visual Studio 2005 Beta 2 ships with the Windows Mobile 2003 Second Edition SDKs pre-installed. Thus, you can immediately develop for that platform out-of-the-box. In order to add Windows Mobile 5.0 support to Visual Studio 2005, you will need to add the necessary Windows Mobile 5.0 Pocket PC or Smartphone SDKs to your installation list. The installation steps below, downloads, additional tools and additional information can be found in the following MSDN article. Install the Tools You Need to Get Started Today http://msdn.microsoft.com/mobility/windowsmobile/howto/windowsmobile5/install/default.aspx As a minimum, the following will provide you with a development environment that can be used to write programs for Windows Mobile 5.0 devices. 1. Start with a default installation of Visual Studio 2005 Beta 2. 2. It is highly recommended to then install the DMA Transport Update. This update changes the default communications method between the device emulators and Visual Studio from TCP/IP to DMA (Direct Memory Access) with a marked improvement in performance since the TCP/IP network protocol stack is eliminated and data is transferred directly via DMA. 3. Install ActiveSync 4.0 which is required for connections to Windows Mobile 5.0 devices. Note that the development environment needs ActiveSync to support application deployment and debugging. 4. Finally install either or both the Windows Mobile 5.0 SDKs. There is one for Pocket PC development and another targeting the Smartphone platform. Each SDK provides headers, libraries, samples and most importantly emulators for testing your applications. These highfidelity emulators allow developers to test most functionality and are vital in the absence of new Windows Mobile 5.0 devices coming to market soon. Once the above actions are completed new device targets will appear in the New Project Dialog for the language you have selected. http://www.microsoft.com/emea/msdn/betaexperience/nlarchive/issue_3/develop_for_windows_mobile_5_with_visual_studio_2005.aspx (2 of 6)19-10-2005 0:58:43
Develop for Windows Mobile 5.0 with Visual Studio 2005
Figure 1. New Project
Note the entries labelled Pocket PC Magneto and Smartphone Magneto. Magneto was the codename for Windows Mobile 5.0 during development and these entries will be changed to reflect the release version of the name in due course. Now that we have the development environment ready, let’s have a look at what Windows Mobile 5.0 brings to mobile developers. As mentioned in the introduction section of this article, Windows Mobile 5.0 is really about three things – Increased Productivity, Great Multimedia and Differentiation. Differentiation is primarily the domain of device manufacturers and cellular operators. We will thus look at the APIs that application developers have access to in the areas of Productivity and Multimedia. Top of page
Windows Mobile 5.0 Productivity APIs State and Notification Broker Mobile devices function in a very fluid environment where, being on the move, their environment changes frequently. It thus becomes important for an application to know what state the device is in at any one time. Examples of interesting states include battery power remaining, or GPRS availability. It was previously difficult to determine a device’s current state and respond to state changes effectively and efficiently because each different component of the device kept its own state information and may http://www.microsoft.com/emea/msdn/betaexperience/nlarchive/issue_3/develop_for_windows_mobile_5_with_visual_studio_2005.aspx (3 of 6)19-10-2005 0:58:43
Develop for Windows Mobile 5.0 with Visual Studio 2005
not even have provided a means to get to the data. With Windows Mobile 5.0, the operating system has centralized its state information into a single store. What is more, an API set is now exposed so that you can access state information in a standard way. The new state store is based on the system registry and state is both recorded and monitored there. The states provided by the operating system are extensive and covers among other things: ●
Phone (e.g. Missed Call, Phone Status, Caller ID)
●
Network Connections (e.g. WiFi, GPRS, modem)
●
Calendar (e.g. Current and Next Appointments)
●
Messaging (e.g. Unread Mail Count, SMS)
●
Many others (e.g. Display Orientation, Cradled)
Additionally, you can extend the states tracked with custom states. The broker, through the API set, allows states to be changed or monitored for change. When a change is detected, a notification is sent to an application that can then react accordingly. You can have transient notifications, which work when the application requesting it is running. The notification takes the form of a window message, a callback or message in a message queue. The following example uses the RegistryNotifyWindow API to send a window message when phone signal strength changes.
#include #include // Set up the notification HREGNOTIFY hNotify = NULL; RegistryNotifyWindow( SN_PHONESIGNALSTRENGTH_ROOT, SN_PHONESIGNALSTRENGTH_PATH, SN_PHONESIGNALSTRENGTH_VALUE, hWnd, WM_MY_WINDOW_MESSAGE, dwUserDefinedValue, NULL, &hNotify);
However, the more powerful version is persistent notifications. This type of notification will cause your application to be started by the operating system if it isn’t already running. Use the RegistryNotifyApp API to request this.
http://www.microsoft.com/emea/msdn/betaexperience/nlarchive/issue_3/develop_for_windows_mobile_5_with_visual_studio_2005.aspx (4 of 6)19-10-2005 0:58:43
Develop for Windows Mobile 5.0 with Visual Studio 2005
#include #include NOTIFICATIONCONDITION nc; nc.ctComparisonType = REG_CT_EQUAL; nc.TargetValue.dw = 1; nc.dwMask = 0xFFFFFFFF; RegistryNotifyApp( SN_CRADLEPRESENT_ROOT, SN_CRADLEPRESENT_PATH, SN_CRADLEPRESENT_VALUE, TEXT("OSServices.CradlePresent"), TEXT("\"\\Program Files\\OSServices\\OSServices.exe\""), NULL, NULL, 0, 0, &nc);
Managed Pocket Outlook Object Model Prior to Windows Mobile 5.0 access to PIM functionality required native C++ programming because no interface classes were provided for Managed code to call. This was partly due to the lack of COM support in Compact Framework 1.0. With Compact Framework 2.0 COM interoperability is available through runtime generated proxy classes so developers can access COM objects directly if required. Additionally a new managed code library is available with Windows Mobile 5.0 that provides access to all PIM functionality from both Compact Framework 1.0 and 2.0 applications. This new functionality can be found within the Microsoft. WindowsMobile.PocketOutlook namespace and provides a streamlined object model that makes working with the PIM elements a lot easier. Prior to Windows Mobile 5.0 access to PIM functionality required native C++ programming because no interface classes were provided for Managed code to call. This was partly due to the lack of COM support in Compact Framework 1.0. With Compact Framework 2.0 COM interoperability is available through runtime generated proxy classes so developers can access COM objects directly if required. Additionally a new managed code library is available with Windows Mobile 5.0 that provides access to all PIM functionality from both Compact Framework 1.0 and 2.0 applications. This new functionality can be found within the Microsoft. WindowsMobile.PocketOutlook namespace and provides a streamlined object model that makes working with the PIM elements a lot easier.
using Microsoft.WindowsMobile.PocketOutlook; . . . using(OutlookSession outlookSession = new OutlookSession()) { Contact contact = new Contact(); contact.FirstName = "Joe"; contact.LastName = "Bloggs"; contact.MobileTelephoneNumber = "+00 (0) 123 456 7890"; http://www.microsoft.com/emea/msdn/betaexperience/nlarchive/issue_3/develop_for_windows_mobile_5_with_visual_studio_2005.aspx (5 of 6)19-10-2005 0:58:43
Develop for Windows Mobile 5.0 with Visual Studio 2005
outlookSession.Contacts.Items.Add( contact ); }
It is clear from the above code that the new model is extremely concise and readable.
Pocket PC Soft-keys On Windows Mobile 5.0 Pocket PC devices, you will find the addition of two hardware keys in similar positions to those that exist on the Smartphone today. These keys, called soft-keys, are designed to relate to menu items immediately above the keys bringing a consistent look and feel across both Pocket PC and Smartphone platforms. Pocket PC applications can now lay out their menu structure to take advantage of these keys and provide quicker access to application functionality for the user.
Top of page
Manage Your Profile ©2005 Microsoft Corporation. All rights reserved. Terms of Use |Trademarks |Privacy Statement
http://www.microsoft.com/emea/msdn/betaexperience/nlarchive/issue_3/develop_for_windows_mobile_5_with_visual_studio_2005.aspx (6 of 6)19-10-2005 0:58:43