判断远端计算机的注册表的键值的方法
using Microsoft.Win32;
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
/// <summary> /// 判断远端注册表 /// </summary> /// <param name="HostName">机器名</param> /// <param name="RegKey">注册表内的键值</param> /// <returns></returns> public static bool IsRegedit(string HostName,string RegKey) { RegistryKey environment_key; bool Result = false; try { environment_key = RegistryKey.OpenRemoteBaseKey(RegistryHive.ClassesRoot, HostName).OpenSubKey(RegKey); if (environment_key == null) Result = false; else Result = true; } catch (Exception ex) { throw new Exception("IsRegedit fail," + ex.Message); } return Result; } |