用什么控件可以判别软件版本号!(50分)

  • 主题发起人 主题发起人 sujunqin
  • 开始时间 开始时间
S

sujunqin

Unregistered / Unconfirmed
GUEST, unregistred user!
谢谢大家了!!!
 
function GetVersion(sFile: string; bIncludeBuild: boolean): string;<br>var<br> &nbsp;dwfvw,dwZero,dwvsf:DWORD;<br> &nbsp;Major,Minor,Release,Build:DWord;<br> &nbsp;pfvw:PChar;<br> &nbsp;pvsf:PVSFixedFileInfo;<br> &nbsp;s:string;<br>begin<br> &nbsp;Result:='';<br> &nbsp;// attempt to read version info size<br> &nbsp;dwfvw:=GetFileVersionInfoSize(PChar(sFile),dwZero);// exit on error<br> &nbsp;if dwfvw &lt;&gt; 0 then begin<br> &nbsp; &nbsp;GetMem(pfvw, dwfvw);<br> &nbsp; &nbsp;try // exit if unable to retrieve version info<br> &nbsp; &nbsp; &nbsp;if (GetFileVersionInfo(PChar(sFile), dwZero, dwfvw, pfvw)) then begin // get the build value<br> &nbsp; &nbsp; &nbsp; &nbsp;if (VerQueryValue(pfvw, '/', Pointer(pvsf), dwvsf)) then begin<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if ((pvsf^.dwFileFlags and VS_FF_PRERELEASE) &gt; 0) then begin<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;s := 'beta; '<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;end<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;else begin<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;s := '';<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;end;<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// For clarity store in temporary variables<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Major := HIWORD(pvsf^.dwFileVersionMS);<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Minor := LOWORD(pvsf^.dwFileVersionMS);<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Release := HIWORD(pvsf^.dwFileVersionLS);<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Build := LOWORD(pvsf^.dwFileVersionLS);<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// Always show full Build Numbers from now GN.. 2/9/03<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Result := Format('Version %d.%d.%d Build %d', [Major, Minor, Release,<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Build]);<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if bIncludeBuild then begin<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if Release &gt; 0 then begin<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Result := Format('Version %d.%d.%d Build %d', [Major, Minor,<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Release, Build])<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;end<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;else begin<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Result := Format('Version %d.%d Build %d', [Major, Minor, Build])<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;end;<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;end<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;else begin<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if Release &gt; 0 then begin<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Result := Format('Version %d.%d.%d', [Major, Minor, Release])<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;end<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;else begin<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Result := Format('Version %d.%d', [Major, Minor])<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;end;<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;end;<br> &nbsp; &nbsp; &nbsp; &nbsp;end;<br> &nbsp; &nbsp; &nbsp;end;<br> &nbsp; &nbsp;finally<br> &nbsp; &nbsp; &nbsp;FreeMem(pfvw);<br> &nbsp; &nbsp;end;<br> &nbsp;end;<br>end;
 
后退
顶部