VB and VBA Users Source Code: Terminate all active RAS connections
[
Home
|
Contents
|
Search
|
Reply
| Previous | Next ]
VB/VBA Source Code
Terminate all active RAS connections
By:
Andrew Baker
Email (spam proof):
Email the originator of this post
Date:
Monday, January 01, 2001
Hits:
698
Category:
Networks
Article:
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 'Author : Andrew Baker 'Date : 01/01/2001 20:26 'Notes : 'Revisions : 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
Terms and Conditions
Support this site
Download a trial version of the Excel Workbook Rebuilder