is it connected to the internet?
i want to find out if the computer that my program is running,
is connected to the internet!
i tried this code that i found here,
but it shows that i'm always online, which is false,
cuz i unplug my connection
here's the code:
VB Code:
Private Const INTERNET_OPEN_TYPE_DIRECT = 1
Private Const INTERNET_FLAG_NO_CACHE_WRITE = &H4000000
Private Declare Function InternetOpen Lib "wininet.dll" _
Alias "InternetOpenA" _
(ByVal lpszAgent As String, _
ByVal dwAccessType As Long, _
ByVal lpszProxyName As String, _
ByVal lpszProxyBypass As String, _
ByVal dwFlags As Long) As Long
Private Declare Function InternetCloseHandle Lib "wininet.dll" _
(ByVal hEnumHandle As Long) As Long
Public Function InternetConnectOpen() As Boolean
Dim hInternet As Long
InternetConnectOpen = False
hInternet = InternetOpen("Vb FTP Transfer", INTERNET_OPEN_TYPE_DIRECT, _
vbNullString, vbNullString, INTERNET_FLAG_NO_CACHE_WRITE)
If hInternet > 0 Then InternetConnectOpen = True
Call InternetCloseHandle(hInternet)
hInternet = 0
End Function
Private Sub Command1_Click()
If InternetConnectOpen Then
MsgBox "online"
Else
MsgBox "offline"
End If
End Sub