EXE & DLL version

How to extract the version number of a EXE or DLL?
I means the number that ou can see if you click property->version
on a EXE or DLL.
Thanks.
parduzAsked:
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.

RuchiCommented:
this is from the web.

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
                      Public Function GetVersion(ByVal sFile As String) As String
                          Dim sVerInfo As String
                          Dim iVerLen As Integer
                          Dim iVerPos As Long
                          iVerLen = GetFileVersionInfoSize(sFile, 0&)
                          sVerInfo = Space(iVerLen)
                          Call GetFileVersionInfo(sFile, 0&, iVerLen, ByVal sVerInfo)
                          iVerPos = InStr(sVerInfo, "FileVersion") + 12
                          If iVerPos = 12 Then
                              'No Version Info, Check for 32bit File -
                              '32Bit Files Return Unicode Strings
                              sVerInfo = StrConv(sVerInfo, vbFromUnicode)
                              iVerPos = InStr(sVerInfo, "FileVersion") + 13
                          End If
                          If iVerPos > 12 Then GetVersion = GetVersion & Mid(sVerInfo, iVerPos, InStr(iVerPos, sVerInfo, Chr(0)) - 1)
                      End Function
                      Private Sub Command1_Click()
                          On Error GoTo UserCancelled
                          With CommonDialog1
                              .DialogTitle = "Select a File.."
                              .CancelError = True
                              .Filter = "All Files|*.dll;*.exe"
                              .ShowOpen
                              Caption = GetVersion(.FileName)
                          End With
                      UserCancelled:
                      End Sub
0
RuchiCommented:
this is the above same code. add a command button on the form.

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
Public Function GetVersion(ByVal sFile As String) As String
Dim sVerInfo As String
Dim iVerLen As Integer
Dim iVerPos As Long
iVerLen = GetFileVersionInfoSize(sFile, 0&)
sVerInfo = Space(iVerLen)
Call GetFileVersionInfo(sFile, 0&, iVerLen, ByVal sVerInfo)
iVerPos = InStr(sVerInfo, "FileVersion") + 12
If iVerPos = 12 Then
    'No Version Info, Check for 32bit File -
    '32Bit Files Return Unicode Strings
    sVerInfo = StrConv(sVerInfo, vbFromUnicode)
    iVerPos = InStr(sVerInfo, "FileVersion") + 13
End If
If iVerPos > 12 Then GetVersion = GetVersion & Mid(sVerInfo, iVerPos, InStr(iVerPos, sVerInfo, Chr(0)) - 1)
End Function
Private Sub Command1_Click()
On Error GoTo UserCancelled
With CommonDialog1
    .DialogTitle = "Select a File.."
    .CancelError = True
    .Filter = "All Files|*.dll;*.exe"
    .ShowOpen
    Caption = GetVersion(.FileName)
End With
UserCancelled:
End Sub
0
MitchBroadheadCommented:
yup
0
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

RuchiCommented:
This is to extract the version number of a DLL or EXE


this is the above same code. add a command button on the form.

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

Public Function GetVersion(ByVal sFile As String) As String
Dim sVerInfo As String
Dim iVerLen As Integer
Dim iVerPos As Long
iVerLen = GetFileVersionInfoSize(sFile, 0&)
sVerInfo = Space(iVerLen)
Call GetFileVersionInfo(sFile, 0&, iVerLen, ByVal sVerInfo)
iVerPos = InStr(sVerInfo, "FileVersion") + 12
If iVerPos = 12 Then
    'No Version Info, Check for 32bit File -
    '32Bit Files Return Unicode Strings
    sVerInfo = StrConv(sVerInfo, vbFromUnicode)
    iVerPos = InStr(sVerInfo, "FileVersion") + 13
End If
If iVerPos > 12 Then GetVersion = GetVersion & Mid(sVerInfo, iVerPos, InStr(iVerPos, sVerInfo, Chr(0)) - 1)
End Function

Private Sub Command1_Click()
On Error GoTo UserCancelled
With CommonDialog1
    .DialogTitle = "Select a File.."
    .CancelError = True
    .Filter = "All Files|*.dll;*.exe"
    .ShowOpen
    Caption = GetVersion(.FileName)
End With
UserCancelled:
End Sub  
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
parduzAuthor Commented:
All right.
Due to a lot of job to do, i check all your coments in the next week.
Thanks to all for the help
0
RuchiCommented:
Again, I am looking forward to your comments.
0
parduzAuthor Commented:
Sorry for the delay, my job is a nightmare.
Thanx again
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.