2014-03-05 2 views
1

설치된 퀵타임 버전을 프로그램 적으로 찾아야합니다. 이전에 나는 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 

퀵타임의 버전을 찾는 방법을 알려주세요.

답변

2

프로젝트에 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'에서

:

그래서 당신은 당신의 쿼리를 변경해야합니다.

+0

퀵타임의 최신 버전에서는 작동하지 않습니다. 그들이 무엇을 변경했는지 궁금합니다. – Harsh

+0

정확한 버전 번호는 무엇입니까? –

+0

@Harsh 맞아요, 제 편집을 참조하십시오. –

관련 문제