Creating Applications for the Pocket PC

Friday Aug 22nd 2003 by Karl Moore

Devices such as the Pocket PC are becoming almost as powerful as the machines sitting on our desks. It makes sense that more and more developers want to create applications directly targeted at such platforms. Learn how to create a Pocket PC application using Visual Basic .NET.

As devices such as the Pocket PC become almost as powerful as the machines sitting on our desks, it makes sense that more and more developers will want to start creating applications directly targeted at such platforms.

In the old days, however, this was pretty difficult. You had eMbedded Visual Basic, which allowed you to create Windows CE applications, but programming inconsistencies and sticky development techniques didn't make for an easy ride.

But, with the release of Visual Studio .NET 2003 (Everett), Microsoft has introduced a new solution. It's a two-part fix that allows you to create applications to run on resource-constrained devices such as the Pocket PC and Windows CE handhelds, in almost the same way that you'd create a regular Windows application.

The first part to the solution is the .NET Compact Framework. This is a mini version of the .NET Framework, weighing in at almost 2MB (compared with 20MB+ for the full Windows version). The .NET Compact Framework runs on your device and includes a large selection of the core Framework classes, including a wide range of controls, plus even stretches to supporting Web services.

The second part to the solution is the ability to create a smart device application. This is like a tiny Windows application, with a typical Pocket PC form defaulting to 240 by 320 pixels. The program is built on top of the .NET Compact Framework (which can run on your development machine) and can be packaged into a CAB file and installed directly on your target device.

TOP TIP Are you using Visual Studio .NET 2002? Although the .NET Compact Framework betas allowed VS .NET 2002 users to create smart device applications, the final release ships only with Visual Studio .NET 2003 (Everett), which means that you either upgrade or ship out.

Building for the Compact Framework

How do you get started with developing for the .NET Compact Framework (CF)? Simply fire up Visual Studio .NET and create a new Smart Device Application. You'll be presented with a wizard, asking what sort of application you'd like to create.

You'll need to choose the platform you wish to target and the type of application you'd like to create. As the industry moves more toward Pocket PC devices, the norm here would be to select a Windows application running on the Pocket PC.

TOP TIP Looking for a niche software market? Hundreds of developers create component libraries for the COM and .NET development worlds. But how many create class libraries for Pocket PC developers? Perhaps libraries that overcome the limitations imposed by the "trimming" of the .NET Compact Framework?

After selecting your project type, you should be presented with your first form. From here, you can begin development just as with a regular Windows application, with a few obvious size restrictions.

The big thing to remember here is that the framework supporting this type of project is not the .NET Framework. It's the .NET Compact Framework. This means that, although you can still develop your program as you would a regular Windows application, not everything will operate exactly as you expect.

For instance, controls will look different and may vary slightly in the way they operate, and certain classes may be unavailable or work in an altered fashion. But it's generally similar: you can add extra forms and open them using standard techniques; you can create smart device class libraries and reference them as you'd expect; and you can add Web references and interact with Web services as usual.

On the whole, it's a relatively easy shift.

Click here for larger image

Figure: Visually designing my Pocket PC application in Visual Studio .NET

So, you've developed a neat Pocket PC project and want to give it a test run. But how? Simply follow the usual VS .NET debugging techniques: select Debug > Start to begin. You should be asked which device you wish to deploy your application on.

For example, creating a Windows application for the Pocket PC will allow you the option of using the Pocket PC 2002 emulator or a live debug session with a connected Pocket PC. Chose your target and select Deploy.

If the .NET CF hasn't yet been installed on your device, VS .NET will install it for you and then run your application. This is where you step in: test your application, step through your code, and identify bugs. This is just the same as with regular Windows applications.

TOP TIP The first time you run the Pocket PC 2002 emulator, you'll probably be asked to set up the device, "tapping" through the welcome screens. The emulator is actually a fully working version of the Pocket PC operating system and therefore reacts in the exact same manner. It's one of the best emulators I've seen.

Figure: A sample application running in the Pocket PC 2002 Emulator

Deploying Your Applications

You've created that application and done the whole testing thing. Now you're ready to roll it out to .NET CF devices around the globe. What's to do?

First, as with regular Windows applications built for the full .NET Framework, a copy of the framework needs to be installed on the machine. This can be installed in RAM by downloading the setup from This is absolutely required: attempting to run a smart device application without the .NET CF installed will raise an error.

TOP TIP Today, most devices will allow the .NET Compact Framework to be installed only into RAM. However, most future Pocket PCs and smart phone devices will come with the .NET Compact Framework already installed in the ROM.

Second, you need to create your application setup. This is fully automated: simply select Build > Build Cab File from within your smart device application project.

TOP TIP If you wish to distribute a bundle of files with your application (game images, for example), add them by right-clicking on your project and selecting Add > Existing Item. You can also put files within subfolders. When installed on the device, the folders and files are extracted in the application root directory, ready for your application to utilize.

Inside your project \Cab\<Configuration>\ folder, you'll find a variety of CAB files (alongside a mass of unimportant DAT files, which you may disregard). Each of these CAB files contains a version of your project specific to a particular processor for the platform you selected. For example, a Pocket PC application will generate versions for the ARM, X86, MIPS, and other processors.

However, as all Pocket PC devices are now standardizing on the ARM v4 processor, the most important CAB file in the list is MyProject_PPC.ARMV4.CAB. This is your project setup, created for the Pocket PC (PPC) ARM v4 processor.

When you're ready to deploy, you can deploy the relevant CAB to your device using ActiveSync (a PC-device synchronization feature that many PDA users will be aware of) or by setting up a file share on your machine, copying the CAB file onto your device, then single-clicking to automatically install.

TOP TIP Want to test CAB deployment on the Pocket PC 2002 emulator? You can simply set up a file share, then copy the CAB file across the emulator ROM, and run! Here's how: first, create a folder containing the CAB file, then set it up as a shared directory (typically, right-click, select Sharing and Security, select "Share this folder", and then click on OK). Next, in your Visual Studio .NET device project, select Tools > Connect to Device. The emulator should appear in the background. On the emulator, select Start > Programs > File Explorer, then click on the network share icon at the bottom-middle of the screen. You should be prompted for the name of your machine (\\MyComputerName), followed by your user name, password, and domain (if required). Open the shared folder, and then click and hold on your CAB file as a series of dots draw themselves on the screen: eventually, a popup menu will appear. Select Copy. Next, switch back to browsing files on your device by clicking on the PDA-style icon at the bottom of the screen. Now select Edit > Paste, and your CAB will be copied to the local machine. (This is required because networked files will not open over the network.) When copying has finished, single-click on the CAB to begin installation. If you receive a naming conflict error when connecting to your file share, it's because you're running on the same machine that you're connecting to. So, click on Start > Settings, select the System tab, click on About, select the Device ID tab, change the Device name, and try again.

You'd be forgiven for thinking the deployment portion of such smart device applications is currently a little immature. It was, apparently, something of an afterthought. You can expect improvements in the next revision (see for the latest). Don't be surprised to find a bundle of third-party InstallShield-style solutions to hit the market shortly, too.

Going on from Here

Although this brief introduction should give you enough fuel to get going with your own PDA applications, there's much more to learn.

For example, did you know that you can run the powerful SQL Server CE on your handheld? And you can write applications to create databases and access your data, perhaps even synchronizing live with a master SQL Server database? It's all true. (Check out the setup and help files in \Microsoft Visual Studio .NET 2003\CompactFrameworkSDK\v1.0.5000\Windows CE for more information.)

You can learn more about creating your own smart device applications by browsing the hidden samples distributed with Visual Studio .NET; they're in the \Microsoft Visual Studio .NET 2003\CompactFrameworkSDK\v1.0.5000\Windows CE\Samples\VB\ folder or online at (Make sure you check out the MapPoint and Cave Man Hank samples!)

And, of course, there are a plethora of books dedicated to the technology: try The Definitive Guide to the .NET Compact Framework by Dan Fergus and Larry Roof ($59.99, ISBN 1-59059-095-3) and SQL Server CE Database Development with the .NET Compact Framework by Rob Tiffany ($44.99, ISBN 1-59059-119-4).

But, for now, go and create. The shift is simple, and the results are pretty amazing.

About the Author

Karl Moore (MCSD, MVP) is an experience author living in Yorkshire, England. He is author of numerous technology books, including the new "Ultimate VB .NET and ASP.NET Code Book" (ISBN 1-59059-106-2, $49.99), plus regularly features at industry conferences and on BBC radio. Moore also runs his own creative consultancy, White Cliff Computing Ltd. Visit his official Web site at

# # #

Mobile Site | Full Site
Copyright 2017 © QuinStreet Inc. All Rights Reserved