Reputation: 85
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.
Upvotes: 2
Views: 7094
Reputation: 323
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
Upvotes: 2
Reputation: 36
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
Upvotes: 2