C#获取当前系统信息的类
来源:互联网 发布:mysql有什么用 编辑:程序博客网 时间:2024/05/16 18:59
/// <summary>
/// Class designed to give information/// about the current system
/// </summary>
public static class Environment
{
#region Public Static Properties
/// <summary>
/// Name of the machine running the app
/// </summary>
public static string MachineName
{
get { return System.Environment.MachineName; }
}
/// <summary>
/// Gets the user name that the app is running under
/// </summary>
public static string UserName
{
get { return System.Environment.UserName; }
}
/// <summary>
/// Name of the domain that the app is running under
/// </summary>
public static string DomainName
{
get { return System.Environment.UserDomainName; }
}
/// <summary>
/// Name of the OS running
/// </summary>
public static string OSName
{
get { return System.Environment.OSVersion.Platform.ToString(); }
}
/// <summary>
/// Version information about the OS running
/// </summary>
public static string OSVersion
{
get { return System.Environment.OSVersion.Version.ToString(); }
}
/// <summary>
/// The service pack running on the OS
/// </summary>
public static string OSServicePack
{
get { return System.Environment.OSVersion.ServicePack; }
}
/// <summary>
/// Full name, includes service pack, version, etc.
/// </summary>
public static string OSFullName
{
get { return System.Environment.OSVersion.VersionString; }
}
/// <summary>
/// Gets the current stack trace information
/// </summary>
public static string StackTrace
{
get { return System.Environment.StackTrace; }
}
/// <summary>
/// Returns the number of processors on the machine
/// </summary>
public static int NumberOfProcessors
{
get { return System.Environment.ProcessorCount; }
}
/// <summary>
/// The total amount of memory the GC believes is used
/// by the app in bytes
/// </summary>
public static long TotalMemoryUsed
{
get { return GC.GetTotalMemory(false); }
}
/// <summary>
/// The total amount of memory that is available in bytes
/// </summary>
public static long TotalMemory
{
get
{
long ReturnValue = 0;
ObjectQuery TempQuery = new ObjectQuery("SELECT * FROM Win32_LogicalMemoryConfiguration");
using (ManagementObjectSearcher Searcher = new ManagementObjectSearcher(TempQuery))
{
foreach (ManagementObject TempObject in Searcher.Get())
{
ReturnValue = long.Parse(TempObject["TotalPhysicalMemory"].ToString()) * 1024;
}
}
return ReturnValue;
}
}
#endregion
}
- C#获取当前系统信息的类
- C#获取当前计算机的硬件及系统信息
- iOS获取当前系统的相关信息
- 获取当前ios系统的版本信息
- java 获取当前系统的版本信息
- 获取当前系统的可用内存信息
- C#获取系统当前鼠标的图案
- c#获取当前系统的时间
- java获取当前系统信息
- java获取当前系统信息
- Java获取当前系统信息
- Java 获取当前系统信息
- C#获取系统信息
- C# 获取系统信息
- C#获取系统信息
- c#获取系统信息的方式
- C#获取用户系统信息的程序
- 用C#获取MOSS中当前登录用户的信息
- c# 装箱与拆箱问题
- Perl 学习笔记 --- 03
- C#的性能到底有多差?
- 怎样打造高性能的移动用户体验
- 扫雷游戏制作全过程01 地雷生成及表示
- C#获取当前系统信息的类
- 使用Exchange 2007部署邮件记录管理
- 在可以调用 OLE 之前,必须将当前线程设置为单线程单元(STA)模式
- sap 开发ftp功能需要的一些函数
- Expdp/Impdp 并行导入导出详细测试
- oracle中sql语句中判断blob的大小
- 早教:平板电脑的新妙用
- php mongoDB 的curd
- uva 101 the blocks problem