如何找到QuickTime版本

残酷的

我需要以编程方式找到已安装的quicktime版本。以前,我正在检查注册表项HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall中的快速时间。但是在quicktime的最新更新(版本7.5)中,它不起作用。

我在vbscript中找到了这段代码,但无法在vb.net中弄清楚该如何做。

strComputer = "."

Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery _
("Select * From Win32_Product Where Name = 'QuickTime'")

If colItems.Count = 0 Then
Wscript.Echo "QuickTime is not installed on this computer."
Else
For Each objItem in colItems
    Wscript.Echo "QuickTime version: " & objItem.Version
Next
End If

请让我知道如何找出快速时间的版本。

比昂·罗格·克林佐(Bjørn-RogerKringsjå)

首先Microsoft WMI Scripting V1.2 Library在您的项目中添加对的引用

然后,您需要在代码页的顶部导入以下名称空间:

Imports System.Runtime.InteropServices
Imports WbemScripting

这是一个例子:

Private Sub CheckVersion()

    Dim service As SWbemServicesEx = Nothing
    Dim collection As SWbemObjectSet = Nothing
    Dim item As SWbemObjectEx = Nothing

    Try

        Dim strComputer As String = "."
        Dim version As String = Nothing

        service = DirectCast(GetObject(String.Concat("winmgmts:\\", strComputer, "\root\cimv2")), SWbemServicesEx)
        collection = service.ExecQuery("Select * From Win32_Product Where Name = 'QuickTime'")

        If ((collection Is Nothing) OrElse (collection.Count = 0)) Then
            MessageBox.Show("QuickTime is not installed on this computer", Me.Text, MessageBoxButtons.OK, MessageBoxIcon.Error)
        Else
            For i As Integer = 0 To (collection.Count - 1)
                item = DirectCast(collection.ItemIndex(i), SWbemObjectEx)
                version = item.Properties_.Item("Version").Value.ToString()
                MessageBox.Show(String.Concat("QuickTime version: ", version), Me.Text, MessageBoxButtons.OK, MessageBoxIcon.Information)
            Next
        End If

    Catch ex As Exception
        MessageBox.Show(ex.Message, Me.Text, MessageBoxButtons.OK, MessageBoxIcon.Error)
    Finally
        If (Not Object.ReferenceEquals(item, Nothing)) Then Marshal.ReleaseComObject(item)
        If (Not Object.ReferenceEquals(collection, Nothing)) Then Marshal.ReleaseComObject(collection)
        If (Not Object.ReferenceEquals(service, Nothing)) Then Marshal.ReleaseComObject(service)
    End Try

End Sub

更新

在最新版本中,名称更改为QuickTime 7

因此,您需要更改查询:

Name = 'QuickTime'Name Like 'QuickTime%'

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章