Results 1 to 2 of 2

Thread: ShutDown a Modem Connection

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Sep 1999
    Location
    Santo Domingo,D.N., Dom. Rep.
    Posts
    707

    Post

    My APP calls Intenet, when you finish the Connection the APP must disconect the MODEM.

    How Can I Do This?

  2. #2
    Guru Yonatan's Avatar
    Join Date
    Apr 1999
    Location
    Israel
    Posts
    892

    Post

    Push this code in a module:
    Code:
    Option Explicit
    
    
    Private Const RAS_MAXENTRYNAME = 256
    Private Const RAS_MAXDEVICETYPE = 16
    Private Const RAS_MAXDEVICENAME = 128
    Private Const RAS_RASCONNSIZE = 412
    
    
    Private Type RASCONN
        dwSize As Long
        hRasConn As Long
        szEntryName(RAS_MAXENTRYNAME) As Byte
        szDeviceType(RAS_MAXDEVICETYPE) As Byte
        szDeviceName(RAS_MAXDEVICENAME) As Byte
    End Type
    
    
    Private Declare Function RasEnumConnections Lib "rasapi32.dll" Alias "RasEnumConnectionsA" (lpRasConn As Any, lpcb As Long, lpcConnections As Long) As Long
    Private Declare Function RasHangUp Lib "rasapi32.dll" Alias "RasHangUpA" (ByVal hRasConn As Long) As Long
    
    
    Public Sub HangUpModem()
        Dim I As Long, lpRasConn(255) As RASCONN, lpcb As Long, lpcConnections As Long
        lpRasConn(0).dwSize = RAS_RASCONNSIZE
        lpcb = RAS_MAXENTRYNAME * RAS_RASCONNSIZE
        If RasEnumConnections(lpRasConn(0), lpcb, lpcConnections) = 0 Then
            For I = 0 To lpcConnections - 1
                Call RasHangUp(lpRasConn(I).hRasConn)
            Next I
        End If
    End Sub
    When your program is done with the modem, use the HangUpModem function to get rid of the connection:

    Private Sub Form_Unload(Cancel As Integer)
    Call HangUpModem
    End Sub


    ------------------
    Yonatan
    Teenage Programmer
    E-Mail: RZvika@netvision.net.il
    ICQ: 19552879
    AIM: RYoni69

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