我有一个项目,我的任务是安装一些 Microsoft KB,但他们希望我在安装 KB 后检查它是否更新了 DLL,我能看到它们不同的唯一方法是 DLL版本。
有没有办法让VB.net检查DLL文件版本(右键单击-属性-详细信息-文件版本)?
我在互联网上找到了一些东西,但我无法让它们工作,或者更有可能我不明白我需要做什么才能获得正确的信息。
对此的任何帮助将不胜感激。
我有一个项目,我的任务是安装一些 Microsoft KB,但他们希望我在安装 KB 后检查它是否更新了 DLL,我能看到它们不同的唯一方法是 DLL版本。
有没有办法让VB.net检查DLL文件版本(右键单击-属性-详细信息-文件版本)?
我在互联网上找到了一些东西,但我无法让它们工作,或者更有可能我不明白我需要做什么才能获得正确的信息。
对此的任何帮助将不胜感激。
这应该会给你一些见解。
编辑
我没有添加文章中的代码,以为我会在链接丢失之前更新答案:
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
调用 DLL 后,为了确保它已加载,您可以使用以下内容从该 DLL 中获取信息(右键单击 DLL 时您会看到的所有内容):
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