I need to find the installed quicktime version programatically. Previously i was checking the registry entry HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall
for quicktime.
But in the latest update of quicktime (Version 7.5) it doesn't work.
I found this piece of code in vbscript but cannot figure out how to do this in 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
Please let me know how to find out the version of quick time.
Start by adding a reference to Microsoft WMI Scripting V1.2 Library
in your project.
Then you'll need to import these namespaces at the top of your code page:
Imports System.Runtime.InteropServices
Imports WbemScripting
Here's an example:
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
Update
In the newest version the name is changed to QuickTime 7
.
So you need to change your query:
From Name = 'QuickTime'
to Name Like 'QuickTime%'
.