Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Determine quicktime version with C#

Tags:

c#

quicktime

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.

like image 894
Zarxrax Avatar asked Mar 15 '26 06:03

Zarxrax


2 Answers

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#.

like image 77
Joel Mueller Avatar answered Mar 17 '26 18:03

Joel Mueller


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);
            }
        }
    }
}
like image 27
Moon Avatar answered Mar 17 '26 19:03

Moon



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!