This commit is contained in:
Alexander
2023-02-02 12:02:14 +03:00
parent 703d2d5a52
commit 8e2f0fdd9c
94 changed files with 25754 additions and 1 deletions

View File

@@ -0,0 +1,93 @@
; ------------------------------------------------------------------------------
; This Source Code Form is subject to the terms of the Mozilla Public License,
; v. 2.0. If a copy of the MPL was not distributed with this file, You can
; obtain one at http://mozilla.org/MPL/2.0/
;
; Copyright (C) 2013, Peter Johnson (www.delphidabbler.com).
;
; $Rev: 1132 $
; $Date: 2013-01-14 03:31:09 +0000 (Mon, 14 Jan 2013) $
;
; Change Log for Version Information Component
; ------------------------------------------------------------------------------
Release v3.3.1 of 14 January 2013
+ Unit names are now qualified with namespace name on Delphi XE2 and later.
+ Changes to demo projects:
- Font and appearance of some controls changed.
- Controls are now themed.
- All form files now in text format.
- Forms are no longer scaled.
- 1st demo program's main window now resizes.
- 2nd demo dialogues' "help" buttona now display online examples instead of help file topics.
- Demos now need Delphi 7 as a minimum.
- New project configurations files.
+ Component source license changed to Mozilla Public License v2.0. (Demos now placed in public domain).
+ MPL text file and documentation wiki shortcut have had names changed.
+ WinHelp help file regenerated with updated copyright date.
+ Documentation revised.
Release v3.3 of 03 November 2010
+ Added operator overloads to TPJVersionNumber record when compiled with Delphi 2006 and later to:
- Support equality tests using =, <>, <, <=, > and >= operators.
- Support implicit casting to a string which formats the version number as a dotted quad (issue #12: http://code.google.com/p/ddab-lib/issues/detail?id=12).
+ Added new helper functions primarily for use with Delphi 2005 and earlier:
- CompareVerNums - compares two version number records.
- VerNumToStr - formats a version number as a dotted quad.
+ Updated TPJVersionNumber topic in help file re changes.
+ Updated HTML documentation.
Release v3.2 of 09 November 2009
+ Changed method used to get character set descriptions. These are now obtained from operating system where possible instead of from hard-wired values.
+ Added compiler directive to switch off unsafe code warnings on compilers that support the directive.
+ Added copy of Mozilla Public License.
+ Corrected error in help file.
+ Modified Demo 2 to enable it to compile on Delphi 2 and 3.
+ Updated documentation and included shortcut file that links to component Wiki.
Release v3.1.1 of 11 December 2005
+ Changed component to Mozilla public license.
+ Fixed minor bug in VIDemo project.
+ Revised HelpEgs demo project to access related help file topics.
+ Updated help file to make examples available from component's main page.
+ Updated HTML documentation.
Release v3.1 of 07 September 2003
+ Fixed to be compatible with C++ Builder - direct access to fields of TVSFixedFileInfo in property declarations were replaced by calls to an indexed property getter function.
Release v3.0.1 of 08 July 2003
+ Changed component palette from PJSoft to DelphiDabbler.
+ Updated HTML documentation.
+ Changed copyright message in help file.
Release v3.0 of 17 February 2002
+ Added ability to access all "translations" stored in a file's version information, rather than just first one. This has been done so that code using earlier versions of this component should continue to work unchanged.
+ Added new property to expose fixed file information record.
+ Added new "string array" property to give access to string information by name: this property can access any custom string information if the name is known.
+ Added properties to return number of "translations" and to select index of "translation" to be used.
+ Added properties to return language and character set codes in addition to descriptive strings.
+ All string info, language and character set properties now return values from the currently selected translation (which defaults to the first translation maintaining backward compatibilty).
+ Empty FileName property now accesses name of host application per command line rather than using Application.ExeName.
+ CharSet property now returns '' for unknown value rather than 'Unknown'.
+ Renamed TVersionNumber record to TPJVersionNumber.
+ Replaced Tvs_FixedFileInfo record with use of Windows unit defined type TVSFixedFileInfo.
+ Renamed unit to PJVersionInfo.
+ Changed component palette from "PJ Stuff" to "PJSoft".
+ Added two demo programs, one is a sample version information reading program and the other implements examples from the help file.
Release v2.1 of 28 November 1999
+ Changed unit name from VerInfo to VInfo to allow component to install under Delphi 3 & 4 (VerInfo clashes with an existing unit in these versions).
+ Removed superfluous conditional compilation directives.
+ Updated HTML documentation to separate 16 bit from 32 bit version, to to include installation notes for Delphi 3/4 and to include update history.
Release v2.0.1 of 08 July 1999
+ Changed palette where component installs to "PJ Stuff" from "Own".
+ Added HTML documentation (shared documentation with Release 1.0.1).
+ Included 16 bit Version Information Component release v1.0.1
Un-released v2.0 of 06 December 1998
+ Forked development - 32 bit development (this fork) began with v2.0 while the 16 bit version continued with v1.0.1
+ Revised for use with Win32 - not backwards compatible with v1.0
Un-released v1.0 of 26 April 1998
+ Original version - 16 bit only.

View File

@@ -0,0 +1,3 @@
[InternetShortcut]
URL=http://www.delphidabbler.com/url/verinfo-docs

373
prereq/dd-verinfo/MPL-2.txt Normal file
View File

@@ -0,0 +1,373 @@
Mozilla Public License Version 2.0
==================================
1. Definitions
--------------
1.1. "Contributor"
means each individual or legal entity that creates, contributes to
the creation of, or owns Covered Software.
1.2. "Contributor Version"
means the combination of the Contributions of others (if any) used
by a Contributor and that particular Contributor's Contribution.
1.3. "Contribution"
means Covered Software of a particular Contributor.
1.4. "Covered Software"
means Source Code Form to which the initial Contributor has attached
the notice in Exhibit A, the Executable Form of such Source Code
Form, and Modifications of such Source Code Form, in each case
including portions thereof.
1.5. "Incompatible With Secondary Licenses"
means
(a) that the initial Contributor has attached the notice described
in Exhibit B to the Covered Software; or
(b) that the Covered Software was made available under the terms of
version 1.1 or earlier of the License, but not also under the
terms of a Secondary License.
1.6. "Executable Form"
means any form of the work other than Source Code Form.
1.7. "Larger Work"
means a work that combines Covered Software with other material, in
a separate file or files, that is not Covered Software.
1.8. "License"
means this document.
1.9. "Licensable"
means having the right to grant, to the maximum extent possible,
whether at the time of the initial grant or subsequently, any and
all of the rights conveyed by this License.
1.10. "Modifications"
means any of the following:
(a) any file in Source Code Form that results from an addition to,
deletion from, or modification of the contents of Covered
Software; or
(b) any new file in Source Code Form that contains any Covered
Software.
1.11. "Patent Claims" of a Contributor
means any patent claim(s), including without limitation, method,
process, and apparatus claims, in any patent Licensable by such
Contributor that would be infringed, but for the grant of the
License, by the making, using, selling, offering for sale, having
made, import, or transfer of either its Contributions or its
Contributor Version.
1.12. "Secondary License"
means either the GNU General Public License, Version 2.0, the GNU
Lesser General Public License, Version 2.1, the GNU Affero General
Public License, Version 3.0, or any later versions of those
licenses.
1.13. "Source Code Form"
means the form of the work preferred for making modifications.
1.14. "You" (or "Your")
means an individual or a legal entity exercising rights under this
License. For legal entities, "You" includes any entity that
controls, is controlled by, or is under common control with You. For
purposes of this definition, "control" means (a) the power, direct
or indirect, to cause the direction or management of such entity,
whether by contract or otherwise, or (b) ownership of more than
fifty percent (50%) of the outstanding shares or beneficial
ownership of such entity.
2. License Grants and Conditions
--------------------------------
2.1. Grants
Each Contributor hereby grants You a world-wide, royalty-free,
non-exclusive license:
(a) under intellectual property rights (other than patent or trademark)
Licensable by such Contributor to use, reproduce, make available,
modify, display, perform, distribute, and otherwise exploit its
Contributions, either on an unmodified basis, with Modifications, or
as part of a Larger Work; and
(b) under Patent Claims of such Contributor to make, use, sell, offer
for sale, have made, import, and otherwise transfer either its
Contributions or its Contributor Version.
2.2. Effective Date
The licenses granted in Section 2.1 with respect to any Contribution
become effective for each Contribution on the date the Contributor first
distributes such Contribution.
2.3. Limitations on Grant Scope
The licenses granted in this Section 2 are the only rights granted under
this License. No additional rights or licenses will be implied from the
distribution or licensing of Covered Software under this License.
Notwithstanding Section 2.1(b) above, no patent license is granted by a
Contributor:
(a) for any code that a Contributor has removed from Covered Software;
or
(b) for infringements caused by: (i) Your and any other third party's
modifications of Covered Software, or (ii) the combination of its
Contributions with other software (except as part of its Contributor
Version); or
(c) under Patent Claims infringed by Covered Software in the absence of
its Contributions.
This License does not grant any rights in the trademarks, service marks,
or logos of any Contributor (except as may be necessary to comply with
the notice requirements in Section 3.4).
2.4. Subsequent Licenses
No Contributor makes additional grants as a result of Your choice to
distribute the Covered Software under a subsequent version of this
License (see Section 10.2) or under the terms of a Secondary License (if
permitted under the terms of Section 3.3).
2.5. Representation
Each Contributor represents that the Contributor believes its
Contributions are its original creation(s) or it has sufficient rights
to grant the rights to its Contributions conveyed by this License.
2.6. Fair Use
This License is not intended to limit any rights You have under
applicable copyright doctrines of fair use, fair dealing, or other
equivalents.
2.7. Conditions
Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted
in Section 2.1.
3. Responsibilities
-------------------
3.1. Distribution of Source Form
All distribution of Covered Software in Source Code Form, including any
Modifications that You create or to which You contribute, must be under
the terms of this License. You must inform recipients that the Source
Code Form of the Covered Software is governed by the terms of this
License, and how they can obtain a copy of this License. You may not
attempt to alter or restrict the recipients' rights in the Source Code
Form.
3.2. Distribution of Executable Form
If You distribute Covered Software in Executable Form then:
(a) such Covered Software must also be made available in Source Code
Form, as described in Section 3.1, and You must inform recipients of
the Executable Form how they can obtain a copy of such Source Code
Form by reasonable means in a timely manner, at a charge no more
than the cost of distribution to the recipient; and
(b) You may distribute such Executable Form under the terms of this
License, or sublicense it under different terms, provided that the
license for the Executable Form does not attempt to limit or alter
the recipients' rights in the Source Code Form under this License.
3.3. Distribution of a Larger Work
You may create and distribute a Larger Work under terms of Your choice,
provided that You also comply with the requirements of this License for
the Covered Software. If the Larger Work is a combination of Covered
Software with a work governed by one or more Secondary Licenses, and the
Covered Software is not Incompatible With Secondary Licenses, this
License permits You to additionally distribute such Covered Software
under the terms of such Secondary License(s), so that the recipient of
the Larger Work may, at their option, further distribute the Covered
Software under the terms of either this License or such Secondary
License(s).
3.4. Notices
You may not remove or alter the substance of any license notices
(including copyright notices, patent notices, disclaimers of warranty,
or limitations of liability) contained within the Source Code Form of
the Covered Software, except that You may alter any license notices to
the extent required to remedy known factual inaccuracies.
3.5. Application of Additional Terms
You may choose to offer, and to charge a fee for, warranty, support,
indemnity or liability obligations to one or more recipients of Covered
Software. However, You may do so only on Your own behalf, and not on
behalf of any Contributor. You must make it absolutely clear that any
such warranty, support, indemnity, or liability obligation is offered by
You alone, and You hereby agree to indemnify every Contributor for any
liability incurred by such Contributor as a result of warranty, support,
indemnity or liability terms You offer. You may include additional
disclaimers of warranty and limitations of liability specific to any
jurisdiction.
4. Inability to Comply Due to Statute or Regulation
---------------------------------------------------
If it is impossible for You to comply with any of the terms of this
License with respect to some or all of the Covered Software due to
statute, judicial order, or regulation then You must: (a) comply with
the terms of this License to the maximum extent possible; and (b)
describe the limitations and the code they affect. Such description must
be placed in a text file included with all distributions of the Covered
Software under this License. Except to the extent prohibited by statute
or regulation, such description must be sufficiently detailed for a
recipient of ordinary skill to be able to understand it.
5. Termination
--------------
5.1. The rights granted under this License will terminate automatically
if You fail to comply with any of its terms. However, if You become
compliant, then the rights granted under this License from a particular
Contributor are reinstated (a) provisionally, unless and until such
Contributor explicitly and finally terminates Your grants, and (b) on an
ongoing basis, if such Contributor fails to notify You of the
non-compliance by some reasonable means prior to 60 days after You have
come back into compliance. Moreover, Your grants from a particular
Contributor are reinstated on an ongoing basis if such Contributor
notifies You of the non-compliance by some reasonable means, this is the
first time You have received notice of non-compliance with this License
from such Contributor, and You become compliant prior to 30 days after
Your receipt of the notice.
5.2. If You initiate litigation against any entity by asserting a patent
infringement claim (excluding declaratory judgment actions,
counter-claims, and cross-claims) alleging that a Contributor Version
directly or indirectly infringes any patent, then the rights granted to
You by any and all Contributors for the Covered Software under Section
2.1 of this License shall terminate.
5.3. In the event of termination under Sections 5.1 or 5.2 above, all
end user license agreements (excluding distributors and resellers) which
have been validly granted by You or Your distributors under this License
prior to termination shall survive termination.
************************************************************************
* *
* 6. Disclaimer of Warranty *
* ------------------------- *
* *
* Covered Software is provided under this License on an "as is" *
* basis, without warranty of any kind, either expressed, implied, or *
* statutory, including, without limitation, warranties that the *
* Covered Software is free of defects, merchantable, fit for a *
* particular purpose or non-infringing. The entire risk as to the *
* quality and performance of the Covered Software is with You. *
* Should any Covered Software prove defective in any respect, You *
* (not any Contributor) assume the cost of any necessary servicing, *
* repair, or correction. This disclaimer of warranty constitutes an *
* essential part of this License. No use of any Covered Software is *
* authorized under this License except under this disclaimer. *
* *
************************************************************************
************************************************************************
* *
* 7. Limitation of Liability *
* -------------------------- *
* *
* Under no circumstances and under no legal theory, whether tort *
* (including negligence), contract, or otherwise, shall any *
* Contributor, or anyone who distributes Covered Software as *
* permitted above, be liable to You for any direct, indirect, *
* special, incidental, or consequential damages of any character *
* including, without limitation, damages for lost profits, loss of *
* goodwill, work stoppage, computer failure or malfunction, or any *
* and all other commercial damages or losses, even if such party *
* shall have been informed of the possibility of such damages. This *
* limitation of liability shall not apply to liability for death or *
* personal injury resulting from such party's negligence to the *
* extent applicable law prohibits such limitation. Some *
* jurisdictions do not allow the exclusion or limitation of *
* incidental or consequential damages, so this exclusion and *
* limitation may not apply to You. *
* *
************************************************************************
8. Litigation
-------------
Any litigation relating to this License may be brought only in the
courts of a jurisdiction where the defendant maintains its principal
place of business and such litigation shall be governed by laws of that
jurisdiction, without reference to its conflict-of-law provisions.
Nothing in this Section shall prevent a party's ability to bring
cross-claims or counter-claims.
9. Miscellaneous
----------------
This License represents the complete agreement concerning the subject
matter hereof. If any provision of this License is held to be
unenforceable, such provision shall be reformed only to the extent
necessary to make it enforceable. Any law or regulation which provides
that the language of a contract shall be construed against the drafter
shall not be used to construe this License against a Contributor.
10. Versions of the License
---------------------------
10.1. New Versions
Mozilla Foundation is the license steward. Except as provided in Section
10.3, no one other than the license steward has the right to modify or
publish new versions of this License. Each version will be given a
distinguishing version number.
10.2. Effect of New Versions
You may distribute the Covered Software under the terms of the version
of the License under which You originally received the Covered Software,
or under the terms of any subsequent version published by the license
steward.
10.3. Modified Versions
If you create software not governed by this License, and you want to
create a new license for such software, you may create and use a
modified version of this License if you rename the license and remove
any references to the name of the license steward (except to note that
such modified license differs from this License).
10.4. Distributing Source Code Form that is Incompatible With Secondary
Licenses
If You choose to distribute Source Code Form that is Incompatible With
Secondary Licenses under the terms of this version of the License, the
notice described in Exhibit B of this License must be attached.
Exhibit A - Source Code Form License Notice
-------------------------------------------
This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at http://mozilla.org/MPL/2.0/.
If it is not possible or desirable to put the notice in a particular
file, then You may include the notice in a location (such as a LICENSE
file in a relevant directory) where a recipient would be likely to look
for such a notice.
You may add additional accurate notices of copyright ownership.
Exhibit B - "Incompatible With Secondary Licenses" Notice
---------------------------------------------------------
This Source Code Form is "Incompatible With Secondary Licenses", as
defined by the Mozilla Public License, v. 2.0.

View File

@@ -0,0 +1,94 @@
charset
charset_property
charsetcode
charsetcode_property
comments
comments_property
companyname
companyname_property
currenttranslation
currenttranslation_property
filedescription
filedescription_property
fileflags
fileflags_property
fileflagsmask
fileflagsmask_property
filename
filename_property
fileos
fileos_property
filesubtype
filesubtype_property
filetype
filetype_property
fileversion
fileversion_property
fileversionnumber
fileversionnumber_property
fixedfileinfo
fixedfileinfo_property
haveinfo
haveinfo_property
internalname
internalname_property
language
language_property
languagecode
languagecode_property
legalcopyright
legalcopyright_property
legaltrademarks
legaltrademarks_property
numtranslations
numtranslations_property
originalfilename
originalfilename_property
privatebuild
privatebuild_property
productname
productname_property
productversion
productversion_property
productversionnumber
productversionnumber_property
specialbuild
specialbuild_property
stringfileinfo
stringfileinfo_property
tpjversioninfo
tpjversioninfo_charset
tpjversioninfo_charsetcode
tpjversioninfo_comments
tpjversioninfo_companyname
tpjversioninfo_currenttranslation
tpjversioninfo_example1
tpjversioninfo_example2
tpjversioninfo_example3
tpjversioninfo_example4
tpjversioninfo_filedescription
tpjversioninfo_fileflags
tpjversioninfo_fileflagsmask
tpjversioninfo_filename
tpjversioninfo_fileos
tpjversioninfo_filesubtype
tpjversioninfo_filetype
tpjversioninfo_fileversion
tpjversioninfo_fileversionnumber
tpjversioninfo_fixedfileinfo
tpjversioninfo_haveinfo
tpjversioninfo_internalname
tpjversioninfo_language
tpjversioninfo_languagecode
tpjversioninfo_legalcopyright
tpjversioninfo_legaltrademarks
tpjversioninfo_numtranslations
tpjversioninfo_object
tpjversioninfo_originalfilename
tpjversioninfo_privatebuild
tpjversioninfo_productname
tpjversioninfo_productversion
tpjversioninfo_productversionnumber
tpjversioninfo_specialbuild
tpjversioninfo_stringfileinfo
tpjversionnumber

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,926 @@
{
* This Source Code Form is subject to the terms of the Mozilla Public License,
* v. 2.0. If a copy of the MPL was not distributed with this file, You can
* obtain one at http://mozilla.org/MPL/2.0/
*
* Copyright (C) 1998-2013, Peter Johnson (www.delphidabbler.com).
*
* $Rev: 1110 $
* $Date: 2013-01-13 23:26:17 +0000 (Sun, 13 Jan 2013) $
*
* Version Information Component. The component reads version information from
* executable files.
}
unit PJVersionInfo;
// Determine if certain features are supported by compiler
// * Supports_Assert - Defined if assertions supported (all compilers
// except Delphi 2).
// * Supports_ResourceString - Defined if resourcestring keyword supported (all
// compilers except Delphi 2).
// * Supports_AdvancedRecords - Defined if advanced records with record methods,
// operator overloads etc. supported (Delphi 2006
// and later).
// * Supports_RTLNameSpaces - Defined if Delphi RTL / VCL unit references
// should be qualified with namespaces.
{$DEFINE Supports_Assert}
{$DEFINE Supports_ResourceString}
{$UNDEF Supports_AdvancedRecords}
{$UNDEF Supports_RTLNameSpaces}
{$IFDEF VER90} // Delphi 2
{$UNDEF Supports_Assert}
{$UNDEF Supports_ResourceString}
{$ENDIF}
// Switch off unsafe code warnings if switch supported
{$IFDEF CONDITIONALEXPRESSIONS}
{$IF CompilerVersion >= 15.0} // >= Delphi 7
{$WARN UNSAFE_CODE OFF}
{$IFEND}
{$IF CompilerVersion >= 18.0} // >= Delphi 2006
{$DEFINE Supports_AdvancedRecords}
{$IFEND}
{$IF CompilerVersion >= 23.0} // Delphi XE2
{$DEFINE Supports_RTLNameSpaces}
{$IFEND}
{$ENDIF}
interface
uses
// Delphi
{$IFDEF Supports_RTLNameSpaces}
Winapi.Windows, System.Classes;
{$ELSE}
Windows, Classes;
{$ENDIF}
type
{
TPJVersionNumber:
Record that encapsulates version numbers.
}
TPJVersionNumber = record
V1: Word; // Major version number
V2: Word; // Minor version number
V3: Word; // Revision version number
V4: Word; // Build number
{$IFDEF Supports_AdvancedRecords}
class operator Implicit(Ver: TPJVersionNumber): string;
{Operator overload that performs implicit conversion of TPJVersionNumber
to string as dotted quad.
@param Ver [in] Version number to be converted.
@return Version number as dotted quad.
}
class operator LessThanOrEqual(Ver1, Ver2: TPJVersionNumber): Boolean;
{Operator overload that compares two version numbers to check if first is
less than or equal to the second.
@param Ver1 [in] First version number.
@param Ver2 [in] Second version number.
@return True if Ver1 <= Ver2, False otherwise.
}
class operator LessThan(Ver1, Ver2: TPJVersionNumber): Boolean;
{Operator overload that compares two version numbers to check if first is
less than second.
@param Ver1 [in] First version number.
@param Ver2 [in] Second version number.
@return True if Ver1 < Ver2, False otherwise.
}
class operator GreaterThan(Ver1, Ver2: TPJVersionNumber): Boolean;
{Operator overload that compares two version numbers to check if first is
greater than second.
@param Ver1 [in] First version number.
@param Ver2 [in] Second version number.
@return True if Ver1 > Ver2, False otherwise.
}
class operator GreaterThanOrEqual(Ver1, Ver2: TPJVersionNumber): Boolean;
{Operator overload that compares two version numbers to check if first is
greater than or equal to the second.
@param Ver1 [in] First version number.
@param Ver2 [in] Second version number.
@return True if Ver1 >= Ver2, False otherwise.
}
class operator Equal(Ver1, Ver2: TPJVersionNumber): Boolean;
{Operator overload that compares two version numbers to check for
equality.
@param Ver1 [in] First version number.
@param Ver2 [in] Second version number.
@return True if Ver1 = Ver2, False otherwise.
}
class operator NotEqual(Ver1, Ver2: TPJVersionNumber): Boolean;
{Operator overload that compares two version numbers to check for
inequality.
@param Ver1 [in] First version number.
@param Ver2 [in] Second version number.
@return True if Ver1 <> Ver2, False otherwise.
}
{$ENDIF}
end;
{
TPJVersionInfo:
Component that accesses the version information embedded in an executable
file and exposes the information as properties. Supports multi-lingual
version iformation resources.
}
TPJVersionInfo = class(TComponent)
private // properties
fFileName: string;
fHaveInfo: Boolean;
fNumTranslations: Integer;
fCurrentTranslation: Integer;
fFixedFileInfo: TVSFixedFileInfo;
procedure SetFileName(AName: string);
function GetProductVersionNumber: TPJVersionNumber;
function GetFileVersionNumber: TPJVersionNumber;
function GetLanguage: string;
function GetCharSet: string;
function GetCharSetCode: WORD;
function GetLanguageCode: WORD;
function GetCurrentTranslation: Integer;
procedure SetCurrentTranslation(const Value: Integer);
function GetStringFileInfo(const Name: string): string;
function GetStringFileInfoByIdx(Index: Integer): string;
function GetFixedFileInfoItemByIdx(Index: Integer): DWORD;
private
fPInfoBuffer: PChar; // Pointer to info buffer
fPTransBuffer: Pointer; // Pointer to translation buffer
procedure GetInfoBuffer(Len: DWORD);
{Creates an info buffer of required size.
@param Len [in] Required buffer size in characters.
}
procedure GetTransBuffer(Len: UINT);
{Creates a translation table buffer of required size.
@param Required buffer size in bytes.
}
function GetTransStr: string;
{Encodes information about the current translation in a string.
@return Required translation information.
}
protected
procedure ClearProperties; virtual;
{Forces properties to return cleared values.
}
procedure ReadVersionInfo; virtual;
{Reads version info from file named by FileName property.
}
public
constructor Create(AOwner: TComponent); override;
{Object constructor. Sets default values.
@param AOwner [in] Component that owns this one. May be nil.
}
destructor Destroy; override;
{Object destructor. Frees allocated memory.
}
property HaveInfo: Boolean
read fHaveInfo;
{Property true if file version info for the file named by the FileName
property has been successfully read}
property FixedFileInfo: TVSFixedFileInfo
read fFixedFileInfo;
{Exposes the whole fixed file info record. Following properties expose
the various fields of it}
property FileVersionNumber: TPJVersionNumber
read GetFileVersionNumber;
{Version number of file in numeric format. From fixed file info}
property ProductVersionNumber: TPJVersionNumber
read GetProductVersionNumber;
{Version number of product in numeric format. From fixed file info}
property FileOS: DWORD index 0
read GetFixedFileInfoItemByIdx;
{Code describing operating system to be used by file, From fixed file
info}
property FileType: DWORD index 1
read GetFixedFileInfoItemByIdx;
{Code descibing type of file. From fixed file info}
property FileSubType: DWORD index 2
read GetFixedFileInfoItemByIdx;
{Code describing sub-type of file - only used for certain values of
FileType property. From fixed file info}
property FileFlagsMask: DWORD index 3
read GetFixedFileInfoItemByIdx;
{Code describing which FileFlags are valid. From fixed file info}
property FileFlags: DWORD index 4
read GetFixedFileInfoItemByIdx;
{Flags describing file state. From fixed file info}
property Comments: string index 0
read GetStringFileInfoByIdx;
{String file info property giving user defined comments in current
translation}
property CompanyName: string index 1
read GetStringFileInfoByIdx;
{String file info property giving name of company in current translation}
property FileDescription: string index 2
read GetStringFileInfoByIdx;
{String file info property giving description of file in current
translation}
property FileVersion: string index 3
read GetStringFileInfoByIdx;
{String file info property giving version number of file in string format
in current translation}
property InternalName: string index 4
read GetStringFileInfoByIdx;
{String file info property giving internal name of file in current
translation}
property LegalCopyright: string index 5
read GetStringFileInfoByIdx;
{String file info property giving copyright message in current
translation}
property LegalTrademarks: string index 6
read GetStringFileInfoByIdx;
{String file info property giving trademark info in current translation}
property OriginalFileName: string index 7
read GetStringFileInfoByIdx;
{String file info property giving original name of file in current
translation}
property PrivateBuild: string index 8
read GetStringFileInfoByIdx;
{String file info property giving information about a private build of
file in current translation}
property ProductName: string index 9
read GetStringFileInfoByIdx;
{String file info property giving name of product in current translation}
property ProductVersion: string index 10
read GetStringFileInfoByIdx;
{String file info property giving version number of product in string
format in current translation}
property SpecialBuild: string index 11
read GetStringFileInfoByIdx;
{String file info property giving information about a special build of
file in current translation}
property StringFileInfo[const Name: string]: string
read GetStringFileInfo;
{Value of named string file info item in current translation. This
property can access both standard and custom string info}
property Language: string
read GetLanguage;
{Name of language in use in current translation}
property CharSet: string
read GetCharSet;
{Name of character set in use in current translation}
property LanguageCode: WORD
read GetLanguageCode;
{Code of laguage in use in current translation}
property CharSetCode: WORD
read GetCharSetCode;
{Code of character set in use in current translation}
property NumTranslations: Integer
read fNumTranslations;
{The number of difference translations (ie languages and char sets) in
the version information}
property CurrentTranslation: Integer
read GetCurrentTranslation write SetCurrentTranslation;
{Zero-based index of the current translation: this is 0 when a file is
first accessed. Set to a value in range 0..NumTranslations-1 to access
other translations. All string info, language and char set properties
return information for the current translation}
published
property FileName: string read fFileName write SetFileName;
{Name of file containing version information. If set to '' (default) the
version information comes from the containing executable file}
end;
function VerNumToStr(const Ver: TPJVersionNumber): string;
{Converts a version number to its string representation as a dotted quad.
@param Ver [in] Version number to be converted.
@return Version number as dotted quad.
}
function CompareVerNums(const Ver1, Ver2: TPJVersionNumber): Integer;
{Compares two version numbers and returns a value indicating if the first is
less than, equal to or greater than the second.
@param Ver1 [in] First version number to compare.
@param Ver2 [in] Second version number to compare.
@return 0 if Ver1 = Ver2, -ve if Ver1 < Ver2, +ve if Ver1 > Ver2.
}
procedure Register;
{Registers this component.
}
implementation
uses
{$IFDEF Supports_RTLNameSpaces}
System.SysUtils;
{$ELSE}
// Delphi
SysUtils;
{$ENDIF}
procedure Register;
{Registers this component.
}
begin
RegisterComponents('DelphiDabbler', [TPJVersionInfo]);
end;
type
// ANSI version of CPINFOEX: provides information about a code page
_cpinfoexA = packed record
MaxCharSize: UINT;
{max length in bytes of a character in the code page}
DefaultChar: array[0..MAX_DEFAULTCHAR-1] of Byte;
{default character used to translate strings to the specific code page}
LeadByte: array[0..MAX_LEADBYTES-1] of Byte;
{fixed-length array of lead byte ranges: all elements null if none}
UnicodeDefaultChar: WideChar;
{unicode default char used in translations from the specific code page}
CodePage: UINT;
{code page value}
CodePageName: array[0..MAX_PATH-1] of AnsiChar;
{full localised name of the code page}
end;
CPINFOEXA = _cpinfoexA;
PCPInfoExA = ^CPINFOEXA;
TCPInfoExA = CPINFOEXA;
// Unicode version of CPINFOEX: provides information about a code page
_cpinfoexW = packed record
MaxCharSize: UINT;
{max length in bytes of a character in the code page}
DefaultChar: array[0..MAX_DEFAULTCHAR-1] of Byte;
{default character used to translate strings to the specific code page}
LeadByte: array[0..MAX_LEADBYTES-1] of Byte;
{fixed-length array of lead byte ranges: all elements null if none}
UnicodeDefaultChar: WideChar;
{unicode default char used in translations from the specific code page}
CodePage: UINT;
{code page value}
CodePageName: array[0..MAX_PATH-1] of WideChar;
{full localised name of the code page}
end;
CPINFOEXW = _cpinfoexW;
PCPInfoExW = ^CPINFOEXW;
TCPInfoExW = CPINFOEXW;
// Set TCPInfoEx etc to required ANSI or Unicode version of structure
{$IFDEF UNICODE}
TCPInfoEx = TCPInfoExW;
PCPInfoEx = PCPInfoExW;
{$ELSE}
TCPInfoEx = TCPInfoExA;
PCPInfoEx = PCPInfoExA;
{$ENDIF}
CPINFOEX = TCPInfoEx;
var
// Pointer to Windows API GetCPInfoEx function if it exists or to GetCPInfoAlt
// otherwise
GetCPInfoExFn: function (CodePage: UINT; dwFlags: DWORD;
var lpCPInfoEx: TCPInfoEx): BOOL; stdcall;
const
// Import name of GetCPInfoEx. Unicode and ANSI versions.
{$IFDEF UNICODE}
cGetCPInfoEx = 'GetCPInfoExW';
{$ELSE}
cGetCPInfoEx = 'GetCPInfoExA';
{$ENDIF}
function GetCPInfoAlt(CodePage: UINT; dwFlags: DWORD;
var lpCPInfoEx: TCPInfoEx): BOOL; stdcall;
{Local implementation of GetCPInfoEx, for use on OSs that don't support
GetCPInfoEx. Calls older GetCPInfo API function and calculates members of
TCPInfoEx not provided by GetCPInfo.
@param CodePage [in] Code page for which information is required.
@param dwFlags [in] Reserved. Must be 0.
@param lpCPInfoEx [in/out] Structure that receives information about the
code page.
@return True on success, False on error.
}
// ---------------------------------------------------------------------------
procedure CopyByteArray(const Src: array of Byte; var Dest: array of Byte);
{Makes a copy of a byte array.
@param Src [in] Byte array to be copied.
@param Dest [in/out] In: Array to receive copy: must be same size as Src.
Out: Receives copy of Src.
}
var
Idx: Integer; // loops thru array
begin
{$IFDEF Supports_Assert}
Assert((Low(Src) = Low(Dest)) and (High(Src) = High(Dest)));
{$ENDIF}
for Idx := Low(Src) to High(Src) do
Dest[Idx] := Src[Idx];
end;
// ---------------------------------------------------------------------------
const
sCodePage = 'Code Page %d'; // description of code page if OS doesn't provide
var
OldInfo: TCPInfo; // old style code page info structure for Win95/NT4
begin
// We haven't got GetCPInfoEx: use old GetCPInfo to get some info
Result := GetCPInfo(CodePage, OldInfo);
if Result then
begin
// We update TCPInfoEx structure from old style structure and calculate
// additional info
// copy over from old style TCPInfo structure
lpCPInfoEx.MaxCharSize := OldInfo.MaxCharSize;
CopyByteArray(OldInfo.DefaultChar, lpCPInfoEx.DefaultChar);
CopyByteArray(OldInfo.LeadByte, lpCPInfoEx.LeadByte);
// no new default char
lpCPInfoEx.UnicodeDefaultChar := #0;
// store reference to code page
lpCPInfoEx.CodePage := CodePage;
// description is simply "Code Page NNN"
StrPLCopy(
lpCPInfoEx.CodePageName,
Format(sCodePage, [CodePage]),
SizeOf(lpCPInfoEx.CodePageName)
);
end;
end;
function VerNumToStr(const Ver: TPJVersionNumber): string;
{Converts a version number to its string representation as a dotted quad.
@param Ver [in] Version number to be converted.
@return Version number as dotted quad.
}
begin
Result := Format('%d.%d.%d.%d', [Ver.V1, Ver.V2, Ver.V3, Ver.V4]);
end;
function CompareVerNums(const Ver1, Ver2: TPJVersionNumber): Integer;
{Compares two version numbers and returns a value indicating if the first is
less than, equal to or greater than the second.
@param Ver1 [in] First version number to compare.
@param Ver2 [in] Second version number to compare.
@return 0 if Ver1 = Ver2, -ve if Ver1 < Ver2, +ve if Ver1 > Ver2.
}
begin
Result := Ver1.V1 - Ver2.V1;
if Result <> 0 then
Exit;
Result := Ver1.V2 - Ver2.V2;
if Result <> 0 then
Exit;
Result := Ver1.V3 - Ver2.V3;
if Result <> 0 then
Exit;
Result := Ver1.V4 - Ver2.V4;
end;
type
{
TTransRec:
Record of language code and char set codes that are returned from version
information.
}
TTransRec = packed record
Lang: Word; // language code
CharSet: Word; // character set code
end;
{
TTransRecs:
Type used to type cast translation data into an array of translation
records.
}
TTransRecs = array[0..1000] of TTransRec;
{
PTransRecs:
Pointer to an array of translation records.
}
PTransRecs = ^TTransRecs;
{ TPJVersionInfo }
procedure TPJVersionInfo.ClearProperties;
{Forces properties to return cleared values.
}
begin
// Record that we haven't read ver info: this effectively clears properties
// since each property read access method checks this flag before returning
// result
fHaveInfo := False;
end;
constructor TPJVersionInfo.Create(AOwner: TComponent);
{Object constructor. Sets default values.
@param AOwner [in] Component that owns this one. May be nil.
}
begin
inherited Create(AOwner);
// Default is no file name - refers to executable file for application
FileName := '';
end;
destructor TPJVersionInfo.Destroy;
{Object destructor. Frees allocated memory.
}
begin
// Ensure that info buffer is freed if allocated
if fPInfoBuffer <> nil then
StrDispose(fPInfoBuffer);
// Ensure that translation buffer is free if allocated
if fPTransBuffer <> nil then
FreeMem(fPTransBuffer);
inherited Destroy;
end;
function TPJVersionInfo.GetCharSet: string;
{Read accessor for CharSet property:
@return String describing character set if version info is available or
empty string if not.
}
var
Info: TCPInfoEx; // receives code page info
CP: Word; // code page
const
// Special code page messages
sUnknownCP = '%d (Unknown Code Page)'; // unknown
// Messages for pages API can't return (managed apps only)
sUTF16LE = '%d (Unicode UTF-16, little endian byte order)';
sUTF16BE = '%d (Unicode UTF-16, big endian byte order)';
sUTF32LE = '%d (Unicode UTF-32, little endian byte order)';
sUTF32BE = '%d (Unicode UTF-32, big endian byte order)';
begin
Result := '';
if fHaveInfo then
begin
CP := GetCharSetCode;
case CP of
// Check for char codes only available in managed apps (API call won't
// find them)
1200: Result := Format(sUTF16LE, [CP]);
1201: Result := Format(sUTF16BE, [CP]);
12000: Result := Format(sUTF32LE, [CP]);
12001: Result := Format(sUTF32BE, [CP]);
else
begin
// Not a known problem code page: get it from OS
if GetCPInfoExFn(CP, 0, Info) then
Result := Info.CodePageName
else
// Give up: can't find it
Result := Format(sUnknownCP, [CP]);
end;
end;
end;
end;
function TPJVersionInfo.GetCharSetCode: WORD;
{Read accessor for CharSetCode property.
@return Char set code for current translation or 0 if there is no
translation or there is no version info.
}
begin
if fHaveInfo and (GetCurrentTranslation >= 0) then
Result := PTransRecs(fPTransBuffer)^[GetCurrentTranslation].CharSet
else
Result := 0;
end;
function TPJVersionInfo.GetCurrentTranslation: Integer;
{Read accessor for CurrentTranslation property.
@return Index to current translation if version info is available or -1 if
not.
}
begin
if fHaveInfo then
Result := fCurrentTranslation
else
Result := -1;
end;
function TPJVersionInfo.GetFileVersionNumber: TPJVersionNumber;
{Read accessor for FileVersionNumber property.
@return Record containing version information. If there is no version info
then all fields will be zero.
}
begin
Result.V1 := HiWord(fFixedFileInfo.dwFileVersionMS);
Result.V2 := LoWord(fFixedFileInfo.dwFileVersionMS);
Result.V3 := HiWord(fFixedFileInfo.dwFileVersionLS);
Result.V4 := LoWord(fFixedFileInfo.dwFileVersionLS);
end;
function TPJVersionInfo.GetFixedFileInfoItemByIdx(Index: Integer): DWORD;
{Read accessor method for various DWORD fields of the fixed file information
record accessed by index.
NOTE: This is a fix for C++ Builder. Delphi is able to access the fields of
the TVSFixedFileInfo record directly in the read clause of the property
declaration but this is not possible in C++ Builder.
@param Index [in] Index of required property.
@return Required DWORD value.
}
begin
case Index of
0: Result := fFixedFileInfo.dwFileOS;
1: Result := fFixedFileInfo.dwFileType;
2: Result := fFixedFileInfo.dwFileSubType;
3: Result := fFixedFileInfo.dwFileFlagsMask;
4: Result := fFixedFileInfo.dwFileFlags;
else Result := 0;
end;
end;
procedure TPJVersionInfo.GetInfoBuffer(Len: DWORD);
{Creates an info buffer of required size.
@param Len [in] Required buffer size in characters.
}
begin
// Clear any existing buffer
if fPInfoBuffer <> nil then
StrDispose(fPInfoBuffer);
// Create the new one
fPInfoBuffer := StrAlloc(Len);
end;
function TPJVersionInfo.GetLanguage: string;
{Read accessor for Language property
@return String describing language or empty string if no version info
available.
}
const
cBufSize = 256; // size of buffer
var
Buf: array[0..Pred(cBufSize)] of Char; // stores langauge string from API call
begin
// Assume failure
Result := '';
// Try to get language name from Win API if we have ver info
if fHaveInfo and
(VerLanguageName(GetLanguageCode, Buf, Pred(cBufSize)) > 0) then
Result := Buf;
end;
function TPJVersionInfo.GetLanguageCode: WORD;
{Read accessor for LanguageCode property
@return Language code for current translation or 0 if there is no
translation or there is no version info.
}
begin
if fHaveInfo and (GetCurrentTranslation >= 0) then
Result := PTransRecs(fPTransBuffer)^[GetCurrentTranslation].Lang
else
Result := 0;
end;
function TPJVersionInfo.GetProductVersionNumber: TPJVersionNumber;
{Read accessor for ProductVersionNumber property.
@return Record containing version information. If there is no version info
then all fields will be zero.
}
begin
Result.V1 := HiWord(fFixedFileInfo.dwProductVersionMS);
Result.V2 := LoWord(fFixedFileInfo.dwProductVersionMS);
Result.V3 := HiWord(fFixedFileInfo.dwProductVersionLS);
Result.V4 := LoWord(fFixedFileInfo.dwProductVersionLS);
end;
function TPJVersionInfo.GetStringFileInfo(const Name: string): string;
{Read accessor for StringFileInfo array property.
@param Name [in] Name of required string information.
@return String associated Name or empty string if there is no version info.
}
var
CommandBuf: array[0..255] of char; // buffer to build API call command str
Ptr: Pointer; // pointer to result of API call
Len: UINT; // length of structure returned from API
begin
// Set default failure result to empty string
Result := '';
// Check if we have valid information recorded in info buffer - exit if not
if fHaveInfo then
begin
// Build API call command string for reading string file info:
// this uses info string + language and character set
StrPCopy(CommandBuf, '\StringFileInfo\' + GetTransStr + '\' + Name);
// Call API to get required string and return it if successful
if VerQueryValue(fPInfoBuffer, CommandBuf, Ptr, Len) then
Result := PChar(Ptr);
end;
end;
function TPJVersionInfo.GetStringFileInfoByIdx(Index: Integer): string;
{Read accessor for all string file info properties.
@param Index [in] Index of required property.
@return Appropriate string value of the indexed property or empty string if
property has no value or there is no version info.
}
const
cNames: array[0..11] of string =
('Comments', 'CompanyName', 'FileDescription', 'FileVersion',
'InternalName', 'LegalCopyright', 'LegalTrademarks', 'OriginalFileName',
'PrivateBuild', 'ProductName', 'ProductVersion', 'SpecialBuild');
{names of predefined string file info strings}
begin
Result := GetStringFileInfo(cNames[Index]);
end;
procedure TPJVersionInfo.GetTransBuffer(Len: UINT);
{Creates a translation table buffer of required size.
@param Required buffer size in bytes.
}
begin
// Clear any existing buffer
if fPTransBuffer <> nil then
FreeMem(fPTransBuffer);
// Create the new one
GetMem(fPTransBuffer, Len);
end;
function TPJVersionInfo.GetTransStr: string;
{Encodes information about the current translation in a string.
@return Required translation information.
}
var
TransRec: TTransRec; // translation record in array of translations
begin
if GetCurrentTranslation >= 0 then
begin
// There is a valid current translation: return hex string related to it
TransRec := PTransRecs(fPTransBuffer)^[GetCurrentTranslation];
Result := Format('%4.4x%4.4x', [TransRec.Lang, TransRec.CharSet]);
end
else
// No valid translation string: return empty string
Result := '';
end;
procedure TPJVersionInfo.ReadVersionInfo;
{Reads version info from file named by FileName property.
}
var
Len: UINT; // length of structs returned from API calls
Ptr: Pointer; // points to version info structures
InfoSize: DWORD; // size of info buffer
Dummy: DWORD; // stores 0 in call to GetFileVersionInfoSize
begin
// Record default value of HaveInfo property - no info read
fHaveInfo := False;
// Store zeros in fixed file info structure: this is used when no info
FillChar(fFixedFileInfo, SizeOf(fFixedFileInfo), 0);
// Set NumTranslations property to 0: this is value if no info
fNumTranslations := 0;
// Record required size of version info buffer
InfoSize := GetFileVersionInfoSize(PChar(fFileName), Dummy);
// Check that there was no error
if InfoSize > 0 then
begin
// Found info size OK
// Ensure we have a sufficiently large buffer allocated
GetInfoBuffer(InfoSize);
// Read file version info into storage and check success
if GetFileVersionInfo(PChar(fFileName), Dummy, InfoSize, fPInfoBuffer) then
begin
// Success: we've read file version info to storage OK
fHaveInfo := True;
// Get fixed file info & copy to own storage
VerQueryValue(fPInfoBuffer, '\', Ptr, Len);
fFixedFileInfo := PVSFixedFileInfo(Ptr)^;
// Get first translation table info from API
VerQueryValue(fPInfoBuffer, '\VarFileInfo\Translation', Ptr, Len);
// Ptr is to block of translation records each of size Len:
// work out number of translations
fNumTranslations := Len div SizeOf(TTransRec);
// store translation array in a buffer
GetTransBuffer(Len);
Move(Ptr^, fPTransBuffer^, Len);
// make first translation in block current one (-1 if no translations)
SetCurrentTranslation(0); // adjusts value to -1 if no translations
end;
end;
end;
procedure TPJVersionInfo.SetCurrentTranslation(const Value: Integer);
{Write acceesor method CurrentTranslation property
@param Index of required translation. If Value is out of range then the
property is set to -1 to indicate no translation.
}
begin
if (Value >= 0) and (Value < NumTranslations) then
fCurrentTranslation := Value
else
fCurrentTranslation := -1
end;
procedure TPJVersionInfo.SetFileName(AName: string);
{Write accessor for FileName property. Action at design time and run time is
different. At design time we simply record the property value while at run
time we store the value and read any version information from the file.
@param AName [in] New value of FileName property. If '' then property is set
to the name of the program's executable file.
}
begin
if csDesigning in ComponentState then
// We are designing, simply record the required name
fFileName := AName
else
begin
// It's run-time
// use Application exec file name if name is ''
if AName = '' then
fFileName := ParamStr(0)
else
fFileName := AName;
// clear all properties and read file version info for new file
ClearProperties;
ReadVersionInfo;
end;
end;
{$IFDEF Supports_AdvancedRecords}
{ TPJVersionNumber }
class operator TPJVersionNumber.Equal(Ver1, Ver2: TPJVersionNumber): Boolean;
{Operator overload that compares two version numbers to check for equality.
@param Ver1 [in] First version number.
@param Ver2 [in] Second version number.
@return True if Ver1 = Ver2, False otherwise.
}
begin
Result := CompareVerNums(Ver1, Ver2) = 0;
end;
class operator TPJVersionNumber.GreaterThan(Ver1,
Ver2: TPJVersionNumber): Boolean;
{Operator overload that compares two version numbers to check if first is
greater than second.
@param Ver1 [in] First version number.
@param Ver2 [in] Second version number.
@return True if Ver1 > Ver2, False otherwise.
}
begin
Result := CompareVerNums(Ver1, Ver2) > 0;
end;
class operator TPJVersionNumber.GreaterThanOrEqual(Ver1,
Ver2: TPJVersionNumber): Boolean;
{Operator overload that compares two version numbers to check if first is
greater than or equal to the second.
@param Ver1 [in] First version number.
@param Ver2 [in] Second version number.
@return True if Ver1 >= Ver2, False otherwise.
}
begin
Result := CompareVerNums(Ver1, Ver2) >= 0;
end;
class operator TPJVersionNumber.Implicit(Ver: TPJVersionNumber): string;
{Operator overload that performs implicit conversion of TPJVersionNumber to
string as dotted quad.
@param Ver [in] Version number to be converted.
@return Version number as dotted quad.
}
begin
Result := VerNumToStr(Ver);
end;
class operator TPJVersionNumber.LessThan(Ver1, Ver2: TPJVersionNumber): Boolean;
{Operator overload that compares two version numbers to check if first is less
than second.
@param Ver1 [in] First version number.
@param Ver2 [in] Second version number.
@return True if Ver1 < Ver2, False otherwise.
}
begin
Result := CompareVerNums(Ver1, Ver2) < 0;
end;
class operator TPJVersionNumber.LessThanOrEqual(Ver1,
Ver2: TPJVersionNumber): Boolean;
{Operator overload that compares two version numbers to check if first is less
than or equal to the second.
@param Ver1 [in] First version number.
@param Ver2 [in] Second version number.
@return True if Ver1 <= Ver2, False otherwise.
}
begin
Result := CompareVerNums(Ver1, Ver2) <= 0;
end;
class operator TPJVersionNumber.NotEqual(Ver1, Ver2: TPJVersionNumber): Boolean;
{Operator overload that compares two version numbers to check for inequality.
@param Ver1 [in] First version number.
@param Ver2 [in] Second version number.
@return True if Ver1 <> Ver2, False otherwise.
}
begin
Result := CompareVerNums(Ver1, Ver2) <> 0;
end;
{$ENDIF}
initialization
// Get reference to GetCPInfoEx function
GetCPInfoExFn := GetProcAddress(GetModuleHandle('Kernel32.dll'), cGetCPInfoEx);
if not Assigned(GetCPInfoExFn) then
GetCPInfoExFn := GetCPInfoAlt;
end.

View File

@@ -0,0 +1,451 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!--
* This Source Code Form is subject to the terms of the Mozilla Public License,
* v. 2.0. If a copy of the MPL was not distributed with this file, You can
* obtain one at http://mozilla.org/MPL/2.0/
*
* Copyright (C) 2005-2013, Peter Johnson (www.delphidabbler.com).
*
* $Rev: 1131 $
* $Date: 2013-01-14 03:27:03 +0000 (Mon, 14 Jan 2013) $
*
* Read-me file for Version Information Component.
-->
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<title>
DelphiDabbler Version Information Component ReadMe
</title>
<style type="text/css">
body {
margin: 1em;
padding: 0;
font-family: Verdana, Arial, sans-serif;
font-size: 9pt;
line-height: 150%;
}
h1 {
margin: 0 0 1em 0;
padding: 0.5em;
border: 1px silver solid;
background-color: #eee;
font-size: 13pt;
font-weight: bold;
text-align: center;
}
h1 .subtitle {
font-style: italic;
color: #336;
}
h2 {
margin: 1em 0 0 0;
padding: 0;
padding-bottom: 6px;
border-bottom: 1px silver solid;
font-size: 11pt;
font-weight: bold;
}
h3 {
margin: 0.5em 0 0 0;
padding: 0;
font-size: 9pt;
font-weight: bold;
}
p {
margin: 0.5em 0 0 0;
padding: 0;
}
ul, ol {
margin: 0.5em 0 0 3em;
padding: 0;
}
ul {
list-style-type: square;
}
ul.spaced li,
ol.spaced li {
margin-top: 0.5em;
}
ul.spaced li,
ol.spaced li {
margin-top: 0.5em;
}
ul.unspaced li,
ol.unspaced li {
margin-top: 0;
}
ul.unspaced li.first,
ol.unspaced li.first {
margin-top: 0.5em;
}
code {
font-family: "Courier New", Courier, monospace;
}
a:link {
color: #336;
text-decoration: underline;
}
a:visited {
color: #669;
text-decoration: underline;
}
a:active {
color: #336;
text-decoration: underline;
}
a:hover {
text-decoration: underline;
}
.pullout {
border-left: 8px silver solid;
background-color: #eee;
margin: 0.5em 0 0 0;
padding: 0.25em 0.5em;
font-style: italic;
}
.indent {
margin-left: 3em;
}
.highlight {
color: #336;
font-style: italic;
font-weight: bold;
}
.endnotes {
margin: 1.5em 0 0 0;
padding: 1em 0 0 0;
border-top: 1px silver solid;
}
.comments {
font-style: italic;
}
.copyright,
.copyright a:link,
.copyright a:visited,
.copyright a:active {
margin: 1em 0 0 0;
color: gray;
font-size: 8pt;
text-align: right;
}
</style>
</head>
<body>
<h1>
<div>Version Information Component</div>
<div class="subtitle">ReadMe</div>
</h1>
<h2 id="contents">
Contents
</h2>
<ul>
<li><a href="#description">Description</a></li>
<li><a href="#installation">Installation</a></li>
<li><a href="#demo">Demo Projects</a></li>
<li><a href="#update">Update History</a></li>
<li><a href="#license">License</a></li>
<li><a href="#bugs">Bugs and Feature Requests</a></li>
<li><a href="#author">About the Author</a></li>
</ul>
<h2 id="description">
Description
</h2>
<p>
<var>TPJVersionInfo</var> is a 32 bit non-visual component for all Win32
versions of Delphi that encapsulates the version information contained in an
executable file's resources.
</p>
<p>
The component reads information from a designated file's
<var>VERSIONINFO</var> resource. The required file is specified in the
component's <var>FileName</var> property. Setting <var>FileName</var> to the
empty string fetches version information for the executable file containing
the component. The boolean <var>HaveInfo</var> property indicates whether the
file contains version information. This component can access variable file
information for each language provided in the resource.
</p>
<p>
Run-time properties enable access to to version information. Properties
enable:
</p>
<ul>
<li>
Access to fixed file information, either by field or the whole record.
</li>
<li>
Access to the number of translations stored in the version information.
</li>
<li>
Selection of the translation for which information is to be returned by
other properties.
</li>
<li>
Access to the language and code page of the current translation &ndash; by
code and by name.
</li>
<li>
Access to the string file information for the current translation &ndash;
named properties access the Microsoft-defined string information, while an
array property gives access to any string item by name.
</li>
</ul>
<p>
Version numbers are encapsulated in <var>TPJVersionNumber</var> records which,
on Delphi 2006 or later, can be directly assigned to a string and can be
compared using the normal equality operators. Helper functions are also
provided for use with earlier Delphis that can format version numbers as text
and can compare them.
</p>
<h3>
Limitations
</h3>
<p>
The component makes calls to the Windows API. Therefore the version
information being read must follow the Microsoft guidelines &ndash; be warned
that not all software complies!
</p>
<h3>
Compatibility
</h3>
<p>
<var>TPJVersionInfo</var> compiles on all Win32 versions and personalities of
Delphi. Releases up v3.3 have tested with Delphi versions 2, 3, 4, 6, 7, 2006
and 2010 while later releases have been tested on Delphi 7 and 2006 to XE3 and
are assumed to work on later versions.
</p>
<p>
The unit name changed to <code>PJVersionInfo</code> at release 3 &ndash; this
means that programs using earlier versions will need to be modified (or to
have an alias set in Delphi's Project Options) before being recompiled using
the new version. Functionally, the component is backward compatible with
earlier versions.
</p>
<h3>
Further information
</h3>
<p>
For detailed information about version information refer to the Windows SDK.
</p>
<h2 id="installation">
Installation
</h2>
<div class="pullout">
<strong>Important Note:</strong> If you are updating from an earlier version
of this component and have installed the <em>DelphiDabbler</em> About Box
Component (<var>TPJAboutBoxDlg</var>) you may need to uninstall it before
updating this component, and re-install the about box component once the
update has been installed. If the About Box Component is earlier that v3.2 it
will need to be updated to the most recent version.
</div>
<p>
The <em>Version Information Component</em> is supplied in a zip file. Before
installing you need to extract all the files from the zip file. The following
files will be extracted:
</p>
<ul>
<li>
<strong><code>PJVersionInfo.pas</code></strong> &ndash; Component source
code.
</li>
<li>
<strong><code>PJVersionInfo.dcr</code></strong> &ndash; Component palette
glyph.
</li>
<li>
<code>PJVersionInfo.hlp</code> &ndash; Help file that integrates into the
Delphi 3-7 IDE.
</li>
<li>
<code>PJVersionInfo.als</code> &ndash; Keyword file required when
integrating the help file with Delphi 6 and 7.
</li>
<li>
<code>ReadMe.htm</code> &ndash; This read-me file.
</li>
<li>
<code>ChangeLog.txt</code> &ndash; Change log.
</li>
<li>
<code>MPL-2.txt</code> &ndash; Mozilla Public License v2.0.
</li>
<li>
<code>Documentation.URL</code> &ndash; Shortcut to the component's online
documentation.
</li>
</ul>
<p>
In addition to the above files you will find the the source code of two <a
href="#demo"
>demo projects</a> along with readme files in the <code>Demos\1</code> and
<code>Demos\2</code> sub-directories.
</p>
<p>
You can now install the component into the Delphi IDE.
</p>
<p>
For Delphi 3 onwards you must include <code>PJVersionInfo.pas</code> and
<code>PJVersionInfo.dcr</code> in a design time package that is installed into
the Delphi IDE. If you need help doing this <a
href="http://www.delphidabbler.com/url/install-comp"
>see here</a>.
</p>
<p>
Note that the help file included in the download can only integrate with the
IDE in Delphi 3-7. For information on how to do this, see <a
href="http://www.delphidabbler.com/articles?article=15"
>this article</a>. Users of other versions of Delphi can either use the help
file as a stand-alone file (in which case some links won't work) or you can
use the component's <a
href="http://www.delphidabbler.com/url/verinfo-docs"
>online documentation</a>.
</p>
<h2 id="demo">
Demo Projects
</h2>
<p>
The source code for two demo projects is included. The demos are:
</p>
<ol class="spaced">
<li>
<code>VIDemo.dpr</code> is an application that can extract and display
version information from any program (provided that the program has valid
version information).
</li>
<li>
<code>HelpEgs.dpr</code> implements all the <a
href="http://delphidabbler.com/url/verinfo-egs"
>examples</a> from the online documentation and help file.
</li>
</ol>
<p>
These demos require Delphi 7 or later.
</p>
<p>
<strong>Note:</strong> To load the projects into Delphi 2007 first delete the
relevant <code>.dproj</code> file and then load the project from the
<code>.bdsproj</code> file.
</p>
<div class="pullout">
With some minor changes they will also compile as 64 bit Windows targets using
the 64 bit Delphi. (Tested with Delphi XE3). To do this create a 64 bit
Windows target, ensure that the compiler can find the component source file
(or a 64 bit compiled unit) and disable automatic version information
generation.
</div>
<h2 id="update">
Update History
</h2>
<p>
A complete change log is provided in a text file that is included in the
download.
</p>
<h2 id="license">
License
</h2>
<p>
This component is released under the terms of the <a
href="http://www.mozilla.org/MPL/2.0/"
>Mozilla Public License v2.0</a>.
</p>
<h2 id="bugs">
Bugs and Feature Requests
</h2>
<p>
Bugs can be reported or new features requested via the <a
href="http://www.delphidabbler.com/url/ddlib-issues"
>Issue Tracker</a>.
</p>
<p>
If no similar report or request has been recorded already, use the <em>New
Issue</em> link to add a new issue. Please select the <em>Defect Report from
User</em> template and be sure to specify the <code>Project-verinfo</code>
label.
</p>
<p>
Feature requests are also made using the Issue Tracker. This time please
select the <em>Feature Request</em> template and, again, specify the
<code>Project-verinfo</code> label.
</p>
<h2 id="author">
About the Author
</h2>
<p>
I'm Peter Johnson &ndash; a hobbyist programmer living in Ceredigion in West
Wales, UK, writing write mainly in Delphi. My programs and code are
available from: <a
href="http://www.delphidabbler.com/"
>http://www.delphidabbler.com/</a>.
</p>
<p>
I can be <a
href="http://www.delphidabbler.com/contact"
>contacted via the website</a>.
</p>
<div class="endnotes">
<div class="comments">
Please <a
href="http://www.delphidabbler.com/contact"
>let me know</a> if you have any comments about the component, but please
use the Issue Tracker noted above to report bugs and request new features.
</div>
<div class="copyright">
This document is copyright &copy; 2005-2013, P D Johnson, <a
href="http://www.delphidabbler.com/"
>www.delphidabbler.com</a>.
</div>
</div>
</body>
</html>

View File

@@ -0,0 +1,72 @@
<?xml version="1.0"?>
<CONFIG>
<Package Version="4">
<PathDelim Value="\"/>
<Name Value="dd_versioninfo"/>
<Author Value="Peter Johnson"/>
<CompilerOptions>
<Version Value="11"/>
<PathDelim Value="\"/>
<SearchPaths>
<UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)\"/>
</SearchPaths>
<Parsing>
<SyntaxOptions>
<SyntaxMode Value="Delphi"/>
</SyntaxOptions>
</Parsing>
<CodeGeneration>
<SmartLinkUnit Value="True"/>
<Optimizations>
<OptimizationLevel Value="3"/>
</Optimizations>
</CodeGeneration>
<Linking>
<Debugging>
<GenerateDebugInfo Value="False"/>
<UseExternalDbgSyms Value="True"/>
</Debugging>
</Linking>
<Other>
<CompilerMessages>
<MsgFileName Value=""/>
</CompilerMessages>
<CompilerPath Value="$(CompPath)"/>
</Other>
</CompilerOptions>
<Description Value=" TPJVersionInfo is a 32 bit non-visual component for all Win32 versions of Delphi that encapsulates the version information contained in an executable file's resources.
The component reads information from a designated file's VERSIONINFO resource. The required file is specified in the component's FileName property. Setting FileName to the empty string fetches version information for the executable file containing the component. The boolean HaveInfo property indicates whether the file contains version information. This component can access variable file information for each language provided in the resource.
Run-time properties enable access to to version information. Properties enable:
Access to fixed file information, either by field or the whole record.
Access to the number of translations stored in the version information.
Selection of the translation for which information is to be returned by other properties.
Access to the language and code page of the current translation by code and by name.
Access to the string file information for the current translation named properties access the Microsoft-defined string information, while an array property gives access to any string item by name.
Version numbers are encapsulated in TPJVersionNumber records which, on Delphi 2006 or later, can be directly assigned to a string and can be compared using the normal equality operators. Helper functions are also provided for use with earlier Delphis that can format version numbers as text and can compare them. "/>
<License Value="This Source Code Form is subject to the terms of the Mozilla Public License"/>
<Version Major="3" Minor="3" Release="1"/>
<Files Count="1">
<Item1>
<Filename Value="PJVersionInfo.pas"/>
<HasRegisterProc Value="True"/>
<UnitName Value="PJVersionInfo"/>
</Item1>
</Files>
<Type Value="RunAndDesignTime"/>
<RequiredPkgs Count="1">
<Item1>
<PackageName Value="FCL"/>
</Item1>
</RequiredPkgs>
<UsageOptions>
<UnitPath Value="$(PkgOutDir)"/>
</UsageOptions>
<PublishOptions>
<Version Value="2"/>
</PublishOptions>
</Package>
</CONFIG>

View File

@@ -0,0 +1,21 @@
{ This file was automatically created by Lazarus. Do not edit!
This source is only used to compile and install the package.
}
unit dd_versioninfo;
interface
uses
PJVersionInfo, LazarusPackageIntf;
implementation
procedure Register;
begin
RegisterUnit('PJVersionInfo', @PJVersionInfo.Register);
end;
initialization
RegisterPackage('dd_versioninfo', @Register);
end.