Reputation: 705
I have an application that uses a DLL to generate fastReports files.
When I need to make changes to the reports data structure I only change this DLL and distribute it to all user of the APP. How can I guarantee that all have the last version before they start?
How can I generate/Extract this information from the DLL file.
Upvotes: 7
Views: 6337
Reputation: 1458
Getting file version requires setting file version in advance.
Upvotes: 4
Reputation: 1957
Get Dll version:
function GetDllVersion: string; //Run in dll project
var
fn: string;
begin
fn := GetModuleName(HInstance);
Result := FileVersionGet(fn); // use Matthias's function
end;
Upvotes: 6
Reputation: 896
JCL have JclFileVersion. Two or three lines and you are done.
Upvotes: 0
Reputation: 2453
This function will get the fileversion as string:
function FileVersionGet( const sgFileName : string ) : string;
var infoSize: DWORD;
var verBuf: pointer;
var verSize: UINT;
var wnd: UINT;
var FixedFileInfo : PVSFixedFileInfo;
begin
infoSize := GetFileVersioninfoSize(PChar(sgFileName), wnd);
result := '';
if infoSize <> 0 then
begin
GetMem(verBuf, infoSize);
try
if GetFileVersionInfo(PChar(sgFileName), wnd, infoSize, verBuf) then
begin
VerQueryValue(verBuf, '\', Pointer(FixedFileInfo), verSize);
result := IntToStr(FixedFileInfo.dwFileVersionMS div $10000) + '.' +
IntToStr(FixedFileInfo.dwFileVersionMS and $0FFFF) + '.' +
IntToStr(FixedFileInfo.dwFileVersionLS div $10000) + '.' +
IntToStr(FixedFileInfo.dwFileVersionLS and $0FFFF);
end;
finally
FreeMem(verBuf);
end;
end;
end;
Upvotes: 13