|
/*
* Created by SharpDevelop.
* User: andy
* Date: 01/01/2008
* Time: 13:51
*
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
using System;
namespace uk.org.aspellclark.common
{
/// <summary>
/// Description of SystemInfo.
/// </summary>
public class SystemInfo
{
// Create a logger for use in this class
private static readonly log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
public static string CurrentUsername
{
get {return System.Windows.Forms.SystemInformation.UserName;}
}
public static string CurrentHostname
{
get {return System.Windows.Forms.SystemInformation.ComputerName;}
}
public static string OsVersion
{
get
{
//return Environment.OSVersion.Platform + ":" + Environment.OSVersion.Version;
log.Info(String.Format("Environment.OSVersion [{0}]", Environment.OSVersion));
log.Info(String.Format("Environment.OSVersion.Platform [{0}]", Environment.OSVersion.Platform));
log.Info(String.Format("Environment.OSVersion.Version [{0}]", Environment.OSVersion.Version));
//log.Info(String.Format("Environment.OSVersion.VersionString [{0}]", Environment.OSVersion.VersionString));
//log.Info(String.Format("Environment.OSVersion.ServicePack [{0}]", Environment.OSVersion.ServicePack));
switch (Environment.OSVersion.Platform)
{
//#ifdef _NET_2_0
case PlatformID.Unix:
{
return "unix";
}
//#endif
case PlatformID.Win32S:
{
return "Win 3.1";
}
case PlatformID.Win32Windows:
{
switch (Environment.OSVersion.Version.Minor)
{
case 0:
{
return "Win95";
}
case 10:
{
return "Win98";
}
case 90:
{
return "WinME";
}
default:
{
return "Unknown";
}
}
}
case PlatformID.Win32NT:
{
switch (Environment.OSVersion.Version.Major)
{
case 3:
{
return "NT 3.51";
}
case 4:
{
return "NT 4.0";
}
case 5:
{
return WinNtVersion();
}
}
break;
}
case PlatformID.WinCE:
{
return "Win CE";
}
}
return "Unknown";
}
}
public static string WinNtVersion()
{
switch (Environment.OSVersion.Version.Minor)
{
case 0:
{
return "Win2000";
}
case 1:
{
return "WinXP";
}
case 2:
{
return "Win2003";
}
default:
{
return "unknown";
}
}
}
public static string OsHostname
{
get { return Environment.MachineName; }
}
public static string MyDocumentsPath
{
get { return Environment.GetFolderPath(Environment.SpecialFolder.Personal); }
}
}//class
}//namespace
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.