asp.net 获取系统中参数的实现代码
程序员文章站
2024-03-06 13:12:14
复制代码 代码如下: /// /// 操作系统名称 /// /// <...
复制代码 代码如下:
/// <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();
}