1
0
-1

Hi Freaks

How to get the file version info out of a DLL ?
I create a signature OS_DLL_VERSION for the windows DLL version.DLL
Then there are a least to entities
OS_LPVOID: Only one field defined as R1024
OS_VS_FIXEDFILEINFO: Defined with the layout of VS_FIXEDFILEINFO

Now I call:
activate "OS_DLL_VERSION"."GetFileVersionInfoA"("<dllname>",0,1024,"OS_LPVOID")
and got the raw file version info

This looks good but then it goes worse:

1)
  activate "OS_DLL_VERSION"."VerQueryValue_FIX"("OS_LPVOID","\","OS_VS_FIXEDFILEINFO",v_NUM2)
  v_NUM2 yields to 52, which is the size of VS_FIXEDFILEINFO

2)
  activate "OS_DLL_VERSION"."VerQueryValueA"("OS_LPVOID","\",v_NUM1,v_NUM2)
  v_NUM2 still 52 and v_NUM1 is a pointer

  Copy the content into "OS_VS_FIXEDFILEINFO"
  activate $INST_KERNEL32$."lstrcpy_VS"("OS_VS_FIXEDFILEINFO",v_NUM1)


DWSIGNATURE.OS_VS_FIXEDFILEINFO in both cases is 0xfeef04bd, that is okay.
But all other fields are 0 (null)

Any idea to get the info?
Without a C wrapper
This should be possible, as UnifAce is programm language to solve all other problems

Ingo










    CommentAdd your comment...

    2 answers

    1.  
      2
      1
      0

      Hi Freaks

      I got a solution. Not straight like C but working (smile)

      First of all, the buffer had to be set to a size >1024, now its 65335.
      Second, I use
      activate "OS_DLL_VERSION"."VerQueryValueA"("OS_LPVOID","\VarFileInfo\Translation",v_PTR1,v_NUM2)
      Now in v_PTR1 is a pointer to a language and codepage struct
      Load the memory  as LONG into UnifAce and I can separat language and codepage
      Format this to a hex string
      v_Subkey1 = $concat(LF_NUM2HEX(language,4)+LF_NUM2HEX(codepage,4)

      With this info
      activate "OS_DLL_VERSION"."VerQueryValueA"("OS_LPVOID","\StringFileInfo\%%v_SUBKEY1%%%\CompanyName",v_PTR1,v_NUM2)
      Load the memory at pointer v_PTR1 into UnifAce and you got the company name

      iI't it easy with UnifAce to get all nesaccary information grins 

      Ingo



      1. Daniel Iseli

        Thanks Freak. (smile) Nice sample.

        If you call GetFileVersionInfoSizeA before calling GetFileVersionInfoA then you'll know how big the buffer is/should be. (wink)


        Daniel

      2. Ingo Stiller

        Hi Daniel
        Nope, doesn't help (smile)
        In UnifAce, you have declare a signature with an oocurrence as parameter
        In this helper-entity there you have to create on field as raw data.
        And this field has a defined length.
        So your signature is also .limited in length.
        This max length you have to consider.
        It would be nice, if at runtime you can change this sizes (allocate/reallocate)
        But with UnifAce ....

        Ingo

      3. Daniel Iseli

        Hi Ingo,

        I would not agree. If you would have done the check then you would have realized immediately that the defined parameter is too small. (tongue)

        And it would of course be nice if the parameters of a C Call-Out could be resized at runtime. Currently a developer needs to use his grey cells a bit more. (wink)

        Daniel

      CommentAdd your comment...
    2.  
      1
      0
      -1

      Hi Ingo,

      Can you use powershell ?

      Create a .bat file, replace yourDllPath by your dll file path:

      @echo off
      for /f "delims=" %%i in ('powershell.exe "(dir yourDllPath).VersionInfo.FileVersion"') do Set versionFile=%%i
      echo %versionFile%


      Call the .bat file from Uniface :

      Variables
      string result
      EndVariables
      activate "oscommand".commandout("test.bat",result)

      Regards,

      Gilles.

      1. Ingo Stiller

        Hi Gilles

        As this components are running at customer site, part of them at a workstation part of them on a server. I'm not sure what environment I got.
        So this acquire of information should be very basic (smile)
        At it's best, UnifAce should do this job *needling*

        Ingo

      CommentAdd your comment...