|
|
|
|
|
Dicas
|
|
Visual Basic (Internet)
|
|
|
Título da Dica: Desconectando uma conexão Dial-Up
|
|
|
|
Postada em 10/11/2000 por Webmaster
webmaster@vbweb.com.br
'Coloque este código em (General) (Declarations) de um módulo
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
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
'Coloque este código em (General) de um módulo
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
'No sistema apenas chame a função HangUp()
|
|
|
|
|