<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <br>
    <div class="moz-cite-prefix">Le 06/11/2013 15:46, Anton Kavalenka a
      écrit :<br>
    </div>
    <blockquote cite="mid:527A5640.7030909@tut.by" type="cite">
      <meta content="text/html; charset=ISO-8859-1"
        http-equiv="Content-Type">
      Handle of EXE (hInstance) or .SO hMod:=Loadlibrary(dll_name);<br>
    </blockquote>
    Works fine on Win32 with <b><big>hInstance</big></b><big>: great !
      <span class="moz-smiley-s11"><span> 8-) </span></span><br>
      I guess it will run on Linux too<br>
      Thanks.<br>
    </big>
    <blockquote cite="mid:527A5640.7030909@tut.by" type="cite"> <br>
      regards,<br>
      Anton<br>
    </blockquote>
    The code I use for Linux is the next one, which works almost the
    same except that the source is a file:<br>
    <br>
    function ReadVersionInfo(const sProgram: string; Out vv: String)
    :Boolean;<br>
    var<br>
      RS : TResources;<br>
      E : TElfResourceReader;<br>
      VR : TVersionResource;<br>
      I : Integer;<br>
    begin<br>
      Result := False; //no version info at all in the file<br>
      RS:=TResources.Create;<br>
      try<br>
        E:=TElfResourceReader.Create;<br>
        try<br>
          Rs.LoadFromFile(sProgram,E);<br>
        finally<br>
          E.Free;<br>
        end;<br>
        VR:=Nil;<br>
        I:=0;<br>
        While (VR=Nil) and (I<RS.Count) do begin<br>
          if RS.Items[i] is TVersionResource then<br>
            VR:=TVersionResource(RS.Items[i]);<br>
          Inc(I);<br>
        end;<br>
        Result:=(VR<>Nil);<br>
        if Result then begin<br>
          vv:= Format('%d.%d.%d.%d',[VR.FixedInfo.FileVersion[0],
    VR.FixedInfo.FileVersion[1], VR.FixedInfo.FileVersion[2],
    VR.FixedInfo.FileVersion[3]]);<br>
        End ;<br>
      Finally<br>
        RS.FRee;<br>
      end;<br>
    <br>
    Question is: does an equivalent to the "T<b><big>Elf</big></b>ResourceReader"
    exist for Windows executable files ?<br>
    I'm pretty sure that you do guess what I'm trying to do: have only
    one fuction to retrieve the version of any program on any platform.
    If a version using a file name can be setup, wonking on the current
    program is easy: check on ParamStr(0).<br>
    Maybe a couple of [$IFDEF ...} will be needed but this is not an
    issue.<br>
    BTW, if the procedure works for WinCE too I'll be the happiest man
    on world.<br>
    If this piece of code could be helpfull to others, it could be
    integrated to FPC or Lazarus, whatever.<br>
    It will need some rewriting though.<br>
    <br>
    Antonio.<br>
    <br>
    <blockquote cite="mid:527A5640.7030909@tut.by" type="cite"> <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">--
_______________________________________________
Lazarus mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Lazarus@lists.lazarus.freepascal.org">Lazarus@lists.lazarus.freepascal.org</a>
<a class="moz-txt-link-freetext" href="http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus">http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus</a>
</pre>
    </blockquote>
    <br>
    <div class="moz-signature">-- <br>
      <table
style="font-family:'Calibri','sans-serif';font-size:8.0pt;color:#002f87;border:0;width:auto;">
        <tbody>
          <tr>
            <td style="vertical-align:bottom;padding:40px 20px
              25px;border-top:1pt solid #BFBFBF;"> <img alt="Sita
                Software"
                src="cid:part1.02000903.03090302@sitasoftware.lu"> </td>
          </tr>
          <tr>
            <td style="vertical-align: top; padding: 5px 20px 0;"> <b>Antonio
                Fortuny</b><br>
              Senior Software engineer<br>
              <br>
              220, avenue de la Liberté<br>
              L-4602 Niederkorn<br>
              Tel.: +352 58 00 93 - 93<br>
              <a style="color:#002f87;cursor:pointer;text-decoration:
                none;" href="http://www.sitasoftware.lu">www.sitasoftware.lu</a><br>
            </td>
          </tr>
          <tr>
            <td style="padding:20px 20px 30px;border-bottom: 1pt solid
              #BFBFBF;" align="right"> <img alt="Your IT Partner"
                src="cid:part3.06060806.07050305@sitasoftware.lu"> </td>
          </tr>
        </tbody>
      </table>
    </div>
  </body>
</html>