/// <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
}
From weizhiai12's column