PDA

Click to See Complete Forum and Search --> : Internet connection


ATBzzz
Aug 23rd, 2000, 08:26 AM
Hi,

how can i start an internet connection using API ?

Thanks

Aug 23rd, 2000, 02:49 PM
Try this:

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

If that doesn't work, you can always do this:

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

ATBzzz
Aug 23rd, 2000, 04:49 PM
it's strange : i have not the InternetAutoDial api

vbzero
Aug 23rd, 2000, 05:14 PM
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

Krass
Aug 31st, 2000, 11:45 AM
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.

vbzero
Aug 31st, 2000, 11:55 AM
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.

Krass
Aug 31st, 2000, 01:02 PM
Was that reply for me? If so, I didn't understand what you meant.

hitcgar
Sep 1st, 2000, 03:10 PM
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:

Krass
Sep 2nd, 2000, 03:28 PM
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.