C # class for retrieving Current System Information

Source: Internet
Author: User

/// <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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.