System Delphi

Title: Getting file/dll version
Question: How do I get the version of my dll?
Answer:
Often you need to get file versions for dlls to check how up to date they are. Here's how:
procedure GetFileVersion(FileName: string; var Major1, Major2,
Minor1, Minor2: Integer);
var
Info: Pointer;
InfoSize: DWORD;
FileInfo: PVSFixedFileInfo;
FileInfoSize: DWORD;
Tmp: DWORD;
begin
InfoSize := GetFileVersionInfoSize(PChar(FileName), Tmp);
if InfoSize = 0 then
//file doesnt have version info/exist
else
begin
GetMem(Info, InfoSize);
try
GetFileVersionInfo(PChar(FileName), 0, InfoSize, Info);
VerQueryValue(Info, '\', Pointer(FileInfo), FileInfoSize);
Major1 := FileInfo.dwFileVersionMS shr 16;
Major2 := FileInfo.dwFileVersionMS and $FFFF;
Minor1 := FileInfo.dwFileVersionLS shr 16;
Minor2 := FileInfo.dwFileVersionLS and $FFFF;
finally
FreeMem(Info, FileInfoSize);
end;
end;
end;
Tested on d5 and w2k. Should be fine for all versions of windows and delphi, but untested. This code was adapted from an example somewhere, so acknowledgments to the original author.