Skip to main content

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










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










Hi Freaks

I got a solution. Not straight like C but working 🙂

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




Hi Freaks

I got a solution. Not straight like C but working 🙂

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



Thanks Freak. 🙂 Nice sample.

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


Daniel


Hi Freaks

I got a solution. Not straight like C but working 🙂

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



Hi Daniel
Nope, doesn't help 🙂
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


Hi Freaks

I got a solution. Not straight like C but working 🙂

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



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. 😜

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. 😉

Daniel


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










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.


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.

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 🙂
At it's best, UnifAce should do this job *needling*

Ingo