Verify the C code for the excel version of the native

  • 2020-05-07 20:17:10
  • OfStack

 
/// <summary> 
///  The installation of the excel The version of the ,0 For no installation , Is greater than 1 Indicates that more than one is installed . 
/// </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(@"SOFTWARE\\Microsoft\\Office"); 
RegistryKey csk; 
string str; 
Hashtable hash = new Hashtable(); 
string[] ss = akey.GetSubKeyNames(); 
foreach (string s in ss) 
{ 
string strem = @"SOFTWARE\\Microsoft\\Office" + @"\\" + 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; 
} 

Related articles: