I read a posting here by Alessandro Vergani, UnPatcher: a COM object for patching files. He created a COM object that used a little known capability (providing you have the needed MS DLL's) that can create and apply delta patches to files. (Please refer to Alessandro's article on availability of the required patch creation and application DLLs).
I decided to create a WTL app that would use his component, but later decided to abandon usage of the component in favor of a direct class wrapper, so as to avoid the need to distribute and register a separate DLL, and make my utility easily distributable as a single .exe. As such, this WTL app is a measly 108K, and has minimal runtime requirements.
The application can create, test and apply patch files, which, if you don't know, are files that represent the deltas between two files so that an original file can be changed to a newer version by "patching", or applying a file that is (hopefully!) much smaller than the new version. Seeing as the two DLLs, mspatcha.dll (apply) and mspatchc.dll (create) are provided by MS, it is obvious that they use patching techniques in Windows installer.
The app is a WTL dialog app created with the WTL wizard. Obviously you will need to install the WTL SDK to build the app, but I was nice enough to include a release exe in the zip anyway.
There is a reusable class
CPatch in patcher.cpp/h that performs all the needed DLL loading/unloading and patch functions. It is pretty self explanatory. Kudos to Alessandro again, as I pasted the code from his COM component, and converted it from there.
There is an exception class,
CPatchError() that is thrown in the event of any patch failures. It does the job of decoding the errors and optionally displaying a
MessageBox. Obviously you will need to wrap calls to the class in
Most of the rest of the APP is WTL boilerplate, with the obvious exception of maindlg.h, which contains all the UI code.
CMainDlg is derived from
CPatch. The actual patch operations are run in a separate thread so as to allow a Cancel button to interrupt the process. You will note that I used the default extension of .ptx for patch files, this was arbitrary. I don't know if ptx is a currently common extension type. FYI, the blue triangle icon is the Greek symbol for delta, meaning change.
I included a couple files, jabberwocky.txt and jabberwocky.ptx so that the apply patch functionality can be tried. After running the patch, the full text of jabberwocky will be patched in, instead of just the first verse!
The UI state is persisted to the registry, so that the UI settings on application close are reloaded on app restart. A little gold plating there :-)
My next objective is to make a patcher than can operate on the contents of two directories, similar to other commercial patch apps such as RTP. Another thing I may do is, add command line handing to this app, and/or make a console app patcher.
As Alessandro states in his posting, the mspatchc.dll (create patch) is probably not on your PC currently, but can be freely downloaded as part of the Windows installer SDK. mspatcha.dll (apply patch) should be on your PC if you have IE 5 installed.
Hope you find this interesting and useful, as I do all the great postings at this phenomenally cool site!