读取远程注册表键值

string UAC = GetRegKey("127.0.0.1", @"SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System", "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;
}

 

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

 

posted @ 2014-04-17 20:00  sherlock99  阅读(413)  评论(2编辑  收藏  举报