Opening up StopwatchCE

12 May 2018
Recently I open-sourced StopwatchCE, a timing program I wrote back in 2010 for Windows Mobile, because I thought that my then-mobile (Sony Xperia X1 — which I still have) had no decent time-keeping utilities. To date it is the only piece of mobile software I have released, and of all my released software is the one I personally found by far the most useful.

This open-sourcing is part of a bigger move of all my software from Software @ RemyNET , which had not been maintained for several years and I am considering decommissioning, into Bitbucket repositories.

Historical background

I am not exactly sure when I started developing StopwatchCE, but the Subversion repository I recovered that contains it was created March 2010, which means at least a significant amount of StopwatchCE was written between finishing my Ph.D and starting my first post-doc job. My interest in WindowsCE dates back to my first proper job, and due to its similarity to desktop Win32 maintained familiarity with it — the first WindowsCE program after getting together a mobile development environment was a port of a Win32 program made with such familiarity in mind, and from what I remember it did not need much modification. The Win32 & WinCE APIs are a type of programming that is quite rare these days, and I count myself lucky having done that type of development professionally back in 2010-2012.

Reasons for opening

A modern online repository is substantially better presenting source code than anything a personal website could do without an almost unreasonable amount of effort, so I had decided to move at least some of my software projects into Bitbucke, and it eventually dawned on me that I was well on the road to simply doing away with my software site completely. This called into question what to do with my closed-source programs, of which StopwatchCE was one — since few people these days would have the hardware to run StopwatchCE, it was only worth keeping online as an open-source showcase, so I decided to move it onto Bitbucket with the other software projects. Since I had not even looked at the source code for several years, I felt there was no reason to keep it to myself.

Doing a rebuild

One of the reasons I had not looked at the StopwatchCE source code for so long, and hence had not considered releasing it, was the lack of a functioning build environment. StopwatchCE was originally developed on a system running Windows Server 2003 using licence keys I got from a software scheme for students, but from what I remember the hard drive had problems, so I did not clone it before going to New Zealand. I had Visual Studio 2008 installed within a Windows 7 Ultimate virtual machine, but it was not setup for mobile development. The virtual machine was a snapshot last run February 2014, and since the clock was still set to Auckland time, probably had not been seriously used since mid-2013. After installing 800MB worth of patches I decided to clean up & compress the image, which went from 23GB to 17GB, and gzipped down to 8GB. I remember setting up the original development environment being a bit of an ordeal, so I wanted to do this setup on a VM I would not be worried about scrapping.

Development setup

Visual Studio 2008 looks like it has some Windows Mobile support included as standard, although I was not aware of this, and in any case only supports earlier versions of Windows Mobile (i.e. Windows Mobile 5 and the earlier PocketPC editions). I got the 32-bit versions since that is what my copy of Windows 7 requires.
drvupdate-x86.exe
This will spend a while searching for Unknown Device drivers and eventually failing, but for some reason in the process the Windows Mobile Device Centre (ActiveSync's successor) will be setup — indicated because the SDK installed later will not complain about it being missing.
vs_emulator.exe
From what I have read Visual Studio 2008 includes emulators, but the default install is slightly broken, so advice is to try this installer and select repair XXX — it seems to sort things for me, although I couldn't find any emulator programs anywhere under the Start Menu. Visual Studio seems to be able to find it though when starting a debug session.
Windows Mobile 6 Professional SDK Refresh.msi
I opted for the v6.0 SDK rather than v6.5 as I think the former is what the project file originally used. I doubt it would have made much difference as all the API calls I used were ones available in earlier versions.
Windows Mobile 6.1.4 Professional Images (USA).msi
The emulator images.
Surprisingly I loaded up the project file and everything worked first time — guessing a lot of the problems I encountered with my earlier development system had been ironed out.

Required project files

One of the first things I did in terms of clean-up was to work out which files can be deleted, as a lot of files included within a Visual Studio project can either be regenerated, or are user settings rather than project settings. Below are details of the files & directories within the project that could and could not be removed:
WinCE.sln - Required
Solution file.
WinCE.ncb - Not required
IntelliSense symbol database. Can get quite big.
WinCE.suo - Not required
Solution User Options. Microsoft states this should not be checked in.
StopwatchCE/*.h - Required
StopwatchCE/*.cpp - Required
Source code. You won't get far without these :)
StopwatchCE/*.rc - Required
StopwatchCE/*.rc2 - Required
Resource files.
StopwatchCE/StopwatchCE.vcproj - Required
Project file.
StopwatchCE/StopwatchCE.vcproj.*.*.user - Not required
Project user settings, which is unique to the user & the computer.
StopwatchCE/StopwatchCEppc.aps - Not required
Precompiled resourcecs used to speed up designer.
WinCE is the name of the solution, which is a collection of projects, and StopwatchCE is the single project within it — from what I remember Visual Studio 2008 does not allow stand-alone projects,

Project cleanup

I changed a resource file to update the website & email addresses shown in the About dialog, and bumped the version number from 1.1beta to 1.2, but otherwise made no changes that would have made any difference to the compiled program. The program code itself is almost entirely untouched, stripping out a few lines of commented-out code and adding in file headers, but otherwise I felt that the project basically did not need any modification to make it presentable — it even used #pragma section tags to denote sections that can be folded. Comments were sparse, but ironically the overall presentation of the code is significantly better than what I saw in some of my other open-source releases.

Final remarks

I had considered open-sourcing StopwatchCE earlier, but the lack of a build environment kicked that intention into the long grass, and having now done it am surprised I had not done it earlier. In the past there may have been feeling for keeping one's best source code to one-self, but now I wonder whether I should put as many of my past projects in the open as I can find.