Hi there
I'm new to Ebasic (still looking at the demo). I figured out that version information for an app could be saved in the resource file, but how do I retrieve that version info so I can display it?
The simplest way I know is to use the API function GetFileVersionInfo
I will see if I can come up with an example.
OK here we go.
This is the test program I came up with:
$main
'Import library needed
'Create the import library by selecting the 'tools' menu and choosing 'Create import library'
'Browse to version.dll and go.
$use "version.lib"
'API imports needed
DECLARE IMPORT,VerQueryValueA(pBlock as POINTER ,lpSubBlock as POINTER,lplpBuffer as POINTER,puLen as POINTER),INT
DECLARE IMPORT,GetFileVersionInfoSizeA(lptstrFilename as STRING,lpdwHandle as POINTER),UINT
DECLARE IMPORT,GetFileVersionInfoA(lptstrFilename as STRING,dwHandle as UINT,dwLen as UINT,lpData as POINTER),INT
'TYPE needed
TYPE VS_FIXEDFILEINFO
UINT dwSignature
UINT dwStrucVersion
UINT dwFileVersionMS
UINT dwFileVersionLS
UINT dwProductVersionMS
UINT dwProductVersionLS
UINT dwFileFlagsMask
UINT dwFileFlags
UINT dwFileOS
UINT dwFileType
UINT dwFileSubtype
UINT dwFileDateMS
UINT dwFileDateLS
ENDTYPE
OPENCONSOLE
STRING strExe:strExe = GETSTARTPATH + "\\fileversion.exe"
STRING version
UINT dwTemp
UINT dwVS:dwVS = 0
UINT dwSize:dwSize = GetFileVersionInfoSizeA(strExe,dwTemp)
POINTER pVer,lpvs
IF(dwSize)
pVer = NEW(CHAR,dwSize)
IF(GetFileVersionInfoA(strExe,0,dwSize,pVer) <> 0)
IF(VerQueryValueA(pVer,"\\",&lpvs,dwVS))
'retriev the file version
UINT nVerMSB:nVerMSB = *<VS_FIXEDFILEINFO>lpvs.dwFileVersionMS
UINT nVerLSB:nVerLSB = *<VS_FIXEDFILEINFO>lpvs.dwFileVersionLS
IF(nVerLSB <> 0)
version = USING("File Version #&#&#&#",nVerMSB>>16,".",nVerMSB & 0xFFFF,"",nVerLSB>>16,"",nVerLSB & 0xFFFF)
ELSE
version = USING("File Version #&#",nVerMSB>>16,".",nVerMSB & 0xFFFF)
ENDIF
version += "\n"
'retrive the product version
nVerMSB = *<VS_FIXEDFILEINFO>lpvs.dwProductVersionMS
nVerLSB = *<VS_FIXEDFILEINFO>lpvs.dwProductVersionlS
IF(nVerLSB <> 0)
version += USING("Product Version #&#&#&#",nVerMSB>>16,".",nVerMSB & 0xFFFF,"",nVerLSB>>16,"",nVerLSB & 0xFFFF)
ELSE
version += USING("Product Version #&#",nVerMSB>>16,".",nVerMSB & 0xFFFF)
ENDIF
ENDIF
ENDIF
DELETE pVer
ELSE
version = "Could not retrieve version information"
ENDIF
PRINT version
PRINT "Press any key to close"
DO:UNTIL INKEY$ <> ""
Attached to this message is the complete project. Remember to answer "yes" when the IDE asks if you want to update the projects paths. It will only ask once when you first open the project ;)
There is a single resource in the project, a versioninfo resource, with the file version set to 7.654 and the product version set to 3.210
Have fun!
Paul.
Thanks!