C
CSharp
C++
Java
Visual Basic
HTML - CSS
Android
Asp
Asp.Net
Php
Python
JavaScript
SQL
XML
Assembly
ActiveX
API
Code Snippets
Database
Files Directories Drives
Forms
Graphics Games
Multimedia
Strings
Windows and Controls
More...
Visual Basic > Other sample source codes
Visual Basic Code > Terminate all active RAS connections
Terminate all active RAS connections To terminate all the open RAS connections use the following routine: Option Explicit 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 Private Const RAS_MAXDEVICETYPE As Integer = 16, RAS_MAXDEVICENAME As Integer = 128, RAS_RASCONNSIZE As Integer = 412, RAS_MAXENTRYNAME As Integer = 256 Private Type tRasConn dwSize As Long hRasConn As Long szEntryName(RAS_MAXENTRYNAME) As Byte szDeviceType(RAS_MAXDEVICETYPE) As Byte szDeviceName(RAS_MAXDEVICENAME) As Byte End Type 'Purpose : Terminates all the active RAS connections 'Inputs : N/A 'Outputs : N/A Sub TerminateRAS() Const ERROR_SUCCESS As Long = 0 Dim lThisConnection As Long, lStructSize As Long, lContCons As Long, lRet As Long Dim tRasConn(255) As tRasConn 'Get info on all all the opened RAS connections tRasConn(0).dwSize = RAS_RASCONNSIZE lStructSize = RAS_MAXENTRYNAME * tRasConn(0).dwSize lRet = RasEnumConnections(tRasConn(0), lStructSize, lContCons) 'hangup all the RAS connections If lRet = ERROR_SUCCESS Then For lThisConnection = 0 To lContCons - 1 lRet = RasHangUp(tRasConn(lThisConnection).hRasConn) Next End If End Sub
Privacy Policy
|
Contact
|
Advertising
|
Link to Us
|
Directory