Home About Me Follow Me on Twitter @mikefrancis Subscribe Resources
# Friday, April 30, 2010

Update: I've updated the sample to be independent of the '\Program Files' string. Also, the sample now supports installing onto a Storage Card.

A popular sample for demonstrating how to install application dependencies via embedded CAB files is MultiCAB Install. With this pattern you can distribute dependant cab files via a single container CAB. “Can apps be distributed via Windows Marketplace for Mobile using this?”,you ask. Yes they can.

Installing SQL Server Compact dependencies is a good fit for this pattern. I have updated the sample here customized to distribute the latest SQL Server Compact for Windows Mobile devices.

The sample checks if SQL Server Compact 3.5 is installed (See IsSQLCEUpdateRequired() in mcsetup.cpp) and if not, launches the multicab EXE which installs each dependant cab in sequence. (See the multicab whitepaper included in the sample for an in-depth explanation of how it works.)

How does the sample check to see if v3.5 is installed? It checks the registry for the following entry:

  1. \Software\Microsoft\Microsoft SQL Server Compact Edition\v3.5

This this exists, then installation of the SQLCE cabs is skipped. Note that this registry key only exists if SQLCE has been installed via a CAB file. That is, this registry key does not exist of SQLCE is in ROM. As of this writing, 3.5 (SP1 or SP2) is not distributed in ROM. See here for a list of OS and corresponding SQLCE versions: Description of the various build versions of SQL Server Compact Edition.

The sample does not do version checking on the binaries. Therefore it does not detect if you are upgrading from SQLCE 3.5 SP1 to SP2. The way it is written now, it will not update the binaries to SP2. This sample does address the popular scenario of updating an ‘off the shelf’ device with the latest version of SQL Server Compact.

More SQL Server Compact Links: Mike

This work is licensed under a Creative Commons license.
posted on Friday, April 30, 2010 8:51:03 PM UTC  #    Comments [5] Trackback
# Wednesday, December 30, 2009

I was developing a few themes for Standard and Professional devices (using the Windows Phone Custom Theme Generator tool to get me started) and found that when installing the CAB on Standard devices, I would get the following error:

The program you have installed may not display properly because it was designed for a previous version of Windows Mobile software.

Normally to fix this error, you would edit the .INF file and add BuildMax=0xE0000000 to the CEDevice section as follows (See here for explanation of BuildMax):

[CEDevice]
VersionMin = 3.0
VersionMax = 100.0
BuildMax=0xE0000000

In this case, I did not have an .INF file since the CAB was generated by the Theme Generator. Doing a Bing search, I found a great tool (Benoit Thonnart's MSCEInf) that helps with the process of creating a .INF file from a CAB file and extracting files from the CAB with the true filenames. Using this tool, I created the .INF file, edited it, and then recreated the CAB file using the .INF file and CABWIZ.EXE. MSCEinf’s feature of extracting the true filename saves a lot of time, saving you the drudgery of renaming the files, as specified in the _setup.xml file, by hand.  (When CABWIZ creates the CAB, it converts the filenames to 8.3 names).

Step-by-Step guide:

  • Create dedicated destination directory.
  • Copy MSCEInfEn to this directory.
  • Create .INF file. 
    • Start MSCEInfEn.EXE
      • Open the CAB file
      • Click on the icon in upper left, ‘Save INF File rebuilt’ to save .INF file.
  • Extract files from CAB, using the true filenames
    • Using MSCEInfEn,  turn Off ‘Use Folders’
      • Click 5th button from left ‘Extract Filenames’ (should see icon with red X through it).
    • Using MSCEInfEn,  extract files
      • Click 4th button from left ‘Extract CAB files with original names in a folder’.
      • Click ‘Extract’ and select the destination directory.
  • At this point you should have the files of your theme / application and the .INF file in the destination directory.
  • Modify .INF file
    • Open .INF file saved in Step 1 and add the following line below [CEStrings]
      • [CEDevice]
        BuildMax=0xE0000000
    • Save .INF file
  • Rebuild CAB file.
    • Start a Command Line. (Start | Run | cmd)
    • Change to the destination directory.
    • Using CABWIZ.EXE recreate the cab file with the following command:
      • Cabwiz <filename>.inf
      • You may see a warning regarding AddReg, this can be ignored.
  • Test the CAB file.

Thanks,

Mike

posted on Wednesday, December 30, 2009 6:38:41 PM UTC  #    Comments [0] Trackback