Windows 8 detection network

Source: Internet
Author: User

It is easy to use to detect networks on Windows 8

Networkinformation class

The class contains the following methods and events:

 
Public static event networkstatuschangedeventhandler networkstatuschanged; // public static ireadonlylist <connectionprofile> getconnectionprofiles (); public static ireadonlylist 
VaR ICP = networkinformation. getinternetconnectionprofile (); If (ICP! = NULL & ICP. networkadapter! = NULL) {var hostname = networkinformation. gethostnames (). singleordefault (HN => hn. ipinformation! = NULL & hn. ipinformation. networkadapter. networkadapterid = ICP. networkadapter. networkadapterid); system. diagnostics. debug. writeline ("available network IP:" + hostname. displayname); system. diagnostics. debug. writeline ("network status:" + ICP. getnetworkconnectivitylevel ());}

Use

 
Networkinformation. getinternetconnectionprofile (); obtain the networkadapter network device after obtaining the network configuration.
 
Getnetworkconnectivitylevel () to get the status of the current network, which is an enumeration type, as follows:
// Summary: // No connectivity. none = 0, // Summary: // local network access only. localaccess = 1, // Summary: // limited Internet access. this value indicates captive portal connectivity, // where local access to a web portal is provided, but access to the internet // requires that specific credentials are provided by the portal. this level // of connectivity is generally encountered when using connections hosted in // public locations (e.g. coffee shops and book stores ). // limited access constrainedinternetaccess = 2, /// Summary: // local and Internet access. internet access internetaccess = 3,

You can use networkstatuschanged in networkinformation to listen for network changes and perform corresponding processing.

You are welcome to reprint it. Please indicate that it is fromBeyondblog blog

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.