Note: the main body of this Code is composedXt0050 is provided, and 911 only sorts it out.
Using system;
Using system. Collections. Generic;
Using system. componentmodel;
Using system. Data;
Using system. drawing;
Using system. text;
Using system. Windows. forms;
Using system. runtime. interopservices;
Namespace pinyin
{
Public partial class form4: Form
{
// Define a constant
Private const long internet_connection_modem = 1; // local system uses a modem to connect to the Internet.
Private const long internet_connection_lan = 2; // local system uses a local area network to connect to the Internet.
Private const long internet_connection_proxy = 4; // local system uses a proxy server to connect to the Internet.
Private const long internet_connection_modem_busy = 8; // no longer used.
Private const long internet_connection_configured = 64; // local system has a valid connection to the Internet, but it might or might not be currently connected.
Private const long internet_connection_offline = 32; // local system is in offline mode.
Private const long internet_ras_installed = 16; // local system has Ras installed.
Public form4 ()
{
Initializecomponent ();
}
// Define (reference) API functions
[Dllimport ("wininet. dll")]
Public static extern bool internetgetconnectedstate (out long lpdwflags, long dwreserved );
Private void button#click (Object sender, eventargs E)
{
Long lfag;
String strconnectiondev = "";
If (internetgetconnectedstate (Out lfag, 0 ))
Strconnectiondev = "the network connection is normal! ";
Else
Strconnectiondev = "network connection unavailable! ";
If (lfag & internet_connection_offline)> 0)
Strconnectiondev + = "offline local system is in offline mode. ";
If (lfag & internet_connection_modem)> 0)
Strconnectiondev + = "modem: the local system uses a modem to connect to the Internet. ";
If (lfag & internet_connection_lan)> 0)
Strconnectiondev + = "LAN Local system uses a LAN to connect to the Internet. ";
If (lfag & internet_connection_proxy)> 0)
Strconnectiondev + = "a proxy ";
If (lfag & internet_connection_modem_busy)> 0)
Strconnectiondev + = "modem but modem is busy ";
MessageBox. Show (strconnectiondev );
}
}
}