DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
  • Refcardz
  • Trend Reports
  • Webinars
  • Zones
  • |
    • Agile
    • AI
    • Big Data
    • Cloud
    • Database
    • DevOps
    • Integration
    • IoT
    • Java
    • Microservices
    • Open Source
    • Performance
    • Security
    • Web Dev
DZone >

Network List Manager API wrapped for .NET

Denzel D. user avatar by
Denzel D.
·
Apr. 21, 10 · · Interview
Like (0)
Save
Tweet
8.94K Views

Join the DZone community and get the full member experience.

Join For Free

One important feature in some of the modern application is the ability to interact with networks of various kinds. However, to get the information directly for a local network (the one the computer is connected to) some extensive API work is required. Windows API Code Pack (WACP) for .NET Framework wraps this API in a set of classes that can be used from a managed application, therefore the developer won’t have to use the system API directly.


The entire Network List Manager API in a managed application with WACP is based on the NetworkListManager class. The hierarchy of properties and methods is outlined below:
 


Via this class, the developer can access the current registered networks (related to the local machine). For example, here is how to get a collection of networks:

NetworkCollection nCollection = NetworkListManager.GetNetworks(NetworkConnectivityLevels.All);

Note that I am querying all networks. NetworkConnectivityLevels can also be Connected or Disconnected. The resulting collection will represent the set of networks registered on the current machine, that also expose a set of properties. Those are outlined below for the Network class:
 


The developer can easily iterate through the networks in the collection to read the properties:

foreach (Network net in nCollection)
{

}

Now, you might be wondering – what is the NetworkId property used for. If you get the network GUID, you can later on query that specific network by calling something similar to this:

Network net = NetworkListManager.GetNetwork(networkID);

Notice the fact that there are two bool properties that are often requested in various applications. Verifying whether a network is generally connected or connected to Internet required is performed by manually checking for the availability of a web resource. This isn’t really a big issue if there is a single network registered, however, if there are more than 1 networks installed, checking each one for connectivity status can become quite complicated. By using the NLM API wrapper the developer can easily track this property for multiple networks, if those are present.


A similar process is applied to connections – the NetworkListManager is able to pick up a list of registered connections or one single connection, if the proper GUID is passed, although those are exposing a different set of properties.


The network IPs are not determined with the help of this wrapper, so the need in direct API calls and web service access is still needed to perform this specific task.

API Network

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • OPC-UA, MQTT, and Apache Kafka: The Trinity of Data Streaming in IoT
  • Ultra-Fast Microservices: When Microstream Meets Wildfly
  • 10 Steps to Become an Outstanding Java Developer
  • Refactoring Java Application: Object-Oriented And Functional Approaches

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • MVB Program
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends:

DZone.com is powered by 

AnswerHub logo