Check whether the network connection is normal

Source: Internet
Author: User

Header file wininet. h
Static library wininet. Lib

Bool internetgetconnectedstate (
Out lpdword lpdwflags,
In DWORD dwreserved
);

 

DWORD flags; // Internet Access Method
Bool m_bonline; // online or not
M_bonline = internetgetconnectedstate (& flags, 0 );
If (m_bonline) // online
{
Switch (& flags)
{

Case internet_connection_modem:
Afxmessagebox ("online: dial-up Internet ");
Break;
Case internet_connection_lan:
Afxmessagebox ("online: via LAN ");
Break;
Case internet_connection_proxy:
Afxmessagebox ("online: proxy ");
Break;
}
If (& flags = internet_connection_modem_busy)
Afxmessagebox ("modem is occupied by other non-Internet connections ");
}
Else
Afxmessagebox ("not online ");

 

In addition, there are more explanations on msdn:

Parameters

Lpdwflags
Address of an unsigned long integer variable where the connection description shocould be returned. This can be a combination of the following values:
Internet_connection_configured
Local system has a valid connection to the Internet, but it may or may not be currently connected.
Internet_connection_lan
Local system uses a local area network to connect to the Internet.
Internet_connection_modem
Local system uses a modem to connect to the Internet.
Internet_connection_modem_busy
No longer used.
Internet_connection_offline
Local System is in offline mode.
Internet_connection_proxy
Local system uses a proxy server to connect to the Internet.
Internet_ras_installed
Local System has Ras installed.
Dwreserved
Reserved. must be set to zero.
Return Value

Returns true if there is an Internet connection, or false otherwise.

Function Information

Windows NT use version 4.0. implemented only as an ANSI function.
Windows use Windows 95 and later. implemented only as an ANSI function.
Header wininet. h
Import library wininet. Lib
Minimum availability Internet Explorer 4.0


The returned value contains internet_connection_offline to determine whether it is offline.

 

 

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.