Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vb.net/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Vb.net 使用已安装的版本号作为变量_Vb.net - Fatal编程技术网

Vb.net 使用已安装的版本号作为变量

Vb.net 使用已安装的版本号作为变量,vb.net,Vb.net,我试图检索各种已安装应用程序的版本号,如果它们低于某个值,则执行操作。例如: Dim regKey As RegistryKey Dim ver As ??????? regKey = Registry.LocalMachine.OpenSubKey("Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Adobe Flash Player ActiveX") ver =

我试图检索各种已安装应用程序的版本号,如果它们低于某个值,则执行操作。例如:

Dim regKey As RegistryKey
        Dim ver As ???????
        regKey = Registry.LocalMachine.OpenSubKey("Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Adobe Flash Player ActiveX")
        ver = regKey.GetValue("DisplayVersion")
                MessageBox.Show(ver)
            If ver < 11.4.402.287 Then
            'Install updated version of software in question
        End If
        regKey.Close()

这两个函数都返回“附加信息:从字符串“11.4.402.287”到类型“Decimal”的转换无效。”

假设您正在查看前两个组件,则进行简单的分析和检查:

Dim va = Ver.split("."c)
If va(0) < 11 OrElse (va(0) = 11) and va(1) < 4) Then 
    'Install updated ....
End If
Dim va=Ver.split(“.”c)
如果va(0)<11或va(0)=11且va(1)<4),则
'安装已更新。。。。
如果结束

用于此的正则表达式可能类似于:

(?<major>\d+)(\.(?<minor>\d+)(\.(?<revision>\d+)(\.(?<build>\d+))?)?)?
(?\d+)(\.(?\d+)(\.(?\d+)(\.(?\d+))?)?
然后,您可以使用组提取版本号:

Dim l_version As Regex = New Regex("(?<major>\d+)(\.(?<minor>\d+)(\.(?<revision>\d+)(\.(?<build>\d+))?)?)?")
Dim l_versionMatch As Match = l_version.Match( "1.2.3" )

Dim l_major As String = l_versionMatch.Groups("major").Value
Dim l\U版本为正则表达式=新正则表达式((?\d+)(\(?\d+)(\(?\d+)(\(?\d+))?)
Dim l_versionMatch As Match=l_version.Match(“1.2.3”)
Dim l_major As String=l_versionMatch.Groups(“major”).值

您可能需要将字符串解析为主要/次要/构建部分,并根据这些部分做出决定(很可能只有前两个数字——主要和次要版本——会引起兴趣。在上面的示例中,11是主要版本号,4是次要版本号)。这显然是最简单的方法。:)
Dim l_version As Regex = New Regex("(?<major>\d+)(\.(?<minor>\d+)(\.(?<revision>\d+)(\.(?<build>\d+))?)?)?")
Dim l_versionMatch As Match = l_version.Match( "1.2.3" )

Dim l_major As String = l_versionMatch.Groups("major").Value