Results 1 to 9 of 9

Thread: Internet connection

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jul 2000
    Posts
    22

    Question

    Hi,

    how can i start an internet connection using API ?

    Thanks

  2. #2
    Guest
    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

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Jul 2000
    Posts
    22

    Exclamation

    it's strange : i have not the InternetAutoDial api

  4. #4
    Hyperactive Member vbzero's Avatar
    Join Date
    Aug 2000
    Location
    Vienna
    Posts
    347

    Exclamation

    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

  5. #5
    Hyperactive Member Krass's Avatar
    Join Date
    Aug 2000
    Location
    Montreal
    Posts
    489
    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.
    Chris

  6. #6
    Hyperactive Member vbzero's Avatar
    Join Date
    Aug 2000
    Location
    Vienna
    Posts
    347

    Exclamation

    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.

  7. #7
    Hyperactive Member Krass's Avatar
    Join Date
    Aug 2000
    Location
    Montreal
    Posts
    489
    Was that reply for me? If so, I didn't understand what you meant.
    Chris

  8. #8
    Lively Member
    Join Date
    Aug 2000
    Location
    quebec
    Posts
    81

    Exclamation

    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.

  9. #9
    Hyperactive Member Krass's Avatar
    Join Date
    Aug 2000
    Location
    Montreal
    Posts
    489
    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.
    Chris

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width