procedure TForm1.Button1Click(Sender: TObject);
var
V1,V2,V3,V4:Word;
VerInfoSize:DWORD;
VerInfo:Pointer;
VerValueSize:DWORD;
VerValue:PVSFixedFileInfo;
Dummy:DWORD;
begin
//Edit1.text 程序所在的路径
VerInfoSize:=GetFileVersionInfoSize(PChar(Edit1.Text),Dummy);
if VerInfoSize =0 then Exit;
GetMem(VerInfo,VerInfoSize);
GetFileVersionInfo(PChar(Edit1.Text),0,VerInfoSize,VerInfo);
VerQueryValue(VerInfo,'/',Pointer(VerValue), VerValueSize);
with VerValue^ do
begin
V1:=dwFileVersionMS shr 16;
V2:=dwFileVersionMS and $FFFF;
V3:=dwFileVersionLS shr 16;
V4:=dwFileVersionLS and $FFFF;
end;
FreeMem(VerInfo,VerInfoSize);
Showmessage(Format('%d.%d.%d.%d',[v1,v2,v3,v4]));
end;