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: [email protected]
ICQ: 19552879
AIM: RYoni69