If you are programming a browser,
this could be handy. Just paste this code
into your program ...
Const
RAS_MAXENTRYNAME = 256
Const RAS_MAXDEVICETYPE = 16
Const RAS_MAXDEVICENAME = 128
Const RAS_RASCONNSIZE = 412
Private Type RasEntryName
dwSize As Long
szEntryName(RAS_MAXENTRYNAME) As Byte
End Type
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
Sub HangUp()
Dim i As Long
Dim lpRasConn(255) As RasConn
Dim lpcb As Long
Dim lpcConnections As Long
Dim hRasConn As Long
lpRasConn(0).dwSize = RAS_RASCONNSIZE
lpcb = RAS_MAXENTRYNAME *
lpRasConn(0).dwSize
lpcConnections = 0
ReturnCode =
RasEnumConnections(lpRasConn(0), lpcb,
lpcConnections)
If ReturnCode = ERROR_SUCCESS Then
For i = 0 To lpcConnections - 1
If Trim(CStr(lpRasConn(i).szEntryName)) =
Trim(gstrispname) Then
hRasConn = lpRasConn(i).hRasConn
ReturnCode = RasHangUp(ByVal hRasConn)
End If
Next i
End If
End Sub
|