如何查看计算机上安装的 Windows Media Player 版本?

发布于 2024-09-19 15:53:01 字数 98 浏览 5 评论 0原文

据我所知,Windows Media Player 10 是 WPF MediaElement 工作的最低要求。以编程方式(从.NET)检查 WMP 是否存在及其版本的好方法是什么?

As far as I know Windows Media Player 10 is the minimum requirement for WPF MediaElement to work. What is a decent way to programmatically (from .NET) check if WMP is present, and its version?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

逆流 2024-09-26 15:53:01

我在安装程序中使用的方法是检查此注册表值:

HKLM
Software\Microsoft\MediaPlayer\PlayerUpgrade
PlayerVersion

PlayerVersion 值将设置为类似“10,0,0,0”的字符串。 (请注意,使用逗号而不是句点来分隔数字。)您需要提取第一个数字(主要版本)并确保它是 10 或更大。

我找不到任何关于如何检测 WMP 的官方文档,但上述方法似乎适用于当前版本的 Windows 和 WMP。

请注意,如果安装了 WMP9(Windows XP 附带的版本),则当您尝试使用 MediaElement 时,您的应用程序不会崩溃,但控件不会呈现任何内容,并且警告消息将打印到调试器。

如果您的应用程序仅在 Vista 或更高版本中使用,则无需担心这些,因为 Vista 附带了 WMP10。

The method I used in my installer is to check this registry value:

HKLM
Software\Microsoft\MediaPlayer\PlayerUpgrade
PlayerVersion

The PlayerVersion value will be set to a string like "10,0,0,0". (Note that commas, not periods, are used to separate the numbers.) You need to extract the first number (the major version) and make sure that it is 10 or higher.

I couldn't find any official documentation about how to detect WMP, but the above method seems to work properly with the current versions of Windows and WMP.

Note that if WMP9 (the version that ships with Windows XP) is installed, your application will not crash when you try to use a MediaElement, but the control won't render anything, and warning messages will be printed to the debugger.

If your application will only be used with Vista or higher, you don't need to worry about any of this, because Vista comes with WMP10.

逆光下的微笑 2024-09-26 15:53:01

以下是检查系统上安装的所有产品的方法:

SelectQuery allProductsQuery = new SelectQuery("Win32_Product");

ManagementObjectSearcher allProducts =
new ManagementObjectSearcher(allProductsQuery);

foreach(ManagementObject product in allProducts.Get())
{
Console.WriteLine("Product {0} is at version {1}",
product.Properties["Name"].Value,
product.Properties["Version"].Value);
}

您需要添加“using System.Management”和对“System.Management.dll”的引用。

要获取特定产品的信息,您可以优化查询或在所有产品中搜索该产品。

Here's how you can check all the products installed on the system:

SelectQuery allProductsQuery = new SelectQuery("Win32_Product");

ManagementObjectSearcher allProducts =
new ManagementObjectSearcher(allProductsQuery);

foreach(ManagementObject product in allProducts.Get())
{
Console.WriteLine("Product {0} is at version {1}",
product.Properties["Name"].Value,
product.Properties["Version"].Value);
}

You need to add "using System.Management" and a reference to "System.Management.dll".

To get informations for a specific product you can refine the query or search the product within all of them.

我ぃ本無心為│何有愛 2024-09-26 15:53:01

我找到了这个解决方案:

FileVersionInfo inf = FileVersionInfo.GetVersionInfo(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles), "Windows Media Player", "wmplayer.exe"));
        if (inf.FileVersion.StartsWith("9"))
        {...

i found this solution:

FileVersionInfo inf = FileVersionInfo.GetVersionInfo(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles), "Windows Media Player", "wmplayer.exe"));
        if (inf.FileVersion.StartsWith("9"))
        {...
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文