C#获取当前系统信息的类

///<summary>

/// Class designed to give information
/// about the current system
/// </summary>
public static classEnvironment
{
#regionPublic Static Properties
/// <summary>
/// Name of the machine running the app
/// </summary>
public static stringMachineName
{
get{ returnSystem.Environment.MachineName;}
}

/// <summary>
/// Gets the user name that the app is running under
/// </summary>
public static stringUserName
{
get{ returnSystem.Environment.UserName;}
}

/// <summary>
/// Name of the domain that the app is running under
/// </summary>
public static stringDomainName
{
get{ returnSystem.Environment.UserDomainName;}
}

/// <summary>
/// Name of the OS running
/// </summary>
public static stringOSName
{
get{ returnSystem.Environment.OSVersion.Platform. ToString();}
}

/// <summary>
/// Version information about the OS running
/// </summary>
public static stringOSVersion
{
get{ returnSystem.Environment.OSVersion.Version. ToString();}
}

/// <summary>
/// The service pack running on the OS
/// </summary>
public static stringOSServicePack
{
get{ returnSystem.Environment.OSVersion.ServicePack;}
}

/// <summary>
/// Full name, includes service pack, version, etc.
/// </summary>
public static stringOSFullName
{
get{ returnSystem.Environment.OSVersion.VersionString;}
}

/// <summary>
/// Gets the current stack trace information
/// </summary>
public static stringStackTrace
{
get{ returnSystem.Environment.StackTrace;}
}

/// <summary>
/// Returns the number of processors on the machine
/// </summary>
public static intNumberOfProcessors
{
get{ returnSystem.Environment.ProcessorCount;}
}

/// <summary>
/// The total amount of memory the GC believes is used
/// by the app in bytes
/// </summary>
public static longTotalMemoryUsed
{
get{ returnGC. GetTotalMemory( false);}
}

/// <summary>
/// The total amount of memory that is available in bytes
/// </summary>
public static longTotalMemory
{
get
{
longReturnValue = 0;
ObjectQuery TempQuery = new ObjectQuery( "SELECT * FROM Win32_LogicalMemoryConfiguration");
using(ManagementObjectSearcher Searcher = new ManagementObjectSearcher(TempQuery))
{
foreach(ManagementObject TempObject inSearcher. Get())
{
ReturnValue = long. Parse(TempObject[ "TotalPhysicalMemory"]. ToString())* 1024;
}
}
returnReturnValue;
}
}
#endregion
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值