CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Apr 1999
    Location
    Alabama USA
    Posts
    32

    How to determine Visual Basic version

    How does one programmatically determine the version of Visual Basic being used?



  2. #2
    Join Date
    Jul 2000
    Location
    Milano, Italy
    Posts
    7,726

    Re: How to determine Visual Basic version

    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.
    ...at present time, using mainly Net 4.0, Vs 2010



    Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
    all the other wonderful people who made and make Codeguru a great place.
    Come back soon, you Gurus.

  3. #3
    Join Date
    Apr 2001
    Posts
    95

    Re: How to determine Visual Basic version

    YOu might be able to use the App object

    i.e

    Dim Version

    Version = App.Version


  4. #4
    Join Date
    Jul 2000
    Location
    Milano, Italy
    Posts
    7,726

    Re: How to determine Visual Basic version

    ? 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.
    ...at present time, using mainly Net 4.0, Vs 2010



    Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
    all the other wonderful people who made and make Codeguru a great place.
    Come back soon, you Gurus.

  5. #5
    Join Date
    Apr 2001
    Posts
    95

    Re: How to determine Visual Basic version

    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 :-)


  6. #6
    Join Date
    Jul 2000
    Location
    Milano, Italy
    Posts
    7,726

    Re: How to determine Visual Basic version

    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.
    ...at present time, using mainly Net 4.0, Vs 2010



    Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
    all the other wonderful people who made and make Codeguru a great place.
    Come back soon, you Gurus.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured