Log in

View Full Version : Bug: Installation with DPI-Specific Resources


gwinter
12-29-2005, 04:55 PM
In WM2003SE developer resource, there is a sample ResDLL that doesn't seem to work correctly.

To optimize a program for QVGA or VGA mode, resolution-specific resources are moved out to external DLLs. There will be 2 DLLs for 96DPI and 192DPI. In order to have a single CAB file that caters for all device, both DLLs are packaged together. But in order to save storage space on user device, there need to be a way to remove the DLL that is not needed for the device. A custom DLL can be specified in the CAB, which will be called before install and after install.

The solution is therefore simple. After install, the custom DLL will call GetDeviceCaps to determine DPI of the device and delete the resource DLL that is not needed.

The problem is, the DPI returned from DLL is always 96. The cause is that the install system, wceload.exe, is not Hi-res aware. Therefore the custom DLL loaded by wceload.exe will also not be Hi-res aware. On a VGA device, the emulation layer in OS will apply pixel doubling and GetDeviceCaps will always return 96DPI.

Workaround:
There is a trick which some has been using to turn off the emulation layer. If an MUI resource file that contain the "HI_RES_AWARE" flag is present, the pixel doubling will not be applied. For example on an English system, the resource file wceload.exe.0409.mui will force the Os to turn off emulation for the install system. The custom DLL will then report the correct DPI value.

Unfortunately, installing such a file might not be considered acceptable practice. The other alternative would be to maintain two separate CABs for QVGA and VGA device.