Gerade gefunden....
Ramses
Hallo
... bei Nicolai, getestet und funktioniert.
Bringt auch den richtigen Status bei LAN-Verbindungen
Option Explicit
'****************************************************
'Von Nicolai Stiehl. Dort ebenfalls unbekannter Autor
'Start Code Sequenz
'-
'Check internet connection state
'Internetverbindung überprüfen
'There is plenty of code around to show you
'how to detect connections to the internet
'when using Dial Up Networking.'
'But how about internet connections over a LAN?
'This code solves your problems.
'Add this code to a module :
'Es gibt genug Code um zu prüfen,
'ob eine Verbindung zum Internet besteht,
'wenn eine DFÜ Verbindung besteht.
'Dieser Code prüft, ob eine Internetverbindung
'über das LAN besteht.
'Fügen Sie diesen Code in ein Modul:
Public Declare
Function InternetGetConnectedState _
Lib "wininet.dll" (ByRef lpSFlags As Long, _
ByVal dwReserved As Long) As Long
Public Const INTERNET_CONNECTION_LAN As Long = &H2
Public Const INTERNET_CONNECTION_MODEM As Long = &H1
Public
Function Online() As Boolean
'If you are online it will return True, otherwise False
Online = InternetGetConnectedState(0&, 0&)
End Function
Public
Function ViaLAN() As Boolean
Dim SFlags As Long
'return the flags associated with the connection
Call InternetGetConnectedState(SFlags, 0&)
'True if the Sflags has a LAN connection
ViaLAN = SFlags And INTERNET_CONNECTION_LAN
End Function
Public
Function ViaModem() As Boolean
Dim SFlags As Long
'return the flags associated with the connection
Call InternetGetConnectedState(SFlags, 0&)
'True if the Sflags has a modem connection
ViaModem = SFlags And INTERNET_CONNECTION_MODEM
End Function
' Den Code einem Formular mit einer Befehlsschaltfläche und 3 Textfeldern hinzufügen
' Der Wert "True" wird für die entsprechende Verbindung zurückgegeben
Sub Check_Online_State()
' Diesen Code der Befehlsschaltfläche hinterlegen
If ViaLAN() = True Then MsgBox "Connect via LAN möglich"
If ViaModem() = True Then MsgBox "Connect via LAN möglich"
If Online() = True Then MsgBox "Sie sind bereits DRIN "
End Sub
'****************************
'Ende Code Sequenz
Gruss Rainer