如何查看计算机上安装的 Windows Media Player 版本?
据我所知,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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我在安装程序中使用的方法是检查此注册表值:
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:
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.
以下是检查系统上安装的所有产品的方法:
您需要添加“using System.Management”和对“System.Management.dll”的引用。
要获取特定产品的信息,您可以优化查询或在所有产品中搜索该产品。
Here's how you can check all the products installed on the system:
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.
我找到了这个解决方案:
i found this solution: