Mega Code Archive

 
Categories / Delphi / Forms
 

Application Version Information and More

Title: Application Version Information and More Question: I did several searches on the web for a simple solution to grab the version number of my application and return it in a string. I found several solutions - but none were as "quick and dirty" as I wanted. Then I went back through Delphi Help and found this little nugget buried deep within. Answer: Here is a little function I created around the code from Delphi Help: ---------- function GetFileVersion(Filename: string): string; var N, Len: DWORD; Buf: PChar; Value: PChar; begin Result := ''; N := GetFileVersionInfoSize(PChar(Filename), N); if N 0 then begin Buf := AllocMem(N); GetFileVersionInfo(PChar(Filename), 0, N, Buf); if VerQueryValue(Buf, PChar('StringFileInfo\040904E4\FileVersion'), Pointer(Value), Len) then Result := Value; FreeMem(Buf, N); end; end; ----------- Filename - Path to the file you wish to get the version number of. For your current application pass in Application.ExeName. You can change the information returned by the function simply by changing "FileVersion" in the following line: PChar('StringFileInfo\040904E4\FileVersion'), ... to one of these which will return what the corresponding information: CompanyName FileDescription FileVersion InternalName LegalCopyright LegalTradeMarks OriginalFileName ProductName ProductVersion Comments Jeff Guidotti