本文介绍了如何检测系统上安装的所有媒体播放器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
您好,
我正在开展一个项目,我需要在用户机器上安装媒体播放器列表(如vlc,KMPlayer,FLVPlayer,Adobe Flash Player等),但我没有任何人都可以帮我。
提前谢谢你。
Hello,
I am working on a project in which I required list of media players (like vlc , KMPlayer, FLVPlayer , Adobe Flash Player etc) installed on user's machine but I don't have any idea how to got that.Can anybody help me.
Thank You in advance.
推荐答案
//...
using System.Management;
//...
List<string> _listOfInterestingPlayers = new List<string>()
{
//add names here
};
//...
//lots of code
//...
List<managementobject> GetMeAllInstalledMediaPlayers()
{
List<managementobject> retlist = new List<managementobject>();
SelectQuery allProductsQuery = new SelectQuery("Win32_Product");
ManagementObjectSearcher allProducts =
new ManagementObjectSearcher(allProductsQuery);
foreach(ManagementObject product in allProducts.Get())
{
Trace.WriteLine("Product {0} is at version {1}",
product.Properties["Name"].Value,
product.Properties["Version"].Value);
//Check whether it is in the list of media players
if(_listOfInterestingPlayers.Contains(product.Properties["Name"].Value))
{
retlist.Add(product);
}
}
return retlist;
}
这篇关于如何检测系统上安装的所有媒体播放器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!