Two Questions:
How do I detect if the user is connected to the internet?
If not, how do I launch the default dial-up connection?
Printable View
Two Questions:
How do I detect if the user is connected to the internet?
If not, how do I launch the default dial-up connection?
Code:'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
'to check if online, text1 will be true if online
Text1 = Online()
'This was a demo project from vb world.
' It had some problems in the module
' that I fixed up.
Thanks, now I just need to know how to connect if there isn't already an active connection.
http://www.vbsquare.com/tips/tip168.html
try this, its also a tip, Im not sure if its what you want though.
That is EXTREMELY close to what I want, the only problem is that it has to have the name of the connection, ie Mine is Olemac, not Freeserve.
Is there any way to detect the name or some alternate way to connect?
Nevermind, I searched through some forum postings for a while for "connect internet" and found one that had this code in it:
Thanks for your help regardless.Code:Const Internet_Autodial_Force_Unattended As Long = 2
Public Declare Function InternetAutodial Lib "wininet.dll" (ByVal dwFlags As
Long, ByVal dwReserved As Long) As Long
Public Declare Function InternetAutodialHangup Lib "wininet.dll" (ByVal
dwReserved As Long) As Long
'Code:
Dim lResult As Long
lResult = InternetAutodial(Internet_Autodial_Force_Unattended, 0&