Private Declare Function InternetGetConnectedStateEx Lib "wininet.dll" Alias "InternetGetConnectedStateExA" (lpdwFlags As Long, lpszConnectionName As Long, dwNameLen As Long, ByVal dwReserved As Long) As Long
Private Sub Form_Load()
Dim strConnectionName As String
Dim lNameLen As Long
Dim lRetVal As Long
Dim lConnectionFlags As Long
Dim lPtr As Long
Dim lNameLenPtr As Long
strConnectionName = Space(256)
lNameLen = 256
lPtr = StrPtr(strConnectionName)
lNameLenPtr = VarPtr(lNameLen)
lRetVal = InternetGetConnectedStateEx(lConnectionFlags, ByVal lPtr, ByVal lNameLen, 0&)
If lRetVal <> 0 Then
MsgBox ("Подключено к сети")
Else
MsgBox ("Отключено от сети")
End If
End Sub |
|