手机
当前位置:查字典教程网 >编程开发 >C#教程 >验证本机的excel版本的C#代码
验证本机的excel版本的C#代码
摘要:复制代码代码如下://////安装的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;

}

【验证本机的excel版本的C#代码】相关文章:

使用Npoi操作excel的解决办法

C#中实现任意List的全组合算法代码

C#中让控件全屏显示的实现代码(WinForm)

C# 得到某一天的起始和截止时间的代码

C# char类型字符转换大小写的实现代码

C#委托初级使用的实例代码

C#中执行批处理文件(*.bat)的方法代码

C#解析json文件的实现代码

c# winform读取xml文件创建菜单的代码

在C#中调用VBScript、javascript等脚本的实现代码

精品推荐
分类导航