1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
| procedure TForm2.Button1Click(Sender: TObject);
VAR
InfoSize: DWORD;
lpdwHandle: Cardinal;
VerBuf: Pointer;
PFI: PVSFixedFileInfo;
VerSize: DWORD;
Fichier,Version:String;
begin
Fichier:='C:\Program Files\Microsoft Office\OFFICE11\WINWORD.EXE';
Version:='';
InfoSize := GetFileVersionInfoSize(Pchar(Fichier), lpdwHandle);
if InfoSize <> 0 then
begin
GetMem(VerBuf, InfoSize);
try
if GetFileVersionInfo(Pchar(Fichier), lpdwHandle, InfoSize, VerBuf) then
if VerQueryValue(VerBuf, '\', Pointer(PFI), VerSize) then
BEGIN
WITH PFI^ DO
BEGIN
Version:=IntToStr(dwFileVersionMS shr 16)+'.'+IntToStr(dwFileVersionMS AND $FFFF);
Version:=Version+'.'+IntToStr(dwFileVersionLS shr 16)+'.'+IntToStr(dwFileVersionLS AND $FFFF);
END;
END;
finally
FreeMem(VerBuf);
end;
end;
showmessage(Version)
end; |
Partager