1

Ive got a project that I have been tasked with, to install some Microsoft KB's, but they want me to check that once the KB has been installed, that it has update the DLL and the only way i can see they differ is by the DLL version.

Is there a way I can get VB.net to check the DLL file version (right click - properties - details - File Version)?

I have found a couple of things on the internet, but I cant get them to work or more likely I do not understand what I need to do to get the correct information.

Any help with this would be great appreciated.

Anton King
  • 75
  • 1
  • 9
  • possible duplicate of [How to Get Version of an Executable file?](http://stackoverflow.com/questions/11237684/how-to-get-version-of-an-executable-file) – Steven Doggart Dec 05 '13 at 16:09

2 Answers2

2

http://msdn.microsoft.com/en-us/library/system.diagnostics.fileversioninfo.fileversion(v=vs.110).aspx

This should give you some insight.

EDIT

I didn't add the code from the article, thought I would update the answer before the link was lost:

Imports System
Imports System.IO
Imports System.Diagnostics



Class Class1

    Public Shared Sub Main(ByVal args() As String)
    ' Get the file version for the notepad.
    ' Use either of the following two commands.
    FileVersionInfo.GetVersionInfo(Path.Combine(Environment.SystemDirectory, "Notepad.exe"))
    Dim myFileVersionInfo As FileVersionInfo = FileVersionInfo.GetVersionInfo(Environment.SystemDirectory + "\Notepad.exe")


    ' Print the file name and version number.
    Console.WriteLine("File: " + myFileVersionInfo.FileDescription + vbLf + "Version number: " + myFileVersionInfo.FileVersion)

    End Sub
End Class
John Janssen
  • 293
  • 2
  • 12
  • 30
2

After calling into a DLL, to ensure it's loaded, You can get the info from that DLL (all the stuff you'd see when right clicking on the DLL) using something like this:

Dim sModule As String

For Each tModule As ProcessModule In Process.GetCurrentProcess().Modules
  sModule = tModule.FileName
  If sModule.ToUpper.Contains(DLLFileName.ToUpper) Then
    Dim myFileVersionInfo As FileVersionInfo = _
           FileVersionInfo.GetVersionInfo(sModule)
    DLLFileAndVersion = sModule & " " & myFileVersionInfo.ProductVersion
  End If
Next