public static object GetRemoteRegistryValue(string server, string username, string password, string KeyName, string name) { object obj = (object)null; string format = Win32Utils.NetAddConnection(server, username, password); try { if (!string.IsNullOrEmpty(format)) { throw new ApplicationException(string.Format((IFormatProvider)CultureInfo.InvariantCulture, format, new object[0])); } RegistryKey registryKey; try { registryKey = RegistryKey.OpenRemoteBaseKey(RegistryHive.LocalMachine, server).OpenSubKey(KeyName); } catch (Exception ex) { registryKey = RegistryKey.OpenRemoteBaseKey(RegistryHive.LocalMachine, server).OpenSubKey(KeyName); } if (registryKey != null) { obj = registryKey.GetValue(name); } } finally { Win32Utils.NetCancelConnection(server); } return(obj); }
public static string ValidateCredentials(string server, string username, string password) { try { return(Win32Utils.NetAddConnection(server, username, password)); } finally { Win32Utils.NetCancelConnection(server); } }
public static bool IsMicrosoftComponentInstalled(string server, string username, string password, string componentFriendlyName, string version) { bool flag = false; string message = Win32Utils.NetAddConnection(server, username, password); try { if (!string.IsNullOrEmpty(message)) { throw new ApplicationException(message); } RegistryKey registryKey1; try { registryKey1 = RegistryKey.OpenRemoteBaseKey(RegistryHive.LocalMachine, server).OpenSubKey("SOFTWARE\\Microsoft\\Active Setup\\Installed Components"); } catch (IOException ex) { registryKey1 = RegistryKey.OpenRemoteBaseKey(RegistryHive.LocalMachine, server).OpenSubKey("SOFTWARE\\Microsoft\\Active Setup\\Installed Components"); } foreach (string subKeyName in registryKey1.GetSubKeyNames()) { RegistryKey registryKey2 = registryKey1.OpenSubKey(subKeyName); string str1 = (string)registryKey2.GetValue((string)null); if (!string.IsNullOrEmpty(str1) && str1.IndexOf(componentFriendlyName, StringComparison.CurrentCultureIgnoreCase) >= 0) { string str2 = ((string)registryKey2.GetValue("Version")).Trim(); if (!string.IsNullOrEmpty(str2) && str2.Replace(",", ".").StartsWith(version)) { flag = true; break; } } } } finally { Win32Utils.NetCancelConnection(server); } return(flag); }