|
-
Aug 23rd, 2000, 08:26 AM
#1
Thread Starter
Junior Member
Hi,
how can i start an internet connection using API ?
Thanks
-
Aug 23rd, 2000, 02:49 PM
#2
Try 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
If that doesn't work, you can always do this:
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
-
Aug 23rd, 2000, 04:49 PM
#3
Thread Starter
Junior Member
it's strange : i have not the InternetAutoDial api
-
Aug 23rd, 2000, 05:14 PM
#4
Hyperactive Member
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
-
Aug 31st, 2000, 11:45 AM
#5
Hyperactive Member
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.
-
Aug 31st, 2000, 11:55 AM
#6
Hyperactive Member
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.
-
Aug 31st, 2000, 01:02 PM
#7
Hyperactive Member
Was that reply for me? If so, I didn't understand what you meant.
-
Sep 1st, 2000, 03:10 PM
#8
Lively Member
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.
-
Sep 2nd, 2000, 03:28 PM
#9
Hyperactive Member
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.
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
|