By default Windows Mobile 6.5 widgets must be distributed via the Windows Marketplace for Mobile. Although you can host your *.widget files on a webserver of your choice the OS will refuse to install them without setting a couple of registry settings on the device.
There is a possible work around for this situation however… and that is packaging up your *.widget file inside of a *.cab file, as the web browser already knows how to download and install those. The challenge with this approach then becomes how to conveniently build the CAB file which will auto-magically install your widget.
Introducing Widget Packager
Widget Packager is a small utility I have developed which can run on your development desktop machine. Once you have developed your WM6.5 widget, you simply drag and drop the resultant *.widget file onto the widget packager main window and you will be prompted to save a matching CAB file.
Place this CAB file on a correctly configured webserver and you are ready to post a link within the mobile version of your website. Anyone that clicks on the link within Internet Explorer for Mobile will be prompted to save or open the file.
Opening the CAB file (or saving it and selecting it within File Explorer at a later date) will cause the standard widget installer to launch to install your new widget. Once installed no trace of the CAB file (such as an entry within the remove programs list) can be found.
As an example, use the web browser on your mobile device to install the following MobileFlashlight widget that I have packaged as a cab file. This should demonstrate the installation process, but don’t take it as a good example of widget design. It was simply the first *.widget file I grabbed while developing this proof of concept.
Limitations of this approach
The dynamic creation of a CAB file, and the installation of widgets from an arbitary webserver is a cool demo, but is it really worth the effort? At this stage I’m not sure it really is. Potential problems with this approach include:
- The CAB file is unsigned – The CAB file (and a setup.dll within it) are unsigned. This means some devices may refuse to install it, or atleast display warning prompts. In order to resolve this you would need to sign the CAB with a Mobile2Market certifcate which is probably more expensive than the Windows Marketplace for Mobile process you are trying to avoid.
- Lack of upgrade mechanism – You would need to develop your own solution for detecting and installing updates to your widget, as obviously you can’t rely upon the marketplace for these features.
- WM6.1+ has a “feature” – Since WM6.1 a feature or bug depending upon your viewpoint means if you create a CAB file and configure it to leave no uninstallation information the OS still detects it when the CAB file is re-ran. This means the user is prompted to uninstall the previous version, and even worse, since no uninstallation information is available the uninstall fails. This isn’t a road block (as the user simply needs to tap “Yes” twice), but it’s not exactly a great user experience either if you attemp to upgrade your widget.
- Internet Explorer’s open/save file dialog sucks – The file save dialog in Pocket Internet Explorer was never that nice, but in WM6.5 it’s a case of one step forwards, two steps backwards. Now it is full screen, but the options are hidden away within menus… As a small hint, you’ll find the “open” option within the menu that pops up when you click the “Menu” softkey. Why they don’t use all that whitespace within the dialog to display two big finger friendly graphical buttons is anyones guess…
So is it really worth it? I’ll let you be the judge of that. One case where it may be useful, is if your widget needs the use of an ActiveX control which needs to be installed as part of the widget installation process. *.widget files don’t support that particular feature, while the Widget Packager could easily be extended to support that.
Download the utility
If you’re interested in trying out the utility, it is available for download. The ZIP file includes the utility, as well as an example *.widget. There are three ways to run the utility
- Run the WidgetPackager.exe GUI, then drag and drop a *.widget file from file explorer onto the main window. You will be prompted for a CAB filename, and it will then be generated.
- Place a shortcut to WidgetPackager.exe on your desktop or quick launch toolbar etc. Drag a *.widget file onto this icon and a *.CAB will appear in the same location.
- Call WidgetPackager.exe from the command line (perhaps as part of an automated build process). Simply specify the name of the *.widget file as a command line parameter and optionally the path for the CAB file (will default to naming the CAB the same as the *.widget file).
For those that are interested the source code for the utility is also included. Perhaps of most interest to developers is the way in which the *.CAB file is built programatically (without the use of cabwiz.exe). This will be the topic of a future blog post.
Is this utility of use to people? Some of the limitations and loose ends (such as no warning if attempting to install on a Windows Mobile 5.0 or 6.0 device) could be resolved with a little more effort and hacking if there was demand.