Este código va en el Formulario.
Option Explicit
Private Sub Form_Click()
TerminateRAS
End Sub
Y este otro en un módulo.
Option Explicit
Private Declare Function RasEnumConnections Lib "rasapi32.DLL" Alias "RasEnumConnectionsA" _
(lpRasConn As Any, lpcb As Long, lpcConnections As Long) As Long
Public Declare Function RasHangUp Lib "rasapi32.DLL" Alias "RasHangUpA" (ByVal hRasConn _
As Long) As Long
Public Const RAS_MAXENTRYNAME As Integer = 256
Public Const RAS_MAXDEVICETYPE As Integer = 16
Public Const RAS_MAXDEVICENAME As Integer = 128
Public Const RAS_RASCONNSIZE As Integer = 412
Public Const ERROR_SUCCESS = 0
Public 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
Sub TerminateRAS()
' Cancela todas las conexiones RAS
Dim i As Long
Dim RasConn(255) As RasConn
Dim structSize As Long
Dim ConnectionsCount As Long
Dim ret As Long
'Fills the RasConn structure with the data of all the opened RAS connections
RasConn(0).dwSize = RAS_RASCONNSIZE
structSize = RAS_MAXENTRYNAME * RasConn(0).dwSize
ret = RasEnumConnections(RasConn(0), structSize, ConnectionsCount)
'hangup all the RAS connections
If ret = ERROR_SUCCESS Then
For i = 0 To ConnectionsCount - 1
ret = RasHangUp(RasConn(i).hRasConn)
Next
End If
End Sub
Enviado por Andrea Tincani
Posted
vie, ago 25 2000 19:17
by
Maverick