СообЧа > База Знаний > Программирование > Visual Basic

Вопрос

Существует ли API функций, которая определяет подключен я к Интернету или нет.

Ответ

Private Const INTERNET_CONNECTION_CONFIGURED = &H40
Private Const INTERNET_CONNECTION_LAN = &H2
Private Const INTERNET_CONNECTION_MODEM = &H1
Private Const INTERNET_CONNECTION_OFFLINE = &H20
Private Const INTERNET_CONNECTION_PROXY = &H4
Private Const INTERNET_RAS_INSTALLED = &H10
Private Declare Function InternetGetConnectedState Lib "wininet.dll"
(ByRef lpdwFlags As Long, ByVal dwReserved As Long) As Long
Private Sub Form_Load()
     'KPD-Team 2001
     'URL: http://www.allapi.net/
     'E-Mail: KPDTeam@Allapi.net
     Dim Ret As Long
     Me.AutoRedraw = True
     'retrieve the connection status
     InternetGetConnectedState Ret, 0&
     'show the result
     If (Ret And INTERNET_CONNECTION_CONFIGURED) = _
INTERNET_CONNECTION_CONFIGURED Then Me.Print "Local system has a valid _
connection to the Internet, but it may or may not be currently _
connected."
  If (Ret And INTERNET_CONNECTION_LAN) = INTERNET_CONNECTION_LAN _
Then Me.Print "Local system uses a local area network to connect to the _
Internet."
  If (Ret And INTERNET_CONNECTION_MODEM) = INTERNET_CONNECTION_MODEM _
Then Me.Print "Local system uses a modem to connect to the Internet."
     If (Ret And INTERNET_CONNECTION_OFFLINE) = _
INTERNET_CONNECTION_OFFLINE Then Me.Print "Local system is in offline _
mode."
  If (Ret And INTERNET_CONNECTION_PROXY) = INTERNET_CONNECTION_PROXY _
Then Me.Print "Local system uses a proxy server to connect to the _
Internet."
  If (Ret And INTERNET_RAS_INSTALLED) = INTERNET_RAS_INSTALLED Then _
Me.Print "Local system has RAS installed."
End Sub

Хвастунов Михаил



Copyright © 2000-2004 Сообщество Чайников
Контактная информация