home *** CD-ROM | disk | FTP | other *** search
Wrap
'Description 'This module provides a simple RAS API to VB applications, based on RASAPI16.DLL. 'All subs beginning with VBRAS may be used externally. 'VBRAS_DIAL_INFO_TYPE is the only type to be used externally. ' 'Written by Adam Ziegler CIS:72147,2221 'Clean Living <g> Option Explicit Const mnVBRAS_MAX_CONNECTIONS = 3 'Max connections VBRAS should support 'For use with VBRASDial Type VBRAS_DIAL_INFO_TYPE PhoneBook As String 'full path, defaults to standard if = "" entryname As String 'entry to dial. If = "", phone number must be provided Username As String 'username for auth. If "" will attempt to use logged-on user Password As String 'if blank, will prompt Domain As String 'Domain for auth. If "" will use from phonebook, if * will use from server PhoneNumber As String 'Will override phonebook entry CallbackNumber As String 'Only valid if server set up for user-specified callback End Type 'Original User Information Length Constants Const UNLEN = 20 'Username Const PWLEN = 14 'Password Const DNLEN = 15 'Domain Const UNLENPlus1 = UNLEN + 1 Const PWLENPlus1 = PWLEN + 1 Const DNLENPlus1 = DNLEN + 1 'Original RASAPI16.DLL Constants Const RASCS_DONE = &H2000 Const RASCS_PAUSED = &H1000 Const RAS_MaxCallbackNumber = 48 Const RAS_MaxDeviceName = 32 Const RAS_MaxDeviceType = 16 Const RAS_MaxEntryName = 20 Const RAS_MaxParamKey = 32 Const RAS_MaxParamValue = 128 Const RAS_MaxPhoneNumber = 128 Const RAS_MaxCallbackNumberPlus1 = RAS_MaxCallbackNumber + 1 Const RAS_MaxDeviceNamePlus1 = RAS_MaxDeviceName + 1 Const RAS_MaxDeviceTypePlus1 = RAS_MaxDeviceType + 1 Const RAS_MaxEntryNamePlus1 = RAS_MaxEntryName + 1 Const RAS_MaxParamKeyPlus1 = RAS_MaxParamKey + 1 Const RAS_MaxParamValuePlus1 = RAS_MaxParamValue + 1 Const RAS_MaxPhoneNumberPlus1 = RAS_MaxPhoneNumber + 1 'Declare RASAPI16.DLL Structures Type RASCONN dwSize As Long ' Size in bytes of RASCONN Structure (30) hrasconn As Long ' handle to connection szEntryName As String * RAS_MaxEntryNamePlus1 'name or "" followed by phone # szFiller As String * 1 'must end on word (2-byte) boundary End Type 'Equiv of _RASCONNSTATE enumerated type Global Const RAS_OpenPort = 0 Global Const RAS_PortOpened = 1 Global Const RAS_ConnectDevice = 2 Global Const RAS_DeviceConnected = 3 Global Const RAS_AllDevicesConnected = 4 Global Const RAS_Authenticate = 5 Global Const RAS_AuthNotify = 6 Global Const RAS_AuthRetry = 7 Global Const RAS_AuthCallback = 8 Global Const RAS_AuthChangePassword = 9 Global Const RAS_AuthProject = 10 Global Const RAS_AuthLinkSpeed = 11 Global Const RAS_AuthAck = 12 Global Const RAS_ReAuthenticate = 13 Global Const RAS_Authenticated = 14 Global Const RAS_PrepareForCallback = 15 Global Const RAS_WaitForModemReset = 16 Global Const RAS_WaitForCallback = 17 Global Const RAS_Interactive = RASCS_PAUSED Global Const RAS_RetryAuthentication = RASCS_PAUSED + 1 Global Const RAS_CallbackSetByCaller = RASCS_PAUSED + 2 Global Const RAS_PasswordExpired = RASCS_PAUSED + 3 Global Const RAS_Connected = RASCS_DONE Global Const RAS_Disconnected = RASCS_DONE + 1 'End _RASCONNSTATE declarations Type RASCONNSTATUS dwSize As Long ' size of struct in bytes (60) rasconnstate As Integer ' one of RASCONNSTATE enum types dwError As Long ' reason for fail if non-zero szDeviceType As String * RAS_MaxDeviceTypePlus1 'current dev type szDevicename As String * RAS_MaxDeviceNamePlus1 'current dev name End Type Type RASDIALPARAMS dwSize As Long ' size of struct (256, calculates to 255) szEntryName As String * RAS_MaxEntryNamePlus1 szPhoneNumber As String * RAS_MaxPhoneNumberPlus1 szCallbackNumber As String * RAS_MaxCallbackNumberPlus1 szUserName As String * UNLENPlus1 szPassword As String * PWLENPlus1 szDomain As String * DNLENPlus1 szFiller As String * 1 End Type Type RASENTRYNAME dwSize As Long ' size of struct (26) szEntryName As String * RAS_MaxEntryNamePlus1 szFiller As String * 1 End Type 'Declare RASAPI16.DLL external functions Declare Function RASDIAL& Lib "RASAPI16.DLL" (reserved As Any, lpszPhonebookPath As Any, lprasdialparams As RASDIALPARAMS, reserved2 As Any, ByVal hwndNotifier As Integer, lphrasconn As Long) 'LPTSTR reserved; /* reserved; must be set to NULL*/ 'LPTSTR lpszPhonebookPath; /* full pathname to Phone Book file*/ 'LPRASDIALPARAMS lpRasDialParams; /* points to calling parameters*/ 'LPVOID reserved2; /* reserved; must be set to NULL*/ 'HWND hwndNotifier; /* notification message for RasDial events*/ 'LPHRASCONN lphrasconn; /* points to variable to receive connection handle*/ Declare Function RasEnumConnections& Lib "RASAPI16.DLL" (lprasconn As RASCONN, lpcb&, lpcConnections&) 'LPRASCONN lprasconn; /* buffer to receive connections data */ 'LPDWORD lpcb; /* size in bytes of buffer */ 'LPDWORD lpcConnections; /* number of connections written to buffer */ 'Following function is not currently used by RASAPIVB 'Declare Function RasEnumEntries& Lib "RASAPI16.DLL" (reserved As Any, lpszPhonebookPath As Any, lprasentryname As RASENTRYNAME, lpcb As Long, lpcEntries As Long) 'LPTSTR reserved; /* reserved; must be NULL */ 'LPTSTR lpszPhonebookPath; /* full path to Phone Book file */ 'LPRASENTRYNAME lprasentryname; /* buffer to receive Phone Book entries */ 'LPDWORD lpcb; /* size in bytes of buffer */ 'LPDWORD lpcEntries; /* number of entries written to buffer */ Declare Function RasGetConnectStatus& Lib "RASAPI16.DLL" (ByVal hrasconn&, lprasconnstatus As RASCONNSTATUS) 'HRASCONN hrasconn; /* handle to Remote Access connection of interest */ 'LPRASCONNSTATUS lprasconnstatus; /* buffer to receive status data */ Declare Function RasGetErrorString& Lib "RASAPI16.DLL" (ByVal uErrorCode%, ByVal lpszErrorString$, ByVal cBufSize&) 'UINT uErrorCode; /* error code to get string for */ 'LPSTR lpszErrorString; /* buffer to hold error string */ 'DWORD cBufSize; /* sizeof buffer */ Declare Function RASHangUp& Lib "RASAPI16.DLL" (ByVal hrasconn As Long) 'HRASCONN hrasconn; /* handle to the Remote Access connection to hang up */ 'Function needed to trap messages with MessageBlaster VBX Declare Function RegisterWindowMessage% Lib "user" (ByVal lpszMessage As String) 'Error contants from RASERROR.H Global Const ERROR_INVALID_HANDLE = 6 Global Const ERROR_NOT_ENOUGH_MEMORY = 8 Global Const RASBASE = 600 Global Const SUCCESS = 0 Global Const PENDING = (RASBASE + 0) Global Const ERROR_INVALID_PORT_HANDLE = (RASBASE + 1) Global Const ERROR_PORT_ALREADY_OPEN = (RASBASE + 2) Global Const ERROR_BUFFER_TOO_SMALL = (RASBASE + 3) Global Const ERROR_WRONG_INFO_SPECIFIED = (RASBASE + 4) Global Const ERROR_CANNOT_SET_PORT_INFO = (RASBASE + 5) Global Const ERROR_PORT_NOT_CONNECTED = (RASBASE + 6) Global Const ERROR_EVENT_INVALID = (RASBASE + 7) Global Const ERROR_DEVICE_DOES_NOT_EXIST = (RASBASE + 8) Global Const ERROR_DEVICETYPE_DOES_NOT_EXIST = (RASBASE + 9) Global Const ERROR_INVALID_BUFFER = (RASBASE + 10) Global Const ERROR_ROUTE_NOT_AVAILABLE = (RASBASE + 11) Global Const ERROR_ROUTE_NOT_ALLOCATED = (RASBASE + 12) Global Const ERROR_INVALID_COMPRESSION_SPECIFIED = (RASBASE + 13) Global Const ERROR_OUT_OF_BUFFERS = (RASBASE + 14) Global Const ERROR_PORT_NOT_FOUND = (RASBASE + 15) Global Const ERROR_ASYNC_REQUEST_PENDING = (RASBASE + 16) Global Const ERROR_ALREADY_DISCONNECTING = (RASBASE + 17) Global Const ERROR_PORT_NOT_OPEN = (RASBASE + 18) Global Const ERROR_PORT_DISCONNECTED = (RASBASE + 19) Global Const ERROR_NO_ENDPOINTS = (RASBASE + 20) Global Const ERROR_CANNOT_OPEN_PHONEBOOK = (RASBASE + 21) Global Const ERROR_CANNOT_LOAD_PHONEBOOK = (RASBASE + 22) Global Const ERROR_CANNOT_FIND_PHONEBOOK_ENTRY = (RASBASE + 23) Global Const ERROR_CANNOT_WRITE_PHONEBOOK = (RASBASE + 24) Global Const ERROR_CORRUPT_PHONEBOOK = (RASBASE + 25) Global Const ERROR_CANNOT_LOAD_STRING = (RASBASE + 26) Global Const ERROR_KEY_NOT_FOUND = (RASBASE + 27) Global Const ERROR_DISCONNECTION = (RASBASE + 28) Global Const ERROR_REMOTE_DISCONNECTION = (RASBASE + 29) Global Const ERROR_HARDWARE_FAILURE = (RASBASE + 30) Global Const ERROR_USER_DISCONNECTION = (RASBASE + 31) Global Const ERROR_INVALID_SIZE = (RASBASE + 32) Global Const ERROR_PORT_NOT_AVAILABLE = (RASBASE + 33) Global Const ERROR_CANNOT_PROJECT_CLIENT = (RASBASE + 34) Global Const ERROR_UNKNOWN = (RASBASE + 35) Global Const ERROR_WRONG_DEVICE_ATTACHED = (RASBASE + 36) Global Const ERROR_BAD_STRING = (RASBASE + 37) Global Const ERROR_REQUEST_TIMEOUT = (RASBASE + 38) Global Const ERROR_CANNOT_GET_LANA = (RASBASE + 39) Global Const ERROR_NETBIOS_ERROR = (RASBASE + 40) Global Const ERROR_SERVER_OUT_OF_RESOURCES = (RASBASE + 41) Global Const ERROR_NAME_EXISTS_ON_NET = (RASBASE + 42) Global Const ERROR_SERVER_GENERAL_NET_FAILURE = (RASBASE + 43) Global Const WARNING_MSG_ALIAS_NOT_ADDED = (RASBASE + 44) Global Const ERROR_AUTH_INTERNAL = (RASBASE + 45) Global Const ERROR_RESTRICTED_LOGON_HOURS = (RASBASE + 46) Global Const ERROR_ACCT_DISABLED = (RASBASE + 47) Global Const ERROR_PASSWD_EXPIRED = (RASBASE + 48) Global Const ERROR_NO_DIALIN_PERMISSION = (RASBASE + 49) Global Const ERROR_SERVER_NOT_RESPONDING = (RASBASE + 50) Global Const ERROR_FROM_DEVICE = (RASBASE + 51) Global Const ERROR_UNRECOGNIZED_RESPONSE = (RASBASE + 52) Global Const ERROR_MACRO_NOT_FOUND = (RASBASE + 53) Global Const ERROR_MACRO_NOT_DEFINED = (RASBASE + 54) Global Const ERROR_MESSAGE_MACRO_NOT_FOUND = (RASBASE + 55) Global Const ERROR_DEFAULTOFF_MACRO_NOT_FOUND = (RASBASE + 56) Global Const ERROR_FILE_COULD_NOT_BE_OPENED = (RASBASE + 57) Global Const ERROR_DEVICENAME_TOO_LONG = (RASBASE + 58) Global Const ERROR_DEVICENAME_NOT_FOUND = (RASBASE + 59) Global Const ERROR_NO_RESPONSES = (RASBASE + 60) Global Const ERROR_NO_COMMAND_FOUND = (RASBASE + 61) Global Const ERROR_WRONG_KEY_SPECIFIED = (RASBASE + 62) Global Const ERROR_UNKNOWN_DEVICE_TYPE = (RASBASE + 63) Global Const ERROR_ALLOCATING_MEMORY = (RASBASE + 64) Global Const ERROR_PORT_NOT_CONFIGURED = (RASBASE + 65) Global Const ERROR_DEVICE_NOT_READY = (RASBASE + 66) Global Const ERROR_READING_INI_FILE = (RASBASE + 67) Global Const ERROR_NO_CONNECTION = (RASBASE + 68) Global Const ERROR_BAD_USAGE_IN_INI_FILE = (RASBASE + 69) Global Const ERROR_READING_SECTIONNAME = (RASBASE + 70) Global Const ERROR_READING_DEVICETYPE = (RASBASE + 71) Global Const ERROR_READING_DEVICENAME = (RASBASE + 72) Global Const ERROR_READING_USAGE = (RASBASE + 73) Global Const ERROR_READING_MAXCONNECTBPS = (RASBASE + 74) Global Const ERROR_READING_MAXCARRIERBPS = (RASBASE + 75) Global Const ERROR_LINE_BUSY = (RASBASE + 76) Global Const ERROR_VOICE_ANSWER = (RASBASE + 77) Global Const ERROR_NO_ANSWER = (RASBASE + 78) Global Const ERROR_NO_CARRIER = (RASBASE + 79) Global Const ERROR_NO_DIALTONE = (RASBASE + 80) Global Const ERROR_IN_COMMAND = (RASBASE + 81) Global Const ERROR_WRITING_SECTIONNAME = (RASBASE + 82) Global Const ERROR_WRITING_DEVICETYPE = (RASBASE + 83) Global Const ERROR_WRITING_DEVICENAME = (RASBASE + 84) Global Const ERROR_WRITING_MAXCONNECTBPS = (RASBASE + 85) Global Const ERROR_WRITING_MAXCARRIERBPS = (RASBASE + 86) Global Const ERROR_WRITING_USAGE = (RASBASE + 87) Global Const ERROR_WRITING_DEFAULTOFF = (RASBASE + 88) Global Const ERROR_READING_DEFAULTOFF = (RASBASE + 89) Global Const ERROR_EMPTY_INI_FILE = (RASBASE + 90) Global Const ERROR_AUTHENTICATION_FAILURE = (RASBASE + 91) Global Const ERROR_PORT_OR_DEVICE = (RASBASE + 92) Global Const ERROR_NOT_BINARY_MACRO = (RASBASE + 93) Global Const ERROR_DCB_NOT_FOUND = (RASBASE + 94) Global Const ERROR_STATE_MACHINES_NOT_STARTED = (RASBASE + 95) Global Const ERROR_STATE_MACHINES_ALREADY_STARTED = (RASBASE + 96) Global Const ERROR_PARTIAL_RESPONSE_LOOPING = (RASBASE + 97) Global Const ERROR_UNKNOWN_RESPONSE_KEY = (RASBASE + 98) Global Const ERROR_RECV_BUF_FULL = (RASBASE + 99) Global Const ERROR_CMD_TOO_LONG = (RASBASE + 100) Global Const ERROR_UNSUPPORTED_BPS = (RASBASE + 101) Global Const ERROR_UNEXPECTED_RESPONSE = (RASBASE + 102) Global Const ERROR_INTERACTIVE_MODE = (RASBASE + 103) Global Const ERROR_BAD_CALLBACK_NUMBER = (RASBASE + 104) Global Const ERROR_INVALID_AUTH_STATE = (RASBASE + 105) Global Const ERROR_WRITING_INITBPS = (RASBASE + 106) Global Const ERROR_INVALID_WIN_HANDLE = (RASBASE + 107) Global Const ERROR_NO_PASSWORD = (RASBASE + 108) Global Const ERROR_NO_USERNAME = (RASBASE + 109) Global Const ERROR_CANNOT_START_STATE_MACHINE = (RASBASE + 110) Global Const ERROR_GETTING_COMMSTATE = (RASBASE + 111) Global Const ERROR_SETTING_COMMSTATE = (RASBASE + 112) Global Const ERROR_COMM_FUNCTION = (RASBASE + 113) Global Const ERROR_CONFIGURATION_PROBLEM = (RASBASE + 114) Global Const ERROR_X25_DIAGNOSTIC = (RASBASE + 115) Global Const ERROR_TOO_MANY_LINE_ERRORS = (RASBASE + 116) Global Const ERROR_OVERRUN = (RASBASE + 117) Global Const ERROR_ACCT_EXPIRED = (RASBASE + 118) Global Const ERROR_CHANGING_PASSWORD = (RASBASE + 119) Global Const ERROR_NO_ACTIVE_ISDN_LINES = (RASBASE + 120) Global Const ERROR_NO_ISDN_CHANNELS_AVAILABLE = (RASBASE + 121) Global Const RASBASEEND = (RASBASE + 121) Sub VBRASDial (rVBRAS_DIAL_INFO As VBRAS_DIAL_INFO_TYPE, hwndNotifier As Integer, lhConnection As Long, nResult As Integer) '************************************************************************** 'Purpose: Initiates RAS connection 'Inputs: 'rVBRAS_DIAL_INFO dial information 'hwndNotifier handle to window to receive messages 'Assumes: 'Returns: 'lhConnection handle to connection 'nResult error code from RASAPI16, =0 if success 'Effects: '************************************************************************** Dim rRASDIALPARAMS As RASDIALPARAMS Dim sPhonebookPath As String Dim bPBIsNull As Integer 'True if user hasn't specified phonebook lhConnection = 0 'ensure is null 'using a non-default phonebook? If rVBRAS_DIAL_INFO.PhoneBook = "" Then bPBIsNull = True Else sPhonebookPath = rVBRAS_DIAL_INFO.PhoneBook + Chr$(0) End If 'set defaults "*" indicates entry in phonebook should be used If rVBRAS_DIAL_INFO.CallbackNumber = "" And (rVBRAS_DIAL_INFO.entryname) <> "" Then rVBRAS_DIAL_INFO.CallbackNumber = "*" End If If rVBRAS_DIAL_INFO.Domain = "" And (rVBRAS_DIAL_INFO.entryname) <> "" Then rVBRAS_DIAL_INFO.Domain = "*" End If 'convert dial info to null-terminated strings rRASDIALPARAMS.dwSize = Len(rRASDIALPARAMS) rRASDIALPARAMS.szEntryName = rVBRAS_DIAL_INFO.entryname + Chr$(0) rRASDIALPARAMS.szPhoneNumber = rVBRAS_DIAL_INFO.PhoneNumber + Chr$(0) rRASDIALPARAMS.szCallbackNumber = rVBRAS_DIAL_INFO.CallbackNumber + Chr$(0) rRASDIALPARAMS.szUserName = rVBRAS_DIAL_INFO.Username + Chr$(0) rRASDIALPARAMS.szPassword = rVBRAS_DIAL_INFO.Password + Chr$(0) rRASDIALPARAMS.szDomain = rVBRAS_DIAL_INFO.Domain + Chr$(0) 'use a different call depending on phonebook If bPBIsNull Then nResult = RASDIAL&(ByVal 0&, ByVal 0&, rRASDIALPARAMS, ByVal 0&, hwndNotifier, lhConnection) Else nResult = RASDIAL&(ByVal 0&, sPhonebookPath, rRASDIALPARAMS, ByVal 0&, hwndNotifier, lhConnection) End If End Sub Sub VBRASGetConnections (nConnections As Long, alhConnection() As Long, asConnectionName() As String, nResult As Integer) '************************************************************************** 'Purpose: returns active RAS connections 'Inputs: 'Assumes: 'Returns: 'nConnections Number of Connections (Max is mnVBRAS_MAX_CONNECTIONS) 'alhConnection() Handles to connections (array numbers start at 1) 'asConnectionName() Name or Phone number of connections 'nResult RASAPI16 error code if non-zero 'Effects: '************************************************************************** Dim nLoopCount As Integer Static aRASCONN(1 To mnVBRAS_MAX_CONNECTIONS) As RASCONN Dim lBufferSize As Long 'RASAPI16 requires first element must hold size of buffer array lBufferSize = mnVBRAS_MAX_CONNECTIONS * Len(aRASCONN(1)) aRASCONN(1).dwSize = Len(aRASCONN(1)) nResult = RasEnumConnections(aRASCONN(1), lBufferSize, nConnections) If nConnections > 0 Then ReDim alhConnection(nConnections) ReDim asConnectionName(nConnections) For nLoopCount = 1 To nConnections alhConnection(nLoopCount) = aRASCONN(nLoopCount).hrasconn asConnectionName(nLoopCount) = aRASCONN(nLoopCount).szEntryName Next End If End Sub Sub VBRASGetConnState (ByVal lhConnection As Long, iConnectionState As Integer, iErrorCode As Integer, sDeviceName As String, sDeviceType As String, nResult As Integer) '************************************************************************** 'Purpose: returns information about a lhConnection, given a valid handle 'Inputs: 'lhConnection handle to lhConnection 'Assumes: handle is valid, but RASAPI16 should return error if not 'Returns: 'iConnectionState one of _RASCONNSTATE constants 'iErrorCode RAS error code, if relevant 'sDeviceName name of device 'sDeviceType device type 'nResult RASAPI16 error code if non-zero 'Effects: '************************************************************************** Dim rRASConnStatus As RASCONNSTATUS rRASConnStatus.dwSize = Len(rRASConnStatus) nResult = RasGetConnectStatus&(lhConnection, rRASConnStatus) iConnectionState = rRASConnStatus.rasconnstate iErrorCode = rRASConnStatus.dwError sDeviceName = rRASConnStatus.szDevicename sDeviceType = rRASConnStatus.szDeviceType End Sub Function VBRASGetConnStateString (ConnState As Integer) As String '************************************************************************** 'Purpose: returns strings describing RAS status codes 'Inputs: 'ConState RAS status code 'Assumes: 'Returns: descriptive string 'Effects: '************************************************************************** Select Case ConnState Case RAS_OpenPort VBRASGetConnStateString = "The communication port is about to be opened." Case RAS_PortOpened VBRASGetConnStateString = "The communication port has been opened successfully." Case RAS_ConnectDevice VBRASGetConnStateString = "A device is about to be connected." Case RAS_DeviceConnected VBRASGetConnStateString = "A device has connected successfully. " Case RAS_AllDevicesConnected VBRASGetConnStateString = "All devices in the device chain have successfully connected." Case RAS_Authenticate VBRASGetConnStateString = "The authentication process is starting." Case RAS_AuthNotify VBRASGetConnStateString = "An authentication event has occurred." Case RAS_AuthRetry VBRASGetConnStateString = "The client has requested another validation attempt with a new username/password/domain." Case RAS_AuthCallback VBRASGetConnStateString = "The Remote Access server has requested a callback number." Case RAS_AuthChangePassword VBRASGetConnStateString = "The client has requested to change the password on the account." Case RAS_AuthProject VBRASGetConnStateString = "The projection phase is starting." Case RAS_AuthLinkSpeed VBRASGetConnStateString = "The link speed calculation phase is starting." Case RAS_AuthAck VBRASGetConnStateString = "An authentication request is being acknowledged." Case RAS_ReAuthenticate VBRASGetConnStateString = "Reauthentication (after callback) is starting." Case RAS_Authenticated VBRASGetConnStateString = "The client has successfully completed authentication." Case RAS_PrepareForCallback VBRASGetConnStateString = "The line is about to disconnect in preparation for callback." Case RAS_WaitForModemReset VBRASGetConnStateString = "The client is delaying in order to give the modem time to reset itself in preparation for callback." Case RAS_WaitForCallback VBRASGetConnStateString = "The client is waiting for an incoming call from the Remote Access server." Case RAS_Interactive VBRASGetConnStateString = "This state corresponds to the Terminal state supported by RASPHONE.EXE." Case RAS_RetryAuthentication VBRASGetConnStateString = "This state corresponds to the Retry Authentication state supported by RASPHONE.EXE." Case RAS_CallbackSetByCaller VBRASGetConnStateString = "This state corresponds to the Callback state supported by RASPHONE.EXE." Case RAS_PasswordExpired VBRASGetConnStateString = "This state corresponds to the Change Password state supported by RASPHONE.EXE." Case RAS_Connected VBRASGetConnStateString = "Successful connection." Case RAS_Disconnected VBRASGetConnStateString = "Disconnection or failed connection." Case Else VBRASGetConnStateString = "Unknown State" End Select End Function Function VBRASGetErrorString (ErrorCode As Integer) As String '************************************************************************** 'Purpose: gets error string from RASAPI16 'Inputs: 'ErrorCode numeric error code 'Assumes: 'Returns: Corresponding error message 'Effects: '************************************************************************** Dim Buffer As String * 256 Dim nResult As Integer nResult = RasGetErrorString(ErrorCode, Buffer, Len(Buffer)) If nResult = 0 Then VBRASGetErrorString = Left$(Buffer, Len(Buffer) - 1) Else VBRASGetErrorString = "Unknown Error" End If End Function Sub VBRASHangUp (lhConnection As Long, nResult As Integer) '************************************************************************** 'Purpose: Hangs up lhConnection 'Inputs: 'lhConnection handle to lhConnection to hang up 'Assumes: Handle is valid 'Returns: 'nResult RASAPI16 error code if non-zero 'Effects: '************************************************************************** nResult = RASHangUp(lhConnection) End Sub Sub VBRASHangUpAll (nResult As Integer) '************************************************************************** 'Purpose: Hangs up all connections 'Inputs: 'Assumes: Handle is valid 'Returns: 'nResult RASAPI16 error code if non-zero 'Effects: '************************************************************************** Dim ConnCount As Long Dim ConnHandle() As Long Dim ConnName() As String VBRASGetConnections ConnCount, ConnHandle(), ConnName(), nResult Do While ConnCount > 0 And nResult = 0 VBRASHangUp ConnHandle(ConnCount), nResult ConnCount = ConnCount - 1 Loop End Sub