Real World Scenario of using Visual Basic. Devices with C#

June 25th, 2014 | Posted by Vidya Vrat in .NET | C#

Abstract

In this article I will share some real-world problems that appear to be complex, but with usage of Microsoft.VisualBasic.Devices those can be easily done.

Scenario

You are working on an application and you come across any of the following requirements before any action can possibly take place:

  • Verify OS name.
  • Make sure CAPS is ON or NOT (as per your application’s need)
  • Check Network availability before you open a browser or load the site.
  • Does the mouse have a wheel?
  • Ability to Ping a URI or Computer’s IP before your entire business logic starts executing.

Introduction

All of the preceding specified situations are valid and used in many real-world applications, the issue is that none of them appear straightforward to implement, as it involves:

  • Communication with Operating System; to know the OS name
  • Communication with Hardware; to know if CAPS is ON or OFF
  • Communication with Network Adaptor; to check if Computer is connected to Network on not
  • Communication with Hardware pointing device; Mouse has wheel or not
  • Perform some action over the network; Pinging a computer or URL

Solution

Microsoft.VisualBasic.Devices is a namespace that helps in such scenarios. The following code example shows the use of various classes.

In order to use Microsoft.VisualBasic.Devices namespace you must add a reference of it to your project/application.

Continue Reading…

 

 

You can follow any responses to this entry through the RSS 2.0 You can leave a response, or trackback.

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.