Jon Funk
May 2nd, 2001, 12:32 PM
How does one programmatically determine the version of Visual Basic being used?
|
Click to See Complete Forum and Search --> : How to determine Visual Basic version Jon Funk May 2nd, 2001, 12:32 PM How does one programmatically determine the version of Visual Basic being used? Cimperiali May 3rd, 2001, 09:47 AM I tried, this work. Just look for VB6.exe (you'll need to type the path to it, too) This code comes from Planet-source-code Submitted on: 4/13/1999 By: Riaan Aspeling Level: Not Given User Rating: By 7 Users Compatibility:VB 5.0, VB 6.0 Users have accessed this code 3254 times. Retrieve the version of a file (EXE/DLL etc). This code should be paste into a module and just called via CheckFileVersion('Path to the Exe or DLL'). ----------------------------------------------- product version to get full file version: modify : ProdVer = Format$(udtVerBuffer.dwProductVersionMSh ) & "." & Format$(udtVerBuffer.dwProductVersionMSl ) & "." & Format$(udtVerBuffer.dwProductVersionLSh ) to get full version ----------------------------------------------- or: To get file version use udtVerBuffer.dwFileVersionMSh udtVerB uffer.dwFileVersionMSl udtVerBuffer.dwF ileVersionLSh udtVerBuffer.dwFileVersio nLSl '************************************** 'Windows API/Global Declarations for :Ch ' eckFileVersion '************************************** Option Explicit Private Declare Function GetFileVersionInfo Lib "Version.dll" Alias "GetFileVersionInfoA" (ByVal lptstrFilename As String, ByVal dwHandle As Long, ByVal dwLen As Long, lpData As Any) As Long Private Declare Function GetFileVersionInfoSize Lib "Version.dll" Alias "GetFileVersionInfoSizeA" (ByVal lptstrFilename As String, lpdwHandle As Long) As Long Private Declare Function VerQueryValue Lib "Version.dll" Alias "VerQueryValueA" (pBlock As Any, ByVal lpSubBlock As String, lplpBuffer As Any, puLen As Long) As Long Private Declare Sub MoveMemory Lib "kernel32" Alias "RtlMoveMemory" (dest As Any, ByVal Source As Long, ByVal Length As Long) Private Type VS_FIXEDFILEINFO dwSignature As Long dwStrucVersionl As Integer ' e.g. = &h0000 = 0 dwStrucVersionh As Integer ' e.g. = &h0042 = .42 dwFileVersionMSl As Integer' e.g. = &h0003 = 3 dwFileVersionMSh As Integer' e.g. = &h0075 = .75 dwFileVersionLSl As Integer' e.g. = &h0000 = 0 dwFileVersionLSh As Integer' e.g. = &h0031 = .31 dwProductVersionMSl As Integer ' e.g. = &h0003 = 3 dwProductVersionMSh As Integer ' e.g. = &h0010 = .1 dwProductVersionLSl As Integer ' e.g. = &h0000 = 0 dwProductVersionLSh As Integer ' e.g. = &h0031 = .31 dwFileFlagsMask As Long' = &h3F for version "0.42" dwFileFlags As Long' e.g. VFF_DEBUG Or VFF_PRERELEASE dwFileOS As Long' e.g. VOS_DOS_WINDOWS16 dwFileType As Long ' e.g. VFT_DRIVER dwFileSubtype As Long ' e.g. VFT2_DRV_KEYBOARD dwFileDateMS As Long' e.g. 0 dwFileDateLS As Long' e.g. 0 End Type '************************************** ' Name: CheckFileVersion ' Description:Retrieve the version of a ' file (EXE/DLL etc). This code should be ' paste into a module and just called via ' CheckFileVersion('Path to the Exe or DLL '). ' By: Riaan Aspeling ' ' ' Inputs:Path to the EXE or DLL file eg. ' "C:\Windows\Notepad.exe" ' ' Returns:A Variant containing the versi ' on of the file eg. "4.10" ' 'Assumes:None ' 'Side Effects:None 'This code is copyrighted and has limite ' d warranties. 'Please see http://www.Planet-Source-Cod ' e.com/xq/ASP/txtCodeId.1589/lngWId.1/qx/ ' vb/scripts/ShowCode.htm 'for details. '************************************** 'Example to use this function 'MsgBox " Notepad's Version is " & Check ' FileVersion("C:\Windows\Notepad.exe") Public Function CheckFileVersion(FilenameAndPath As Variant) As Variant On Error GoTo HandelCheckFileVersionError Dim lDummy As Long, lsize As Long, rc As Long Dim lVerbufferLen As Long, lVerPointer As Long Dim sBuffer() As Byte Dim udtVerBuffer As VS_FIXEDFILEINFO Dim ProdVer As String lsize = GetFileVersionInfoSize(FilenameAndPath, lDummy) If lsize < 1 Then Exit Function ReDim sBuffer(lsize) rc = GetFileVersionInfo(FilenameAndPath, 0&, lsize, sBuffer(0)) rc = VerQueryValue(sBuffer(0), "\", lVerPointer, lVerbufferLen) MoveMemory udtVerBuffer, lVerPointer, Len(udtVerBuffer) '**** Determine Product Version number * ' *** ProdVer = Format$(udtVerBuffer.dwProductVersionMSh) & "." & Format$(udtVerBuffer.dwProductVersionMSl) CheckFileVersion = ProdVer Exit Function HandelCheckFileVersionError: CheckFileVersion = "N/A" Exit Function End Function Special thanks to Lothar "the Great" Haensler, Tom Archer, Bruno Paris and all the other wonderful people who made and make Codeguru a great place. Come back soon, you Gurus. slcotten May 3rd, 2001, 11:19 AM YOu might be able to use the App object i.e Dim Version Version = App.Version Cimperiali May 3rd, 2001, 11:24 AM ? App.Version ? Try it yourself... Special thanks to Lothar "the Great" Haensler, Tom Archer, Bruno Paris and all the other wonderful people who made and make Codeguru a great place. Come back soon, you Gurus. slcotten May 3rd, 2001, 12:43 PM Sorry about that I was unable to test it at the time... my bad :-( Try this though... Dim sVersion as String sVersion = cstr(App.Major) & "." & App.Minor & "." & App.Revision & "." Hope THAT is what you are looking for :-) Cimperiali May 4th, 2001, 01:49 AM We should ask to Jon Funk if he meaned the version of project build with Vb (your answer) or the version of VB running on a machine (my answer; even if this last is quite a strange request...) :-) Best regards, Cesare Imperiali Special thanks to Lothar "the Great" Haensler, Tom Archer, Bruno Paris and all the other wonderful people who made and make Codeguru a great place. Come back soon, you Gurus. codeguru.com
Copyright Internet.com Inc., All Rights Reserved. |