Kod: Tümünü seç
#If Win64 Then
Public Flg As LongPtr
Public Declare PtrSafe Function InternetGetConnectedState Lib "wininet.dll" (lpdwFlags As LongPtr, _
ByVal dwReserved As Long) As Boolean
#Else
Public Flg As Long
Public Declare Function InternetGetConnectedState Lib "wininet.dll" (lpdwFlags As Long, _
ByVal dwReserved As Long) As Boolean
#End If
Private Const INTERNET_CONNECTION_MODEM As Long = &H1
Private Const INTERNET_CONNECTION_LAN As Long = &H2
Private Const INTERNET_CONNECTION_PROXY As Long = &H4
Private Const INTERNET_CONNECTION_OFFLINE As Long = &H20
Function IsInternetConnected() As Boolean
Dim R As Long
R = InternetGetConnectedState(Flg, 0&)
If CBool(R) Then
IsInternetConnected = True
Else
IsInternetConnected = False
End If
End Function
Sub main()
If IsInternetConnected Then
MsgBox "İnternete bağlısınız", vbInformation, "Www.ExcelVBA.Net"
Else
MsgBox "İnternet bağlantısı yok", vbInformation, "Www.ExcelVBA.Net"
End If
End Sub