|
-
Aug 22nd, 2000, 03:11 PM
#1
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.
-
Aug 22nd, 2000, 03:22 PM
#2
Fanatic Member
Hi Sc0rp,
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.
-
Aug 22nd, 2000, 04:20 PM
#3
Problem
There's a problem with this code
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 connected then it returns - true.
If I'm NOT connected it also returns - true.
Any ideas?
BTW, is it true that 'wininet.dll' comes with IE4?
-
Aug 22nd, 2000, 04:31 PM
#4
Frenzied Member
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
-
Aug 22nd, 2000, 04:42 PM
#5
That doesn't work as well
-
Aug 22nd, 2000, 04:53 PM
#6
Frenzied Member
It works for me in my program...email me, I'll send it to you
[email protected]
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|