AW: Ping
26.06.2018 16:18:02
UweD
Hallo
ich hab im Archiv folgendes gefunden:
Option Explicit
Private Declare Function gethostbyname Lib "WSOCK32.DLL" _
(ByVal HostName As String) As Long
Private Declare Function WSAStartup Lib "WSOCK32.DLL" (ByVal _
wVersionRequired As Long, lpWSAData As WinSocketDataType) _
As Long
Private Declare Function WSACleanup Lib "WSOCK32.DLL" () As Long
Const WS_VERSION_REQD As Long = &H101&
Private Type HostDeType
hName As Long
hAliases As Long
hAddrType As Integer
hLength As Integer
hAddrList As Long
End Type
Private Type WinSocketDataType
wversion As Integer
wHighVersion As Integer
szDescription(0 To 128) As Byte
szSystemStatus(0 To 256) As Byte
iMaxSockets As Integer
iMaxUdpDg As Integer
lpszVendorInfo As Long
End Type
Private Function InitSocketAPI() As Long
Dim Result As Integer
Dim SocketData As WinSocketDataType
InitSocketAPI = WSAStartup(WS_VERSION_REQD, SocketData)
End Function
Private Function Check_Connected(Name As String) As String
Dim HostDeAddress As Long
HostDeAddress = gethostbyname(Name)
If HostDeAddress = 0 Then
Check_Connected = "Keine Verbindung"
Else
Check_Connected = "Verbindung besteht"
End If
End Function
wird dann so aufgerufen
Sub Pruefe_Verbindung()
If InitSocketAPI = 0 Then
MsgBox Check_Connected("192.168.178.1") ' hier die IP / oder Website eintragen
Call WSACleanup
Else
MsgBox ("Socket Error! Die Verbindung kann nicht geprüft werden")
End If
End Sub
https://www.herber.de/forum/archiv/1056to1060/1056144_Per_VBA_pruefen_ob_Online.html
LG UweD