Board index » delphi » Version Information

Version Information


2003-10-25 08:37:34 PM
delphi102
I am creating my first project containing Version Information and I know
this information is stored with the compiled code.
How do I programatically access this information so I can add the current
Version Information to an About Dialog when the About Dialog is created?
Thanks!
 
 

Re:Version Information

"Gary Lowe" <XXXX@XXXXX.COM>wrote in
Quote
I am creating my first project containing Version Information and I
know this information is stored with the compiled code.

How do I programatically access this information so I can add the
current Version Information to an About Dialog when the About Dialog
is created?
here's one easy and elegant way: grab the TVersionInfo component
from the "Delphi Free Stuff" section of Wayne Niddery's site
(www.logicfundamentals.com/)
--
Mark Vaughan
___________
Visit the Numerical Methods in Pascal web page at
www-rab.larc.nasa.gov/nmp/fNMPhome.htm
 

Re:Version Information

Hi.
Where can I find information about to manage numbers concerning version
project?
Major version
Minor Version
Release
Build
Thanks
Adalberto Baldini
 

Re:Version Information

adalberto baldini writes:
Quote
Hi.
Where can I find information about to manage numbers concerning
version project? Major version
Minor Version
Release
Build
procedure GetApplicationVersionInfo( var W1, W2, W3, W4: Word );
var
VerInfoSize, VerValueSize, Dummy: DWord;
VerInfo: Pointer;
VerValue: PVSFixedFileInfo;
begin
VerInfoSize := GetFileVersionInfoSize( PChar( ParamStr( 0 )
),
Dummy );
if VerInfoSize>0 then
begin
GetMem( VerInfo, VerInfoSize );
try
GetFileVersionInfo( PChar( ParamStr( 0 ) ),
0,
VerInfoSize,
VerInfo );
VerQueryValue( VerInfo,
'\',
Pointer( VerValue ),
VerValueSize );
with VerValue^ do
begin
W1 := dwFileVersionMS shr 16;
W2 := dwFileVersionMS and $FFFF;
W3 := dwFileVersionLS shr 16;
W4 := dwFileVersionLS and $FFFF;
end;
finally
FreeMem( VerInfo, VerInfoSize );
end;
end;
end;
John Leavey
 

Re:Version Information

Quote
>Where can I find information about to manage numbers concerning
procedure GetApplicationVersionInfo( var W1, W2, W3, W4: Word );
Also, check the project | options | version info - you need to enable the
auto-versioning or set the version information there before reading it
later.
HTH
Lauchlan M
 

Re:Version Information

"Stephane Tremblay" <XXXX@XXXXX.COM>writes:
Quote

How we can get the version information of our projet in run
time.
//-------------------------------------------------------------
#ifndef VerInfoH
#define VerInfoH
//-------------------------------------------------------------
struct TVersionInformation
{
private:
char *Buffer;
public:
bool Available;
AnsiString CompanyName;
AnsiString FileDescription;
AnsiString FileVersion;
AnsiString InternalName;
AnsiString LegalCopyright;
AnsiString LegalTrademarks;
AnsiString OriginalFilename;
AnsiString ProductName;
AnsiString ProductVersion;
AnsiString Comments;
TVersionInformation()
{
Buffer = NULL;
Available = false;
CompanyName = "";
FileDescription = "";
FileVersion = "";
InternalName = "";
LegalCopyright = "";
LegalTrademarks = "";
OriginalFilename = "";
ProductName = "";
ProductVersion = "";
Comments = "";
DWORD Handle, Size = ::GetFileVersionInfoSize( Application->ExeName.c_str(), &Handle );
if( Size )
{
UINT Length;
LPVOID lpBuffer;
unsigned short *LangCharSet;
Buffer = new char[ Size ];
LPVOID pBlock = (LPVOID) Buffer;
if( ::GetFileVersionInfo( Application->ExeName.c_str(), Handle, Size, pBlock ) )
{
if( ::VerQueryValue( pBlock, "\\VarFileInfo\\Translation", (void **)&LangCharSet, &Length ) )
{
AnsiString Prefix;
Prefix.sprintf("\\StringFileInfo\\%04x%04x\\", LangCharSet[0], LangCharSet[1] );
if( ::VerQueryValue( pBlock, AnsiString( Prefix + "CompanyName" ).c_str(), &lpBuffer, &Length ) ) CompanyName = (char *) lpBuffer;
if( ::VerQueryValue( pBlock, AnsiString( Prefix + "FileDescription" ).c_str(), &lpBuffer, &Length ) ) FileDescription = (char *) lpBuffer;
if( ::VerQueryValue( pBlock, AnsiString( Prefix + "FileVersion" ).c_str(), &lpBuffer, &Length ) ) FileVersion = (char *) lpBuffer;
if( ::VerQueryValue( pBlock, AnsiString( Prefix + "InternalName" ).c_str(), &lpBuffer, &Length ) ) InternalName = (char *) lpBuffer;
if( ::VerQueryValue( pBlock, AnsiString( Prefix + "LegalCopyright" ).c_str(), &lpBuffer, &Length ) ) LegalCopyright = (char *) lpBuffer;
if( ::VerQueryValue( pBlock, AnsiString( Prefix + "LegalTrademarks" ).c_str(), &lpBuffer, &Length ) ) LegalTrademarks = (char *) lpBuffer;
if( ::VerQueryValue( pBlock, AnsiString( Prefix + "OriginalFilename" ).c_str(), &lpBuffer, &Length ) ) OriginalFilename = (char *) lpBuffer;
if( ::VerQueryValue( pBlock, AnsiString( Prefix + "ProductName" ).c_str(), &lpBuffer, &Length ) ) ProductName = (char *) lpBuffer;
if( ::VerQueryValue( pBlock, AnsiString( Prefix + "ProductVersion" ).c_str(), &lpBuffer, &Length ) ) ProductVersion = (char *) lpBuffer;
if( ::VerQueryValue( pBlock, AnsiString( Prefix + "Comments" ).c_str(), &lpBuffer, &Length ) ) Comments = (char *) lpBuffer;
Available = true;
}
}
}
}
~TVersionInformation()
{
if( Buffer ) delete [] Buffer;
}
};
//-------------------------------------------------------------
#endif
Usage:
#include "VersionInfo.h"
//-------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
TVersionInformation Info;
if( Info.Available )
{
ShowMessage("CompanyName : " + Info.CompanyName );
ShowMessage("FileDescription : " + Info.FileDescription );
ShowMessage("FileVersion : " + Info.FileVersion );
ShowMessage("InternalName : " + Info.InternalName );
ShowMessage("LegalCopyright : " + Info.LegalCopyright );
ShowMessage("LegalTrademarks : " + Info.LegalTrademarks );
ShowMessage("OriginalFilename : " + Info.OriginalFilename );
ShowMessage("ProductName : " + Info.ProductName );
ShowMessage("ProductVersion : " + Info.ProductVersion );
ShowMessage("Comments : " + Info.Comments );
}
else ShowMessage("Version Information Not Available.");
}
//-------------------------------------------------------------
~ JD
 

Re:Version Information

How we can get the version information of our projet in run time.
Thanks.