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: [EMAIL PROTECTED]
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: [EMAIL PROTECTED] 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 [email protected] http://ns3.123.co.nz/mailman/listinfo/delphi
<<winmail.dat>>
_______________________________________________ Delphi mailing list [email protected] http://ns3.123.co.nz/mailman/listinfo/delphi
