function getVersion : string;
{ ---------------------------------------------------------
Extracts the FileVersion element of the VERSIONINFO
structure that Delphi maintains as part of a project's
options.
Results are returned as a standard string. Failure
is reported as "".
Note that this implementation was derived from similar
code used by Delphi to validate ComCtl32.dll. For
details, see COMCTRLS.PAS, line 3541.
-------------------------------------------------------- }
const
NOVIDATA = '';
var
dwInfoSize, // Size of VERSIONINFO structure
dwVerSize, // Size of Version Info Data
dwWnd: DWORD; // Handle for the size call.
FI: PVSFixedFileInfo; // Delphi structure; see WINDOWS.PAS
ptrVerBuf: Pointer; // pointer to a version buffer
strFileName, // Name of the file to check
strVersion : string; // Holds parsed version number
begin
function getVersion : string;
{ ---------------------------------------------------------
Extracts the FileVersion element of the VERSIONINFO
structure that Delphi maintains as part of a project's
options.
Results are returned as a standard string. Failure
is reported as "".
Note that this implementation was derived from similar
code used by Delphi to validate ComCtl32.dll. For
details, see COMCTRLS.PAS, line 3541.
-------------------------------------------------------- }
const
NOVIDATA = '';
var
dwInfoSize, // Size of VERSIONINFO structure
dwVerSize, // Size of Version Info Data
dwWnd: DWORD; // Handle for the size call.
FI: PVSFixedFileInfo; // Delphi structure; see WINDOWS.PAS
ptrVerBuf: Pointer; // pointer to a version buffer
strFileName, // Name of the file to check
strVersion : string; // Holds parsed version number
begin
strFileName := paramStr( 0 );
dwInfoSize :=
getFileVersionInfoSize( pChar( strFileName ), dwWnd);
if ( dwInfoSize = 0 ) then
result := NOVIDATA
else
begin
getMem( ptrVerBuf, dwInfoSize );
try
if getFileVersionInfo( pChar( strFileName ),
dwWnd, dwInfoSize, ptrVerBuf ) then
if verQueryValue( ptrVerBuf, '',
pointer(FI), dwVerSize ) then
strVersion :=
format( '%d.%d.%d.%d',
[ hiWord( FI.dwFileVersionMS ),
loWord( FI.dwFileVersionMS ),
hiWord( FI.dwFileVersionLS ),
loWord( FI.dwFileVersionLS ) ] );
finally
freeMem( ptrVerBuf );
end;
end;
Result := strVersion;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
lblVersion.Caption := '버젼: ' + getVersion;
end;
end.