代码如下:
/// <summary>
/// 操作系统名称
/// </summary>
/// <returns></returns>
public string getOSInfo()
{
return System.Environment.OSVersion.Platform.ToString();
}
/// <summary>
/// 操作系统版本
/// </summary>
/// <returns></returns>
public string getOSVersion()
{
return System.Environment.OSVersion.ToString();
}
/// <summary>
/// 机器名
/// </summary>
/// <returns></returns>
public string getMachineName()
{
return System.Environment.MachineName.ToString();
}
/// <summary>
/// 登录系统的用户名
/// </summary>
/// <returns></returns>
public string getUserName()
{
return System.Environment.UserName.ToString();
}
/// <summary>
/// 获取逻辑盘
/// </summary>
/// <returns></returns>
public string getLogicalDrives()
{
string drivers = "";
string[] logical_drivers = System.Environment.GetLogicalDrives();
foreach (string dr in logical_drivers)
{
drivers += dr + ";";
}
return drivers;
}
/// <summary>
/// 获取网络域名
/// </summary>
/// <returns></returns>
public string getDomainName()
{
return System.Environment.UserDomainName.ToString();
}
/// <summary>
/// 获取网络内存占用
/// </summary>
/// <returns></returns>
public string getUsedMemory()
{
return (System.Environment.WorkingSet/(1024.0*1024.0)).ToString("F")+"M";
}
/// <summary>
/// 公共语言运行库的主版本、次版本、内部版本和修订号
/// </summary>
/// <returns></returns>
public string getFxVersion()
{
return System.Environment.Version.ToString();
}