System.Windows.Forms namespace has SystemInformation class. The class has various static properties. To get information about the current system environment, use the class.
To determine the startup mode of the system, use BootMode property. The property can have values : Normal, FailSafe or FailSafeWithNetwork. All these values are defined in BootMode enumeration of System.Windows.Forms namespace.
using System.Windows.Forms;
//Add reference to System.Windows.Forms assembly.
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine(SystemInformation.BootMode.ToString());
}
}
}
To access the computer name, use ComputerName property.
To find out number of displays connected to machine, MonitorCount propery will help us.
Availability of mouse can be checked with the help of property MousePresent.
{
if(SystemInformation.MousePresent)
Console.WriteLine("System has the mouse connected");
}
To check for network connection availability, use Network property.
Console.WriteLine("System is connected to the network.");
No comments:
Post a Comment