Tarma WebUpdate sample application
The Samples\WebUpdate folder contains a sample application that illustrates how to use the Tarma WebUpdate DLL to update or install an application. The sample program is a console application written in C++ that requires Microsoft Visual C++ 6.0 or later to build.
Delphi note: There is also an equivalent Borland Delphi version of this application available; look for the WebUpdate.dpr file. Please be aware that the TWU interface uses C-style null-terminated strings rather than Pascal-style counted strings. The sample application illustrates how to use the null-terminated strings.
You may use the program as-is or copy its code to your own application, subject to the terms and conditions of the License agreement. Remember to include the appropriate version of the Tarma WebUpdate DLL with your application; see Tarma WebUpdate for a list of the available DLL versions.
WebUpdate [/install][/update] package_name pif_url
- Specifies that package_name must be installed regardless of any existing installation.
- Specifies that package_name must be installed only if already present on the system and newer than the existing installation.
- Name of the package to install, as listed in the package information file specified by pif_url. If the package has dependencies, the dependencies are also installed if necessary.
- URL to the package information file that contains the package information. This can be any valid URL, for example:
Be sure to include the file:// prefix if you are referring to a local or UNC file path.
If neither /install nor /update are specified, the program lists the available package information.
The Samples\WebUpdate folder contains the following files:
|WebUpdate.cpp||Source code for the application|
|WebUpdate.dpr||Borland Delphi source code. You will also need TWU.pas from the Include folder.|
|WebUpdate.dsp||Microsoft Visual C++ 6.0 project file|
|WebUpdate.dsw||Microsoft Visual C++ 6.0 workspace file|
|WebUpdate.sln||Microsoft Visual C++ 2003 solution file|
|WebUpdate.vcproj||Microsoft Visual C++ 2003 project file|
The internal implementation of the program follows this outline (the Delphi program is similar):
// Open the connection and retrieve the package information TWUOpenUpdateURL(pif_url); // Find the desired package pPackage = TWUFindPackage(package_name); // Enumerate the package and its dependencies to download them. // If a package is required and downloaded, pPackage->lUserCookie1 // is set to TRUE as a marker for the second pass. TWUEnumPackageDependencies(pPackage, _WUDownloadCB); // Enumerate the package and its dependencies to install them // (only packages with pPackage->lUserCookie1 set to TRUE). TWUEnumPackageDependencies(pPackage, _WUInstallCB); // Perform clean up TWUCleanupDownloads; TWUCloseSession;
To test this program, try the following scenarios. They use the update.txt file stored on Tarma's own web server; see Sample file in the package information file topic for its contents.
Check available version (only)
WebUpdate tin3 https://tarma.com/download/update.txt
Lists the latest available version of InstallMate but does not download or install anything.
WebUpdate /install tin3 https://tarma.com/download/update.txt
Download and installs the latest available version of InstallMate, regardless of the currently installed version (if any).
WebUpdate /update tin3 https://tarma.com/download/update.txt
Downloads and installs the latest available version of InstallMate, but only if an earlier version is already present.