Code snippet ...
|
uses Windows, Classes, SysUtils;
type
TVS_FIXEDFILEINFO = record
dwSignature: DWORD ;
dwStrucVersion: DWORD ;
dwFileVersionMS: DWORD ;
dwFileVersionLS: DWORD ;
dwProductVersionMS: DWORD ;
dwProductVersionLS: DWORD ;
dwFileFlagsMask: DWORD ;
dwFileFlags: DWORD ;
dwFileOS: DWORD ;
dwFileType: DWORD ;
dwFileSubtype: DWORD ;
dwFileDateMS: DWORD ;
dwFileDateLS: DWORD ;
end;
TVS_VERSION_INFO = packed record
Length :WORD;
wValueLength :WORD;
wType :WORD;
szKey:array[0..Length('VS_VERSION_INFO')] of WideChar;
Padding1 :array[0..0] of Word;
FixedInfo :TVS_FIXEDFILEINFO;
end;
function GetVersion: string;
var
rs: TResourceStream;
w: Word;
vsvi: TVS_VERSION_INFO;
ffi: TVS_FIXEDFILEINFO;
begin
result := '';
rs := TResourceStream.CreateFromID(hInstance, 1, RT_VERSION);
try
rs.read(vsvi, sizeof(vsvi));
if vsvi.wValueLength <> sizeof(vsvi.FixedInfo) then exit;
with vsvi.FixedInfo do
result := format('%d.%d.%d (build %d)',
[dwFileVersionMS shr 16, dwFileVersionMS and $FFFF,
dwFileVersionLS shr 16, dwFileVersionLS and $FFFF]);
finally
rs.Free;
end;
end;
lblVersionNum.caption := 'Version ' + GetVersion;
|
|
|
|