dll version information

How do I get the version in formation for a dll file from within VB.

I want to do something like:

DLLFile.Filename = "C:\Test.dll"
debug.print DLLFilename.VersionNumber

Thanks.
TheNuggetAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

aswirthmCommented:
Here is some code using api function.
You need a type declaration and some api-declares. Paste them in a global module. It works fine:

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
   
Declare Function GetFileVersionInfoSize Lib "Version.dll" Alias _
   "GetFileVersionInfoSizeA" (ByVal lptstrFilename As String, _
   lpdwHandle As Long) As Long
   
Declare Function VerQueryValue Lib "Version.dll" Alias _
   "VerQueryValueA" (pBlock As Any, ByVal lpSubBlock As String, _
   lplpBuffer As Any, puLen As Long) As Long
   
Declare Sub MoveMemory Lib "kernel32" Alias "RtlMoveMemory" _
   (dest As Any, ByVal Source As Long, ByVal length As Long)

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

This should get you the version info:
   

    Dim rc As Long
    Dim lDummy As Long
    Dim lBufferLen As Long
    Dim lVerPointer As Long
    Dim udtVerBuffer As VS_FIXEDFILEINFO
    Dim lVerbufferLen As Long
    Dim sFileVer As String
   
    '*** Get size ****
    lBufferLen = GetFileVersionInfoSize(sFullFileName, lDummy)
   
    If lBufferLen < 1 Then
        GetCarmaFileVersion = ""
        Exit Function
    End If
   
    '**** Store info to udtVerBuffer struct ****
    ReDim sBuffer(lBufferLen) As Byte
    rc = GetFileVersionInfo(sFullFileName, 0&, lBufferLen, sBuffer(0))
    rc = VerQueryValue(sBuffer(0), "\", lVerPointer, lVerbufferLen)
    MoveMemory udtVerBuffer, lVerPointer, Len(udtVerBuffer)
   
    '**** Determine File Version number ****
    sFileVer = Format$(udtVerBuffer.dwFileVersionMSh) & "." & _
       Format$(udtVerBuffer.dwFileVersionMSl) & "." & _
       Format$(udtVerBuffer.dwFileVersionLSh) & "." & _
       Format$(udtVerBuffer.dwFileVersionLSl)


Cheers,
       aswirthm
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
1114goddersCommented:
Yes but how do you get the values to populate sFullFileName ?????
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.