Using this simple function, you will be able to read version information
from any application executable. It’s very useful for example to show
your own application version on title bar or “About” dialog.
function AppVersion(const Filename: string):string; var dwHandle: THandle; dwSize: DWORD; lpData, lpData2: Pointer; uiSize: UINT; begin Result := ''; dwSize := GetFileVersionInfoSize(PChar(FileName), dwSize); if dwSize <> 0 then begin GetMem(lpData, dwSize); if GetFileVersionInfo(PChar(FileName), dwHandle, dwSize, lpData) then begin uiSize := Sizeof(TVSFixedFileInfo); VerQueryValue(lpData, '\', lpData2, uiSize); with PVSFixedFileInfo(lpData2)^ do Result := Format('%d.%02d.%02d.%02d', [HiWord(dwProductVersionMS), LoWord(dwProductVersionMS),HiWord(dwProductVersionLS), LoWord(dwProductVersionLS)]); end; FreeMem(lpData, dwSize); end; end; procedure TForm1.Button1Click(Sender: TObject); begin ShowMessage('Version: ' + AppVersion(Application.ExeName)); end;
Δεν υπάρχουν σχόλια:
Δημοσίευση σχολίου