Hi,
how can i start an internet connection using API ?
Thanks
Printable View
Hi,
how can i start an internet connection using API ?
Thanks
Try this:
If that doesn't work, you can always do this:Code:Private Const INTERNET_AUTODIAL_FORCE_ONLINE = 1
Private Const INTERNET_AUTODIAL_FORCE_UNATTENDED = 2
Private Declare Function InternetAutodial Lib "wininet.dll"_
(ByVal dwFlags As Long, ByVal dwReserved As Long) As Long
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 dialed connection
If InternetAutodialHangup(0) Then
MsgBox "You're Disconnected!", vbInformation
End If
End Sub
Code:Private Sub Command1_Click()
Dim X
'Replace ConnectionName with something like Netzero
'or a Dial-Up Connection in your Dial-Up Networking Folder
X = Shell("rundll32.exe rnaui.dll,RnaDial " & "ConnectionName", 1)
DoEvents
'You can type in your password before the { below.
SendKeys "{enter}", True
DoEvents
End Sub
it's strange : i have not the InternetAutoDial api
If you don't have a dialup connection you can also use
the winsock control to establish a connection to the
internet, or maybe to another computer.
To see an example check out the MSDN examples for
winsock.
sub-zero
Visual Studio 6.0 Enterprise Edition
I am also using these methods. But I couldn't find out how to know if the user is currently connected to the internet.
I don't want it to auto-dial if not connected, I just want to know if, TRUE OR FALSE, the computer currently is connected to the internet.
Then it would be usefull when you try to ping the host.
But note: If the other side uses a firewall and echo reply and echo request is disabled then you can't know if the computer is offline.
Was that reply for me? If so, I didn't understand what you meant.
if you didn't understand that last post (vbzero) the you
should probably take some time and study how the internet
and networks in general work before tackling an actual
application.
I suggest you search the web for tutorials on this.
You have to check both dial-up connections AND proxy server connections.
Checking for all of this is complexe enough to warrant
using an ActiveX control or canned code that does it for you.
I think some of the controls shipped with IE can do this.
:cool:
Couldn't I just ping myself instead of the host? Unless pinging myself also works when not on the net?!.. which I doubt.
I think that would be a solution to my problem. Checking both dial-up and proxy is a very bad thing.