|
Technical answers from the trenches |
|
Displaying Version Information
| ||||
Posted: 25 January 2001 |
||||
  |
Applies to: Delphi 4.0 and later |
|||
  |
Audience: Intermediate |
|||
IntroductionWindows has long provided a VERSIONINFO structure designed to help application developers present version, copyright, and contact information in a consistent, professional, and (perhaps most importantly) easy-to-locate fashion. For example, if you right-click a program file in Windows Explorer and then choose Properties, the property sheet will contain a Version tab listing various details about the program. This tab only appears, however, when the application is compiled with a VERSIONINFO structure. Unfortunately, VERSIONINFO is not the easiest structure to work with; it has several complexities that many developers politely describe as "daunting." Recognizing an opportunity during the development of Delphi 4.0, Borland added a compilation option that creates and maintains VERSIONINFO structures in your projects. This option also increments version numbers when you build your project. This can be a tremendous time-saving device, especially if you've been relying on manually updated constants. Yet, the Version Info Project Options only provides half the solution. There are times when you want to extract pieces of this structure for your own use. For example, you might want to display the version number in your About box. The following function shows one way to do this: function getVersion : string;
{ ---------------------------------------------------------
Extracts the FileVersion element of the VERSIONINFO
structure that Delphi maintains as part of a project's
options.
Results are returned as a standard string. Failure
is reported as "Granted, this is a very limited implementation, for it only extract the version number. However, there are times when that's all you need. Note: A more complete implementation can be found in Delphi 5 Developer's Guide; see Sources for details. Here's one way you might use this in your application: procedure TfrmAboutBox.FormCreate(Sender: TObject); begin lblVersion.Caption := 'Version: ' + getVersion; end; Sources:
|
|||
|
||||||||
|
Copyright © 2000-2004, techtricks.com; All Rights Reserved. Acknowledgements, Disclaimers, Terms and Conditions. |
||||||||
|
Article last updated on 31 May 2003
|
||
|
|
||
|
[- End -]
|