프로젝트에 Microsoft WMI Scripting V1.2 Library
에 대한 참조를 추가하여 시작하십시오.
그런 다음 코드 페이지의 상단에 다음의 네임 스페이스를 가져해야합니다 :
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
업데이트 최신 버전에서
: 여기
Imports System.Runtime.InteropServices
Imports WbemScripting
하는 예입니다 이름이 QuickTime 7
으로 변경됩니다. Name Like 'QuickTime%'
에 Name = 'QuickTime'
에서
:
그래서 당신은 당신의 쿼리를 변경해야합니다.
퀵타임의 최신 버전에서는 작동하지 않습니다. 그들이 무엇을 변경했는지 궁금합니다. – Harsh
정확한 버전 번호는 무엇입니까? –
@Harsh 맞아요, 제 편집을 참조하십시오. –