How do I check if a user is connected to the internet and how do I get the name of the connection if he is?
BTW, I tried the various RAS APIs but they only work with dialups.
Printable View
How do I check if a user is connected to the internet and how do I get the name of the connection if he is?
BTW, I tried the various RAS APIs but they only work with dialups.
Check out this previous thread from this site:
http://forums.vb-world.net/showthrea...threadid=10198
Also, I think there's a tutorial on this site that deals with the same topic. Snoop around for it.
All the best.
There's a problem with this code
If I'm connected then it returns - true.Code:Public Declare Function InternetGetConnectedState Lib "wininet.dll" (ByRef lpSFlags As Long, ByVal dwReserved As Long) As Long
Public Function IsOnline() As Boolean
'If you are online it will return True, otherwise False
IsOnline = InternetGetConnectedState(0&, 0&)
End Function
If I'm NOT connected it also returns - true.
Any ideas?
BTW, is it true that 'wininet.dll' comes with IE4?
there is a problem in a module, try this:
Code:'in a button
Text1 = ViaLAN()
Text2 = ViaModem()
Text3 = Online()
If Text3.Text = "True" Then MsgBox "You are online"
If Text3.Text = "False" Then MsgBox "You are not online"
'in Declarations
Private Sub HowConnected_Click()
Text1 = ViaLAN()
Text2 = ViaModem()
Text3 = Online()
If Text2.Text = "True" Then MsgBox "You are connected with a modem"
If Text1.Text = "True" Then MsgBox "You are connected with a LAN"
If Text3.Text = "False" Then MsgBox "You aren't online!"
End Sub
'in a module
Option Explicit
Public Declare Function InternetGetConnectedState _
Lib "wininet.dll" (ByRef lpSFlags As Long, _
ByVal dwReserved As Long) As Long
Public Const INTERNET_CONNECTION_LAN As Long = &H2
Public Const INTERNET_CONNECTION_MODEM As Long = &H1
Public 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
That doesn't work as well :(
It works for me in my program...email me, I'll send it to you
[email protected]