Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
297 views
in Technique[技术] by (71.8m points)

c# - How to check what version of Windows Media Player is installed on the machine?

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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

HKLM
SoftwareMicrosoftMediaPlayerPlayerUpgrade
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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...