首页 > 编程 > .NET > 正文

asp.net 获取系统中参数的实现代码

2020-01-18 00:35:16
字体:
来源:转载
供稿:网友
复制代码 代码如下:

/// <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();
}
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表