kann ich irgendwie mit VBA feststellen, ob eine Onlineverbindung besteht?
Gruß Frank
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
Option Explicit
Private Declare Function RasEnumConnections Lib "rasapi32.dll" Alias "RasEnumConnectionsA" (lpRasCon As Any, lpcb As Long, lpcConnections As Long) As Long
Private Enum Constant
RAS_MaxEntryName = 256
RAS_MaxDeviceType = 16
RAS_MaxDeviceName = 32
Max_Fill = 96
End Enum
Private Type RASType
dwSize As Long
hRasCon As Long
szEntryName(RAS_MaxEntryName) As Byte
szDeviceType(RAS_MaxDeviceType) As Byte
szDeviceName(RAS_MaxDeviceName) As Byte
dwFill(Max_Fill) As Byte
End Type
Public Sub Test()
Dim RAS(255) As RASType
Dim lg As Long, lpcon As Long
RAS(0).dwSize = 412
lg = 256 * RAS(0).dwSize
RasEnumConnections RAS(0), lg, lpcon
If lpcon = 0 Then
MsgBox "Keine Online-Verbindung gefunden", 64, "Information"
Else
MsgBox "Online-Verbindung steht", 64, "Information"
End If
End Sub
Option Explicit
Declare Function InternetGetConnectedState Lib "wininet.dll" (ByRef K As Long, ByVal Rola As Long) As Long
Sub teste_online()
Dim ol As Boolean
ol = InternetGetConnectedState(0&, 0&)
If ol Then
MsgBox "Verbindung besteht!"
Else
MsgBox "Nix da!"
End If
End Sub