PlanetSquires Forums

Support Forums => Other Software and Code => Topic started by: Anonymous on May 16, 2004, 07:47:00 PM

Title: Obtaining version information programmatically
Post by: Anonymous on May 16, 2004, 07:47:00 PM
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
Title: Obtaining version information programmatically
Post by: Ed Turner on May 16, 2004, 07:59:14 PM
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
Title: Obtaining version information programmatically
Post by: Anonymous on May 16, 2004, 08:29:33 PM
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
Title: Obtaining version information programmatically
Post by: Anonymous on May 17, 2004, 01:41:15 PM
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
Title: Obtaining version information programmatically
Post by: Ed Turner on May 17, 2004, 04:26:27 PM
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).
Title: Obtaining version information programmatically
Post by: Ed Turner on May 17, 2004, 07:35:45 PM
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
Title: Obtaining version information programmatically
Post by: Anonymous on May 18, 2004, 10:44:45 AM
Thanks Ed!

Andrew
Title: Obtaining version information programmatically
Post by: TechSupport on June 03, 2004, 09:30:16 AM
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".