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

///<summary>

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

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

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

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

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

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

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

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

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值