{"id":186,"date":"2007-05-12T16:48:27","date_gmt":"2007-05-12T14:48:27","guid":{"rendered":" http:\/\/www.nsonic.de\/blog\/2007\/05\/how-to-get-versioninformation\/"},"modified":"2007-05-12T16:48:29","modified_gmt":"2007-05-12T14:48:29","slug":"how-to-get-versioninformation","status":"publish","type":"post","link":"https:\/\/www.nsonic.de\/blog\/2007\/05\/how-to-get-versioninformation\/","title":{"rendered":"How To Get VersionInformation"},"content":{"rendered":"<p><em>> Can I get the Application Version, which I set using IDE&#8217;s option menu , in<br \/>\n> code? How?<br \/>\n<\/em><br \/>\nHere&#8217;s an example:<br \/>\n<!--more--><br \/>\n[code lang=&#8221;delphi&#8221;]type<br \/>\n  PTransBuffer = ^TTransBuffer;<br \/>\n  TTransBuffer = array[1..4] of smallint;<\/p>\n<p>const<br \/>\n  CInfoStr : array[1..4] of string =<br \/>\n    (&#8216;FileVersion&#8217;,&#8217;LegalCopyright&#8217;, &#8216;ProductName&#8217;, &#8216;ProductVersion&#8217;);<\/p>\n<p>procedure TFrmAbout.GetVersionInfo(AVersionList: TStrings);<br \/>\nvar<br \/>\n  filename: string;<br \/>\n  i:        integer;<br \/>\n  infoSize: DWORD;<br \/>\n  ptrans:   PTransBuffer;<br \/>\n  transStr: string;<br \/>\n  typeStr:  string;<br \/>\n  value:    PChar;<br \/>\n  verBuf:   pointer;<br \/>\n  verSize:  DWORD;<br \/>\n  wnd:      DWORD;<br \/>\nbegin<br \/>\n  AVersionList.Clear;<br \/>\n  filename := Application.ExeName;<br \/>\n  infoSize := GetFileVersioninfoSize(PChar(filename), wnd);<\/p>\n<p>  if infoSize <> 0 then<br \/>\n  begin<br \/>\n    GetMem(verBuf, infoSize);<br \/>\n    try<br \/>\n      if GetFileVersionInfo(PChar(filename), wnd, infoSize, verBuf) then<br \/>\n      begin<br \/>\n        VerQueryvalue(verBuf, PChar(&#8216;\\VarFileInfo\\Translation&#8217;),<br \/>\n                      Pointer(ptrans), verSize);<\/p>\n<p>        transStr := IntToHex(ptrans^[1], 4) + IntToHex(ptrans^[2], 4);<\/p>\n<p>        for i := Low(CInfoStr) to High(CInfoStr) do<br \/>\n        begin<br \/>\n          typeStr := &#8216;StringFileInfo\\&#8217; + transStr + &#8216;\\&#8217; + CInfoStr[i];<\/p>\n<p>          if VerQueryvalue(verBuf, PChar(typeStr),<br \/>\n                           Pointer(value), verSize) then<br \/>\n            (*AVersionList.Add(CInfoStr[i] + &#8216;: &#8216; + value);<br \/>\n            *)<br \/>\n            AVersionList.Add(value);<br \/>\n        end<br \/>\n      end;<br \/>\n    finally<br \/>\n      FreeMem(verBuf);<br \/>\n    end;<\/p>\n<p>  end;<br \/>\nend;<br \/>\n[\/code]<\/p>\n<p>[tags]Delphi, Misc, Files[\/tags]<\/p>\n","protected":false},"excerpt":{"rendered":"<p>> Can I get the Application Version, which I set using IDE&#8217;s option menu , in > code? How? Here&#8217;s an example:<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"spay_email":""},"categories":[11],"tags":[75,112,107],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p71Tml-30","_links":{"self":[{"href":"https:\/\/www.nsonic.de\/blog\/wp-json\/wp\/v2\/posts\/186"}],"collection":[{"href":"https:\/\/www.nsonic.de\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.nsonic.de\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.nsonic.de\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.nsonic.de\/blog\/wp-json\/wp\/v2\/comments?post=186"}],"version-history":[{"count":0,"href":"https:\/\/www.nsonic.de\/blog\/wp-json\/wp\/v2\/posts\/186\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.nsonic.de\/blog\/wp-json\/wp\/v2\/media?parent=186"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.nsonic.de\/blog\/wp-json\/wp\/v2\/categories?post=186"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.nsonic.de\/blog\/wp-json\/wp\/v2\/tags?post=186"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}