• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 242
  • Last Modified:

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.
0
parduz
Asked:
parduz
  • 4
  • 2
1 Solution
 
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 new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

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

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now