[DUG] Version number
Sean Cross - CRM
sean.cross at crm.co.nz
Fri Nov 3 12:07:05 NZDT 2006
type
TVersionArray = array[1..4] of word;
function ModuleFileName: String;
var
szFileName: array[0..MAX_PATH] of Char;
begin
GetModuleFileName(hInstance, szFileName, MAX_PATH);
Result := szFileName;
end;
function GetVersionArray: TVersionArray;
var
VerInfoSize, VerValueSize, DUMMY: DWORD;
VerInfo:pointer;
VerValue: PVSFixedFileInfo;
begin
try
VerInfoSize:=GetFileVersionInfoSize(Pchar(ModuleFileName), DUMMY);
GetMem(verinfo, verinfosize);
try
GetFileVersionInfo(pchar(Application.exename),0,VerInfoSize, VerInfo);
VerQueryValue(VerInfo,'\',Pointer(VerValue), VerValueSize);
With VerValue^ do
begin
Result[1] := dwFileVersionMS shr 16; //Major
Result[2] := dwFileVersionMS and $FFFF; //Minor
Result[3] := dwFileVersionLS shr 16; //Release
Result[4] := dwFileVersionLS and $FFFF; //Build
end;
finally
FreeMem(VerInfo, VerInfoSize);
end;
except
Result[1] := 0; //Major
Result[2] := 0; //Minor
Result[3] := 0; //Release
Result[4] :=0; //Build
end;
// Result:=V; // format('%d.%d.%d.%d',[V[1],v[2],v[3],v[4]]);
end;
function GetVersion: string;
var v: TVersionArray;
strZero: string;
begin
v:= GetVersionArray;
if v[2]<10 then
strZero:= '0'
else
strZero:= '';
result := format('%d.%s%d.%d.%d',[V[1], strZero, v[2],v[3],v[4]]);
end;
Regards
Sean
-----------------------------
Sean Cross
Systems Development
Catalyst Risk Manangement
PO Box 230
Napier
Phone: 06 835 5868
Mobile: 027 276 6439
Email: sean.cross at crm.co.nz
www.crm.co.nz
Offices in Auckland, Napier, Wellington & Christchurch
Disclaimer:
"The information contained in this document is confidential to the addressee(s) and may be legally privileged. Any view or opinions expressed are those of the author and may not be those of CRM. No guarantee or representation is made that this communication is free of errors, viruses or interference. If you have received this e-mail message in error please delete it and notify me. Thank you."
________________________________
From: delphi-bounces at ns3.123.co.nz on behalf of John Bird
Sent: Fri 3/11/2006 11:49 a.m.
To: 'NZ Borland Developers Group - Delphi List'
Subject: [DUG] Version number
How do I get the current program version number from inside a program at
runtime (the one that can be set to auto-increment in the builds in Options)
John
_______________________________________________
Delphi mailing list
Delphi at ns3.123.co.nz
http://ns3.123.co.nz/mailman/listinfo/delphi
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/ms-tnef
Size: 7029 bytes
Desc: not available
Url : http://ns3.123.co.nz/pipermail/delphi/attachments/20061103/1fcb8e86/attachment.bin
More information about the Delphi
mailing list