TdcVersionInfo component
Properties |
The dcVersionInfo component is used to extract version information from a file.
|
Simply set the FileName property to a file which contains version information and read any of dcVersionInfo's properties.
|
The following example demonstrates how to get the FileVersion for the SHELL32.DLL:
|
procedure TForm1.Button1Click(Sender: TObject);
|
begin
|
with dcVersionInfo1 do
|
try
|
// if file does not contain the version info - exception raised
|
FileName := 'shell32.dll';
|
|
// if succeed displaying the FileVersion (string value)
|
LabelVersion1.Caption := FileVersion;
|
|
// and 16-bit values:
|
LabMajor.Caption := IntToStr(FileVerMajor); // Major version
|
LabMinor.Caption := IntToStr(FileVerMinor); // Minor version
|
LabRelease.Caption := IntToStr(FileVerRelease); // Release #
|
LabBuild.Caption := IntToStr(FileVerBuild); // Build #
|
except
|
end;
|
end;
|
For example, we'd like to check the version number of the Internet Explorer (COMCTL32.DLL):
|
const
|
IE_VER581 = (5 shl 16) or 81; // IE5.1 (Win2000 Pro)
|
IE_VER580 = (5 shl 16) or 80; // IE5 (Win98 SE)
|
IE_VER472 = (4 shl 16) or 72; // IE4.01
|
IE_VER471 = (4 shl 16) or 71; // IE4
|
IE_VER470 = (4 shl 16) or 70; // IE3
|
IE_VER400 = (4 shl 16) or 00; // Win95 first release version
|
|
begin
|
// ------- skipped --------
|
try
|
dcVersionInfo1.FileName := 'comctl32.dll';
|
if dcVersionInfo1.FileMajorVersion >= IE_VER472 then
|
begin
|
// ----
|
end;
|
except
|
end;
|
dcVersionInfo will raise an exception if the file cannot be found, or if the file does not contain version information. The exception will be raised when you attempt to point the FILENAME to the file without version information. Use try..except blocks to handle an exception.
|