Click here to Skip to main content
Click here to Skip to main content

Developing and Deploying Pocket PC Setup Applications

, 20 Jan 2004
Rate this:
Please Sign up or sign in to vote.
Learn how to create a single .msi file that is run from the desktop to install an application on different Pocket PC devices. The development process is automated so it's easy to build and package all of the necessary components into the .msi file. Sample code is provided for C# and VB.NET.

This article has been provided courtesy of MSDN.

Contents

Overview

The following are key points when developing and deploying Pocket PC applications:

  • Pocket PC devices have different processors (ARM, SH3, MIPS, etc.).
  • Applications are deployed using cabinet (.cab) files.
  • Each processor type requires a different .cab file.
  • The Cab Wizard (cabwiz.exe) generates processor-specific .cab files.
  • The WinCE Application Manager deploys and installs .cab files on Pocket PC devices from the desktop.

The deployment process and uninstalling are discussed first, followed by development and automating the development process.

Deployment

Users can install Pocket PC applications by copying and running the appropriate .cab file to their device, but a better solution installs the application on the device by running a .msi file on their desktop. This .msi file detects the type of device, copies the correct .cab file to the device, and installs the application by running the .cab file. All of this is transparent to the user; they run a .msi file on their desktop and the application is automatically installed on the Pocket PC.

The following are the steps involved in the MSI-based deployment:

  • User runs the .msi file on their desktop.
  • The .msi file unpacks processor-specific .cab files, setup.ini and a custom installer component.
  • The installer component is executed during the installation, and deploys and installs the correct .cab file to the device by running the WinCE Application Manager.
  • The setup.ini file describes the application to the WinCE Application Manager.

The diagram below shows the pieces involved in this process followed by information on each piece.

Figure 1. Pieces involved in the deployment process

.msi File

The .msi file is the single file that installs your Pocket PC application from the desktop. The user runs the .msi file and it unpacks processor-specific .cab files, a customer installer component, and a setup.ini file.

.cab Files

Pocket PC applications are installed by running .cab files on the device. These are self-extracting files that contain installation instructions and all of the files required by the application. The files are processor-specific, so a separate .cab file is required for each processor type supported by the application.

Installer Component

This is a custom installer component that is executed during the installation process. It runs the WinCE Application Manager to copy and install the correct .cab file to the device.

Setup.ini File

This initialization file describes the application to the WinCE Application Manager and is required to install apps through the application manager.

WinCE Application Manager

The WinCE Application Manager (CeAppMgr.exe) resides on the user's desktop system and is used to install and uninstall applications on Pocket PC devices. The following shows the application manager prompting the user to install the sample application on the Pocket PC device.

Figure 2. Installing a Pocket PC application from the desktop

Uninstalling

The .cab file stores information on the Pocket PC so the application can be uninstalled. Users can uninstall the application using the Pocket PC directly or from the desktop. To uninstall the application using the Pocket PC, users select Remove Programs from the Settings application, as shown below.

Figure 3. Using Pocket PC to uninstall an application

Just like installing, users can also uninstall the application from their desktop. They select the application from the Control Panel application Add or Remove Programs and click the Remove button. This executes the custom installer component that runs the WinCE Application Manager in uninstall mode (does not specify a setup.ini file). The user unchecks the application and clicks OK to uninstall the application from the Pocket PC device.

Figure 4. Uninstalling a Pocket PC application from the desktop

Development

The development goal is to generate the .msi file with the least amount of work (one click if possible). First, let's see what pieces are involved in the development process:

  • The BuildCab.bat file starts the process by running the Cab Wizard.
  • The information file (.inf) describes the application to the Cab Wizard.
  • The Cab Wizard generates different .cab files for the processor types specified in the .inf file.
  • The .cab files, along with a custom installer component and a setup.ini file are packaged into a .msi file.

The diagram below shows the pieces involved in this process, followed by information on each piece.

Figure 5. Pieces involved in the development process

BuildCab.bat

The BuildCab.bat file builds processor-specific .cab files by running the Cab Wizard tool. Visual Studio generates a template BuildCab.bat file when you select Build Cab Files from the Build menu. It's a good idea to let Microsoft® Visual Studio® generate this file, then copy it to a different location and make any changes. Most likely, the only change required is specifying a new path for the .cab and log files. The sample BuildCab.bat is shown below.

"C:\Program Files\Microsoft Visual Studio .NET 
  2003\CompactFrameworkSDK\v1.0.5000\Windows CE\..\bin\..\bin\cabwiz.exe" 
  "c:\program files\pocketpc deploy 
  sample\Source\CS\PocketApp\BuildCabs\PocketApp_PPC.inf" /dest 
  "c:\program files\pocketpc deploy 
  sample\Source\CS\PocketApp\BuildCabs\Cabs" /err CabWiz.PPC.log /cpu 
  ARMV4 ARM SH3 MIPS X86 WCE420X86

Information File (.inf)

The Microsoft Windows® CE .NET .inf file specifies installation settings and application files to the Cab Wizard. Like the BuildCab.bat file, Visual Studio generates a template .inf file when Build Cab Files is selected. You should initially generate this file with Visual Studio and then copy it to another location to make any changes. The file usually requires minimal changes; usually just updating the Provider name.

Visual Studio generates a .inf file that contains references to vsd_setup.dll. This component is used for version checking and reports information if the Pocket PC device does not have the correct version of the .NET Compact Framework installed. It is a good idea to keep this in your application but it has been removed from the sample code for simplicity.

A sample file is shown below. You can visit Microsoft Windows CE .NET: Creating an .inf File for more information on .inf files.

[Version]
Signature="$Windows NT$"
Provider="Sample Company"
CESignature="$Windows CE$"

[CEStrings]
AppName="PocketApp"
InstallDir=%CE1%\%AppName%

[CEDevice]
VersionMin=3.00
VersionMax=4.99

[DefaultInstall]
CEShortcuts=Shortcuts
CopyFiles=Files.Common

[SourceDisksNames]
1=,"Common1",,"C:\Code\Microsoft\Pocket PC 
  Whitepapers\Deployment\Code\CS\PocketApp\obj\Release\"

[SourceDisksFiles]
PocketApp.exe=1

[DestinationDirs]
Files.Common=0,%InstallDir%
Shortcuts=0,%CE2%\Start Menu

[Files.Common]
PocketApp.exe,,,0

[Shortcuts]
PocketApp,0,PocketApp.exe,%CE11%

Cab Wizard

The Cab wizard (cabwiz.exe) generates .cab files that can be installed on different Pocket PC devices. A .inf file is used to describe the application to the wizard and is passed as the first argument on the command line. Other optional arguments are the destination directory, error log file, and CPU types. You can visit Microsoft Windows CE .NET: CAB Wizard Syntax for more information on running the wizard.

Installer Component

The custom installer component automates the deployment process by handling the AfterInstall and AfterUninstall events and running the WinCE Application Manager. The path to the application manager is stored in the registry under the HKLM\software\Microsoft\Windows\CurrentVersion\App Paths\CEAppMgr.exe registry key. The code for the AfterInstall and AfterUninstall events is shown below.

C#

private void Installer_AfterInstall(object sender,
   System.Configuration.Install.InstallEventArgs e)
{
   // get fullpath to .ini file
   string arg = Path.Combine(
      Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location),
      "Setup.ini");

   // run WinCE App Manager to install .cab file on device
   RunAppManager(arg);
}

private void Installer_AfterUninstall(object sender, 
  System.Configuration.Install.InstallEventArgs e)
{
   // run app manager in uninstall mode (without any arguments)
   RunAppManager(null);
}

private void RunAppManager(string arg)
{
   // get path to the app manager
   const string RegPath = @"Software\Microsoft\Windows\" +
      @"CurrentVersion\App Paths\CEAppMgr.exe";

   RegistryKey key = Registry.LocalMachine.OpenSubKey(RegPath);
   string appManager = key.GetValue("") as string;
   
   if (appManager != null)
   {
      // launch the app
      Process.Start(
         string.Format("\"{0}\"", appManager), 
         (arg == null) ? "" : string.Format("\"{0}\"", arg));
   }
   else
   {
      // could not locate app manager
      MessageBox.Show("Could not launch the WinCE Application Manager.");
   }
}

VB.NET

Private Sub Installer_AfterInstall(ByVal sender As Object, _
   ByVal e As System.Configuration.Install.InstallEventArgs) _
   Handles MyBase.AfterInstall

   ' get fullpath to .ini file
   Dim arg As String = Path.Combine(Path.GetDirectoryName( _
      System.Reflection.Assembly.GetExecutingAssembly().Location), _
      "Setup.ini")

   ' run WinCE App Manager to install .cab file on device
   RunAppManager(arg)
End Sub

Private Sub Installer_AfterUninstall(ByVal sender As Object, _
   ByVal e As System.Configuration.Install.InstallEventArgs) _
   Handles MyBase.AfterUninstall
   ' run app manager in uninstall mode (without any arguments)
   RunAppManager(Nothing)
End Sub

Private Sub RunAppManager(ByVal arg As String)
   ' get path to the app manager
   Const RegPath As String = "Software\Microsoft\Windows\" & _
      "CurrentVersion\App Paths\CEAppMgr.exe"

   Dim key As RegistryKey = Registry.LocalMachine.OpenSubKey(RegPath)
   Dim appManager As String = CStr(key.GetValue(""))

   If Not (appManager Is Nothing) Then
      If arg Is Nothing Then
      Process.Start(String.Format("""{0}""", appManager))
      Else
         ' launch the app
         Process.Start( _
            String.Format("""{0}""", appManager), _
            String.Format("""{0}""", arg))
      End If
   Else
      ' could not locate app manager
      MessageBox.Show("Could not find app manager")
   End If
End Sub

Setup.ini File

The .ini file describes the Pocket PC application and is required when using the WinCE Application Manger to deploy applications to Pocket PC devices. The sample setup.ini file is shown below. You should set the Version, Description and CabFiles properties in your application. You can visit Microsoft Windows CE 3.0: Creating an .ini File for the Application Manager for more information on .ini files.

[CEAppManager]
Version      = 1.0
Component    = App

[App]
Description  = Sample Pocket PC application.
CabFiles     = 
  PocketApp_PPC.X86.CAB,PocketApp_PPC.ARM.CAB,PocketApp_PPC.ARMV4.CAB,
  PocketApp_PPC.MIPS.CAB,PocketApp_PPC.SH3.CAB,PocketApp_PPC.WCE420X86.CAB

.msi File

This is the file that is distributed to users. It contains everything necessary to deploy the Pocket PC application from the desktop to different Pocket PC devices.

Automating the Development Process

Now that you are familiar with all of the pieces involved in the development process, let's see how the build can be automated. The key points are:

  • Create one solution with multiple projects (Pocket PC app, customer installer, and setup).
  • Add the installer component as Install and Uninstall custom actions in the setup project.
  • Use a pre-build event to call the BuildCab.bat file to generate the .cab files.
  • Specify project dependencies so projects are built in the correct order.
  • Use Configuration Manager to build the Pocket PC application for debug builds, and build all projects for release builds.

The following section discusses the C# and Microsoft Visual Basic® .NET sample solutions in more detail. The C# solution builds all projects (Pocket PC app, custom installer component and .msi file) with one click. Visual Basic.NET requires more steps since Microsoft Visual Studio® is missing these two features:

  1. A solution cannot contain VB.NET projects that target different platforms (the Pocket PC app cannot be in the same solution as the custom installer component).
  2. Pre-build and post-build events are not supported for any VB.NET projects.

The VB.NET solution is still automated, just not as much as the C# version.

Solutions and Projects

The C# solution contains three projects: PocketPC App, Custom Installer and Setup. The PocketApp project is a Smart Device application that contains the Pocket PC code. The CustomInstaller project is the customer installer component and the Setup project packages up everything into a .msi file. The C# solution is shown below.

Figure 6. C# solution that contains Pocket PC, installer component and setup projects

Two solutions are required for VB.NET. The first contains the Smart Device project called PocketApp. The second solution generates the .msi file and contains the projects CustomInstaller, Pre-Build and Setup. The CustomInstaller and Setup projects are equivalent to the C# projects and the Pre-Build project is a C++ Makefile project; it does not contain any C++ code and is only used to specify a pre-build event. The VB solutions are shown below.

Figure 7. VB.NET solutions that contain Pocket PC, installer component, pre-build and setup projects

PocketApp project

The PocketApp project is a simple Smart Device, "hello world" application; a placeholder for your Pocket PC project. The BuildCab.bat and PocketApp_PPC.inf files are used to build the .cab files and the setup.ini file is used when deploying the application. The app.ico file is the application icon and appears in Programs group on the Pocket PC. Specifying the application icon is shown for the C# and VB.NET versions.

Figure 8. Specifying the application icon in C#

Figure 9. Specifying the application icon in VB.NET

Figure 10. Icon shows up in the Programs group on the Pocket PC

CustomInstaller project

This is the component that runs the WinCE Application Manager to deploy .cab files to the Pocket PC device. The code for the C# and VB.NET versions is shown earlier in this paper.

Setup project

The Setup project generates a .msi file that contains the processor-specific .cab files, installer component, and setup.ini file. The CustomerInstaller component is added as Install and Uninstall custom actions as shown below.

Figure 11. Adding the Install and Uninstall custom actions

Pre-build event

You need to run the BuildCab.bat file to generate the .cab files after the PocketApp project is built. Visual Studio does not allow you to specify post-build events for C# Smart Device projects, so we do the next best thing and define a pre-build event for the CustomInstaller project.

Figure 12. Using a pre-build event to build the .cab files in C#

Visual Studio does not allow any build events for VB.NET projects so a C++ Makefile project is used to define the pre-build event as shown below:

Figure 13. Using a C++ pre-build event for the VB.NET solution

Project dependencies

It's important to set the correct build order since the solution contains multiple projects. For C#, the build order is set to PocketApp, CustomInstaller and Setup as shown below.

Figure 14. Specifying the build order for the C# solution

The VB.NET version contains two solutions; the PocketApp solution should be built first, followed by the PocketPCSetup solution. The build order for the setup solution is shown below.

Figure 15. Specifying the build order for the VB.NET solution

Configuration manager

Configuration Manager is used to build the Pocket PC project in debug mode and all projects in release mode. That way, you don't go through the entire build process just to debug the Pocket PC application. The C# version is shown below.

This is not necessary for the VB.NET version since it has one solution for the Pocket PC app and another solution to generate the .msi file.

Figure 16. Only build the Pocket PC project in debug mode

Figure 17. Build all projects in release mode

Installing and Building the Sample Solutions

The following are notes on installing and building the sample solutions.

  • Run the PocketPC Deploy Sample.msi file to install the C# and VB.NET solutions to your system. Links to the Visual Studio solution files are added to the Start menu under the PocketPC Deploy Sample group.
  • The hard coded paths in the BuildCab.bat and PocketApp_PPC.inf files are updated to match your system (path to sample installation folder and Visual Studio). You should double-check the path information in these files if you have trouble building the samples.
  • Select release mode to build all projects (debug just builds the Pocket PC app).
  • The .msi file is called PocketApp Setup.msi and is created in the Setup\Release folder.

Links

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

No Biography provided

Comments and Discussions

 
Generalce.net articles [modified] Pinmembercodemobile31-Oct-08 19:47 
Generalindependent PinmemberGabriel X20-Dec-07 7:05 
GeneralBuilding an automatical setting for network connection management application for pocket pc 2003 Pinmemberzafax422-Jun-07 3:51 
GeneralRe: Building an automatical setting for network connection management application for pocket pc 2003 Pinmemberhjgode24-Jun-07 22:00 
AnswerRe: Building an automatical setting for network connection management application for pocket pc 2003 Pinmemberzafax48-Jul-07 7:27 
QuestionCreating a simple software for network connection management for pocket pc 2003 Pinmemberzafax422-Jun-07 3:46 
QuestionDeploying to several PDA Pinmemberhvistro5-Dec-06 22:14 
AnswerRe: Deploying to several PDA Pinmembercaphin13-Feb-07 21:15 
Generaladd graphics library to pocket pc Pinmemberamjadamq15-Oct-06 0:04 
Generalchanging the paths in the Batch file... PinmemberZippyBubbleHead25-Aug-06 0:01 
GeneralProblems with Pocket PC development. PinmemberDiplomat_Dave22-Aug-06 14:03 
GeneralAn easier way of creating installers.. PinmemberUncleMike98727-Jun-06 5:48 
Generalreboot the device at the end of teh installation Pinmembertyounsi22-May-06 11:33 
GeneralRe: reboot the device at the end of teh installation Pinmemberhjgode24-Jun-07 22:04 
QuestionHow to include files in the package? Pinmemberbeeyung8-Apr-06 4:45 
GeneralPocket PC Deployment PinmemberSridhar R23-Jan-06 18:45 
GeneralRe: Pocket PC Deployment Pinmemberqbuster20-Mar-06 12:53 
GeneralRe: Pocket PC Deployment Pinmemberhugo.green14-Apr-06 4:37 
GeneralDeploying web application on PDA Pinmemberpk123us4-Dec-05 19:36 
GeneralSQLHelper for PocketPC Pinmembercarlr3-Oct-05 21:33 
QuestionHow to include OpenNetCF installation in your setup Pinsussaiecaramba13-Aug-05 16:04 
AnswerRe: How to include OpenNetCF installation in your setup Pinmemberkernunnos17-Dec-06 17:57 
Generalnot able to show an xml file PinsussAnonymous15-Jul-05 1:41 
QuestionUninstall From code? PinmemberVbGuru61327-Jun-05 14:58 
AnswerRe: Uninstall From code? Pinmembertom_dx27-Jun-05 16:23 
QuestionHow to adding .net compact framework to deployment PinmemberDhana MG15-Jun-05 0:19 
AnswerRe: How to adding .net compact framework to deployment PinmemberAchintya Jha3-Oct-05 15:18 
GeneralThe Application doesnt come up in ADD Remove Programs of Active Sync Pinmemberjasdeepjabbal21-May-05 23:14 
GeneralPocket PC Install Failed PinmemberSpeto11-May-05 4:40 
GeneralCab File Creation PinmemberDeepu Paul9-May-05 10:46 
GeneralRetriving the System Date Information PinmemberDeepu Paul6-May-05 2:30 
QuestionHow Convert Program in Device Nokia Pinmemberdailywake19-Mar-05 6:30 
GeneralNew HP h 6300 Pocket PC PinmemberAlex Evans14-Feb-05 13:35 
GeneralHelp Connect to SQL Server PinmemberMichaelwang2222225-Nov-04 13:27 
GeneralRe: Help Connect to SQL Server Pinmemberslice2727-Nov-04 4:02 
GeneralRe: Help Connect to SQL Server Pinmembercarlr3-Oct-05 21:27 
QuestionHow to include an MDB database PinmemberAlex Evans18-Apr-04 18:04 
AnswerRe: How to include an MDB database PinmemberAlex Evans12-Dec-04 9:06 
GeneralSample Code Failed to install. Pinmemberskragglerock13-Apr-04 9:08 
GeneralRe: Sample Code Failed to install. Pinmemberrj453-Mar-05 8:18 
GeneralRe: Sample Code Failed to install. PinmemberGeorge Elder2-Jul-05 14:08 
GeneralRe: Sample Code Failed to install. Pinsussgelder2-Jul-05 17:28 
GeneralSetup Failed.. Pinmemberebbeweb1-Mar-04 7:10 
GeneralRe: Setup Failed.. PinmemberKyle Tillman3-Mar-04 18:36 
GeneralRe: Setup Failed.. Pinmembercon8kta25-May-05 3:59 
GeneralRe: Setup Failed.. [My Solution] PinmemberKyle Tillman4-Mar-04 12:37 
GeneralNo go PinmemberAlex Evans24-May-04 11:24 
GeneralRe: No go PinmemberKyle Tillman24-May-04 16:14 
GeneralRe: Setup Failed.. [My Solution] Pinmemberdudorange9-Dec-04 18:53 
GeneralRe: Setup Failed.. Pinmembergmhanna28-Jul-04 17:29 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Mobile
Web03 | 2.8.140709.1 | Last Updated 21 Jan 2004
Article Copyright 2004 by Microsoft - Compact Framework
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid