ghudson
Registered User.
- Local time
- Today, 03:58
- Joined
- Jun 8, 2002
- Messages
- 6,194
Anyone have a fail proof way to detect if a user has opened a database with a wireless connection? I found this code @ http://www.experts-exchange.com/Sof...Office_Suites/MS_Office/Excel/Q_23102110.html but I am not able to test it since I do not have access to a wireless connection. Anyone have a moment to test if the IsInternetConnectionWireless() function will really test TRUE if you are running the code while your computer is connected to a wireless network? The TesingConnectionType() function will quickly run all three tests. Thanks!
I am correctly getting True for the IsInternetConnectionLAN and InternetConnected functions and a False for the IsInternetConnectionWireless function so I am hoping that the IsInternetConnectionWireless function will correctly test True when run from a computer connected wirelessly. Thanks!
Code:
Private Const INTERNET_CONNECTION_LAN = &H2
Private Const INTERNET_CONNECTION_MODEM = &H1
Private Const FLAG_ICC_FORCE_CONNECTION = &H1
Private Declare Function InternetGetConnectedState Lib "wininet.dll" (ByRef lpdwFlags As Long, ByVal dwReserved As Long) As Long
Private Declare Function InternetCheckConnection Lib "wininet.dll" Alias "InternetCheckConnectionA" (ByVal lpszUrl As String, ByVal dwFlags As Long, ByVal dwReserved As Long) As Long
Public Sub TesingConnectionType()
Call IsInternetConnectionLAN
MsgBox "IsInternetConnectionLAN = " & IsInternetConnectionLAN
Call InternetConnected
MsgBox "InternetConnected = " & InternetConnected
Call IsInternetConnectionWireless
MsgBox "IsInternetConnectionWireless = " & IsInternetConnectionWireless
End Sub
Public Function IsInternetConnectionLAN() As Boolean
On Error GoTo Err_IsInternetConnectionLAN
Dim Result As Boolean
Dim Flags As Long
Result = InternetGetConnectedState(Flags, 0&)
If Flags > 0 Then
IsInternetConnectionLAN = True
End If
Exit_IsInternetConnectionLAN:
Exit Function
Err_IsInternetConnectionLAN:
MsgBox Err.Number & " - " & Err.Description, vbCritical, "IsInternetConnectionLAN()"
Resume Exit_IsInternetConnectionLAN
End Function
Private Function InternetConnected()
On Error GoTo Err_InternetConnected
If InternetCheckConnection("http://www.google.com/", FLAG_ICC_FORCE_CONNECTION, 0&) = 0 Then
InternetConnected = False
Else
InternetConnected = True
End If
Exit_InternetConnected:
Exit Function
Err_InternetConnected:
MsgBox Err.Number & " - " & Err.Description, vbCritical, "InternetConnected()"
Resume Exit_InternetConnected
End Function
Public Function IsInternetConnectionWireless() As Boolean
On Error GoTo Err_IsInternetConnectionWireless
IsInternetConnectionWireless = Not IsInternetConnectionLAN And InternetConnected
Exit_IsInternetConnectionWireless:
Exit Function
Err_IsInternetConnectionWireless:
MsgBox Err.Number & " - " & Err.Description, vbCritical, "IsInternetConnectionWireless()"
Resume Exit_IsInternetConnectionWireless
End Function
I am correctly getting True for the IsInternetConnectionLAN and InternetConnected functions and a False for the IsInternetConnectionWireless function so I am hoping that the IsInternetConnectionWireless function will correctly test True when run from a computer connected wirelessly. Thanks!