如何检查什么版本的Windows Media Player安装在机器上?版本、安装在、机器上、Media

2023-09-04 00:18:31 作者:一个人走 ゅ

据我知道的Windows Media Player 10是WPF的MediaElement工作的最低要求。什么是体面的方式以编程方式(从.NET)检查,如果WMP是present,它的版本?

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?

推荐答案

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

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

HKLM
Software\Microsoft\MediaPlayer\PlayerUpgrade
PlayerVersion

的PlayerVersion值将被设定为像10,0,0,0的字符串。 (请注意,逗号,不期间,用于分离的数字。)需要提取第一号码(主版本),并确保它是10或更高。

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.

我找不到有关如何检测WMP任何官方文件,但上面的方法似乎与Windows和WMP的当前版本正常工作。

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.

请注意,如果WMP9安装(随Windows XP的版本),应用程序将无法当您尝试使用MediaElement的崩溃,但控制不会呈现任何内容,警告信息会被打印到调试器

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.

如果您的应用程序只能与Vista或更高版本可以使用,你不需要担心任何的这个,因为Vista自带的WMP10。

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.