Zarxrax
Zarxrax

Reputation: 95

Determine quicktime version with C#

I am writing a C# application and I need to determine if quicktime is installed on the system and what version. This is on windows.

Upvotes: 3

Views: 479

Answers (2)

Moon
Moon

Reputation: 35265

Try this:

using (RegistryKey key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"))
{
    if (key != null)
    {
        foreach (string subKeyName in key.GetSubKeyNames())
        {
            using (RegistryKey subKey = key.OpenSubKey(subKeyName))
            {
                if (subKey == null) continue;

                var displayName = subKey.GetValue("DisplayName") as string;

                if (displayName == null || !displayName.Equals("QuickTime")) continue;

                var version = subKey.GetValue("DisplayVersion");

                Console.WriteLine(displayName);
                Console.WriteLine(version);
            }
        }
    }
}

Upvotes: 2

Joel Mueller
Joel Mueller

Reputation: 28735

A quick Google search turned up the following code from this page:

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

"But wait!" you say, "That's VBScript, not C#!" That's true, but it's VBScript that does WMI queries. Another quick Google search turns up how to do WMI queries from C#.

Upvotes: 6

Related Questions