验证本机的excel版本的C#代码
验证本机的excel版本的C#代码
发布时间:2016-12-28 来源:查字典编辑
摘要:复制代码代码如下://////安装的excel的版本,0为没有安装,大于1说明安装了多个.//////publicstaticListExc...

复制代码 代码如下:

/// <summary>

/// 安装的excel的版本,0为没有安装,大于1说明安装了多个.

/// </summary>

/// <returns></returns>

public static List<string> ExcelVersion()

{

List<string> list = new List<string>();

List<string> lisemp = new List<string>();

List<string> listvison = new List<string>();

RegistryKey rk = Registry.LocalMachine;

RegistryKey akey = rk.OpenSubKey(@"SOFTWAREMicrosoftOffice");

RegistryKey csk;

string str;

Hashtable hash = new Hashtable();

string[] ss = akey.GetSubKeyNames();

foreach (string s in ss)

{

string strem = @"SOFTWAREMicrosoftOffice" + @"" + s;

csk = rk.OpenSubKey(strem);

string[] csd = csk.GetSubKeyNames();

foreach (string sk in csd)

{

if (sk == "Excel")

{

str = strem + @"" + "Excel";

list.Add(str);

lisemp.Add(s);

}

}

}

if (list != null)

{

for (int index = 0; index < list.Count; index++)

{

list[index] = list[index] + @"InstallRoot";

RegistryKey f = rk.OpenSubKey(list[index]);

if (f != null)

{

listvison.Add(lisemp[index]);

}

}

}

return listvison;

}

推荐文章
猜你喜欢
附近的人在看
推荐阅读
拓展阅读
相关阅读
网友关注
最新C#教程学习
热门C#教程学习
编程开发子分类