`
hududanyzd
  • 浏览: 780384 次
文章分类
社区版块
存档分类
最新评论

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
}
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics