读取远程注册表键值

string UAC = GetRegKey("127.0.0.1", @"SOFTWAREMicrosoftWindowsCurrentVersionPoliciesSystem", "LocalAccountTokenFilterPolicy");
private static string GetRegKey(string ClientIP, string path, string key)
{
    string result = "";
    try
    {
        RegistryKey regKey = RegistryKey.OpenRemoteBaseKey(RegistryHive.LocalMachine, ClientIP).OpenSubKey(path);
        result = regKey.GetValue(key).ToString();
        regKey.Close();
    }
    catch (Exception ex)
    {
        result = ex.ToString();
    }
    return result;
}

网上的方法有误...直接坑了我一下午。

原文地址:https://www.cnblogs.com/sherlock99/p/3671780.html