参考: http://www.delphitop.com/html/hanshu/4627.html
procedure GetVersionInfo(const FileName:string; var vs:string); var VerInfoSize,VerValueSize,Dummy:DWORD; VerInfo: Pointer; VerValue: PVSFixedFileInfo; V1,V2,V3,V4:Word; begin vs:=''; if not FileExists(FileName) then exit; VerInfoSize:=GetFileVersionInfoSize(PChar(FileName),Dummy); if VerInfoSize=0 then exit; GetMem(VerInfo,VerInfoSize); if not GetFileVersionInfo(PChar(FileName),0,VerInfoSize,VerInfo) then exit; 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; vs:=inttostr(v1)+'.'+inttostr(v2)+'.'+inttostr(v3)+'.'+inttostr(v4); end; FreeMem(VerInfo,VerInfoSize); end;
经测试,管用!
标签:版本号,Delphi,inttostr,FileName,VerInfo,获取,vs,exit,VerInfoSize From: https://www.cnblogs.com/Master-Qi/p/16834768.html