Click to Rate and Give Feedback
Code Samples for Windows Mobile
Windows Mobile
Windows Embedded CE-
3/25/2008

The Windows Mobile Software Developer's Kit (SDK) ships with over a hundred code samples. These are working applications that can help you learn to develop software for the Windows Mobile platform.

The code samples are installed when you install the Windows Mobile 6 Professional SDK and the Windows Mobile 6 Standard SDK . Each SDK ships with code samples that are common to both platforms, as well as samples that are specific to each platform.

By default, the Windows Mobile 6 Professional code samples are copied to the folder

C:\Program Files\Windows Mobile 6 SDK\Samples\Pocket PC\

By default, the Windows Mobile 6 Standard code samples are copied to the folder

C:\Program Files\Windows Mobile 6 SDK\Samples\Smartphone\

By default, common code samples are copied to the folder

C:\Program Files\Windows Mobile 6 SDK\Samples\Common\

The majority of the code samples are C++ Win32 applications. These are found in the CPP subfolder. To use a code sample, navigate to the solution file (*.sln) you want to study, and double-click it. Microsoft Visual Studio 2005 launches, loading the solution. You can then build the solution, modify it, and deploy it.

Note:
For your convenience, each code sample topic contains the default fully-qualified path-name of the associated solution file. If you set up your development environment using the defaults, you can simply copy this information to the Clipboard, and then paste it into the Run dialog box to launch it in Visual Studio.
Note:
If an error is generated when building the samples, please try copying them to another location.

The following table contains a detailed listing of the code samples included with the Windows Mobile 6 Professional SDK and the Windows Mobile 6 Standard SDK.

Feature Area Code Sample Topic Language Windows Mobile 6 Professional Windows Mobile 6 Standard APIs Used Description

ActiveSync

Sync Manager

C++ Win32

x

x

ActiveSyncStart, ActiveSyncStop

Launches and terminates sync sessions. Displays the use of State and Notification APIs to register for changes to the two sync related Status Entries.

Folder : \Common\CPP\Win32\SyncManager

Camera

Camera Capture Graph

C++ Win32

x

 

ICaptureGraphBuilder2 Interface

Demonstrates the basic video capture functionalities using the native Camera APIs. Captures and encodes a video clip in WMV format. Captures and encodes a still image in jpeg format.

Folder : \PocketPC\CPP\win32\CameraCapture

 

Camera Capture

C++ Win32

x

x

SHCameraCapture

Take pictures and videos using the native Camera Capture API.

Folder : \Common\CPP\Win32\CECamera

 

Camera Capture

C#

x

x

Microsoft.WindowsMobile.Forms.CameraCaptureDialog

Demonstrates how to take pictures and videos using the CameraCaptureDialog managed API.

Folder: \Common\CS\CECamera

Cellcore

Telephone Dialer

C++ Win32

x

x

lineInitialize, lineNegotiateAPIVersion, lineGetDevCaps, lineDrop, lineDeallocateCall, lineClose

Demonstrates how to dial a call with a modem using TAPI.

Folder : \Common\CPP\Win32\CellCore\CeDialer

 

Synchronous TAPI

C++ Win32

x

x

lineNegotiateAPIVersion, lineGetDevCaps, lineGetGeneralInfo, lineInitializeEx, lineOpen, lineClose, lineShutdown

Demonstrates ExTAPI functionality.

Folder : \Common\CPP\Win32\CellCore\ExTAPI

 

Asynchronous TAPI

C++ Win32

x

x

lineNegotiateAPIVersion, lineGetDevCaps, lineGetGeneralInfo, LINEINITIALIZEEXPARAMS, lineNegotiateExtVersion, lineGetOperatorStatus, lineOpen, lineClose, lineShutdown

Demonstrates ExTAPI asynchronous functionality.

Folder : \Common\CPP\Win32\CellCore\ExTAPIAsync

 

Hello (SMS)

C++ Win32

x

x

SmsSendMessage

Demonstrates simple SMS message Sender.

Folder : \Common\CPP\Win32\CellCore\SMS\HelloSMS

 

Hello (Telephone)

C++ Win32

x

x

tapiRequestMakeCall

Demonstrates simple TAPI dialer.

Folder : \Common\CPP\Win32\CellCore\TAPI\HelloTAPI

 

Sending Data over SMS

C++ Win32

x

x

WapOpen, WapSend, WapRead, WapClose

Demonstrates both sending and receiving data via the Wireless Datagram Protocol (WDP) over Short Messaging Service (SMS).

Folder : \Common\CPP\Win32\CellCore\WDP_SMS

Phone and Communications

Bluetooth Device Discovery

C++ Win32

x

 

Bluetooth, Implementing Synchronous Device Discovery, WSALookupServiceBegin (Windows Sockets), WSALookupServiceNext (Windows Sockets), WSALookupServiceEnd (Windows Sockets)

Provides an implementation of simple Bluetooth device discovery via the Winsock 2 API.

Folder : \PocketPC\CPP\win32\Bluetooth\btsearch

 

Chatting over Bluetooth

C++ Win32

x

 

Bluetooth, Implementing Asynchronous Device Discovery

Demonstrates how to create peer-to-peer communications between two devices using Bluetooth wireless technology.

Folder : \PocketPC\CPP\win32\Bluetooth\BthChat

 

Bluetooth Game

C#

x

x

System.Drawing,Microsoft.WindowsMobile.SharedSource.Bluetooth

Demonstrates how to use the Windows Embedded Source Tools for Bluetooth Technology.

Folder: \Common\CS\Bluetooth\SpaceWar2D

 

Connection Manager Helper

C++ MFC

x

 

ConnMgrEstablishConnection, ConnMgrConnectionStatus, ConnMgrReleaseConnection, ConnMgrMapURL, ConnMgrProviderMessage

Demonstrates how to write a simplified Connection Manager client by deriving functionality from a helper class.

Folder : \PocketPC\CPP\MFC\CMHELPER

 

Time Server Synchronization

C++ Win32

 

x

ConnMgrReleaseConnection, ConnMgrEnumDestinations, ConnMgrEstablishConnection

Demonstrates how to use Connection Manager to establish a connection to a Time Server, and synchronize the device's internal clock.

Folder : \Smartphone\CPP\Win32\CMTime

 

WDP over SMS

C++ Win32

x

x

WapOpen, WapSend, WapRead, WapClose

Demonstrates how to send and receive data using the Wireless Datagram Protocol (WDP), over the Short Messaging Service (SMS) transport.

Folder : \Common\CPP\Win32\CellCore\WDP_SMS

 

WAP at WDP Layer

C++Win32

x

x

WapOpen, WapSend, WapRead, WapClose, WapGetNextPrimitiveSize

Demonstrates how to use the WAP APIs at the WDP Layer.

Folder : \Common\CPP\Win32\WDP

 

Ring Tone Manager

C#

x

x

SndGetSoundDirectoriesList, SndPlaySync, SndPlayAsync, SndOpen, SndStop, SndClose, PInvoke

Scans the device for audio files and also lets you copy those files to a directory where they will be recognize as a ring tone file. It PInvokes SndPlayAsync in order to preview the ringtones.

Folder : \Common\CS\RingtoneManager

Device Configuration and Security

WAP Provisioning Client

C++ Win32

 

x

DMProcessConfigXML

Loads WAP provisioning XML from a string resource and passes it to DMProcessConfigXML.

Folder : \Common\CPP\Win32\CfgClient

 

Setup in a CAB

C++ Win32

x

x

Installation Functions, CreateProcess

Demonstrates a user-interactive sample of a setup.dll that can be included in CAB files to perform complex operations.

Folder : \Common\CPP\Win32\SetupDLL

 

Viewing Security Settings

C#

x

x

ProcessConfiguration, TestConfiguration

Demonstrates how work with security policies and certificates.

Folder : \Common\CS\SecurityViewer

 

Custom Authentication Reset Component

C++

x

 

ARCSetup, ARCRequest, ARCGetValue

Demonstrates how to create a custom Authentication Reset Component (ARC).

Folder : \PocketPC\CPP\win32\AuthReset

 

LAP Plug-in for Windows Mobile Professional

C++Win32

x

 

InitLAP (function), DeinitLAP, VerifyUser (LAP), VerifyUserStart, VerifyUserToTop, LAPCreateEnrollmentConfigDialog, LAPCancelVerifySequence, LAPDisplayCodeword, LAPDisplayPreWipe, LAPLockoutUser, LASSGetValue

Implements a LAP plug-in, including all optional LAP APIs.

Folder : \PocketPC\CPP\win32\LAP

 

LAP Plug-in for Windows Mobile Standard

C++Win32

x

 

InitLAP (function), DeinitLAP, VerifyUser (LAP), VerifyUserStart, VerifyUserStop, VerifyUserToTop, LAPCreateEnrollmentConfigDialog, LAPCancelVerifySequence, LAPDisplayCodeword, LAPDisplayPreWipe, LAPLockoutUser, LASSGetValue

Implements a LAP plug-in, including all optional LAP APIs.

Folder : \Smartphone\CPP\win32\LAP

Direct 3D Mobile

D3D Create Device

C++ Win32

x

 

Direct3D Mobile Application Development

Creates a Direct3D device and uses it to clear the window.

Folder :\PocketPC\CPP\win32\Directx\d3dm\tutorials\tut01_createdevice

 

D3D Vertices

C++ Win32

x

 

Direct3D Mobile Application Development, IDirect3DMobileDevice::CreateVertexBuffer

Demonstrates the way vertices are transformed (meaning they are already in 2D window coordinates) and lit (meaning we are not using Direct3D Mobile lighting, but are supplying our own colors).

Folder : \PocketPC\CPP\win32\Directx\d3dm\tutorials\Tut02_vertices

 

D3D Matrices

C++ Win32

x

 

Direct3D Mobile Application Development, IDirect3DMobileDevice::SetTransform

Demonstrates the use of 4x4 matrices to transform the geometry with translations, rotations, scaling, and setting up our camera.

Folder : \PocketPC\CPP\win32\Directx\d3dm\tutorials\Tut03_matrices

 

D3D Dynamic Lighting

C++ Win32

x

 

Direct3D Mobile Application Development, D3DMLIGHT, IDirect3DMobileDevice::LightEnable

Demonstrates how to render 3D geometry with dynamic lighting.

Folder : \PocketPC\CPP\win32\Directx\d3dm\tutorials\Tut04_lights

 

D3D Texture Mapping

C++ Win32

x

 

Direct3D Mobile Application Development, IDirect3DMobileDevice::SetTexture, IDirect3DMobileDevice::SetTextureStageState

Demonstrates how to render texture-mapped 3D geometry.

Folder : \PocketPC\CPP\win32\Directx\d3dm\tutorials\Tut05_textures

 

D3D Fixed Point Data

C++ Win32

x

 

Direct3D Mobile Application Development

Demonstrates how to accept both floating point and fixed point (16.16) data types.

Folder : \PocketPC\CPP\win32\Directx\D3DM\tutorials\Tut06_fixedpoint

Direct Draw

DDraw Initialization

C++ Win32

x

 

DirectDraw

Demonstrates how to initialize DirectDraw and create a DirectDraw surface.

Folder : \PocketPC\CPP\win32\Directx\DDraw\DDex1

 

DDraw and Bitmaps

C++ Win32

x

 

DirectDraw

Demonstrates how to add a bitmap. Extends DDex1.

Folder : \PocketPC\CPP\win32\Directx\DDraw\Ddex2

 

DDraw Off-Screen Surfaces

C++ Win32

x

 

DirectDraw

Demonstrates the use of off-screen surfaces.

Folder : \PocketPC\CPP\win32\Directx\DDraw\Ddex3

 

DDraw and Audio

C++ Win32

x

 

DirectDraw

Demonstrates how to combine DirectDraw and waveform audio.

Folder : \PocketPC\CPP\win32\Directx\DDraw\Donuts2

 

DDraw and Animation

C++ Win32

x

 

DirectDraw

Demonstrates DirectDraw animation using overlays.

Folder : \PocketPC\CPP\win32\Directx\DDraw\Mosquito

DPI Awareness

Crossword

C++ Win32

x

 

ChangeDisplaySettingsEx, WM_SETTINGCHANGE, WM_SIZE, GetDeviceCaps, GetSystemMetrics, SHGetUIMetrics

Demonstrates how to convert a basic application into a high DPI aware application and into a landscape/portrait aware application.

Folder : \PocketPC\CPP\win32\Crossword

 

Screen Resolution

C++ Win32

x

 

Developing DPI Aware Applications

As you are developing applications for new high-resolution devices with 192 DPI resolution displays, you might wonder where the new high-resolution bitmaps and resources should go. The simplest solution is to include them in the same EXECUTABLE alongside the old, low-resolution resources. However, this approach wastes storage space. Device screens only have one resolution, which never changes for that device. Therefore, if the application is deployed to a 96 DPI device, it doesn't need 192 DPI resources - and vice versa.

Folder : \PocketPC\CPP\win32\Resdll

EDB

CEDB to EDB Migration

C++Win32

x

x

EDB Reference, CeOidGetInfoEx2 (EDB), CeMountDBVol (EDB), CeCreateDatabaseWithProps (EDB), CeCreateSession (EDB), CeOpenDatabaseInSession (EDB), CeSeekDatabaseEx (EDB)

Demonstrates how an application that used CEDB can been ported to use EDB.

Folder : \Common\CPP\Win32\FileDB

FileDRM

DRM Files

C++ Win32

x

x

FileDrmIsDRM, FileDrmShowLicenseInfo, FileDrmVerifyRights, FileDrmCreateFile, FileDrmGetMetric, FileDrmCommitRights

Demonstrates how to use the FileDRM APIs.

Folder : \Common\CPP\Win32\FileDRM

Imaging

Imaging Sample

C++ Win32

x

x

IImage, IImagingFactory

Demonstrates how to use the imaging.dll to load and display an image file.

Folder : \Common\CPP\Win32\Imaging

Internet Explorer Mobile

AXSample

C++ ATL

x

x

ActiveX Controls, ATL, COM

Demonstrates how to use ATL to create an ActiveX control, and how to access it in a web page.

Folder : \Common\CPP\ATL\AXSample

 

Web Browsing

C++ Win32

x

 

HTML Control API

Demonstrates the use of the HTML Viewer control, including the use of the DTM_NAVIGATE message to cause the control to download and display content from a URL.

Folder : \PocketPC\CPP\win32\browse

 

The Browser Helper Object (BHO)

C++ ATL

x

x

IWebBrowser2, DWebBrowserEvents2

Demonstrates now to create a Browser Helper Object (BHO), which Internet Explorer Mobile loads each time it starts up.

Folder : \Common\CPP\ATL\PIEHelper

 

Using Internet Explorer Mobile In Your Application

C++ ATL

x

x

IWebBrowser2, DWebBrowserEvents2

Demonstrates how to reuse the Internet Explorer Mobile web browser in a mobile application.

Folder : \Common\CPP\ATL\MiniPIE

Menu extensions, POOM Named Properties

Medical History

C++ Win32

x

 

IItem::SetProps, IPOutlookApp2::GetIDsFromNames, IPOutlookApp2, IPOutlookApp2::GetItemFromOidEx, IItem, IContextMenu, IObjectWithSite

Demonstrates how to add a menu extension to the contacts summary card.

Folder : \PocketPC\CPP\win32\MedicalHistory

Message Queuing

Message Queuing Sample

C++ Win32

x

x

Using the MSMQAdm Utility, Debugging MSMQ Installations, MSMQ Reference

Demonstrates how to use message queuing (MSMQ). It is a visual wrapper around MSMQADM.exe.

Folder : \Common\CPP\Win32\MSMQ\VisAdm

Messaging (MAPI)

Push Messaging

C++ Win32

x

x

ShellExecuteEx

Demonstrates a push client that receives a push message and saves the message's body into a file and then calls ShellExecuteEx on that file.

Folder : \Common\CPP\Win32\FileClient

 

Set Message Store Properties

C++ Win32

x

x

IMAPISession, IMAPITable, IMAPIProp::GetProps, IMAPIProp::SetProps

Demonstrates how to use IMsgStore::GetProps and IMsgStore::SetProps how to retrieve and set properties on message stores.

Folder : \PocketPC\CPP\win32\MailSet

 

MAPI Rules

C++ Win32

x

x

IMailRuleClient, IMailRuleClient::ProcessMessage, IMailRuleClient::Initialize, IMsgStore, IMsgStore::OpenEntry, IMessage, IMAPIProp::GetProps, MAPI Properties

Demonstrates how to implement a MAPI Rule Client, a COM object which can handle and filter incoming MAPI messages.

Folder : \Common\CPP\Win32\MapiRule

 

Read View Menu Extension

C++ Win32

x

x

IContextMenu, IObjectWithSite, MailComposeMessage

Demonstrates how to reply to an email message using a default email account.

Folder : \Common\CPP\Win32\ReadViewMenuExt

 

Sending E-mail

C++ Win32

x

x

Messaging API (CE MAPI) Reference, MAPILogonEx, CbSRowSet, IMAPISession::GetMsgStoresTable, IMAPISession::OpenMsgStore, IMAPITable::QueryRows, IMsgStore::OpenEntry, IMAPIProp::GetProps, IMAPIFolder::CreateMessage, IMessage::SubmitMessage, MAPIFreeBuffer, FreeProws

Demonstrates how to use several CEMAPI APIs.

Folder : \Common\CPP\Win32\SendMail

 

New Messaging Transport

C++ Win32

x

 

IMailSyncHandler

Demonstrates how to create a new messaging transport.

Folder : \PocketPC\CPP\win32\TransportDemo

 

New Message Class

C++ Win32

x

 

IFormProviderEx, IMailRuleClient

Implements a new message class appropriate for SMS notifications from your DVR.

Folder : \PocketPC\CPP\win32\TV_Inbox

Phone

Calling Card

C++ Win32

 

x

PhoneMakeCall, IContextMenu::QueryContextMenu

Demonstrates how to make a calling card call directly from the Contacts screen.

Folder : Common\CPP\Win32\CallingCard

 

Get Device's Phone Number

C++ Win32

x

x

IWebBrowser2, DWebBrowserEvents2

Demonstrates how to retrieve the phone number of a device.

Folder : \Common\CPP\Win32\GetPhoneNumber

 

Find a Lost Phone

C#, VB

 

x

State and Notifications Broker, Microsoft.WindowsMobile.PocketOutlook.MessageInterception, Microsoft.WindowsMobile.Status, PlaySound, PInvoke

Demonstrates how to write an application that helps you locate your phone if you lose it.

Folder : \Smartphone\CS\PhoneFinder

Folder : \Smartphone\VB\PhoneFinder

 

Manage SIM Contacts

C++ Win32

 

x

SIM Manager Reference, SimDeinitialize, SimGetDevCaps, SimInitialize, SimReadPhonebookEntry, Telephony

Demonstrates how to add phone numbers to, and delete phone numbers from, a Subscriber Identity Module (SIM).

Folder : \Smartphone\cpp\Win32\SIMMgr

POOM

Calendar List View

C++ Win32

x

 

CEPROPVAL, GetCursor, IDispatch, IFolder, IItem, InitCommonControlsEx (function), INITCOMMONCONTROLSEX (structure), IPOutlookApp2, IPOutlookItemCollection, LoadCursor, LVCOLUMN, LVITEM, MSG, SetCursor, SHINITDLGINFO, SHMENUBARINFO

Demonstrates how to use the POOM IItem interface for appointment items, and POOM notifications. It displays a list-view with all calendar items.

Folder : \PocketPC\CPP\win32\CalendarView

 

Picture Dialer

C++ Win32

x

x

Pocket Outlook Object Model (POOM), ChooseContact

Demonstrates how to associate a phone number and picture with a digit in a grid. Pressing the digit will dial the phone number.

Folder : \Common\CPP\Win32\PictureDialer

 

Register a Source Provider

C++ Win32

x

 

CEPROPVAL, IPimSrcContactListIcon::Paint, IPimSrcContactSummaryCard::Display, PIMSRC_COLOR, Source Provider Customization Type Flags

The following application registers a source provider for the Contacts and Calendar applications.

Folder : \PocketPC\CPP\win32\PimExProvider

 

POOM Master

C++ Win32

x

x

Pocket Outlook Object Model (POOM), IPOutlookApp, IPOutlookItemCollection, ITask, IContact, IAppointment, ListView_InsertItem, Date and Time Picker Controls Reference

Demonstrates how to use the POOM API. Via an owner-drawn list-view control, POOMMaster displays currently stored PIM items (Contacts, Tasks, and calendar Appointments).

Folder : \Common\CPP\Win32\PoomMaster

 

Manage Tasks

C++ Win32

 

x

IPOutlookItemCollection, IRecurrencePattern, ITask

Demonstrates how to write a Personal Information Manager (PIM)/Messaging application that uses API members from the Pocket Outlook Object Model (POOM) to create, delete, and otherwise manage tasks.

Folder : \Smartphone\cpp\Win32\poomtasks

 

Task Tree

C++ Win32

x

 

Pocket Outlook Object Model (POOM)

Demonstrates how to display tasks in a tree view. Enables user to add new tasks to the tree.

Folder : \PocketPC\CPP\win32\TaskTree

 

POOM Application

C#

x