インストールされているQuickTimeバージョンをプログラムで見つける必要があります。以前は、レジストリエントリHKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall
でQuickTimeをチェックしていました。しかし、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
QuickTimeのバージョンを見つける方法を教えてください。
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]
コメントを追加