Obtaining version information programmatically

Started by Anonymous, May 16, 2004, 07:47:00 PM

Previous topic - Next topic

Anonymous

I could figure out how to do the following, but maybe someone has a code snippet which they would be willing to share?

With FireFly comes the ability to auto-increment the version number of the application being developed (great feature!).

However retrieving the file version from the executable isn't so simple (unlike in VB where it was dead easy).

So, does anyone have a small extract of code for retrieving the version from the application?

Andrew

Ed Turner

Here's what I use.


Function GetVersionStringInfo () As String
   Local svPtr As Asciiz Ptr, sVerBuffer As String
   Local i As Dword, stPtr As aboutStringTable Ptr
   Local sPathName AS STRING, sType AS STRING
   sPathName = pgmname & ".exe"
   sType = "FileVersion"
   i = GetFileVersionInfoSize(BYCOPY sPathName, 0???)
   If i = 0 Then Exit Function
   sVerBuffer = Space$(i)
   GetFileVersionInfo ByCopy sPathName, 0???, i, ByVal StrPtr(sVerBuffer)
   If VerQueryValue(ByVal StrPtr(sVerBuffer), "\StringFileInfo", stPtr, i) Then
       If VerQueryValue(ByVal StrPtr(sVerBuffer), "\StringFileInfo\" + @stPtr.zLangID + "\" + sType, svPtr, i) Then
           Function = @svPtr
       End If
   End If
End Function

Anonymous

Excellent stuff Ed! Many thanks!

I've always wondered why Microsoft made getting the version information so damned difficult. Jumping thru hoops whilst standing on one leg would be easier!

Andrew

Anonymous

Ed - the code snippet you kindly supplied doesn't compile. I get an error on the following line:

   Local stPtr As aboutStringTable Ptr

What am I missing?

Andrew

Ed Turner

Oops... my bad  :oops:
I'm away from my development machine right now, but as soon as I get home I'll post it here.  (be about 3 hours from now).

Ed Turner

Here's the missing UDT.  Sorry 'bout that.


Type aboutStringTable
   wLength     As Dword            ' Length of string file info
   zLangID     As Asciiz * 9       ' Language ID and Code page
End Type


TechSupport

For anyone lurking.... in the new versions of FireFly, you simply have to reference the internal type variable called "App" in order to retrieve all of this information. Refer to the FireFly help file under "FireFly Functions".