ASP.NET Core 2.2 and Angular 7 : Instructor-led online courses conducted by Bipin Joshi. Next batches starting in February 2019. Limited seats. More details are available here
Obtaining System Information
In certain applications you need to know system level settings of the machine where it is being executed. For example, you may want to know whether the machine is connected to a network, whether it has right handed mouse or left handed etc. The SystemInformation class from System.Windows.Forms namespace makes such information available to you. I guess this class is present in System.Windows.Forms namespace because such requirements more commonly arise in windows based application than web or any other applications. The SystemInformation class consists of static (shared in VB.NET) properties only. In this article I will explain some of them that are more useful.
Determining the Boot Mode of the system
By Boot Mode it means how the system is started - Normally, in Safe Mode or in Safe Mode with network support. This information is given by BootMode property. The property returns a value that is of type BootMode enumeration. The possible values are Normal, FailSafe (safe mode) and FailSafeWithNetwork (safe mode with network support).
Determining whether computer is connected with network
You can easily check whether your computer is connected to a network using Network property. This property returns True if the machine is connected to network false otherwise.
Determining whether security manager is available with the OS
Windows NT and 2000 comes with Security Manager that governs file system security. Such security is not available for Windows95/98 machines. The Secure property indicates whether security is present on the machine (true) or not (false).
Determining whether mouse is present
You can check whether a mouse is attached to the machine using MousePresent property. This property returns true if mouse is attached false otherwise.
Determining number of mouse buttons
You can know how many buttons the mouse has using the MouseButtons property. This property returns an integer indicating number of buttons.
Determining whether mouse buttons are swapped
Windows allows lot of customization to the users. You can swap functionality of right and left mouse buttons. You can determine whether these buttons are swapped using a boolean property - MouseButtonsSwapped.
Determining whether sound feedback is on
Windows allows various sounds when your application performs certain action. For example, on a sound enabled system if you delete a file you can get a sound feedback. You can check whether this sound feedback is turned on or not using a boolean property called ShowSounds. This can be used to provide accessibility features in your application.
Determining computer name
Another frequently needed information is computer name on which the application is running. You can get that by using ComputerName property.
Determining domain name
Domain name for the currently logged in user is returned by a string property - UserDomainName. For stand alone machines this property returns computer name.
Determining user name
This is one of the common requirement in windows forms applications. You can get the name of currently logged in user via UserName property.
Determining whether current process is running interactively
Some applications can not be run in interactive fashion. For example, ASP.NET pages can not have something like message box in the server side code. You can check whether a the current process is running interactively with the user using UserInteractive property (true/false).
.NET provides many easy to use classes that make programmer's life easy. System.Windows.Forms.SystemInformation is such a class. This class has static properties only. We saw many useful properties of the class.
Posted On : 11 January 2003
Tags : .NET Framework Windows Forms VB.NET C#
is a software consultant, trainer, author, yoga mentor, and spiritual guide having 23+ years of experience in software development, consulting, and training. He conducts instructor-led online training courses
in ASP.NET Core, ASP.NET MVC, and Design Patterns for individuals and small groups. He is a published author and has authored or co-authored books for Apress and Wrox press. Having embraced the Yoga way of life he also teaches Ajapa Yoga
to interested individuals. To know more about him click here
Get connected : Twitter Facebook