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.
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 SDK\Samples\PocketPC\CPP\win32\resdll
Microsoft Visual Studio 2005 launches and loads the solution.
Build the solution (Ctrl+Shift+B).
Deploy the solution (F5).
Build the CAB project.
Copy the CAB file to the mobile device.
Run the CAB file on the mobile device. This installs "ResDLL.exe" into the following folder:
The ResDLL solution contains the following six projects:
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.
Creates a DLL called Res_096.dll which contains the 96 DPI resources.
Creates a DLL called Res_192.dll which contains the 192 DPI resources.
Creates an executable that calls Res.DLL (either RES_096.DLL or RES_192.DLL after it is renamed).
Creates the Smart Device CAB project. When built, the CAB ends up in the project's release directory.
SetupDPI.DLL is 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.DLL renames the file, removing the number. Otherwise, SetupDPI.DLL deletes the file.
For example, if the mobile device's display resolution is 192DPI, SetupDPI.DLL deletes RES_096.DLL and 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.DLL after setup completes.