-
I've looked at several examples of how to detect if there is an internet connection present and how to connect via dial-up. But they all have their problems...what i need is to detect if a connection exists (preferable not using winsock) and if there is no connection then bring up the connect dialog...The examples that i've seen ask for the connection name, but i need to do this with out asking the connection name...just bring up the "connect to" dialog box.
Thanx,
D!m
-
I'm sure there is a better way but you could run the dos command route print and see if 0.0.0.0 0.0.0.0 goes someplace.
-
nm about the detecting part, i can always use good ol registry for that. But how about bringing up the connect box? Anyone?
-
I had this in my notes from a week ago
I never used it
---------------------
FORCE CONNECTION
------------------------
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&)
-
no go, doesn't produce any errors and doesn't seem to do anything. Any ideas?
-
This is about the same code. But it's coming from me, so maybe it will work ;].
Code:
Private Declare Function InternetAutodial Lib "wininet.dll" _
(ByVal dwFlags As Long, ByVal dwReserved As Long) As Long
Private Const INTERNET_AUTODIAL_FORCE_ONLINE = 1
Private Const INTERNET_AUTODIAL_FORCE_UNATTENDED = 2
Private Declare Function InternetAutodialHangup Lib "wininet.dll" _
(ByVal dwReserved As Long) As Long
Private Sub Command1_Click()
'To prompt the user to connect to the Net
If InternetAutodial(INTERNET_AUTODIAL_FORCE_ONLINE, 0) Then
MsgBox "You're Connected!", vbInformation
End If
'To automatically start dialling
If InternetAutodial(INTERNET_AUTODIAL_FORCE_UNATTENDED, 0) Then
MsgBox "You're Connected!", vbInformation
End If
'To disconnect an automatically dialled connection
If InternetAutodialHangup(0) Then
MsgBox "You're Disconnected!", vbInformation
End If
End Sub
-
It does seem to work...but i think i'm missing something here cause it just seems to check if there is a connection. It pops up 3 msgboxes "You Are Connected" "You Are connected" "You are disconnected"
I did go offline to test it, but same events occur.
Any ideas Matthew?
-
I do have a code that'll connect you, but only if you know the connections name.
Code:
'Start an internet connection only showing the dialog
Dim X
'connection_name=ISP (Ex: Netzero, Freeinternet)
X = Shell("rundll32.exe rnaui.dll,RnaDial " _
& "connection_name", 1)
'Start an internet connection and click connect
Dim X
'connection_name=ISP (Ex: Netzero, Freeinternet)
X = Shell("rundll32.exe rnaui.dll,RnaDial " & "connection_name", 1)
DoEvents
'You can type in your password before the { below.
SendKeys "{enter}", True
DoEvents