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
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones AWS Cloud
by AWS Developer Relations
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones
AWS Cloud
by AWS Developer Relations
The Latest "Software Integration: The Intersection of APIs, Microservices, and Cloud-Based Systems" Trend Report
Get the report
  1. DZone
  2. Data Engineering
  3. Databases
  4. Network List Manager API wrapped for .NET

Network List Manager API wrapped for .NET

Denzel D. user avatar by
Denzel D.
·
Apr. 21, 10 · Interview
Like (0)
Save
Tweet
Share
9.35K 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

  • File Uploads for the Web (2): Upload Files With JavaScript
  • Using Swagger for Creating a PingFederate Admin API Java Wrapper
  • Introduction to Containerization
  • Implementing PEG in Java

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • 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: