Important:
This is retired content. This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This content may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.
4/8/2010

This code sample is named ResDLL. It demonstrates how to create a CAB install with the smarts to tailor the installation to the target device's screen resolution.

When you develop applications for the newer high-resolution Windows Mobile devices with 192 DPI resolution displays, you might consider how to include the high-resolution versions of bitmaps and resources in your executable. The simplest solution is to just include them in the executable along with the low-resolution version of the bitmaps and resources — but this approach ends up wasting precious storage space. Since mobile devices have screens with a resolution that never changes, resources targeted at screen resolutions other that the one used on the mobile device, are neither needed nor used.

A better approach is to separate the application resources into resolution-specific DLLs — one targeted at 96 DPI devices, and another targeted at 192 DPI devices. This allows the mobile device to become an interactive part of the installation process, enabling it to dictate which specific resources it requires.

Feature Area

Relevant APIs

Usage

To run the code sample
  1. Navigate to the solution file (*.sln), and double-click it. By default, the solution file is copied to the following folder:

    C:\Program Files\Windows Mobile 6.5.3 DTK\Samples\PocketPC\CPP\win32\resdll

    Microsoft Visual Studio launches and loads the solution.

  2. Build the solution ( Ctrl+Shift+B).

  3. Deploy the solution ( F5).

To use the application
  1. Build the CAB project.

  2. Copy the CAB file to the mobile device.

  3. Run the CAB file on the mobile device. This installs "ResDLL.exe" into the following folder:

    \Program Files\ResDll\

Remarks

The ResDLLsolution contains the following six projects:

GetRealDPI

Creates an executable that returns the actual resolution (DPI) of the mobile device. This executable is called from SetupDPI.DLL. It is required because the Wceload Tool(the executable that runs the CAB installer) could fake the DPI value returned in order to pixel-double older applications running on hi-resolution mobile devices.

RES_096

Creates a DLL called Res_096.dllwhich contains the 96 DPI resources.

RES_192

Creates a DLL called Res_192.dllwhich contains the 192 DPI resources.

ResDLL

Creates an executable that calls Res.DLL(either RES_096.DLL or RES_192.DLL after it is renamed).

Setup_DPI

Creates the Smart Device CAB project. When built, the CAB ends up in the project's release directory.

SetupDPI

SetupDPI.DLLis a setup DLL used in the installation CAB file. It is run after your application's install process has completed. It takes a list of files as input. It finds this list in the registry. For each file, if the filename ends in a number, and that number is the same as the display resolution, then SetupDPI.DLLrenames the file, removing the number. Otherwise, SetupDPI.DLLdeletes the file.

For example, if the mobile device's display resolution is 192DPI, SetupDPI.DLLdeletes RES_096.DLLand rename it RES.DLL.

The list of files is found under [HKLM\Software\Microsoft\SetupDPI]. Each key name is a path to a file. The value and type of the key is ignored. These registry keys will be populated by the CAB file, and will be deleted by SetupDPI.DLLafter setup completes.

Development Environments

Pocket PC SDK:Windows Mobile Professional SDK 

Development Environment:Visual Studio 2005 and 2008.

ActiveSync:Version 4.5.

See Also