C#获取远程计算机硬件信息实例(支持linux和windows)
2020-12-13 03:41
标签:style blog http color strong width
C#获取远程计算机硬件信息实例(支持linux和windows),搜素材,soscw.com C#获取远程计算机硬件信息实例(支持linux和windows) 标签:style blog http color strong width 原文地址:http://www.cnblogs.com/lonelyxmas/p/3814955.html
/// 获取查询队列 ///
///
///
///
///
///
///
private static ManagementObjectCollection GetQueryObject(string ip, string username, string password, string queryString)
{
ConnectionOptions co = new ConnectionOptions();
string hostname = !string.IsNullOrEmpty(ip) ? NetManager.GetRemoteHostName(ip) : "";
co.Username = (string.IsNullOrEmpty(hostname)?"":hostname+ "\\" ) + username;
co.Password = password;
ManagementScope scm = string.IsNullOrEmpty(ip) || ip.Trim()=="" || ip.ToLower().Trim() == "localhost" || ip.ToLower().Trim() == "127.0.0.1" ?
new ManagementScope(@"\\localhost\root\cimv2"):new ManagementScope(@"\\" + ip + @"\root\cimv2", co);
ManagementObjectSearcher query = new ManagementObjectSearcher(scm, oq);
return query.Get();
}
但linux主机获取不全面
欢迎提交linux硬件信息获取通用的shell命令
文章标题:C#获取远程计算机硬件信息实例(支持linux和windows)
文章链接:http://soscw.com/essay/28104.html