Attribute VB_Name = "modDUN" Option Explicit '============================================================================================================= ' ' modDUN Module ' ------------- ' ' Created By : Kevin Wilson ' http://www.TheVBZone.com ( The VB Zone ) ' http://www.TheVBZone.net ( The VB Zone .net ) ' ' Last Update : July 10, 2001 ' ' VB Versions : 5.0 / 6.0 ' ' Requires : For Windows 95(pre OEM Service Release 2) you need to install ' Dial-Up Networking (DUN) 1.2x Upgrade ' ' Description : This module was written to give low-level access to the Dial-Up Network(DUN) and everything ' to do with Remote Access Server(RAS) automation via VB. This module is a very advanced module and it is not recommended that you use it unless you're well versed in Visual Basic and the use of Win32 API calls in VB. ' ' Notice : In this module, strings are passed byreference (ByRef) because the majority of the API calls ' expect parameters that are pointers to a string. These APIs accept NULL as a valid parameter. ' In order to pass a NULL string value correctly to an API in Visual Basic, you must pass the ' key word "vbNullString" by reference. ' ' See Also : * RAS & Visual Basic ' http://www.totalenviro.com/PlatformVB ' ' * About Remote Access Service: ' http://msdn.microsoft.com/library/psdk/network/ras4over_71k5.htm ' ' * RAS Functions ' http://msdn.microsoft.com/library/psdk/network/rasclnt_5zsj.htm ' ' * RAS Administration Functions ' http://msdn.microsoft.com/library/psdk/rras/rasadmin_8usz.htm ' ' *SAMPLE: RasEnum.exe Shows How to Call the RasEnumEntries API in Visual Basic ' http://support.microsoft.com/support/kb/articles/Q242/1/45.ASP?LN=EN-US&SD=gn&FR=0 ' ' * Routing and Remote Access Service Download: ' http://www.microsoft.com/ntserver/nts/downloads/winfeatures/rras/rrasdown.asp?RLD=188 ' ' * TechNet - Networking & RAS ' http://www.microsoft.com/technet/network/default.asp?RLD=188 ' '============================================================================================================= ' ' LEGAL: ' ' You are free to use this code as long as you keep the above heading information intact and unchanged. Credit ' given where credit is due. Also, it is not required, but it would be appreciated if you would mention ' somewhere in your compiled program that that your program makes use of code written and distributed by ' Kevin Wilson (www.TheVBZone.com). Feel free to link to this code via your web site or articles. ' ' You may NOT take this code and pass it off as your own. You may NOT distribute this code on your own server ' or web site. You may NOT take code created by Kevin Wilson (www.TheVBZone.com) and use it to create products, ' utilities, or applications that directly compete with products, utilities, and applications created by Kevin ' Wilson, TheVBZone.com, or Wilson Media. You may NOT take this code and sell it for profit without first ' obtaining the written consent of the author Kevin Wilson. ' ' These conditions are subject to change at the discretion of the owner Kevin Wilson at any time without ' warning or notice. Copyright© by Kevin Wilson. All rights reserved. ' '============================================================================================================= '------------------------------------------------------------------------------------------------------------- ' Enumeration Declarations '------------------------------------------------------------------------------------------------------------- ' RAS Connection States Private Enum RasConnState RASCS_OpenPort = 0 RASCS_PortOpened RASCS_ConnectDevice RASCS_DeviceConnected RASCS_AllDevicesConnected RASCS_Authenticate RASCS_AuthNotify RASCS_AuthRetry RASCS_AuthCallback RASCS_AuthChangePassword RASCS_AuthProject RASCS_AuthLinkSpeed RASCS_AuthAck RASCS_ReAuthenticate RASCS_Authenticated RASCS_PrepareForCallback RASCS_WaitForModemReset RASCS_WaitForCallback RASCS_Projected RASCS_StartAuthentication RASCS_CallbackComplete RASCS_LogonNetwork RASCS_SubEntryConnected RASCS_SubEntryDisconnected RASCS_Interactive = &H1000 'RASCS_PAUSED RASCS_RetryAuthentication RASCS_CallbackSetByCaller RASCS_PasswordExpired RASCS_InvokeEapUI RASCS_Connected = &H2000 'RASCS_DONE RASCS_Disconnected End Enum ' Operating system enumerations Public Enum OSTypes OS_Unknown = 0 ' "Unknown" OS_Win32 = 32 ' "Win 32" OS_Win95 = 95 ' "Windows 95" OS_Win98 = 98 ' "Windows 98" OS_WinNT_351 = 351 ' "Windows NT 3.51" OS_WinNT_40 = 40 ' "Windows NT 4.0" OS_Win2000 = 2000 ' "Windows 2000" End Enum Public Enum RasEntryOptions RASEO_UseCountryAndAreaCodes = &H1 ' If this flag is set, the dwCountryID, dwCountryCode, and szAreaCode members are used to construct the phone number. If this flag is not set, these members are ignored. This flag corresponds to the Use Country and Area Codes check box in the Phone dialog box. RASEO_SpecificIpAddr = &H2 ' If this flag is set, RAS tries to use the IP address specified by ipaddr as the IP address for the dial-up connection. If this flag is not set, the value of the ipaddr member is ignored. Setting the RASEO_SpecificIpAddr flag corresponds to selecting the Specify an IP Address setting in the TCP/IP settings dialog box. Clearing the RASEO_SpecificIpAddr flag corresponds to selecting the Server Assigned IP Address setting in the TCP/IP settings dialog box. Currently, an IP address set in the phone-book entry properties or retrieved from a server overrides the IP address set in the network control panel. RASEO_SpecificNameServers = &H4 ' If this flag is set, RAS uses the ipaddrDns, ipaddrDnsAlt, ipaddrWins, and ipaddrWinsAlt members to specify the name server addresses for the dial-up connection. If this flag is not set, RAS ignores these members. Setting the RASEO_SpecificNameServers flag corresponds to selecting the Specify Name Server Addresses setting in the TCP/IP Settings dialog box. Clearing the RASEO_SpecificNameServers flag corresponds to selecting the Server Assigned Name Server Addresses setting in the TCP/IP Settings dialog box. RASEO_IpHeaderCompression = &H8 ' If this flag is set, RAS negotiates to use IP header compression on PPP connections. If this flag is not set, IP header compression is not negotiated. This flag corresponds to the Use IP Header Compression check box in the TCP/IP settings dialog box. It is generally advisable to set this flag because IP header compression significantly improves performance. The flag should be cleared only when connecting to a server that does not correctly negotiate IP header compression. RASEO_RemoteDefaultGateway = &H10 ' If this flag is set, the default route for IP packets is through the dial-up adapter when the connection is active. If this flag is clear, the default route is not modified. This flag corresponds to the Use Default Gateway on Remote Network check box in the TCP/IP settings dialog box. RASEO_DisableLcpExtensions = &H20 ' If this flag is set, RAS disables the PPP LCP extensions defined in RFC 1570. This may be necessary to connect to certain older PPP implementations, but interferes with features such as server callback. Do not set this flag unless specifically required. RASEO_TerminalBeforeDial = &H40 ' If this flag is set, RAS displays a terminal window for user input before dialing the connection. RASEO_TerminalAfterDial = &H80 ' If this flag is set, RAS displays a terminal window for user input after dialing the connection. Do not set this flag if a dial-up networking script is to be associated with the connection, because scripting has its own terminal implementation. RASEO_SwCompression = &H200 ' If this flag is set, software compression is negotiated on the link. Setting this flag causes the PPP driver to attempt to negotiate CCP with the server. This flag should be set by default, but clearing it can reduce the negotiation period if the server does not support a compatible compression protocol. RASEO_RequireEncryptedPw = &H400 ' If this flag is set, only secure password schemes can be used to authenticate the client with the server. This prevents the PPP driver from using the PAP plain-text authentication protocol to authenticate the client. The CHAP and SPAP authentication protocols are also supported. Clear this flag for increased interoperability, and set it for increased security. This flag corresponds to the Require Encrypted Password check box in the Security dialog box. See also RASEO_RequireMsEncryptedPw. RASEO_RequireMsEncryptedPw = &H800 ' If this flag is set, only Microsoft’s secure password schemes can be used to authenticate the client with the server. This prevents the PPP driver from using the PPP plain-text authentication protocol, MD5-CHAP, MS-CHAP, or SPAP. The flag should be cleared for maximum interoperability and should be set for maximum security. This flag takes precedence over RASEO_RequireEncryptedPw. This flag corresponds to the Require Microsoft Encrypted Password check box in the Security dialog box. See also RASEO_RequireDataEncryption. RASEO_RequireDataEncryption = &H1000 ' If this flag is set, data encryption must be negotiated successfully or the connection should be dropped. This flag is ignored unless RASEO_RequireMsEncryptedPw is also set. This flag corresponds to the Require Data Encryption check box in the Security dialog box. RASEO_NetworkLogon = &H2000 ' If this flag is set, RAS logs on to the network after the point-to-point connection is established. This flag currently has no effect under Windows NT. RASEO_UseLogonCredentials = &H4000 ' If this flag is set, RAS uses the user name, password, and domain of the currently logged-on user when dialing this entry. This flag is ignored unless RASEO_RequireMsEncryptedPw is also set. Note that this setting is ignored by the RasDial function, where specifying empty strings for the szUserName and szPassword members of the RASDIALPARAMS structure gives the same result. This flag corresponds to the Use Current Username and Password check box in the Security dialog box. RASEO_PromoteAlternates = &H8000 ' This flag has an effect when alternate phone numbers are defined by the dwAlternateOffset member. If this flag is set, an alternate phone number that connects successfully becomes the primary phone number, and the current primary phone number is moved to the alternate list. This flag corresponds to the check box in the Alternate Numbers dialog box. RASEO_SecureLocalFiles = &H10000 ' Windows NT/2000: If this flag is set, RAS checks for existing remote file system and remote printer bindings before making a connection with this entry. Typically, you set this flag on phone-book entries for public networks to remind users to break connections to their private network before connecting to a public network. ' RASEO_ModemLights = &H100 ' Windows 2000: If this flag is set, a status monitor will be displayed in the Task Bar. ' RASEO_RequireEAP = &H20000 ' Windows 2000: If this flag is set, an Extensible Authentication Protocol (EAP) must be supported for authentication. ' RASEO_RequirePAP = &H40000 ' Windows 2000: If this flag is set, Password Authentication Protocol must be supported for authentication. ' RASEO_RequireSPAP = &H80000 ' Windows 2000: If this flag is set, Shiva's Password Authentication Protocol must be supported for authentication. ' RASEO_Custom = &H100000 ' Windows 2000: If this flag is set, the connection will use custom encryption. ' RASEO_PreviewPhoneNumber = &H200000 ' Windows 2000: If this flag is set, the remote access dialer displays the phone number to be dialed. ' RASEO_SharedPhoneNumbers = &H800000 ' Windows 2000: If this flag is set, phone numbers are shared. ' RASEO_PreviewUserPw = &H1000000 ' Windows 2000: If this flag is set, the remote access dialer displays the user's name and password prior to dialing. ' RASEO_PreviewDomain = &H2000000 ' Windows 2000: If this flag is set, the remote access dialer displays the domain name prior to dialing. ' RASEO_ShowDialingProgress = &H4000000 ' Windows 2000: If this flag is set, the remote access dialer displays its progress in establishing the connection. ' RASEO_RequireCHAP = &H8000000 ' Windows 2000: If this flag is set, the Challenge Handshake Authentication Protocol must be supported for authentication. ' RASEO_RequireMsCHAP = &H10000000 ' Windows 2000: If this flag is set, the Microsoft Challenge Handshake Authentication Protocol must be supported for authentication. ' RASEO_RequireMsCHAP2 = &H20000000 ' Windows 2000: If this flag is set, version 2 of the Microsoft Challenge Handshake Authentication Protocol must be supported for authentication. ' RASEO_RequireW95MSCHAP = &H40000000 ' Windows 2000: If this flag is set, MS-CHAP must send the LanManager-hashed password. ' RASEO_CustomScript = &H80000000 ' Windows 2000: If this flag is set, RAS will invoke a custom-scripting DLL after establishing the connection to the server. End Enum Public Enum RasProjection RASP_Amb = &H10000 ' Specifies the Authentication Message Block (AMB) authentication protocol. AMB is a NetBIOS-based protocol used to authenticate with downlevel remote access servers ( all those prior to Windows NT 3.5). The corresponding data structure is a RASAMB. RASP_PppNbf = &H803F ' Specifies the NetBEUI Framer (NBF) protocol. NBFCP is a PPP network control protocol used to negotiate the parameters necessary to ship NetBEUI packets on a WAN link. The corresponding data structure is a RASPPPNBF. RASP_PppIpx = &H802B ' Specifies the Internetwork Packet Exchange (IPX) control protocol. IPXCP is a PPP network control protocol used to negotiate the parameters necessary to ship IPX packets on a WAN link. The corresponding data structure is a RASPPPIPX. RASP_PppIp = &H8021 ' Specifies the Internet Protocol (IP) control protocol. IPCP is a PPP network control protocol used to negotiate the parameters necessary to ship IP packets on a WAN link. The corresponding data structure is a RASPPPIP. ' RASP_PppCcp = &H80FD ' Windows 2000: Specifies the Compression Control Protocol (CCP). CCP enables computers using PPP to negotiate compression algorithms and parameters. The corresponding data structure is RASPPPCCP. ' RASP_PppLcp = &HC021 ' Windows 2000: Specifies the Link Control Protocol (LCP). LCP is used by computers to establish, modify, and terminate PPP connections. The corresponding data structure is RASPPPLCP. ' RASP_Slip = &H20000 ' Windows 2000: Specifies the Serial Line Internet Protocol (SLIP). SLIP is a framing protocol used primarily in UNIX environments. End Enum Public Enum RASNetProtocols RASNP_NetBEUI = &H1 ' Negotiate the NetBEUI protocol. RASNP_IPX = &H2 ' Negotiate the IPX protocol. RASNP_IP = &H4 ' Negotiate the TCP/IP protocol. End Enum Public Enum RasFramingProtocols RASFP_PPP = &H1 ' Point-to-Point Protocol (PPP) RASFP_SLIP = &H2 ' Serial Line Internet Protocol (SLIP) RASFP_RAS = &H4 ' Asynchronous NetBEUI, Microsoft proprietary protocol implemented in Windows NT 3.1 and Windows for Workgroups 3.11 End Enum ' Windows NT Enh./Windows 2000 'Public Enum DialModes ' RASEDM_DialAll = 1 ' Dial all subentries initially. ' RASEDM_DialAsNeeded = 2 ' Adjust the number of subentries as bandwidth is needed. RAS uses the dwDialExtraPercent, dwDialExtraSampleSeconds, dwDialHangUpExtraPercent, and dwHangUpExtraSampleSeconds members to determine when to dial or disconnect a subentry. 'End Enum ' Windows NT Enh./Windows 2000 'Public Enum DisconnectModes ' RASIDS_Disabled = &HFFFFFFFF ' There is no idle time out for this connection. ' RASIDS_UseGlobalValue = 0 ' Use the user preference value as the default. 'End Enum ' Windows 2000 or later 'Public Enum PhoneBookTypes ' RASET_Phone = ? ' Phone line, for example, modem, ISDN, X.25. ' RASET_Vpn = ? ' Virtual Private Network ' RASET_Direct = ? ' Direct serial or parallel connection ' RASET_Internet = ? ' Internet Connection Services (ICS) 'End Enum ' Windows 2000 or later 'Public Enum EncryptionTypes ' ET_40Bit =? ' Require encryption ' ET_128Bit =? ' Require strong encryption ' ET_None =? ' No encryption ' ET_Require =? ' Require encryption ' ET_RequireMax =? ' Require maximum-strength encryption. ' ET_Optional =? ' Do encryption if possible. No encryption is okay. 'End Enum ' Windows 2000 or later 'Public Enum StrategyTypes ' VS_Default =? ' With this strategy, RAS dials PPTP first. If PPTP fails, L2TP is attempted. Whichever protocol succeeds is tried first in subsequent dialing for this entry. ' VS_PptpOnly =? ' RAS will dial only PPTP. ' VS_PptpFirst =? ' RAS will always dial PPTP first. ' VS_L2tpOnly =? ' RAS will dial only L2TP. ' VS_L2tpFirst =? ' RAS will always dial L2TP first. 'End Enum '------------------------------------------------------------------------------------------------------------- ' Type Declarations '------------------------------------------------------------------------------------------------------------- Public Type RASENTRYNAME dwSize As Long szEntryName(257) As Byte End Type Public Type RASIPADDR ' IP Address Structure - xxx.xxx.xxx.xxx a As Byte B As Byte c As Byte d As Byte End Type Public Type RASPBDIALOG ' [ Windows NT Only ] dwSize As Long ' IN - Specifies the size of this structure, in bytes. Before calling RasPhonebookDlg, set this member to sizeof(RASPBDIALOG) to indicate the version of the structure. If dwSize is not a valid size, RasPhonebookDlg fails and sets the dwError member to ERROR_INVALID_SIZE. hwndOwner As Long ' IN - Specifies the window that owns the modal RasPhonebookDlg dialog box. This member can be any valid window handle, or it can be NULL if the dialog box has no owner. dwFlags As Long ' IN - A set of bit flags that indicate the options enabled for the dialog box. This parameter can be a combination of the following values. (See RASPBDFLAG_* Constants) xDlg As Long ' IN - Specifies the horizontal screen coordinate of the upper-left corner of the dialog box. This value is used only if the RASPBDFLAG_PositionDlg flag is set. yDlg As Long ' IN - Specifies the vertical screen coordinate of the upper-left corner of the dialog box. This value is used only if the RASPBDFLAG_PositionDlg flag is set. dwCallbackID As Long ' IN - Specifies an application-defined value that is passed to the callback function specified by pCallback. You can use dwCallbackId to pass a pointer to application-specific context information. pCallback As Long ' IN - Pointer to a RasPBDlgFunc callback function that receives notifications of user activity while the dialog box is open. This member can be NULL if you do not want notifications. dwError As Long ' OUT - The RasPhonebookDlg function sets this member to a system error code or RAS error code if an error occurs. If no error occurs, the function sets dwError to zero. This value is ignored on input. Reserved As Long ' IN - Reserved; must be zero. Reserved2 As Long ' IN - Reserved; must be zero. End Type Public Type RASDIALDIALOG ' [ Windows NT Only ] dwSize As Long ' IN - Specifies the size of this structure, in bytes. Before calling RasDialDlg, set this member to sizeof(RASDIALDIALOG) to indicate the version of the structure. If dwSize is not a valid size, RasDialDlg fails and sets the dwError member to ERROR_INVALID_SIZE. hwndOwner As Long ' IN - Specifies the window that owns the modal RasDialDlg dialog boxes. This member can be any valid window handle, or it can be NULL if the dialog box has no owner. dwFlags As Long ' IN - A bit flag that indicates the options that are enabled for the dialog box. You can specify the following value : RASDDFLAG_PositionDlg xDlg As Long ' IN - Specifies the horizontal screen coordinate of the upper-left corner of the dialog box. This value is used only if the RASDDFLAG_PositionDlg flag is set. yDlg As Long ' IN - Specifies the vertical screen coordinate of the upper-left corner of the dialog box. This value is used only if the RASDDFLAG_PositionDlg flag is set. dwSubEntry As Long ' IN - Specifies the subentry or subentries to dial. If dwSubEntry is zero, RasDialDlg dials all subentries associated with the specified phone-book entry. Otherwise, to indicate the index of the individual subentry to dial, dwSubEntry must be a number from one to the number of subentries. dwError As Long ' OUT - The RasDialDlg function sets this member to a system error code or RAS error code if an error occurs. If no error occurs, the function sets dwError to zero. This value is ignored on input. Reserved As Long ' IN - Reserved; must be zero. Reserved2 As Long ' IN - Reserved; must be zero. End Type Public Type RASMONITORDIALOG ' [ Windows NT Only ] dwSize As Long ' IN - Specifies the size of this structure, in bytes. Before calling RasMonitorDlg, set this member to sizeof(RASMONITORDLG) to indicate the version of the structure. If dwSize is not a valid size, RasMonitorDlg fails and sets the dwError member to ERROR_INVALID_SIZE. hwndOwner As Long ' IN - Specifies the window that owns the modal RasMonitorDlg property sheet. This member can be any valid window handle, or it can be NULL if the property sheet has no owner. dwFlags As Long ' IN - A bit flag that indicates the options that are enabled for the property sheet. You can specify the following value : RASMDFLAG_PositionDlg dwStartPage As Long ' IN - A set of bit flags that indicate the initial page of the property sheet to display on top. You can specify one of the following values : RASMDPAGE_Status, RASMDPAGE_Summary, RASMDPAGE_Preferences xDlg As Long ' IN - Specifies the horizontal screen coordinate of the upper-left corner of the property sheet. This value is used only if the RASMDFLAG_PositionDlg flag is set. yDlg As Long ' IN - Specifies the vertical screen coordinate of the upper-left corner of the property sheet. This value is used only if the RASMDFLAG_PositionDlg flag is set. dwError As Long ' OUT - The RasMonitorDlg function sets this member to a system error code or RAS error code if an error occurs. If no error occurs, the function sets dwError to zero. This value is ignored on input. Reserved As Long ' IN - Reserved; must be zero. Reserved2 As Long ' IN - Reserved; must be zero. End Type Public Type RASENTRYDIALOG ' [ Windows NT Only ] dwSize As Long ' IN - Specifies the size of this structure, in bytes. Before calling RasEntryDlg, set this member to sizeof(RASENTRYDLG) to indicate the version of the structure. If dwSize is not a valid size, RasEntryDlg fails and sets the dwError member to ERROR_INVALID_SIZE. hwndOwner As Long ' IN - Specifies the window that owns the modal RasEntryDlg dialog box. This member can be any valid window handle, or it can be NULL if the dialog box has no owner. dwFlags As Long ' IN - A set of bit flags that indicate the options enabled for the dialog box. This parameter can be a combination of the RASEDFLAG_PositionDlg flag and one of the other flags listed following to indicate whether the RasEntryDlg function is creating, copying, or editing a phone-book entry. xDlg As Long ' IN - Specifies the horizontal screen coordinate of the upper-left corner of the dialog box. This value is used only if the RASEDFLAG_PositionDlg flag is set. yDlg As Long ' IN - Specifies the vertical screen coordinate of the upper-left corner of the dialog box. This value is used only if the RASEDFLAG_PositionDlg flag is set. szEntry As String * 267 ' OUT - On exit, szEntry is set to the name of the phone-book entry that was edited or created. dwError As Long ' OUT - The RasEntryDlg function sets this member to a system error code or RAS error code if an error occurs. If no error occurs, the function sets dwError to zero. This value is ignored on input. Reserved As Long ' IN - Reserved; must be zero. Reserved2 As Long ' IN - Reserved; must be zero. End Type Type RASCONNSTATUS_VB lRasConnState As Long ' Specifies a RASCONNSTATE enumerator value that indicates the current state of the RasDial connection process; that is, the piece of the RasDial process that is currently executing. Two state values are especially significant: ' - RASCS_Connected : Indicates that the connection has been successfully established. ' - RASCS_Disconnected : Indicates that the connection has failed. dwError As Long ' If nonzero, indicates the reason for failure. The value is one of the error values from the RAS header file or one of ERROR_NOT_ENOUGH_MEMORY or ERROR_INVALID_HANDLE. sDeviceType As String ' A string that specifies the type of the current device, if available. For example, common device types supported by RAS are "modem", "pad", "switch", "isdn", or "null". sDeviceName As String ' A string that specifies the name of the current device, if available. This would be the name of the modem — for example, "Hayes Smartmodem 2400"; the name of the PAD, for example "US Sprint"; or the name of a switch device, for example "Racal-Guardata". sNTPhoneNumber As String ' Windows NT Enh./Windows 2000 : Phone number of the connection End Type Public Type RASDIALEXTENSIONS dwSize As Long ' Specifies the size of this structure, in bytes. Set this member to sizeof(RASDIALEXTENSIONS). This indicates the version of the structure. dwfOptions As Long ' A set of bit flags that specify RasDial extensions. The default value for each of these bit flags is zero. (See Constants RDEOPT_*) hwndParent As Long ' Handle to a parent window that a security DLL can use for dialog box creation and centering. Note that this is not the window that receives RasDial progress notifications. This member is optional; it is not required when no security DLL is defined. The default value for this member is NULL. Reserved As Long ' This member is reserved for future use. It must be set to zero. End Type Public Type RASDIALPARAMS dwSize As Long ' Specifies the structure size, in bytes. szEntryName As String * 257 ' Specifies a string containing the phone-book entry to use to establish the connection. An empty string ("") specifies a simple modem connection on the first available modem port, in which case a nonempty szPhoneNumber must be provided. ' Windows NT 4.0 and later versions: The callback number is no longer stored in the registry. Specifying an asterisk for szCallbackNumber causes RAS to return error 704: ERROR_BAD_CALLBACK_NUMBER. szPhoneNumber As String * 129 ' Specifies a string that contains an overriding phone number. An empty string ("") indicates that the phone-book entry's phone number should be used. If szEntryName is "", szPhoneNumber cannot be "". szCallbackNumber As String * 129 ' Specifies a string that contains a callback phone number. An empty string ("") indicates that callback should not be used. This string is ignored unless the user has "Set By Caller" callback permission on the RAS server. An asterisk indicates that the number stored in the phone book should be used for callback. szUserName As String * 257 ' Specifies a string that contains the user's user name. This string is used to authenticate the user's access to the remote access server. szPassword As String * 257 ' Specifies a string that contains the user's password. This string is used to authenticate the user's access to the remote access server. ' Windows NT/2000: You can use szPassword to send a new password to the remote server when you restart a RasDial connection from a RASCS_PasswordExpired paused state. When changing a password on an entry that calls Microsoft Networks, you should limit the new password to 14 characters in length to avoid down-level compatibility problems. ' Windows 2000 and later versions: When retrieving the password using the RasGetEntryDialParams function, the szPassword member does not receive the actual password. Instead, szPassword receives a handle to the saved password. You can substitute this handle for the saved password in calls to RasSetDialParams, and RasDial. When presented with this handle, RasDial retrieves and uses the saved password. The value of this handle may change in future versions of the operating system; do not develop code that depends on the contents or format of this value. szDomain As String * 16 ' Specifies a string that contains the domain on which authentication is to occur. An empty string ("") specifies the domain in which the remote access server is a member. An asterisk specifies the domain stored in the phone book for the entry. Padding(2) As Byte ' * Padding to make sure that the type is the right size 'dwSubEntry As Long ' Windows NT Enhanced : Specifies the index of the initial subentry to dial. If the dial mode is RASEDM_DialAsNeeded, RAS dials this subentry. If dwSubEntry is not a valid subentry index, RAS dials the first subentry. If the dial mode of the phone-book entry is RASEDM_DialAll, dwSubEntry is ignored. If the phone-book entry has no subentries, dwSubEntry is ignored. The subentry indices are one-based. That is, the first subentry has an index of one, the second subentry as an index of two, and so on. The RASENTRY structure returned by RasGetEntryProperties indicates the dial mode (dwDialMode) and number of subentries (dwSubEntries) for the phone-book entry. ' Windows 2000 and later: If dwSubEntry specifies a valid subentry index, RAS dials the specified subentry regardless of the dial mode. If the dial mode is RASEDM_DialAll and dwSubEntry is zero, RAS dials all of the subentries. 'dwCallbackID As Long ' Windows NT Enh./Windows 2000: Specifies an application-defined value that RAS passes to your RasDialFunc2 callback function. End Type Type RASCONN_VB ' RASCONN hRasConn As Long ' Specifies the remote access connection. This handle is used in other remote access API calls. sEntryName As String ' A string that specifies the phone-book entry used to establish the remote access connection. If the connection was established using an empty entry name, this string consists of a PERIOD followed by the connection phone number. sDeviceType As String ' Windows NT 4.0 and later: A null-terminated string that contains the device type through which the connection is made. sDeviceName As String ' Windows NT 4.0 and later: A null-terminated string that contains the device name through which the connection is made. sPhonebook As String ' Windows NT 4.0 and later: The full path and file name to the phone book containing the entry for this connection. lngSubEntry As Long ' Windows NT 4.0 and later: For multilink connections, specifies the subentry index of one of the connected links. Subentry indices are one based. guidEntry(15) As Byte ' Windows 2000 : A GUID (Globally Unique IDentifier) that represents the phone-book entry. The value of this member corresponds to that of the guidid member in the RASENTRY structure. End Type Public Type RASAMB ' * The RasGetProjectionInfo function returns a RASAMB data structure when its rasprojection parameter has the value RASP_Amb. dwSize As Long ' Specifies the size of the structure, in bytes. Before calling the RasGetProjectionInfo function, set this member to sizeof(RASAMB). The function can then determine the version of the RASAMB data structure that the caller of RasGetProjectionInfo is expecting. This allows backward compatibility for compiled applications if there are future enhancements to the data structure. dwError As Long ' Contains the result of the PPP control protocol negotiation. A value of zero indicates success. A nonzero value indicates failure, and is the actual fatal error that occurred during the control protocol negotiation, the error that prevented the projection from completing successfully. szNetBiosError As String * 17 ' If dwError has the value ERROR_NAME_EXISTS_ON_NET, the szNetBiosError field contains a zero-terminated string that is the NetBIOS name that caused the conflict. For other values of dwError, this field contains the null string. bLana As Byte ' Specifies the NetBIOS network adapter identifier, or LANA, on which the remote access connection was established. This member contains the value 0xFF if a connection was not established. End Type Public Type RASPPPNBF ' * The RasGetProjectionInfo function returns a RASPPPNBF data structure when its rasprojection parameter has the value RASP_PppNbf. dwSize As Long ' Specifies the size of the structure, in bytes. Before calling the RasGetProjectionInfo function, set this member to sizeof(RASPPPNBF). The function can then determine the version of the RASPPPNBF data structure that the caller of RasGetProjectionInfo is expecting. This allows backwards compatibility for compiled applications if there are future enhancements to the data structure. dwError As Long ' Contains the result of the PPP control protocol negotiation. A value of zero indicates success. A nonzero value indicates failure, and is the actual fatal error that occurred during the control protocol negotiation, the error that prevented the projection from completing successfully. dwNetBiosError As Long ' If dwError has the value ERROR_SERVER_NOT_RESPONDING or ERROR_NETBIOS_ERROR, the dwNetBiosError field contains the NetBIOS error that occurred. For other values of dwError, this field contains zero. ' Windows 95: This member is undefined. szNetBiosError As String * 17 ' If dwError has the value ERROR_NAME_EXISTS_ON_NET, the szNetBiosError field contains a zero-terminated string that is the NetBIOS name that caused the conflict. For other values of dwError, this field contains the null string. szWorkstationName As String * 17 ' Contains a zero-terminated string that is the local workstation's computer name. This unique computer name is the closest NetBIOS equivalent to a client's NetBEUI address on a remote access connection. bLana As Byte ' Specifies the NetBIOS network adapter identifier, or LANA, on which the remote access connection was established. This member contains the value 0xFF if a connection was not established. End Type Public Type RASPPPIPX ' * The RasGetProjectionInfo function returns a RASPPPIPX data structure when its rasprojection parameter has the value RASP_PppIpx. dwSize As Long ' Specifies the size of the structure, in bytes. Before calling the RasGetProjectionInfo function, set this member to sizeof(RASPPPIPX). The function can then determine the version of the RASPPPIPX data structure that the caller of RasGetProjectionInfo is expecting. This allows backwards compatibility for compiled applications if there are future enhancements to the data structure. dwError As Long ' Contains the result of the PPP control protocol negotiation. A value of zero indicates success. A nonzero value indicates failure, and is the actual fatal error that occurred during the control protocol negotiation, the error that prevented the projection from completing successfully. szIpxAddress As String * 22 ' Contains a zero-terminated string that is the client's IPX address on the RAS connection. This address string has the form net.node; for example, "1234ABCD.12AB34CD56EF". End Type Public Type RASPPPIP ' * The RasGetProjectionInfo function returns a RASPPPIP data structure when its rasprojection parameter has the value RASP_PppIp. dwSize As Long ' Specifies the size of the structure, in bytes. Before calling the RasGetProjectionInfo function, set this member to indicate the version of the RASPPPIP structure that you are using. For information about earlier versions of this structure, see the following Remarks section. dwError As Long ' Contains the result of the PPP control protocol negotiation. A value of zero indicates success. A nonzero value indicates failure, and is the actual fatal error that occurred during the control protocol negotiation, the error that prevented the projection from completing successfully. szIpAddress As String * 22 ' Contains a zero-terminated string that is the client's IP address on the RAS connection. This address string has the form a.b.c.d; for example, "11.101.237.71". szServerIpAddress As String * 22 ' Contains a null-terminated string that is the IP address of the remote PPP peer (that is, the server's IP address). This string is in "a.b.c.d" form. PPP does not require that servers provide this address, but Windows NT/Windows 2000 servers will consistently return the address anyway. Other PPP vendors may not provide the address. If the address is not available, this member returns an empty string, "". ' dwOptions As Long ' Windows 2000 and later : Specifies IPCP options for the local computer. Currently, the only option is RASIPO_VJ. This option indicates that IP datagrams sent by the local computer are compressed using Van Jacobson compression. ' dwServerOptions As Long ' Windows 2000 and later : Specifies IPCP options for the remote peer. Currently, the only option is RASIPO_VJ. This option indicates that IP datagrams sent by the remote peer (that is, received by the local computer) are compressed using Van Jacobson compression. End Type ' [ Windows 2000 or later ] 'Public Type RASPPPCCP ' * The RASPPPCCP structure contains information that describes the results of a Compression Control Protocol (CCP) negotiation. ' dwSize As Long ' Size of the RASPPPCCP structure. Ensure that this member contains the size of the structure before using the structure in a function call. ' dwError As Long ' If the negotiation was unsuccessful, dwError contains the error that occurred. ' dwCompressionAlgorithm As Long ' The compression algorithm in use by the client. The following table shows the possible values for this member: ' ' - RASCCPCA_MPPC : Microsoft Point to Point Compression (MPPC) Protocol (RFC 2118) ' ' - RASCCPCA_STAC : STAC option 4 (RFC 1974) ' dwOptions As Long ' Specifies the compression options on the client. The following options are supported. ' ' - RASCCPO_Compression : Compression without encryption. ' ' - RASCCPO_HistoryLess : Microsoft Point to Point Encryption (MPPE) in stateless mode. The session key is changed after every packet. This mode improves performance on high latency networks, or networks that experience significant packet loss. ' ' - RASCCPO_Encryption56bit : MPPE using 56 bit keys. (Used when a connection is made over Layer 2 Tunneling Protocol (L2TP), and the connection uses IPSec encryption) ' ' - RASCCPO_Encryption40bit : MPPE using 40 bit keys. (Used when a connection is made over Layer 2 Tunneling Protocol (L2TP), and the connection uses IPSec encryption) ' ' - RASCCPO_Encryption128bit : MPPE using 128 bit keys. (Used when a connection is made over Layer 2 Tunneling Protocol (L2TP), and the connection uses IPSec encryption) ' dwServerCompressionAlgorithm As Long ' The compression algorithm in use by the server. The following table shows the possible values for this member. ' ' - RASCCPCA_MPPC : Microsoft Point to Point Compression (MPPC) Protocol ' ' - RASCCPCA_STAC : STAC option 4 ' dwServerOptions As Long ' Specifies the compression options on the server. The following options are supported. ' ' - RASCCPO_Compression : Compression without encryption. ' ' - RASCCPO_HistoryLess : Microsoft Point to Point Encryption (MPPE) in stateless mode. The session key is changed after every packet. This mode improves performance on high latency networks, or networks that experience significant packet loss. ' ' - RASCCPO_Encryption56bit : MPPE using 56 bit keys. (Used when a connection is made over Layer 2 Tunneling Protocol (L2TP), and the connection uses IPSec encryption) ' ' - RASCCPO_Encryption40bit : MPPE using 56 bit keys. (Used when a connection is made over Layer 2 Tunneling Protocol (L2TP), and the connection uses IPSec encryption) ' ' - RASCCPO_Encryption128bit : MPPE using 56 bit keys. (Used when a connection is made over Layer 2 Tunneling Protocol (L2TP), and the connection uses IPSec encryption) 'End Type ' [ Windows 2000 or later ] 'Public Type RASPPPLCP ' dwSize As Long ' Size of the RASPPPLCP structure. Ensure that this member contains the size of the structure before using the structure in a function call. ' fBundled As Long ' If this member is TRUE, the connection is composed of multiple links. Otherwise, this member is FALSE. ' dwError As Long ' If the negotiation was unsuccessful, dwError contains the error that occurred. ' dwAuthenticationProtocol As Long ' The authentication protocol used to authenticate the client. This member can be one of the following values. ' ' - RASLCPAP_PAP : Password Authentication Protocol ' ' - RASLCPAP_SPAP : Shiva Password Authentication Protocol ' ' - RASLCPAP_CHAP : Challenge Handshake Authentication Protocol ' ' - RASLCPAP_EAP : Extensible Authentication Protocol ' dwAuthenticationData As Long ' Provides additional information about the authentication protocol specified by the dwAuthenticationProtocol member. This member can be one of the following values. ' ' - RASLCPAD_CHAP_MD5 : MD5 CHAP ' ' - RASLCPAD_CHAP_MS : Microsoft CHAP ' ' - RASLCPAD_CHAP_MSV2 : Microsoft CHAP version 2 ' dwEapTypeId As Long ' Provides the type ID of the extensible authentication protocol (EAP) used to authenticate the local computer. The value of this member is valid only if dwAuthenticationProtocol is RASLCPAPP_EAP. ' dwServerAuthenticationProtocol As Long ' The authentication protocol used to authenticate the server. See the dwAuthenticationProtocol member for a list of possible values. ' dwServerAuthenticationData As Long ' Provides additional information about the authentication protocol specified by dwServerAuthenticationProtocol. See the dwAuthenticationData member for a list of possible values. ' dwServerEapTypeId As Long ' Provides the type ID of the extensible authentication protocol (EAP) used to authenticate the remote computer. The value of this member is valid only if dwServerAuthenticationProtocol is RASLCPAP_EAP. ' fMultilink As Long ' If this member is TRUE, the connection supports multi-link. Otherwise, this member is FALSE. ' dwTerminateReason As Long ' This member always has a value of zero. ' dwServerTerminateReason As Long ' This member always has a value of zero. ' szReplyMessage As String * RAS_MaxReplyMessage ' Pointer to a string that contains the message, if any, from the authentication protocol success/failure packet. ' dwOptions As Long ' Provides additional LCP options for the local computer. This member is a combination of the following flags. ' ' - RASLCPO_PFC : Protocol Field Compression (see RFC 1172) ' ' - RASLCPO_ACFC : Address and Control Field Compression (see RFC 1172) ' ' - RASLCPO_SSHF : Short Sequence Number Header Format (see RFC 1990) ' ' - RASLCPO_DES_56 : DES 56-bit encryption ' ' - RASLCPO_3_DES : Triple DES Encryption ' dwServerOptions As Long ' Provides addition LCP options for the remote computer. This member is a combination of the following flags. ' ' - RASLCPO_PFC Protocol Field Compression (see RFC 1172) ' ' - RASLCPO_ACFC Address and Control Field Compression (see RFC 1172) ' ' - RASLCPO_SSHF Short Sequence Number Header Format (see RFC 1990) ' ' - RASLCPO_DES_56 DES 56-bit encryption ' ' - RASLCPO_3_DES Triple DES Encryption 'End Type ' [ Windows 2000 or later ] 'Public Type RASSLIP ' dwSize As Long ' Specifies the size, in bytes, of the RASSLIP structure. Before calling the RasGetProjectionInfo function, set dwSize to sizeof(RASSLIP) to identify the version of the structure. ' dwError As Long ' Specifies whether SLIP is configured. If dwError is zero, SLIP framing is configured. Otherwise, dwError is ERROR_PROTOCOL_NOT_CONFIGURED. ' szIpAddress As String * 22 ' A null-terminated string that contains the client's IP address on the RAS connection. This address string has the form a.b.c.d; for example, "11.101.237.71". 'End Type Public Type RASENTRY_VB ' RASENTRY Options As RasEntryOptions ' A set of bit flags that specify connection options. CountryID As Long ' Specifies the TAPI country identifier. Use the RasGetCountryInfo function to enumerate country identifiers. This member is ignored unless the dwfOptions member specifies the RASEO_UseCountryAndAreaCodes flag. CountryCode As Long ' Specifies the country code portion of the phone number. The country code must correspond to the country identifier specified by dwCountryID. If dwCountryCode is zero, the country code is based on the country identifier specified by dwCountryID. This member is ignored unless dwfOptions specifies the RASEO_UseCountryAndAreaCodes flag. AreaCode As String ' Specifies the area code as a null-terminated string. If the dialing location does not have an area code, specify an empty string (""). Do not include parentheses or other delimiters in the area code string. (For example, "206" is a valid area code; "(206)" is not. This member is ignored unless the dwfOptions member specifies the RASEO_UseCountryAndAreaCodes flag. LocalPhoneNumber As String ' Specifies a null-terminated string containing a telephone number. The way RAS uses this string depends on whether the dwfOptions member specifies the RASEO_UseCountryAndAreaCodes flag. If the flag is set, RAS combines szLocalPhoneNumber with the country and area codes specified by the dwCountryID, dwCountryCode , and szAreaCode members. If the flag is not set, RAS uses the szLocalPhoneNumber string as the entire phone number. AlternateNumbers As String ' Specifies the offset, in bytes, from the beginning of the structure to a list of consecutive null-terminated strings. The last string is terminated by two consecutive null characters. The strings are alternate phone numbers that RAS dials in the order listed if the primary number (see szLocalPhoneNumber) fails to connect. The alternate phone number strings are ANSI or Unicode, depending on whether you use the ANSI or Unicode version of the structure. ipAddr As RASIPADDR ' Specifies the IP address to be used while this connection is active. This member is ignored unless dwfOptions specifies the RASEO_SpecificIpAddr flag. ipAddrDns As RASIPADDR ' Specifies the IP address of the DNS server to be used while this connection is active. This member is ignored unless dwfOptions specifies the RASEO_SpecificNameServers flag. ipAddrDnsAlt As RASIPADDR ' Specifies the IP address of a secondary or backup DNS server to be used while this connection is active. This member is ignored unless dwfOptions specifies the RASEO_SpecificNameServers flag. ipAddrWins As RASIPADDR ' Specifies the IP address of the WINS server to be used while this connection is active. This member is ignored unless dwfOptions specifies the RASEO_SpecificNameServers flag. ipAddrWinsAlt As RASIPADDR ' Specifies the IP address of a secondary WINS server to be used while this connection is active. This member is ignored unless dwfOptions specifies the RASEO_SpecificNameServers flag. FrameSize As Long ' Specifies the network protocol frame size. The value should be either 1006 or 1500. This member is ignored unless dwFramingProtocol specifies the RASFP_Slip flag. fNetProtocols As RASNetProtocols ' Specifies the network protocols to negotiate. FramingProtocol As RasFramingProtocols ' Specifies the framing protocol used by the server. PPP is the emerging standard. SLIP is used mainly in UNIX environments. To use Compressed SLIP, set the RASFP_Slip flag and set the RASEO_IpHeaderCompression flag in the dwfOptions member. ' Windows 2000 or later: The RASFP_Ras flag is no longer supported. As a result, Windows 2000 and later computers will not be able to connect to Lan Manager, Windows for Workgroups 3.11, or Windows NT 3.1 servers. However, these earlier platforms will continue to be able to connect to Windows 2000 and later servers. ScriptName As String ' Specifies a null-terminated string containing the name of the script file. The file name should be a full path. ' Windows NT/2000: To indicate a Windows NT/Windows 2000 SWITCH.INF script name, set the first character of the name to "[". AutodialDll As String ' Specifies a null-terminated string containing the full path and file name of the dynamic-link library (DLL) for the customized AutoDial handler. If szAutodialDll contains an empty string (""), RAS uses the default dialing user interface and the szAutodialFunc member is ignored. AutodialFunc As String ' Specifies a null-terminated string containing the exported name of the RASADFunc function for the customized AutoDial handler. An AutoDial DLL must provide both ANSI and Unicode versions of the RASADFunc handler. However, do not include the "A" or "W" suffix in the name specified by szAutodialFunc. DeviceType As String ' Specifies a null-terminated string indicating the RAS device type referenced by szDeviceName. (See DeviceTypes Enumeration) ' Windows 95: The RASDT_Vpn device type is supported on Windows 95 only if Microsoft Dial-Up Networking Version 1.2 is installed. The RASDT_X25 and RASDT_Pad device types are not supported on Windows 95. ' Windows 98: The RASDT_Vpn device type is supported on Windows 98. However, the RASDT_X25 and RASDT_Pad device types are not currently supported on Windows 98. DeviceName As String ' Contains a null-terminated string containing the name of a TAPI device to use with this phone-book entry, for example, "XYZ Corp 28800 External". To enumerate all available RAS-capable devices, use the RasEnumDevices function. X25PadType As String ' Contains a null-terminated string that identifies the X.25 PAD type. Set this member to "" unless the entry should dial using an X.25 PAD. ' Windows NT/2000: Under Windows NT/Windows 2000, the szX25PadType string maps to a section name in PAD.INF. X25Address As String ' Contains a null-terminated string that identifies the X.25 address to connect to. Set this member to "" unless the entry should dial using an X.25 PAD or native X.25 device. X25Facilities As String ' Contains a null-terminated string that specifies the facilities to request from the X.25 host at connection. This member is ignored if szX25Address is an empty string (""). X25UserData As String ' Contains a null-terminated string that specifies additional connection information supplied to the X.25 host at connection. This member is ignored if szX25Address is an empty string (""). Channels As Long ' ( Undocumented ) ' NT4En_SubEntries As Long ' Windows NT Enh.: Specifies the number of multilink subentries associated with this entry. When calling RasSetEntryProperties, set this member to zero. To add subentries to a phone-book entry, use the RasSetSubEntryProperties function. ' NT4En_DialMode As DialModes ' Windows NT Enh.: Specifies whether RAS should dial all of this entry's multilink subentries when the entry is first connected. This member can be one of the following values. ' NT4En_DialExtraPercent As Long ' Windows NT Enh./Windows 2000: Specifies a percent of the total bandwidth available from the currently connected subentries. RAS dials an additional subentry when the total bandwidth used exceeds dwDialExtraPercent percent of the available bandwidth for at least dwDialExtraSampleSeconds seconds. This member is ignored unless the dwDialMode member specifies the RASEDM_DialAsNeeded flag. ' NT4En_DialExtraSampleSeconds As Long ' Windows NT Enh./Windows 2000: Specifies the number of seconds that current bandwidth usage must exceed the threshold specified by dwDialExtraPercent before RAS dials an additional subentry. This member is ignored unless the dwDialMode member specifies the RASEDM_DialAsNeeded flag. ' NT4En_HangUpExtraPercent As Long ' Windows NT Enh./Windows 2000: Specifies a percent of the total bandwidth available from the currently connected subentries. RAS terminates (hangs up) an existing subentry connection when total bandwidth used is less than dwHangUpExtraPercent percent of the available bandwidth for at least dwHangUpExtraSampleSeconds seconds. This member is ignored unless the dwDialMode member specifies the RASEDM_DialAsNeeded flag. ' NT4En_HangUpExtraSampleSeconds As Long ' Windows NT Enh./Windows 2000: Specifies the number of seconds that current bandwidth usage must be less than the threshold specified by dwHangUpExtraPercent before RAS terminates an existing subentry connection. This member is ignored unless the dwDialMode member specifies the RASEDM_DialAsNeeded flag. ' NT4En_IdleDisconnectSeconds As DisconnectModes ' Windows NT Enh./Windows 2000: Specifies the number of seconds after which the connection is terminated due to inactivity. Note that unless the idle time out is disabled, the entire connection is terminated if the connection is idle for the specified interval. This member can specify a number of seconds, or one of the following values. ' Win2000_Type As PhoneBookTypes ' Windows 2000 or later: The type of phone-book entry. This member can be one of the following types. ' Win2000_EncryptionType As EncryptionTypes ' Windows 2000 or later: The type of encryption to use for Microsoft Point to Point Encryption (MPPE) with the connection. This member can be one of the following values. ' Win2000_CustomAuthKey As Long ' Windows 2000 or later: This member is used for Extensible Authentication Protocol (EAP). This member contains the authentication key provided to the EAP vendor. ' Win2000_guidId(0 To 15) As Byte ' Windows 2000 or later: The GUID (Globally Unique IDentifier) that represents this phone-book entry. This member is not settable. ' Win2000_CustomDialDll As String ' Windows 2000 or later: A null-terminated string containing the full path and file name for the dynamic link library (DLL) that implements the custom-dialing functions. This DLL should export Unicode versions of functions named RasCustomDial, RasCustomHangup, RasCustomEntryDlg, and RasCustomDialDlg. These functions should have prototypes RasCustomDialFn and RasCustomHangUpFn as defined in Ras.h, and RasCustomDialDlgFn and RasCustomEntryDlgFn as defined in Rasdlg.h. If szCustomDialDll contains an empty string, RAS uses the default system dialer. ' Win2000_VpnStrategy As StrategyTypes ' Windows 2000 or later: The VPN strategy to use when dialing a VPN connection. This member can have one of the following values. End Type ' Type for getting the user's OS information Public Type OSVERSIONINFO dwOSVersionInfoSize As Long dwMajorVersion As Long dwMinorVersion As Long dwBuildNumber As Long dwPlatformId As Long szCSDVersion As String * 128 End Type '------------------------------------------------------------------------------------------------------------- ' Constants Declarations '------------------------------------------------------------------------------------------------------------- ' Constants - General Private Const MAX_PATH = 260 + 1 ' Extra 1 for NULL terminator Private Const WM_RASDIALEVENT = &HCCCD ' Windows RAS Dialing Event Message Private Const RASDIALEVENT = "RasDialEvent" Private WM_RASDIALEVENT_REG As Long Private RegisterFailed As Boolean ' Constants - GlobalAlloc Public Const GMEM_FIXED = &H0 Public Const GMEM_ZEROINIT = &H40 Public Const GPTR = (GMEM_FIXED Or GMEM_ZEROINIT) ' Constants - RASPBDIALOG.dwFlags (Windows NT Only) Public Const RASPBDFLAG_PositionDlg = &H1 ' Causes RasPhonebookDlg to use the values specified by the xDlg and yDlg members to position the dialog box. If this flag is not set, the dialog box is centered on the owner window, unless hwndOwner is NULL, in which case, the dialog box is centered on the screen. Public Const RASPBDFLAG_ForceCloseOnDial = &H2 ' Turns on the close-on-dial option, overriding the user's preference. This option is appropriate with features such as RAS AutoDial where the user's goal is to make a connection immediately. Public Const RASPBDFLAG_NoUser = &H10 ' Causes the RasPBDlgFunc callback function specified by the pCallback member to receive a RASPBDEVENT_NoUser notification when the dialog box is starting up. This flag is for use in situations in which there is no logged-on user, as in the WinLogon application. Typically, applications should not use this flag. Public Const RASPBDFLAG_UpdateDefaults = &H80000000 ' Causes the default window position to be saved on exit. This flag is used primarily by RASPHONE.EXE and should not be used by typical applications. ' Constants - RASDIALDIALOG.dwFlags (Windows NT Only) Public Const RASDDFLAG_PositionDlg = &H1 Public Const RASDDFLAG_LinkFailure = &H80000000 ' Constants - RASMONITORDIALOG.dwFlags (Windows NT Only) Public Const RASMDFLAG_PositionDlg = &H1 Public Const RASMDFLAG_UpdateDefaults = &H80000000 ' Constants - RASMONITORDIALOG.dwStartPage (Windows NT Only) Public Const RASMDPAGE_Status = 0 Public Const RASMDPAGE_Summary = 1 Public Const RASMDPAGE_Preferences = 2 ' Constants - RASENTRYDIALOG.dwFlags (Windows NT Only) Public Const RASEDFLAG_PositionDlg = &H1 ' Causes RasEntryDlg to use the values specified by the xDlg and yDlg members to position the dialog box. If this flag is not set, the dialog box is centered on the owner window, unless hwndOwner is NULL, in which case, the dialog box is centered on the screen. Public Const RASEDFLAG_NewEntry = &H2 ' Causes RasEntryDlg to display a wizard for creating a new phone-book entry. Public Const RASEDFLAG_CloneEntry = &H4 ' Causes RasEntryDlg to create a new entry by copying the properties of an existing entry. The function displays a property sheet containing the properties associated with the phone-book entry specified by the lpszEntry parameter of RasEntryDlg. The user can edit the properties and specify a name for the new entry. Public Const RASEDFLAG_NoRename = &H8 ' Causes RasEntryDlg to display a property sheet for editing the properties of the phone-book entry specified by the lpszEntry parameter of RasEntryDlg. The user can change the properties of the entry but not its name. Public Const RASEDFLAG_ShellOwned = &H40000000 ' (Undocumented) ' Constants - RAS Size Limits Public Const RASMax_DeviceType = 16 Public Const RASMax_PhoneNumber = 128 Public Const RASMax_IpAddress = 15 Public Const RASMax_IpxAddress = 21 Public Const RASMax_EntryName = 256 Public Const RASMax_DeviceName = 128 Public Const RASMax_CallbackNumber = RASMax_PhoneNumber Public Const RASMax_AreaCode = 10 Public Const RASMax_PadType = 32 Public Const RASMax_X25Address = 200 Public Const RASMax_Facilities = 200 Public Const RASMax_UserData = 200 ' Constants - RASENTRY.szDeviceType Public Const RASDT_Modem = "modem" ' A modem accessed through a COM port. Public Const RASDT_Isdn = "isdn" ' An ISDN card with corresponding NDISWAN driver installed. Public Const RASDT_X25 = "x25" ' An X.25 card with corresponding NDISWAN driver installed. 'Public Const RASDT_Vpn = "vpn" ' Windows 2000: A virtual private network connection. 'Public Const RASDT_Pad = "pad" ' Windows 2000: A Packet Assembler/Disassembler. 'Public Const RASDT_Generic = "generic" ' Windows 2000: Generic 'Public Const RASDT_Serial = "serial" ' Windows 2000: Direct serial connection through a serial port. 'Public Const RASDT_FrameRelay = "framerelay" ' Windows 2000: Frame Relay 'Public Const RASDT_Atm = "atm" ' Windows 2000: Asynchronous Transfer Mode 'Public Const RASDT_Sonet = "sonet" ' Windows 2000: Sonet 'Public Const RASDT_SW56 = "sw56" ' Windows 2000: Switched 56K Access 'Public Const RASDT_Irda = "irda" ' Windows 2000: Infrared Data Association (IrDA) compliant device. 'Public Const RASDT_Parallel = "parallel" ' Windows 2000: Direct parallel connection through a parallel port. ' Constants - RASDIALEXTENSIONS.dwfOptions Public Const RDEOPT_UsePrefixSuffix = &H1 ' If this bit flag is one, RasDial uses the prefix and suffix that is in the RAS phonebook.If this bit flag is zero, RasDial ignores the prefix and suffix that is in the RAS phonebook.If no phonebook entry name is specified in the call to RasDial, the actual value of this bit flag is ignored, and it is assumed to be zero. Public Const RDEOPT_PausedStates = &H2 ' If this bit flag is one, RasDial accepts paused states. Examples of paused states are terminal mode, retry logon, change password, and set callback number.If this bit flag is zero, RasDial reports a fatal error if it enters a paused state. Public Const RDEOPT_IgnoreModemSpeaker = &H4 ' If this bit flag is one, RasDial ignores the modem speaker setting that is in the RAS phonebook, and uses the setting specified by the RDEOPT_SetModemSpeaker bit flag.If this bit flag is zero, RasDial uses the modem speaker setting that is in the RAS phonebook, and ignores the setting specified by the RDEOPT_SetModemSpeaker bit flag.If no phonebook entry name is specified in the call to RasDial, the choice is between using a default setting or the setting specified by the RDEOPT_SetModemSpeaker bit flag. The default setting is used if RDEOPT_IgnoreModemSpeaker is zero. The setting specified by RDEOPT_SetModemSpeaker is used if RDEOPT_IgnoreModemSpeaker is one. Public Const RDEOPT_SetModemSpeaker = &H8 ' If this bit flag is one, and RDEOPT_IgnoreModemSpeaker is one, RasDial sets the modem speaker on. If this bit flag is zero, and RDEOPT_IgnoreModemSpeaker is one, RasDial sets the modem speaker off.If RDEOPT_IgnoreModemSpeaker is zero, RasDial ignores the value of RDEOPT_SetModemSpeaker, and sets the modem speaker based on the RAS phonebook setting or the default setting. Public Const RDEOPT_IgnoreSoftwareCompression = &H10 ' If this bit flag is one, RasDial ignores the software compression setting that is in the RAS phonebook, and uses the setting specified by the RDEOPT_SetSoftwareCompression bit flag.If this bit flag is zero, RasDial uses the software compression setting that is in the RAS phonebook, and ignores the setting specified by the RDEOPT_SetSoftwareCompression bit flag.If no phonebook entry name is specified in the call to RasDial, the choice is between using a default setting or the setting specified by the RDEOPT_SetSoftwareCompression bit flag. The default setting is used if RDEOPT_IgnoreSoftwareCompression is zero. The setting specified by RDEOPT_SetSoftwareCompression is used if RDEOPT_IgnoreSoftwareCompression is one. Public Const RDEOPT_SetSoftwareCompression = &H20 ' If this bit flag is one, and RDEOPT_IgnoreSoftwareCompression is one, RasDial uses software compression. If this bit flag is zero, and RDEOPT_IgnoreSoftwareCompression is one, RasDial does not use software compression.If RDEOPT_IgnoreSoftwareCompression is zero, RasDial ignores the value of RDEOPT_SetSoftwareCompression, and sets the software compression state based on the RAS phonebook setting or the default setting. Public Const RDEOPT_PauseOnScript = &H400 ' Used internally by the RasDialDlg function so that a Windows-95-style logon script is executed in a terminal window visible to the user. Applications should not set this flag. Public Const RDEOPT_DisableConnectedUI = &H40 ' ( Undocumented ) Public Const RDEOPT_DisableReconnectUI = &H80 ' ( Undocumented ) Public Const RDEOPT_DisableReconnect = &H100 ' ( Undocumented ) Public Const RDEOPT_NoUser = &H200 ' ( Undocumented ) Public Const RDEOPT_Router = &H800 ' ( Undocumented ) ' Constants - RasGetEntryProperties Errors Public Const RASBASE = 600 ' RAS base error number Public Const ERROR_INVALID_PARAMETER = 87 ' Invalid parameter passed to function Public Const ERROR_INVALID_SIZE = (RASBASE + 32) ' The structure size is incorrect. Public Const ERROR_BUFFER_INVALID = (RASBASE + 10) ' The buffer is invalid. Public Const ERROR_BUFFER_TOO_SMALL = (RASBASE + 3) ' Caller's buffer is too small. Public Const ERROR_CANNOT_OPEN_PHONEBOOK = (RASBASE + 21) ' Cannot open the phone book file. Public Const ERROR_CANNOT_FIND_PHONEBOOK_ENTRY = (RASBASE + 23) ' Cannot find the phone book entry. ' Constants - RasDial(...dwNotifyType...) Public Const RASDN_FORMNOTIFY = &HFFFFFFFF ' The lpvNotifier parameter is a handle to a window to receive progress notification messages. In a progress notification message, wParam is the equivalent of the rasconnstate parameter of RasDialFunc and RasDialFunc1, and lParam is the equivalent of the dwError parameter of RasDialFunc and RasDialFunc1. The progress notification message uses a system registered message code. Public Const RASDN_RasDialFunc = 0 ' The lpvNotifier parameter points to a RasDialFunc callback function. Public Const RASDN_RasDialFunc1 = 1 ' The lpvNotifier parameter points to a RasDialFunc1 callback function. Public Const RASDN_RasDialFunc2 = 2 ' Windows NT/2000: The lpvNotifier parameter points to a RasDialFunc2 callback function. ' Constants - Operating systems Private Const VER_PLATFORM_WIN32s = 0 Private Const VER_PLATFORM_WIN32_WINDOWS = 1 Private Const VER_PLATFORM_WIN32_NT = 2 '------------------------------------------------------------------------------------------------------------- ' Public Varaible Declarations '------------------------------------------------------------------------------------------------------------- Public hRASConnection As Long ' Handle to an open RAS/Dial-Up connection '------------------------------------------------------------------------------------------------------------- ' API Function / Sub Declarations '------------------------------------------------------------------------------------------------------------- ' General Win32 APIs: Private Declare Sub CopyMemory Lib "kernel32.dll" Alias "RtlMoveMemory" (ByRef Destination As Any, ByRef Source As Any, ByVal Length As Long) Private Declare Function FormatMessage Lib "kernel32.dll" Alias "FormatMessageA" (ByVal dwFlags As Long, lpSource As Any, ByVal dwMessageId As Long, ByVal dwLanguageId As Long, ByVal lpBuffer As String, ByVal nSize As Long, Arguments As Long) As Long Private Declare Function GetVersionEx Lib "kernel32.dll" Alias "GetVersionExA" (ByRef lpVersionInformation As OSVERSIONINFO) As Long Private Declare Function GlobalAlloc Lib "kernel32.dll" (ByVal wFlags As Long, ByVal dwBytes As Long) As Long Private Declare Function GlobalFree Lib "kernel32.dll" (ByVal hMem As Long) As Long Private Declare Function RegisterWindowMessage Lib "USER32.DLL" Alias "RegisterWindowMessageA" (ByVal LPString As String) As Long Private Declare Function SendMessage Lib "USER32.DLL" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long ' RAS / DUN APIs: Private Declare Function RasCreatePhonebookEntry Lib "RASAPI32.DLL" Alias "RasCreatePhonebookEntryA" (ByVal hWnd As Long, ByVal lpszPhonebook As String) As Long Private Declare Function RasDeleteEntry Lib "RASAPI32.DLL" Alias "RasDeleteEntryA" (ByVal lpszPhonebook As String, ByVal lpszEntry As String) As Long Private Declare Function RasDial Lib "RASAPI32.DLL" Alias "RasDialA" (ByRef lpRasDialExtensions As RASDIALEXTENSIONS, ByVal lpszPhonebook As String, ByRef lprasdialparams As RASDIALPARAMS, ByVal dwNotifierType As Long, ByVal lpvNotifier As Long, ByRef lphRasConn As Long) As Long Private Declare Function RasEditPhonebookEntry Lib "RASAPI32.DLL" Alias "RasEditPhonebookEntryA" (ByVal hWnd As Long, ByVal lpszPhonebook As String, ByVal lpszEntryName As String) As Long Private Declare Function RasEnumConnections Lib "RASAPI32.DLL" Alias "RasEnumConnectionsA" (ByRef lpRasconn As Any, ByRef lpcB As Long, ByRef lpcConnections As Long) As Long Private Declare Function RasEnumDevices Lib "RASAPI32.DLL" Alias "RasEnumDevicesA" (ByRef lpRasDevInfo As Any, ByRef lpcB As Long, ByRef lpCDevices As Long) As Long Private Declare Function RasEnumEntries Lib "RASAPI32.DLL" Alias "RasEnumEntriesA" (ByVal Reserved As String, ByVal szPhoneBook As String, ByRef lpRasEntries As Any, ByRef lpcB As Long, ByRef lpcEntries As Long) As Long Private Declare Function RasGetConnectStatus Lib "RASAPI32.DLL" Alias "RasGetConnectStatusA" (ByVal hRasConn As Long, ByRef lpRasConnStatus As Any) As Long Private Declare Function RasGetEntryDialParams Lib "RASAPI32.DLL" Alias "RasGetEntryDialParamsA" (ByVal lpszPhonebook As String, ByRef lprasdialparams As RASDIALPARAMS, ByRef lpfPassword As Long) As Long Private Declare Function RasGetEntryProperties Lib "RASAPI32.DLL" Alias "RasGetEntryPropertiesA" (ByVal lpszPhonebook As String, ByVal lpszEntry As String, ByRef lpRasEntry As Any, ByRef lpdwEntryInfoSize As Long, ByRef lpbDeviceInfo As Any, ByRef lpdwDeviceInfoSize As Long) As Long Private Declare Function RasGetErrorString Lib "RASAPI32.DLL" Alias "RasGetErrorStringA" (ByVal uErrorValue As Long, ByVal lpszErrorString As String, ByVal cBufSize As Long) As Long Private Declare Function RasGetProjectionInfo Lib "RASAPI32.DLL" Alias "RasGetProjectionInfoA" (ByVal hRasConn As Long, ByRef RasProjection As RasProjection, ByRef lpProjection As Any, ByVal lpcB As Long) As Long Private Declare Function RasHangUp Lib "RASAPI32.DLL" Alias "RasHangUpA" (ByVal hRasConn As Long) As Long Private Declare Function RasRenameEntry Lib "RASAPI32.DLL" Alias "RasRenameEntryA" (ByVal lpszPhonebook As String, ByVal lpszOldEntry As String, ByVal lpszNewEntry As String) As Long Private Declare Function RasSetEntryDialParams Lib "RASAPI32.DLL" Alias "RasGetEntryDialParamsA" (ByVal lpszPhonebook As String, ByRef lprasdialparams As RASDIALPARAMS, ByVal fRemovePassword As Long) As Long Private Declare Function RasSetEntryProperties Lib "RASAPI32.DLL" Alias "RasSetEntryPropertiesA" (ByVal lpszPhonebook As String, ByVal lpszEntry As String, lpRasEntry As Any, ByVal dwEntryInfoSize As Long, lpbDeviceInfo As Any, ByVal dwDeviceInfoSize As Long) As Long Private Declare Function RasValidateEntryName Lib "RASAPI32.DLL" Alias "RasValidateEntryNameA" (ByVal lpszPhonebook As String, ByVal lpszEntry As String) As Long Private Declare Function InternetAutodial Lib "WININET.DLL" (ByVal dwFlags As Long, ByVal hwndParent As Long) As Long Private Declare Function InternetAutodialHangup Lib "WININET.DLL" (ByVal dwReserved As Long) As Long Private Declare Function InternetDial Lib "WININET.DLL" Alias "InternetDialA" (ByVal hwndParent As Long, ByVal strEntryName As String, ByVal dwFlags As Long, lpdwConnection As Long, ByVal dwReserved As Long) As Long Private Declare Function InternetHangUp Lib "WININET.DLL" (ByVal dwConnection As Long, ByVal dwReserved As Long) As Long ' Windows NT Only: Private Declare Function RasPhonebookDlg Lib "RASDLG.DLL" Alias "RasPhonebookDlgA" (ByVal lpszPhonebook As String, ByVal lpszEntry As String, ByRef lpInfo As RASPBDIALOG) As Long Private Declare Function RasDialDlg Lib "RASDLG.DLL" Alias "RasDialDlgA" (ByVal lpszPhonebook As String, ByVal lpszEntry As String, ByVal lpszPhoneNumber As String, ByRef lpInfo As RASDIALDIALOG) As Long Private Declare Function RasMonitorDlg Lib "RASDLG.DLL" Alias "RasMonitorDlgA" (ByVal lpszDeviceName As String, ByRef lpInfo As RASMONITORDIALOG) As Long Private Declare Function RasEntryDlg Lib "RASDLG.DLL" Alias "RasEntryDlgA" (ByVal lpszPhonebook As String, ByVal lpszEntry As String, ByRef lpInfo As RASENTRYDIALOG) As Long ' This is a callback function used to recieve connection messages (RasDialFunc - Type 1) ' * WARNING : If you put a break in this function or try to step through this function, ' you will most likely crash the VB IDE. I don't know why... just how it is. Public Function RAS_CallbackFunc(ByVal unMsg As Long, ByVal RasConState As Long, ByVal dwError As Long) As Long ' Make sure that the event has been registered If WM_RASDIALEVENT_REG = 0 Then ' If previously tried to register the event and it failed, don't try again If RegisterFailed = False Then ' Register the RASDIALEVENT event WM_RASDIALEVENT_REG = RegisterWindowMessage(RASDIALEVENT) If WM_RASDIALEVENT_REG = 0 Then RegisterFailed = True End If End If End If ' If the unMsg parameter isn't a WM_RASDIALEVENT event, exit out. If (unMsg <> WM_RASDIALEVENT) And (unMsg <> WM_RASDIALEVENT_REG) Then Exit Function End If ' Put the connection state in the IMMEDIATE window Debug.Print "Connection State = " & CStr(RasConState) & " - " & GetConStateSTR(RasConState) If dwError <> 0 Then ' An error occured ! Debug.Print "## RAS Error ## " & CStr(dwError) End If End Function ' Function that takes a RASENTRY variable and sets all it's members back to their default values Public Function RAS_ClearEntry(ByRef EntryToClear As RASENTRY_VB) On Error Resume Next With EntryToClear .Options = 0 .CountryID = 0 .CountryCode = 0 .AreaCode = vbNullString .LocalPhoneNumber = vbNullString .AlternateNumbers = vbNullString .ipAddr.a = 0 .ipAddr.B = 0 .ipAddr.c = 0 .ipAddr.d = 0 .ipAddrDns.a = 0 .ipAddrDns.B = 0 .ipAddrDns.c = 0 .ipAddrDns.d = 0 .ipAddrDnsAlt.a = 0 .ipAddrDnsAlt.B = 0 .ipAddrDnsAlt.c = 0 .ipAddrDnsAlt.d = 0 .ipAddrWins.a = 0 .ipAddrWins.B = 0 .ipAddrWins.c = 0 .ipAddrWins.d = 0 .ipAddrWinsAlt.a = 0 .ipAddrWinsAlt.B = 0 .ipAddrWinsAlt.c = 0 .ipAddrWinsAlt.d = 0 .FrameSize = 0 .fNetProtocols = 0 .FramingProtocol = 0 .ScriptName = vbNullString .AutodialDll = vbNullString .AutodialFunc = vbNullString .DeviceType = vbNullString .DeviceName = vbNullString .X25PadType = vbNullString .X25Address = vbNullString .X25Facilities = vbNullString .X25UserData = vbNullString .Channels = 0 ' .NT4En_SubEntries = 0 ' .NT4En_DialMode = 0 ' .NT4En_DialExtraPercent = 0 ' .NT4En_DialExtraSampleSeconds = 0 ' .NT4En_HangUpExtraPercent = 0 ' .NT4En_HangUpExtraSampleSeconds = 0 ' .NT4En_IdleDisconnectSeconds = 0 ' .Win2000_Type = 0 ' .Win2000_EncryptionType = 0 ' .Win2000_CustomAuthKey = 0 ' Erase .Win2000_guidId ' .Win2000_CustomDialDll = vbNullString ' .Win2000_VpnStrategy = 0 End With End Function Public Function RAS_GetConnections(ByRef Return_ConnArray() As RASCONN_VB, ByRef Return_ConnCount As Long) As Boolean Dim ReturnValue As Long Dim ByteArray() As Byte Dim aLens As Variant Dim dwSize As Long Dim lpcB As Long Dim lpConns As Long Dim MyCounter As Long ' Clear the return variables Erase Return_ConnArray Return_ConnCount = 0 ' Redimention the byte array to hold the buffer ReDim ByteArray(3) aLens = Array(692&, 676&, 412&, 32&) For MyCounter = 0 To 3 dwSize = aLens(MyCounter) CopyMemory ByteArray(0), dwSize, 4 lpcB = 4 ReturnValue = RasEnumConnections(ByteArray(0), lpcB, lpConns) If ReturnValue <> 632 And ReturnValue <> 610 Then Exit For End If Next MyCounter ' Get how many connections are active Return_ConnCount = lpConns If lpConns = 0 Then RAS_GetConnections = True Exit Function End If lpcB = dwSize * lpConns ReDim ByteArray(lpcB - 1) CopyMemory ByteArray(0), dwSize, 4 ReturnValue = RasEnumConnections(ByteArray(0), lpcB, lpConns) ' Resize the array to hold all the connections' information ReDim Return_ConnArray(lpConns - 1) ' Now copy the bytes to the Return_ConnArray array For MyCounter = 0 To lpConns - 1 With Return_ConnArray(MyCounter) CopyMemory .hRasConn, ByteArray(MyCounter * dwSize + 4), 4 If dwSize = 32& Then .sEntryName = ByteToString_Trim(ByteArray(MyCounter * dwSize + 8), 21&) Else .sEntryName = ByteToString_Trim(ByteArray(MyCounter * dwSize + 8), 257&) .sDeviceType = ByteToString_Trim(ByteArray(MyCounter * dwSize + 265), 17&) .sDeviceName = ByteToString_Trim(ByteArray(MyCounter * dwSize + 282), 129&) If dwSize > 412& Then .sPhonebook = ByteToString_Trim(ByteArray(MyCounter * dwSize + 411), 260&) CopyMemory .lngSubEntry, ByteArray(MyCounter * dwSize + 672), 4 If dwSize > 676& Then CopyMemory .guidEntry(0), ByteArray(MyCounter * dwSize + 676), 16 End If End If End If End With Next RAS_GetConnections = True End Function Public Function RAS_GetConnectionStatus(ByRef Return_RasConnStatus As RASCONNSTATUS_VB) As Boolean Dim ReturnValue As Long Dim MyCounter As Long Dim dwSize As Long Dim SizeArray As Variant Dim ByteArray() As Byte ' Make sure there's a connection made If hRASConnection = 0 Then MsgBox "There is connection open to get the status from.", vbOKOnly + vbExclamation, " No Connection Open" Exit Function End If ' Get all possible sizes of the structure for the different OSs (Win9x, WinNT, Win2000) SizeArray = Array(288&, 160&, 64&) ' Try the different sizes and call the function For MyCounter = 0 To 2 dwSize = SizeArray(MyCounter) ReDim ByteArray(dwSize - 1) CopyMemory ByteArray(0), dwSize, 4 ReturnValue = RasGetConnectStatus(hRASConnection, ByteArray(0)) If ReturnValue <> 632 Then Exit For End If Next ' Check for errors in calling the API If ReturnValue <> 0 Then RAS_GetLastError ReturnValue, "RasGetConnectStatus", True Exit Function End If ' Copy the information into the specified structure With Return_RasConnStatus CopyMemory .lRasConnState, ByteArray(4), 4 CopyMemory .dwError, ByteArray(8), 4 .sDeviceType = ByteToString_Trim(ByteArray(12), 17&) If dwSize = 64& Then .sDeviceName = ByteToString_Trim(ByteArray(29), 33&) ElseIf dwSize = 160& Then .sDeviceName = ByteToString_Trim(ByteArray(29), 129&) Else .sDeviceName = ByteToString_Trim(ByteArray(29), 129&) .sNTPhoneNumber = ByteToString_Trim(ByteArray(158), 129&) End If End With RAS_GetConnectionStatus = True End Function ' Function that checks if the specified entry exists in the specified phonebook Public Function RAS_CheckIfEntryExists(ByRef Return_Exists As Boolean, ByRef strEntryName As String, Optional ByRef strPhonebook As String = vbNullString) As Boolean Dim ReturnValue As Long Dim TheOS As OSTypes ' Make sure that the parameters passed are NULL terminated so they are passed to the API correctly If strEntryName <> vbNullString Then If Right(strEntryName, 1) <> Chr(0) Then strEntryName = strEntryName & Chr(0) End If End If If strPhonebook <> vbNullString Then If Right(strPhonebook, 1) <> Chr(0) Then strPhonebook = strPhonebook & Chr(0) End If End If ' If the user's OS is Win9x, change the phonebook = vbNullString because entries are ' stored in the Windows Registry, not a phonebook If strPhonebook <> vbNullString Then If GetOS(TheOS) = False Then strPhonebook = vbNullString Else If (TheOS = OS_Win95) Or (TheOS = OS_Win98) Then strPhonebook = vbNullString End If End If End If ' Validate the information passed to the function ReturnValue = RasValidateEntryName(strEntryName, strEntryName) ' Check the results Select Case ReturnValue Case 0 ' ERROR_SUCCESS ' The entry name is valid but doesn't exist in the specified phonebook RAS_CheckIfEntryExists = False Case 123 ' ERROR_INVALID_NAME ' The entry name is invalid RAS_CheckIfEntryExists = False Case 183 ' ERROR_ALREADY_EXISTS ' The entry name exists in the specified phonebook RAS_CheckIfEntryExists = True Case Else ' RasValidateEntryName failed RAS_CheckIfEntryExists = False End Select End Function ' You MUST specify either strEntryName or strPhoneNumber. They can not both be left blank. ' If both strEntryName ans strPhoneNumber are specified, this function will attempt to use ' the phone number specified in the entry name first. Public Function RAS_Dial(ByVal UseCallbackFunc As Boolean, Optional ByRef strEntryName As String = vbNullString, Optional ByRef strPhoneNumber As String = vbNullString, Optional ByRef strUserName As String = vbNullString, Optional ByRef strPassword As String = vbNullString) As Boolean Dim DialExtInfo As RASDIALEXTENSIONS Dim DialParInfo As RASDIALPARAMS Dim lngPassword As Long Dim ReturnValue As Long ' If there is already a connection opened, exit If hRASConnection <> 0 Then MsgBox "There is currently already a connection open.", vbOKOnly + vbExclamation, " Connection Already Opened" RAS_Dial = False Exit Function End If ' Make sure that the parameters passed are NULL terminated so they are passed to the API correctly If strEntryName <> vbNullString Then If Right(strEntryName, 1) <> Chr(0) Then strEntryName = strEntryName & Chr(0) End If Else strEntryName = strEntryName & Chr(0) End If If strPhoneNumber <> vbNullString Then If Right(strPhoneNumber, 1) <> Chr(0) Then strPhoneNumber = strPhoneNumber & Chr(0) End If End If If strUserName <> vbNullString Then If Right(strUserName, 1) <> Chr(0) Then strUserName = strUserName & Chr(0) End If End If If strPassword <> vbNullString Then If Right(strPassword, 1) <> Chr(0) Then strPassword = strPassword & Chr(0) End If End If With DialExtInfo .dwSize = Len(DialExtInfo) End With With DialParInfo .dwSize = Len(DialParInfo) .szPhoneNumber = strPhoneNumber .szEntryName = strEntryName .szUserName = strUserName .szPassword = strPassword End With ReturnValue = RasGetEntryDialParams(vbNullString, DialParInfo, lngPassword) If UseCallbackFunc = True Then ReturnValue = RasDial(DialExtInfo, vbNullString, DialParInfo, 0, AddressOf RAS_CallbackFunc, hRASConnection) Else ReturnValue = RasDial(DialExtInfo, vbNullString, DialParInfo, 0, 0, hRASConnection) End If End Function ' Function that performs a quick and simple dial ruitine by calling the VB Shell function ' which runs a RAS .DLL with dialing perameters. This prob isn't the best way to do this. Public Function RAS_DialQuick(ByRef strEntryName As String, Optional ByRef strUserName As String, Optional ByRef strPassword As String) As Boolean On Error Resume Next Dim TheOS As OSTypes ' Get the operating system to find out how to call the dialog If GetOS(TheOS) = False Then MsgBox "Could not get operating system which is needed to determine how to dial.", vbOKOnly + vbExclamation, " Error Getting Operating System" RAS_DialQuick = False Exit Function End If ' Windows 95 / Windows 98 : Dial-Up If (TheOS = OS_Win95) Or (TheOS = OS_Win98) Then If Shell("Rundll Rnaui.dll,RnaDial " & strEntryName) = 0 Then RAS_DialQuick = False Else RAS_DialQuick = True End If ' Windows NT / Windows 2000 : Dial-Up ElseIf (TheOS = OS_WinNT_40) Or (TheOS = OS_Win2000) Then ' If the entry name has spaces in it, make sure to enclose it in quotations If InStr(strEntryName, " ") > 0 Then strEntryName = Chr(34) & strEntryName & Chr(34) End If If Shell("RASDIAL " & strEntryName & " " & strUserName & " " & strPassword) = 0 Then RAS_DialQuick = False Else RAS_DialQuick = True End If End If End Function Public Function RAS_HangUp(Optional ByVal DisplayErrorMsg As Boolean = False) As Boolean Dim ReturnValue As Long ' Check if there is a connection created by the RAS_Dial function If hRASConnection = 0 Then If DisplayErrorMsg = True Then MsgBox "There is currently no connection open to close.", vbOKOnly + vbExclamation, " No Connection Open To Close" End If RAS_HangUp = True Exit Function End If ' Hang up the connection ReturnValue = RasHangUp(hRASConnection) If ReturnValue = 0 Then hRASConnection = 0 RAS_HangUp = True Else RAS_GetLastError ReturnValue, "RasHangUp", DisplayErrorMsg RAS_HangUp = False End If End Function Function RAS_HangUp_ALL() As Boolean Dim aVBRasConns() As RASCONN_VB Dim ReturnValue As Long Dim BufferArray() As Byte Dim TempArray As Variant Dim BufferSize As Long Dim BufferSize1 As Long Dim ConnectionCount As Long Dim MyCounter As Long ' Create buffers to use in this process ReDim BufferArray(3) TempArray = Array(692&, 676&, 412&, 32&) ' Find how many connections are open For MyCounter = 0 To 3 BufferSize = TempArray(MyCounter) CopyMemory BufferArray(0), BufferSize, 4 BufferSize1 = 4 ReturnValue = RasEnumConnections(BufferArray(0), BufferSize1, ConnectionCount) If ReturnValue <> 632 And ReturnValue <> 610 Then RAS_HangUp_ALL = False Exit For End If Next ' If there are no connections currently open, exit If ConnectionCount = 0 Then RAS_HangUp_ALL = True Exit Function End If ' Create the real buffers that will recieve the connection information BufferSize1 = BufferSize * ConnectionCount ReDim BufferArray(BufferSize1 - 1) CopyMemory BufferArray(0), BufferSize, 4 ReturnValue = RasEnumConnections(BufferArray(0), BufferSize1, ConnectionCount) ' Now copy the bytes to the aVBRasConns array ReDim aVBRasConns(ConnectionCount - 1) For MyCounter = 0 To ConnectionCount - 1 With aVBRasConns(MyCounter) CopyMemory .hRasConn, BufferArray(MyCounter * BufferSize + 4), 4 If BufferSize = 32& Then .sEntryName = ByteToString_Trim(BufferArray(MyCounter * BufferSize + 8), 21&) Else .sEntryName = ByteToString_Trim(BufferArray(MyCounter * BufferSize + 8), 257&) .sDeviceType = ByteToString_Trim(BufferArray(MyCounter * BufferSize + 265), 17&) .sDeviceName = ByteToString_Trim(BufferArray(MyCounter * BufferSize + 282), 129&) If BufferSize > 412& Then .sPhonebook = ByteToString_Trim(BufferArray(MyCounter * BufferSize + 411), 260&) CopyMemory .lngSubEntry, BufferArray(MyCounter * BufferSize + 672), 4 If BufferSize > 676& Then CopyMemory .guidEntry(0), BufferArray(MyCounter * BufferSize + 676), 16 End If End If End If End With Next ' One by one close the connections For MyCounter = 0 To ConnectionCount - 1 If RasHangUp(aVBRasConns(MyCounter).hRasConn) <> 0 Then RAS_HangUp_ALL = False Else RAS_HangUp_ALL = True End If Next End Function ' Function that starts up the "Add Modem" dialog Public Function RAS_Dlg_AddModem() As Boolean If Shell("RunDLL32 shell32.dll,Control_RunDLL MODEM.CPL,Modems,Add") = 0 Then RAS_Dlg_AddModem = False Else RAS_Dlg_AddModem = True End If End Function ' Function that starts up the "Confirgure Modem" dialog Public Function RAS_Dlg_ConfigModem() As Boolean If Shell("RunDLL32 shell32.dll,Control_RunDLL MODEM.CPL,Modems") = 0 Then RAS_Dlg_ConfigModem = False Else RAS_Dlg_ConfigModem = True End If End Function ' Function that displays the "Create Dial-Up" dialog Public Function RAS_Dlg_CreateDUN(Optional ByRef strPhonebook As String = vbNullString, Optional ByVal OwnerFormHandle As Long) As Boolean Dim ReturnValue As Long Dim TheOS As OSTypes ' Make sure that the parameters passed are NULL terminated so they are passed to the API correctly If strPhonebook <> vbNullString Then If Right(strPhonebook, 1) <> Chr(0) Then strPhonebook = strPhonebook & Chr(0) End If End If ' If the user's OS is Win9x, change the phonebook = vbNullString because entries are ' stored in the Windows Registry, not a phonebook If strPhonebook <> vbNullString Then If GetOS(TheOS) = False Then strPhonebook = vbNullString Else If (TheOS = OS_Win95) Or (TheOS = OS_Win98) Then strPhonebook = vbNullString End If End If End If ' Open the dialog ReturnValue = RasCreatePhonebookEntry(OwnerFormHandle, strPhonebook) If ReturnValue = 0 Then RAS_Dlg_CreateDUN = True Else RAS_GetLastError ReturnValue, "RasCreatePhonebookEntry", True RAS_Dlg_CreateDUN = False End If End Function ' Function that displays the "Edit Dial-Up" dialog Public Function RAS_Dlg_EditDUN(ByRef strEntryName As String, Optional ByRef strPhonebook As String = vbNullString, Optional ByVal OwnerFormHandle As Long) As Boolean Dim ReturnValue As Long Dim TheOS As OSTypes ' Make sure that the parameters passed are NULL terminated so they are passed to the API correctly If strEntryName <> vbNullString Then If Right(strEntryName, 1) <> Chr(0) Then strEntryName = strEntryName & Chr(0) End If End If If strPhonebook <> vbNullString Then If Right(strPhonebook, 1) <> Chr(0) Then strPhonebook = strPhonebook & Chr(0) End If End If ' If the user's OS is Win9x, change the phonebook = vbNullString because entries are ' stored in the Windows Registry, not a phonebook If strPhonebook <> vbNullString Then If GetOS(TheOS) = False Then strPhonebook = vbNullString Else If (TheOS = OS_Win95) Or (TheOS = OS_Win98) Then strPhonebook = vbNullString End If End If End If ' Open the dialog ReturnValue = RasEditPhonebookEntry(OwnerFormHandle, strPhonebook, strEntryName) If ReturnValue = 0 Then RAS_Dlg_EditDUN = True Else RAS_GetLastError ReturnValue, "RasEditPhonebookEntry", True RAS_Dlg_EditDUN = False End If End Function ' Windows 9x Only : Function that displays the the "Make New Connection" dialog Public Function RAS_Dlg_ConWizard(Optional ByVal SkipFisrtScreen As Boolean = False) As Boolean If SkipFisrtScreen = True Then RAS_Dlg_ConWizard = Shell("Rundll Rnaui.dll,RnaWizard") Else RAS_Dlg_ConWizard = Shell("Rundll Rnaui.dll,RnaWizard ,1") End If End Function ' Windows NT Only : Function that displays the Phonebook dialog Public Function RAS_DlgNT_Dial(ByRef strPhoneNumber As String, ByRef strEntryName As String, Optional ByRef strPhonebook As String = vbNullString, Optional ByVal OwnerFormHandle As Long) As Boolean Dim DialInfo As RASDIALDIALOG Dim ReturnValue As Long Dim TheOS As OSTypes ' Make sure that the parameters passed are NULL terminated so they are passed to the API correctly If strPhoneNumber <> vbNullString Then If Right(strPhoneNumber, 1) <> Chr(0) Then strPhoneNumber = strPhoneNumber & Chr(0) End If End If If strEntryName <> vbNullString Then If Right(strEntryName, 1) <> Chr(0) Then strEntryName = strEntryName & Chr(0) End If End If If strPhonebook <> vbNullString Then If Right(strPhonebook, 1) <> Chr(0) Then strPhonebook = strPhonebook & Chr(0) End If End If ' If the user's OS is Win9x, change the phonebook = vbNullString because entries are ' stored in the Windows Registry, not a phonebook If strPhonebook <> vbNullString Then If GetOS(TheOS) = False Then strPhonebook = vbNullString Else If (TheOS = OS_Win95) Or (TheOS = OS_Win98) Then strPhonebook = vbNullString End If End If End If ' Initialize the structure to be passed to the API With DialInfo .dwSize = Len(DialInfo) .hwndOwner = OwnerFormHandle .dwSubEntry = 1 End With ' Open the dialog ReturnValue = RasDialDlg(strPhonebook, strEntryName, strPhoneNumber, DialInfo) If ReturnValue <> 0 Then RAS_DlgNT_Dial = True Else If RAS_GetLastError(DialInfo.dwError, "RasDialDlg", True) = True Then RAS_DlgNT_Dial = False Else RAS_DlgNT_Dial = True End If End If End Function ' Windows NT Only : Allows you to copy the specified DUN entry to another Public Function RAS_DlgNT_EntryCopy(Optional ByRef Return_EntryCreated As String, Optional ByRef strEntryName As String = vbNullString, Optional ByRef strPhonebook As String = vbNullString, Optional ByVal OwnerFormHandle As Long) As Boolean Dim EntryInfo As RASENTRYDIALOG Dim ReturnValue As Long Dim TheOS As OSTypes ' Make sure that the parameters passed are NULL terminated so they are passed to the API correctly If strEntryName <> vbNullString Then If Right(strEntryName, 1) <> Chr(0) Then strEntryName = strEntryName & Chr(0) End If End If If strPhonebook <> vbNullString Then If Right(strPhonebook, 1) <> Chr(0) Then strPhonebook = strPhonebook & Chr(0) End If End If ' If the user's OS is Win9x, change the phonebook = vbNullString because entries are ' stored in the Windows Registry, not a phonebook If strPhonebook <> vbNullString Then If GetOS(TheOS) = False Then strPhonebook = vbNullString Else If (TheOS = OS_Win95) Or (TheOS = OS_Win98) Then strPhonebook = vbNullString End If End If End If ' Initialize the structure to be passed to the API With EntryInfo .dwSize = Len(EntryInfo) .hwndOwner = OwnerFormHandle .dwFlags = RASEDFLAG_CloneEntry .szEntry = strEntryName End With ' Open the dialog ReturnValue = RasEntryDlg(strPhonebook, strEntryName, EntryInfo) If ReturnValue <> 0 Then Return_EntryCreated = Left(EntryInfo.szEntry, InStr(EntryInfo.szEntry, Chr(0)) - 1) RAS_DlgNT_EntryCopy = True Else If RAS_GetLastError(EntryInfo.dwError, "RasMonitorDlg", True) = True Then RAS_DlgNT_EntryCopy = False Else Return_EntryCreated = Left(EntryInfo.szEntry, InStr(EntryInfo.szEntry, Chr(0)) - 1) RAS_DlgNT_EntryCopy = True End If End If End Function ' Windows NT Only : Allows you to edit the properties of the specified DUN entry Public Function RAS_DlgNT_EntryEdit(ByRef strEntryName As String, Optional ByRef strPhonebook As String = vbNullString, Optional ByVal OwnerFormHandle As Long) As Boolean Dim EntryInfo As RASENTRYDIALOG Dim ReturnValue As Long Dim TheOS As OSTypes ' Make sure that the parameters passed are NULL terminated so they are passed to the API correctly If strEntryName <> vbNullString Then If Right(strEntryName, 1) <> Chr(0) Then strEntryName = strEntryName & Chr(0) End If End If If strPhonebook <> vbNullString Then If Right(strPhonebook, 1) <> Chr(0) Then strPhonebook = strPhonebook & Chr(0) End If End If ' If the user's OS is Win9x, change the phonebook = vbNullString because entries are ' stored in the Windows Registry, not a phonebook If strPhonebook <> vbNullString Then If GetOS(TheOS) = False Then strPhonebook = vbNullString Else If (TheOS = OS_Win95) Or (TheOS = OS_Win98) Then strPhonebook = vbNullString End If End If End If ' Initialize the structure to be passed to the API With EntryInfo .dwSize = Len(EntryInfo) .hwndOwner = OwnerFormHandle .szEntry = strEntryName .dwFlags = RASEDFLAG_NoRename End With ' Open the dialog ReturnValue = RasEntryDlg(strPhonebook, strEntryName, EntryInfo) If ReturnValue <> 0 Then RAS_DlgNT_EntryEdit = True Else If RAS_GetLastError(EntryInfo.dwError, "RasMonitorDlg", True) = True Then RAS_DlgNT_EntryEdit = False Else RAS_DlgNT_EntryEdit = True End If End If End Function ' Windows NT Only : Allows you to create a new DUN entry Public Function RAS_DlgNT_EntryNew(ByRef Return_EntryCreated As String, Optional ByRef strEntryName As String = vbNullString, Optional ByRef strPhonebook As String = vbNullString, Optional ByVal OwnerFormHandle As Long) As Boolean Dim EntryInfo As RASENTRYDIALOG Dim ReturnValue As Long Dim TheOS As OSTypes ' Make sure that the parameters passed are NULL terminated so they are passed to the API correctly If strEntryName <> vbNullString Then If Right(strEntryName, 1) <> Chr(0) Then strEntryName = strEntryName & Chr(0) End If End If If strPhonebook <> vbNullString Then If Right(strPhonebook, 1) <> Chr(0) Then strPhonebook = strPhonebook & Chr(0) End If End If ' If the user's OS is Win9x, change the phonebook = vbNullString because entries are ' stored in the Windows Registry, not a phonebook If strPhonebook <> vbNullString Then If GetOS(TheOS) = False Then strPhonebook = vbNullString Else If (TheOS = OS_Win95) Or (TheOS = OS_Win98) Then strPhonebook = vbNullString End If End If End If ' Initialize the structure to be passed to the API With EntryInfo .dwSize = Len(EntryInfo) .hwndOwner = OwnerFormHandle .dwFlags = RASEDFLAG_NewEntry .szEntry = strEntryName End With ' Open the dialog ReturnValue = RasEntryDlg(strPhonebook, strEntryName, EntryInfo) If ReturnValue <> 0 Then Return_EntryCreated = Left(EntryInfo.szEntry, InStr(EntryInfo.szEntry, Chr(0)) - 1) RAS_DlgNT_EntryNew = True Else If RAS_GetLastError(EntryInfo.dwError, "RasMonitorDlg", True) = True Then RAS_DlgNT_EntryNew = False Else Return_EntryCreated = Left(EntryInfo.szEntry, InStr(EntryInfo.szEntry, Chr(0)) - 1) RAS_DlgNT_EntryNew = True End If End If End Function ' Windows NT Only : Displays the DUN Monitor property sheet that describes the status of RAS connections. Public Function RAS_DlgNT_Monitor(Optional ByRef strDeviceName As String = vbNullString, Optional ByVal OwnerFormHandle As Long) As Boolean Dim MonInfo As RASMONITORDIALOG Dim ReturnValue As Long ' Make sure that the parameters passed are NULL terminated so they are passed to the API correctly If strDeviceName <> vbNullString Then If Right(strDeviceName, 1) <> Chr(0) Then strDeviceName = strDeviceName & Chr(0) End If End If ' Initialize the structure to be passed to the API With MonInfo .dwSize = Len(MonInfo) .hwndOwner = OwnerFormHandle End With ' Open the dialog ReturnValue = RasMonitorDlg(strDeviceName, MonInfo) If ReturnValue <> 0 Then RAS_DlgNT_Monitor = True Else If RAS_GetLastError(MonInfo.dwError, "RasMonitorDlg", True) = True Then RAS_DlgNT_Monitor = False Else RAS_DlgNT_Monitor = True End If End If End Function ' Windows NT Only : Function that displays the Phonebook dialog Public Function RAS_DlgNT_PhoneBook(Optional ByRef strEntryName As String = vbNullString, Optional ByRef strPhonebook As String = vbNullString, Optional ByVal OwnerFormHandle As Long) As Boolean Dim PBInfo As RASPBDIALOG Dim ReturnValue As Long Dim TheOS As OSTypes ' Make sure that the parameters passed are NULL terminated so they are passed to the API correctly If strEntryName <> vbNullString Then If Right(strEntryName, 1) <> Chr(0) Then strEntryName = strEntryName & Chr(0) End If End If If strPhonebook <> vbNullString Then If Right(strPhonebook, 1) <> Chr(0) Then strPhonebook = strPhonebook & Chr(0) End If End If ' If the user's OS is Win9x, change the phonebook = vbNullString because entries are ' stored in the Windows Registry, not a phonebook If strPhonebook <> vbNullString Then If GetOS(TheOS) = False Then strPhonebook = vbNullString Else If (TheOS = OS_Win95) Or (TheOS = OS_Win98) Then strPhonebook = vbNullString End If End If End If ' Initialize the structure to be passed to the API With PBInfo .dwSize = Len(PBInfo) .hwndOwner = OwnerFormHandle End With ' Open the dialog ReturnValue = RasPhonebookDlg(strPhonebook, strEntryName, PBInfo) If ReturnValue <> 0 Then RAS_DlgNT_PhoneBook = True Else If RAS_GetLastError(PBInfo.dwError, "RasEditPhonebookEntry", True) = True Then RAS_DlgNT_PhoneBook = False Else RAS_DlgNT_PhoneBook = True End If End If End Function ' Function that returns all the Dial-Up / RAS devices and their types Public Function RAS_GetDevices(ByRef Return_DeviceArray() As String, ByRef Return_TypeArray() As String, ByRef Return_DeviceCount As Long) As Boolean On Error GoTo ErrorTrap Dim ReturnValue As Long Dim MyCounter As Long Dim BufferSize As Long Dim DeviceCount As Long Dim ReturnBuffer() As Byte Dim BufferLength As Long ' Clear the string arrays passed Return_DeviceCount = 0 Erase Return_DeviceArray Erase Return_TypeArray ' Get the device count ReturnValue = RasEnumDevices(ByVal 0&, BufferSize, DeviceCount) ' If there are no RAS devices on this system, exit If DeviceCount = 0 Then RAS_GetDevices = True Exit Function End If ' Initialize the buffers to be passed to the API BufferLength = BufferSize \ DeviceCount ReDim ReturnBuffer(BufferSize - 1) CopyMemory ReturnBuffer(0), BufferLength, 4 ' Get the device information ReturnValue = RasEnumDevices(ReturnBuffer(0), BufferSize, DeviceCount) If DeviceCount = 0 Then Exit Function End If ' Return the information collected about the devices Return_DeviceCount = DeviceCount ReDim Return_DeviceArray(DeviceCount - 1) As String ReDim Return_TypeArray(DeviceCount - 1) As String For MyCounter = 0 To DeviceCount - 1 Return_TypeArray(MyCounter) = ByteToString_Trim(ReturnBuffer((MyCounter * BufferLength) + 4), 17) Return_DeviceArray(MyCounter) = ByteToString_Trim(ReturnBuffer((MyCounter * BufferLength) + 21), BufferLength - 21) Next RAS_GetDevices = True Exit Function ErrorTrap: If Err.Number = 0 Then ' No Error Resume Next ElseIf Err.Number = 20 Then ' Resume Without Error Resume Next Else ' Unknown Error MsgBox Err.Source & " encountered the following error:" & Chr(13) & Chr(13) & "Error Number = " & CStr(Err.Number) & Chr(13) & "Error Description = " & Err.Description, vbOKOnly + vbExclamation, " Error - " & Err.Description RAS_GetDevices = False Err.Clear Exit Function End If End Function ' Routine that returns the names of all the Dial-Up entries in the specified phonebook Public Function RAS_GetEntries(ByRef Return_DUNArray() As String, ByRef Return_DUNCount As Long, Optional ByRef strPhonebook As String = vbNullString) As Boolean On Error GoTo ErrorTrap Dim RasEntry As RASENTRYNAME Dim EntryCount As Long Dim BufferSize As Long Dim ReturnValue As Long Dim MyCounter As Long Dim TempBuffer As Long Dim TempPointer As Long Dim TempSize As Long Dim TheOS As OSTypes ' Make sure that the parameters passed are NULL terminated so they are passed to the API correctly If strPhonebook <> vbNullString Then If Right(strPhonebook, 1) <> Chr(0) Then strPhonebook = strPhonebook & Chr(0) End If End If ' If the user's OS is Win9x, change the phonebook = vbNullString because entries are ' stored in the Windows Registry, not a phonebook If strPhonebook <> vbNullString Then If GetOS(TheOS) = False Then strPhonebook = vbNullString Else If (TheOS = OS_Win95) Or (TheOS = OS_Win98) Then strPhonebook = vbNullString End If End If End If ' Clear the string array passed Erase Return_DUNArray ' Initialize the dwSize field RasEntry.dwSize = LenB(RasEntry) + (LenB(RasEntry) Mod 4) ' Call RasEnumEntries with BufferSize = 0 to find out the required input buffer size ReturnValue = RasEnumEntries(vbNullString, strPhonebook, RasEntry, BufferSize, EntryCount) ' If any other error besides Error_Buffer_Too_Small exit the procedure If ReturnValue = 0 Then MsgBox "There are no Dial-Up entries on this system.", vbOKOnly + vbExclamation, " No Entries To List" RAS_GetEntries = False Exit Function ElseIf ReturnValue <> 603 Then RAS_GetLastError ReturnValue, "RasEnumEntries", True Exit Function End If ' Allocate input buffer with required size TempBuffer = GlobalAlloc(GPTR, BufferSize) ' Initialize the first entry CopyMemory ByVal TempBuffer, RasEntry, LenB(RasEntry) ' Call RasEnumEntries to enumerate the phonebook entries in the default system phonebook ReturnValue = RasEnumEntries(vbNullString, strPhonebook, ByVal TempBuffer, BufferSize, EntryCount) ' RasEnumEntries returned success If ReturnValue = 0 Then TempPointer = TempBuffer ' Copy the values of the first entry CopyMemory RasEntry, ByVal TempPointer, LenB(RasEntry) ' Add the phone book entry to the combo box Return_DUNCount = 1 ReDim Return_DUNArray(0 To Return_DUNCount - 1) As String Return_DUNArray(Return_DUNCount - 1) = (ByteToString(RasEntry.szEntryName)) TempSize = RasEntry.dwSize TempPointer = TempPointer + TempSize ' Add subsequent entries to the combo box For MyCounter = 1 To EntryCount - 1 Return_DUNCount = Return_DUNCount + 1 ReDim Preserve Return_DUNArray(0 To Return_DUNCount - 1) As String Return_DUNArray(Return_DUNCount - 1) = (ByteToString(RasEntry.szEntryName)) CopyMemory RasEntry, ByVal TempPointer, LenB(RasEntry) Return_DUNArray(Return_DUNCount - 1) = (ByteToString(RasEntry.szEntryName)) TempPointer = TempPointer + TempSize Next MyCounter ' RasEnumEntries returned an error Else RAS_GetLastError ReturnValue, "RasEnumEntries", True End If ' Free the allocated input buffer GlobalFree TempBuffer RAS_GetEntries = True Exit Function ErrorTrap: If Err.Number = 0 Then ' No Error Resume Next ElseIf Err.Number = 20 Then ' Resume Without Error Resume Next Else ' Unknown Error MsgBox Err.Source & " encountered the following error:" & Chr(13) & Chr(13) & "Error Number = " & CStr(Err.Number) & Chr(13) & "Error Description = " & Err.Description, vbOKOnly + vbExclamation, " Error - " & Err.Description RAS_GetEntries = False Err.Clear Exit Function End If End Function ' Function that returns displays the RAS error message for the specified error number Public Function RAS_GetLastError(ByVal ErrorNumber As Long, Optional ByVal LastAPICalled As String = "last", Optional ByVal DisplayErrorMsg As Boolean = True) As Boolean On Error Resume Next Const MAX_ERRLEN = 512 Dim ErrMsg As String Dim ReturnValue As Long ' No Error Occured If ErrorNumber = 0 Then RAS_GetLastError = False Exit Function End If ' Allocate buffer to receive the error description ErrMsg = String(MAX_ERRLEN, Chr(0)) If ErrorNumber <= 600 Then ' Get the error description ReturnValue = FormatMessage(&H1000, ByVal 0&, ErrorNumber, 0&, ErrMsg, MAX_ERRLEN, ByVal 0&) ' The "FormatMessage" API Failed If ReturnValue = 0 Then ErrMsg = "Unknown Error (FormatMessage API Failed To Retrieve Error Information)" Else ErrMsg = Left(ErrMsg, InStr(ErrMsg, Chr(0)) - 1) End If Else ' Get the error description ReturnValue = RasGetErrorString(ErrorNumber, ErrMsg, MAX_ERRLEN) ' The "ErrorNumber" value is not a valid RAS error number If ReturnValue = ERROR_INVALID_PARAMETER Then RAS_GetLastError = False Exit Function ' The "RasGetErrorString" API Failed ElseIf ReturnValue <> 0 Then ErrMsg = "Unknown Error (RasGetErrorString API Failed To Retrieve Error Information)" ' Got the error description Else ErrMsg = Left(ErrMsg, InStr(ErrMsg, Chr(0)) - 1) End If End If ' If the user specified to show the error dialog, show it If DisplayErrorMsg = True Then MsgBox "The following error occured while calling the " & LastAPICalled & " RAS API:" & Chr(13) & Chr(13) & "Error Number = " & CStr(ErrorNumber) & Chr(13) & "Error Description = " & ErrMsg, vbOKOnly + vbExclamation, " RAS API Error" End If RAS_GetLastError = True End Function ' Function that deletes an existing entry Public Function RAS_DeleteEntry(ByRef strEntryName As String, Optional ByRef strPhonebook As String = vbNullString) As Boolean Dim ReturnValue As Long Dim TheOS As OSTypes ' Make sure that the parameters passed are NULL terminated so they are passed to the API correctly If strEntryName <> vbNullString Then If Right(strEntryName, 1) <> Chr(0) Then strEntryName = strEntryName & Chr(0) End If End If If strPhonebook <> vbNullString Then If Right(strPhonebook, 1) <> Chr(0) Then strPhonebook = strPhonebook & Chr(0) End If End If ' If the user's OS is Win9x, change the phonebook = vbNullString because entries are ' stored in the Windows Registry, not a phonebook If strPhonebook <> vbNullString Then If GetOS(TheOS) = False Then strPhonebook = vbNullString Else If (TheOS = OS_Win95) Or (TheOS = OS_Win98) Then strPhonebook = vbNullString End If End If End If ' Delete the entry ReturnValue = RasDeleteEntry(strPhonebook, strEntryName) If ReturnValue <> 0 Then RAS_GetLastError ReturnValue, "RasDeleteEntry", True RAS_DeleteEntry = False Else RAS_DeleteEntry = True End If End Function ' Function that takes an existing entry and renames it Public Function RAS_RenameEntry(ByRef strEntryName As String, ByRef strNewName As String, Optional ByRef strPhonebook As String = vbNullString) As Boolean Dim ReturnValue As Long Dim TheOS As OSTypes ' Make sure that the parameters passed are NULL terminated so they are passed to the API correctly If strEntryName <> vbNullString Then If Right(strEntryName, 1) <> Chr(0) Then strEntryName = strEntryName & Chr(0) End If End If If strNewName <> vbNullString Then If Right(strNewName, 1) <> Chr(0) Then strNewName = strNewName & Chr(0) End If End If If strPhonebook <> vbNullString Then If Right(strPhonebook, 1) <> Chr(0) Then strPhonebook = strPhonebook & Chr(0) End If End If ' If the user's OS is Win9x, change the phonebook = vbNullString because entries are ' stored in the Windows Registry, not a phonebook If strPhonebook <> vbNullString Then If GetOS(TheOS) = False Then strPhonebook = vbNullString Else If (TheOS = OS_Win95) Or (TheOS = OS_Win98) Then strPhonebook = vbNullString End If End If End If ' Rename the entry ReturnValue = RasRenameEntry(strPhonebook, strEntryName, strNewName) If ReturnValue <> 0 Then RAS_GetLastError ReturnValue, "RasRenameEntry", True RAS_RenameEntry = False Else RAS_RenameEntry = True End If End Function ' Function that returns the properties of the specified DUN entry Public Function RAS_GetEntryInfo(ByRef Return_RasEntry As RASENTRY_VB, ByRef strEntryName As String, Optional ByRef strPhonebook As String = vbNullString) As Boolean On Error GoTo ErrorTrap Dim ReturnValue As Long Dim BufferSize As Long Dim BufferLength As Long Dim ReturnBuffer() As Byte Dim PtrPosition As Long Dim StringLength As Long Dim TheOS As OSTypes ' Make sure that the parameters passed are NULL terminated so they are passed to the API correctly If strPhonebook <> vbNullString Then If Right(strPhonebook, 1) <> Chr(0) Then strPhonebook = strPhonebook & Chr(0) End If End If If strEntryName <> vbNullString Then If Right(strEntryName, 1) <> Chr(0) Then strEntryName = strEntryName & Chr(0) End If End If ' If the user's OS is Win9x, change the phonebook = vbNullString because entries are ' stored in the Windows Registry, not a phonebook If strPhonebook <> vbNullString Then If GetOS(TheOS) = False Then strPhonebook = vbNullString Else If (TheOS = OS_Win95) Or (TheOS = OS_Win98) Then strPhonebook = vbNullString End If End If End If ' Clear the entry passed to this function RAS_ClearEntry Return_RasEntry ' Get the buffer lengths required ReturnValue = RasGetEntryProperties(vbNullString, vbNullString, ByVal 0&, BufferSize, ByVal 0&, ByVal 0&) ReturnValue = RasGetEntryProperties(strPhonebook, strEntryName, ByVal 0&, BufferLength, ByVal 0&, ByVal 0&) ' The first call should return error 603 which indicates the buffers need to be bigger/initialized If ReturnValue <> 603 Then RAS_GetEntryInfo = False RAS_GetLastError ReturnValue, "RasGetEntryProperties", True Exit Function End If ' Initialize the right sized buffers to pass to the API ReDim ReturnBuffer(BufferLength - 1) CopyMemory ReturnBuffer(0), BufferSize, 4 ' Get the properties ReturnValue = RasGetEntryProperties(strPhonebook, strEntryName, ReturnBuffer(0), BufferLength, ByVal 0&, ByVal 0&) RAS_GetEntryInfo = ReturnValue ' If an error occured, display it If ReturnValue <> 0 Then RAS_GetEntryInfo = False RAS_GetLastError ReturnValue, "RasGetEntryProperties", True Exit Function End If ' Copy the information to the proper buffers / variables With Return_RasEntry CopyMemory .Options, ReturnBuffer(4), 4 CopyMemory .CountryID, ReturnBuffer(8), 4 CopyMemory .CountryCode, ReturnBuffer(12), 4 .AreaCode = ByteToString_Trim(ReturnBuffer(16), 11) .LocalPhoneNumber = ByteToString_Trim(ReturnBuffer(27), 129) CopyMemory PtrPosition, ReturnBuffer(156), 4 If PtrPosition <> 0 Then StringLength = BufferLength - PtrPosition .AlternateNumbers = String(StringLength, 0) CopyMemory ByVal .AlternateNumbers, ReturnBuffer(PtrPosition), StringLength End If CopyMemory .ipAddr, ReturnBuffer(160), 4 CopyMemory .ipAddrDns, ReturnBuffer(164), 4 CopyMemory .ipAddrDnsAlt, ReturnBuffer(168), 4 CopyMemory .ipAddrWins, ReturnBuffer(172), 4 CopyMemory .ipAddrWinsAlt, ReturnBuffer(176), 4 CopyMemory .FrameSize, ReturnBuffer(180), 4 CopyMemory .fNetProtocols, ReturnBuffer(184), 4 CopyMemory .FramingProtocol, ReturnBuffer(188), 4 .ScriptName = ByteToString_Trim(ReturnBuffer(192), 260) .AutodialDll = ByteToString_Trim(ReturnBuffer(452), 260) .AutodialFunc = ByteToString_Trim(ReturnBuffer(712), 260) .DeviceType = ByteToString_Trim(ReturnBuffer(972), 17) If BufferSize = 1672& Then StringLength = 33 Else StringLength = 129 End If .DeviceName = ByteToString_Trim(ReturnBuffer(989), StringLength) PtrPosition = 989 + StringLength .X25PadType = ByteToString_Trim(ReturnBuffer(PtrPosition), 33) PtrPosition = PtrPosition + 33 .X25Address = ByteToString_Trim(ReturnBuffer(PtrPosition), 201) PtrPosition = PtrPosition + 201 .X25Facilities = ByteToString_Trim(ReturnBuffer(PtrPosition), 201) PtrPosition = PtrPosition + 201 .X25UserData = ByteToString_Trim(ReturnBuffer(PtrPosition), 201) PtrPosition = PtrPosition + 203 CopyMemory .Channels, ReturnBuffer(PtrPosition), 4 ' If BufferSize > 1768 Then 'NT4 Enhancements & Win2000 ' CopyMemory .NT4En_SubEntries, ReturnBuffer(1768), 4 ' CopyMemory .NT4En_DialMode, ReturnBuffer(1772), 4 ' CopyMemory .NT4En_DialExtraPercent, ReturnBuffer(1776), 4 ' CopyMemory .NT4En_DialExtraSampleSeconds, ReturnBuffer(1780), 4 ' CopyMemory .NT4En_HangUpExtraPercent, ReturnBuffer(1784), 4 ' CopyMemory .NT4En_HangUpExtraSampleSeconds, ReturnBuffer(1788), 4 ' CopyMemory .NT4En_IdleDisconnectSeconds, ReturnBuffer(1792), 4 ' ' If BufferSize > 1796 Then ' Win2000 ' CopyMemory .Win2000_Type, ReturnBuffer(1796), 4 ' CopyMemory .Win2000_EncryptionType, ReturnBuffer(1800), 4 ' CopyMemory .Win2000_CustomAuthKey, ReturnBuffer(1804), 4 ' CopyMemory .Win2000_guidId(0), ReturnBuffer(1808), 16 ' .Win2000_CustomDialDll = ByteToString_Trim(ReturnBuffer(1824), 260) ' CopyMemory .Win2000_VpnStrategy, ReturnBuffer(2084), 4 ' End If ' End If End With RAS_GetEntryInfo = True Exit Function ErrorTrap: If Err.Number = 0 Then ' No Error Resume Next ElseIf Err.Number = 20 Then ' Resume Without Error Resume Next Else ' Unknown Error MsgBox Err.Source & " encountered the following error:" & Chr(13) & Chr(13) & "Error Number = " & CStr(Err.Number) & Chr(13) & "Error Description = " & Err.Description, vbOKOnly + vbExclamation, " Error - " & Err.Description RAS_GetEntryInfo = False Err.Clear Exit Function End If End Function ' * IMPORTANT NOTE: ' Remote access projection is the process whereby a remote access server and a remote ' client negotiate network protocol-specific information. A remote access server uses ' this network protocol-specific information to represent a remote client on the network. ' ' Windows NT/2000 : Remote access projection information is not available until the ' operating system has executed the RasDial RASCS_Projected state on the remote access ' connection. If RasGetProjectionInfo is called prior to the RASCS_Projected state, ' it returns ERROR_PROJECTION_NOT_COMPLETE. ' ' Windows 95 : Windows 95 Dial-Up Networking does not support the RASCS_Projected state. ' The projection phase may be done during the RASCS_Authenticate state. If the ' authentication is successful, the connection operation proceeds to the ' RASCS_Authenticated state, and projection information is available for successfully ' configured protocols. If RasGetProjectionInfo is called prior to the ' RASCS_Authenticated state, it returns ERROR_PROTOCOL_NOT_CONFIGURED. Public Function RAS_PPP_GetClientIPX(ByRef Return_IPX As String) As Boolean Dim IPXInfo As RASPPPIPX Dim ReturnValue As Long Dim TheSize As Long ' Make sure there's a connection made If hRASConnection = 0 Then MsgBox "There is connection open to get the client IP from.", vbOKOnly + vbExclamation, " No Connection Open" Exit Function End If ' Initialize the variable to recieve the information TheSize = Len(IPXInfo) IPXInfo.dwSize = TheSize ' Get the PPP/IP information - which includes the clients's IP ReturnValue = RasGetProjectionInfo(hRASConnection, RASP_PppIp, IPXInfo, VarPtr(TheSize)) If ReturnValue = 0 Then Return_IPX = Left(IPXInfo.szIpxAddress, InStr(IPXInfo.szIpxAddress, Chr(0)) - 1) RAS_PPP_GetClientIPX = True Else Return_IPX = "" RAS_GetLastError ReturnValue, "RasGetProjectionInfo", True RAS_PPP_GetClientIPX = False End If End Function ' * IMPORTANT NOTE: ' Remote access projection is the process whereby a remote access server and a remote ' client negotiate network protocol-specific information. A remote access server uses ' this network protocol-specific information to represent a remote client on the network. ' ' Windows NT/2000 : Remote access projection information is not available until the ' operating system has executed the RasDial RASCS_Projected state on the remote access ' connection. If RasGetProjectionInfo is called prior to the RASCS_Projected state, ' it returns ERROR_PROJECTION_NOT_COMPLETE. ' ' Windows 95 : Windows 95 Dial-Up Networking does not support the RASCS_Projected state. ' The projection phase may be done during the RASCS_Authenticate state. If the ' authentication is successful, the connection operation proceeds to the ' RASCS_Authenticated state, and projection information is available for successfully ' configured protocols. If RasGetProjectionInfo is called prior to the ' RASCS_Authenticated state, it returns ERROR_PROTOCOL_NOT_CONFIGURED. Public Function RAS_PPP_GetClientIP(ByRef Return_IP As String) As Boolean Dim PPPInfo As RASPPPIP Dim ReturnValue As Long Dim TheSize As Long ' Make sure there's a connection made If hRASConnection = 0 Then MsgBox "There is connection open to get the client IP from.", vbOKOnly + vbExclamation, " No Connection Open" Exit Function End If ' Initialize the variable to recieve the information TheSize = Len(PPPInfo) PPPInfo.dwSize = TheSize ' Get the PPP/IP information - which includes the clients's IP ReturnValue = RasGetProjectionInfo(hRASConnection, RASP_PppIp, PPPInfo, VarPtr(TheSize)) If ReturnValue = 0 Then Return_IP = Left(PPPInfo.szIpAddress, InStr(PPPInfo.szIpAddress, Chr(0)) - 1) RAS_PPP_GetClientIP = True Else Return_IP = "" RAS_GetLastError ReturnValue, "RasGetProjectionInfo", True RAS_PPP_GetClientIP = False End If End Function ' * IMPORTANT NOTE: ' Remote access projection is the process whereby a remote access server and a remote ' client negotiate network protocol-specific information. A remote access server uses ' this network protocol-specific information to represent a remote client on the network. ' ' Windows NT/2000 : Remote access projection information is not available until the ' operating system has executed the RasDial RASCS_Projected state on the remote access ' connection. If RasGetProjectionInfo is called prior to the RASCS_Projected state, ' it returns ERROR_PROJECTION_NOT_COMPLETE. ' ' Windows 95 : Windows 95 Dial-Up Networking does not support the RASCS_Projected state. ' The projection phase may be done during the RASCS_Authenticate state. If the ' authentication is successful, the connection operation proceeds to the ' RASCS_Authenticated state, and projection information is available for successfully ' configured protocols. If RasGetProjectionInfo is called prior to the ' RASCS_Authenticated state, it returns ERROR_PROTOCOL_NOT_CONFIGURED. Public Function RAS_PPP_GetServerIP(ByRef Return_IP As String) As Boolean Dim PPPInfo As RASPPPIP Dim ReturnValue As Long Dim TheSize As Long ' Make sure there's a connection made If hRASConnection = 0 Then MsgBox "There is connection open to get the server IP from.", vbOKOnly + vbExclamation, " No Connection Open" Exit Function End If ' Initialize the variable to recieve the information TheSize = Len(PPPInfo) PPPInfo.dwSize = TheSize ' Get the PPP/IP information - which includes the server's IP ReturnValue = RasGetProjectionInfo(hRASConnection, RASP_PppIp, PPPInfo, VarPtr(TheSize)) If ReturnValue = 0 Then Return_IP = Left(PPPInfo.szServerIpAddress, InStr(PPPInfo.szServerIpAddress, Chr(0)) - 1) RAS_PPP_GetServerIP = True Else Return_IP = "" RAS_GetLastError ReturnValue, "RasGetProjectionInfo", True RAS_PPP_GetServerIP = False End If End Function ' Function that does one of the following two things: ' - If the specified entry name exists, this changes the properties of that entry ' - If the specified entry name does NOT exist, this creates it with the specified properties Public Function RAS_SetEntryInfo(ByRef strEntryName As String, ByRef RasEntry As RASENTRY_VB, Optional ByRef strPhonebook As String = vbNullString) As Boolean On Error GoTo ErrorTrap Dim ReturnValue As Long Dim BufferSize As Long Dim BufferLength As Long Dim ReturnBuffer() As Byte Dim PtrPosition As Long Dim StringLength As Long Dim TheOS As OSTypes ' Make sure that the parameters passed are NULL terminated so they are passed to the API correctly If strPhonebook <> vbNullString Then If Right(strPhonebook, 1) <> Chr(0) Then strPhonebook = strPhonebook & Chr(0) End If End If ' If the user's OS is Win9x, change the phonebook = vbNullString because entries are ' stored in the Windows Registry, not a phonebook If strPhonebook <> vbNullString Then If GetOS(TheOS) = False Then strPhonebook = vbNullString Else If (TheOS = OS_Win95) Or (TheOS = OS_Win98) Then strPhonebook = vbNullString End If End If End If ' Get the buffer sizes needed ReturnValue = RasGetEntryProperties(vbNullString, vbNullString, ByVal 0&, BufferSize, ByVal 0&, ByVal 0&) ' The first call should return error 603 which indicates the buffers need to be bigger/initialized If ReturnValue <> 603 Then RAS_SetEntryInfo = False RAS_GetLastError ReturnValue, "RasGetEntryProperties", True Exit Function End If ' Initialize the right sized buffers to be passed to the API StringLength = Len(RasEntry.AlternateNumbers) BufferLength = BufferSize + StringLength + 1 ReDim ReturnBuffer(BufferLength) ' Copy the properties to be set into the buffers to be passed to the API With RasEntry CopyMemory ReturnBuffer(0), BufferSize, 4 CopyMemory ReturnBuffer(4), .Options, 4 CopyMemory ReturnBuffer(8), .CountryID, 4 CopyMemory ReturnBuffer(12), .CountryCode, 4 StringToByte ReturnBuffer(16), .AreaCode, 11 StringToByte ReturnBuffer(27), .LocalPhoneNumber, 129 If StringLength > 0 Then CopyMemory ReturnBuffer(BufferSize), ByVal .AlternateNumbers, StringLength CopyMemory ReturnBuffer(156), BufferSize, 4 End If CopyMemory ReturnBuffer(160), .ipAddr, 4 CopyMemory ReturnBuffer(164), .ipAddrDns, 4 CopyMemory ReturnBuffer(168), .ipAddrDnsAlt, 4 CopyMemory ReturnBuffer(172), .ipAddrWins, 4 CopyMemory ReturnBuffer(176), .ipAddrWinsAlt, 4 CopyMemory ReturnBuffer(180), .FrameSize, 4 CopyMemory ReturnBuffer(184), .fNetProtocols, 4 CopyMemory ReturnBuffer(188), .FramingProtocol, 4 StringToByte ReturnBuffer(192), .ScriptName, 260 StringToByte ReturnBuffer(452), .AutodialDll, 260 StringToByte ReturnBuffer(712), .AutodialFunc, 260 StringToByte ReturnBuffer(972), .DeviceType, 17 If BufferSize = 1672& Then StringLength = 33 Else StringLength = 129 End If StringToByte ReturnBuffer(989), .DeviceName, StringLength PtrPosition = 989 + StringLength StringToByte ReturnBuffer(PtrPosition), .X25PadType, 33 PtrPosition = PtrPosition + 33 StringToByte ReturnBuffer(PtrPosition), .X25Address, 201 PtrPosition = PtrPosition + 201 StringToByte ReturnBuffer(PtrPosition), .X25Facilities, 201 PtrPosition = PtrPosition + 201 StringToByte ReturnBuffer(PtrPosition), .X25UserData, 201 PtrPosition = PtrPosition + 203 CopyMemory ReturnBuffer(PtrPosition), .Channels, 4 ' If BufferSize > 1768 Then 'NT4 Enhancements & Win2000 ' CopyMemory ReturnBuffer(1768), .NT4En_SubEntries, 4 ' CopyMemory ReturnBuffer(1772), .NT4En_DialMode, 4 ' CopyMemory ReturnBuffer(1776), .NT4En_DialExtraPercent, 4 ' CopyMemory ReturnBuffer(1780), .NT4En_DialExtraSampleSeconds, 4 ' CopyMemory ReturnBuffer(1784), .NT4En_HangUpExtraPercent, 4 ' CopyMemory ReturnBuffer(1788), .NT4En_HangUpExtraSampleSeconds, 4 ' CopyMemory ReturnBuffer(1792), .NT4En_IdleDisconnectSeconds, 4 ' ' If BufferSize > 1796 Then ' Win2000 ' CopyMemory ReturnBuffer(1796), .Win2000_Type, 4 ' CopyMemory ReturnBuffer(1800), .Win2000_EncryptionType, 4 ' CopyMemory ReturnBuffer(1804), .Win2000_CustomAuthKey, 4 ' CopyMemory ReturnBuffer(1808), .Win2000_guidId(0), 16 ' StringToByte ReturnBuffer(1824), .Win2000_CustomDialDll, 260 ' CopyMemory ReturnBuffer(2084), .Win2000_VpnStrategy, 4 ' End If ' End If End With ' Set the properties ReturnValue = RasSetEntryProperties(strPhonebook, strEntryName, ReturnBuffer(0), BufferSize, ByVal 0&, ByVal 0&) ' If an error occured, display it If RAS_GetLastError(ReturnValue, "RasSetEntryProperties", True) = False Then RAS_SetEntryInfo = True End If Exit Function ErrorTrap: If Err.Number = 0 Then ' No Error Resume Next ElseIf Err.Number = 20 Then ' Resume Without Error Resume Next Else ' Unknown Error MsgBox Err.Source & " encountered the following error:" & Chr(13) & Chr(13) & "Error Number = " & CStr(Err.Number) & Chr(13) & "Error Description = " & Err.Description, vbOKOnly + vbExclamation, " Error - " & Err.Description RAS_SetEntryInfo = False Err.Clear Exit Function End If End Function '=============================================================================================== ' FUNCTIONS ONLY USED INSIDE THIS MODULE '=============================================================================================== ' This function takes in a Byte array and converts into a String Private Function ByteToString(ByRef ByteArray() As Byte) As String On Error Resume Next Dim MyCounter As Integer While MyCounter < UBound(ByteArray) And ByteArray(MyCounter) <> 0 ByteToString = ByteToString & Chr(ByteArray(MyCounter)) MyCounter = MyCounter + 1 Wend End Function ' This function takes a memory buffer, and takes the specified byptes and puts them into a string Private Function ByteToString_Trim(ByRef bPos As Byte, ByVal lngMaxLen As Long) As String On Error Resume Next ByteToString_Trim = String(lngMaxLen + 1, Chr(0)) CopyMemory ByVal ByteToString_Trim, bPos, lngMaxLen ByteToString_Trim = Left(ByteToString_Trim, InStr(ByteToString_Trim, Chr(0)) - 1) End Function ' This Function takes a string and breaks it up into a byte array Private Sub StringToByte(ByRef bPos As Byte, ByRef strToCopy As String, ByRef lngMaxLen As Long) On Error Resume Next Dim lngLen As Long lngLen = Len(strToCopy) If lngLen = 0 Then Exit Sub ElseIf lngLen > lngMaxLen Then lngLen = lngMaxLen End If CopyMemory bPos, ByVal strToCopy, lngLen End Sub ' Function that returns the connection state as a string given it's long value Private Function GetConStateSTR(ByVal RasConState As Long) As String On Error Resume Next Select Case RasConState Case RASCS_OpenPort GetConStateSTR = "Communication port is about to be opened" Case RASCS_PortOpened GetConStateSTR = "Communication port has been opened successfully" Case RASCS_ConnectDevice GetConStateSTR = "Device is about to be connected" ' RasGetConnectStatus can be called to determine the name and type of the device being connected. Case RASCS_DeviceConnected GetConStateSTR = "Device has connected successfully" ' RasGetConnectStatus can be called to determine the name and type of the device being connected. For a simple modem connection, RASCS_ConnectDevice and RASCS_DeviceConnected will be called only once. For a dial-up X.25 PAD connection, the pair will be called first for the modem, then for the PAD. If a preconnect switch is configured, the pair will be called for the switch before any other devices connect. Likewise, the pair will be called for a postconnect switch after any other devices connect.Windows 95: Note that Windows 95 does not currently support multistage connections such as the X.25 PAD connection described earlier. Case RASCS_AllDevicesConnected GetConStateSTR = "All devices in the device chain have successfully connected" ' At this point, the physical link is established. Case RASCS_Authenticate GetConStateSTR = "Authentication process is starting" ' Remote access does not allow the remote client to generate any traffic on the LAN until authentication has been successfully completed. ' Remote access authentication on a Windows NT or Windows 95 server consists of : ' 1) Validating the user name / password on the specified domain, ' 2) Projecting the client onto the LAN. This means that the remote access server does what is necessary to send and receive data on the LAN on behalf of the client. For example, the remote access server might need to add a NetBIOS name that corresponds to the client’s computer name, ' 3) Call-back processing in which the client hangs up and the server calls back. (The user needs special permissions on the remote access server for this.), ' 4) Calculating the link speed. This is necessary to correctly set transport time-outs to match the relatively slow speed of the remote link. Case RASCS_AuthNotify GetConStateSTR = "Authentication event has occurred" ' If dwError is zero, this event will be immediately followed by one of the more specific authentication states following. If dwError is nonzero, authentication has failed, and the error value indicates why. Case RASCS_AuthRetry GetConStateSTR = "Client has requested another validation attempt with a new user Name/Password/Domain" ' This state does not occur in Windows NT v3.1 Case RASCS_AuthCallback GetConStateSTR = "Remote Access Server (RAS) has requested a callback number" ' This occurs only if the user has "Set By Caller" callback privilege on the server. Case RASCS_AuthChangePassword GetConStateSTR = "Client has requested to change the password on the account" ' This state does not occur in Windows NT v3.1 Case RASCS_AuthProject GetConStateSTR = "Projection phase is starting" Case RASCS_AuthLinkSpeed GetConStateSTR = "The link-speed calculation phase is starting" Case RASCS_AuthAck GetConStateSTR = "Authentication request is being acknowledged" Case RASCS_ReAuthenticate GetConStateSTR = "Reauthentication (after callback) is starting" Case RASCS_Authenticated GetConStateSTR = "Client successfully completed authentication" Case RASCS_PrepareForCallback GetConStateSTR = "Line is about to disconnect in preparation for callback" Case RASCS_WaitForModemReset GetConStateSTR = "Client is delaying in order to give the modem time to reset itself in preparation for callback" Case RASCS_WaitForCallback GetConStateSTR = "Client is waiting for an incoming call from the Remote Access Server (RAS)" Case RASCS_Projected GetConStateSTR = "Projection result information is available" 'This state occurs after the RASCS_AuthProject state. You can access the projection result information by calling RasGetProjectionInfo Case RASCS_StartAuthentication ' Windows 95 Only GetConStateSTR = "User authentication is being initiated or retried" Case RASCS_CallbackComplete ' Windows 95 Only GetConStateSTR = "Client has been called back and is about to resume authentication" Case RASCS_LogonNetwork ' Windows 95 Only GetConStateSTR = "Client is logging on to the network" Case RASCS_SubEntryConnected GetConStateSTR = "A subentry has been connected during the dialing process" ' (When dialing a multilink phone-book entry) The dwSubEntry parameter of a RasDialFunc2 callback function indicates the index of the subentry. When the final state of all subentries in the phone-book entry has been determined, the connection state is RASCS_Connected if one or more subentries have been connected successfully. Case RASCS_SubEntryDisconnected GetConStateSTR = "A subentry has been disconnected during the dialing process" ' (When dialing a multilink phone-book entry) The dwSubEntry parameter of a RasDialFunc2 callback function indicates the index of the subentry. Case RASCS_Interactive GetConStateSTR = "Terminal state reported" 'This state corresponds to the terminal state supported by RASPHONE.EXE. This state does not occur in Windows NT v3.1 Case RASCS_RetryAuthentication GetConStateSTR = "Retry authentication state reported" ' This state corresponds to the retry authentication state supported by RASPHONE.EXE. This state does not occur in Windows NT v3.1 Case RASCS_CallbackSetByCaller GetConStateSTR = "Callback state reported" ' This state corresponds to the callback state supported by RASPHONE.EXE. This state does not occur in Windows NT v3.1 Case RASCS_PasswordExpired GetConStateSTR = "Change password state reported" ' This state corresponds to the change password state supported by RASPHONE.EXE. This state does not occur in Windows NT v3.1 Case RASCS_Connected GetConStateSTR = "Connected Successfully" Case RASCS_Disconnected GetConStateSTR = "Disconnected or failed to connect" Case Else GetConStateSTR = "..." End Select End Function ' Function to set the windows information variables Private Function GetOS(Optional ByRef Return_WinOS As OSTypes, Optional ByRef Return_WinVersion As String, Optional ByRef Return_WinBuild As String) As Boolean On Error GoTo ErrorTrap Dim OSinfo As OSVERSIONINFO Dim RetValue As Long Dim PID As String OSinfo.dwOSVersionInfoSize = 148 OSinfo.szCSDVersion = Space(128) RetValue = GetVersionEx(OSinfo) If RetValue = 0 Then MsgBox "An error occured while trying to get the OS version and information." & Chr(13) & "Click OK to continue.", vbOKOnly + vbExclamation, " Error Getting OS Information" GetOS = False Exit Function End If With OSinfo Select Case .dwPlatformId Case VER_PLATFORM_WIN32s PID = "Win 32" Return_WinOS = OS_Win32 Case VER_PLATFORM_WIN32_WINDOWS If .dwMinorVersion = 0 Then PID = "Windows 95" Return_WinOS = OS_Win95 ElseIf .dwMinorVersion = 10 Then PID = "Windows 98" Return_WinOS = OS_Win98 End If Case VER_PLATFORM_WIN32_NT If .dwMajorVersion = 3 Then PID = "Windows NT 3.51" Return_WinOS = OS_WinNT_351 ElseIf .dwMajorVersion = 4 Then PID = "Windows NT 4.0" Return_WinOS = OS_WinNT_40 ElseIf .dwMajorVersion = 5 Then PID = "Windows 2000" Return_WinOS = OS_Win2000 End If Case Else PID = "Unknown" Return_WinOS = OS_Unknown End Select End With Return_WinVersion = Trim(Str(OSinfo.dwMajorVersion) & "." & LTrim(Str(OSinfo.dwMinorVersion))) Return_WinBuild = Trim(Str(OSinfo.dwBuildNumber)) GetOS = True Exit Function ErrorTrap: If Err.Number = 0 Then Resume Next ElseIf Err.Number = 20 Then Resume Next Else MsgBox Err.Source & " caused the following error while getting the OS version:" & Chr(13) & Chr(13) & "Error Number = " & CStr(Err.Number) & Chr(13) & "Error Description = " & Err.Description, vbOKOnly + vbExclamation, " Error - " & Err.Description Err.Clear GetOS = False Exit Function End If End Function ' This function does what Netscape and MSIE do when you type in them... they ' auto-complete what you're typing based on what's already in the combo box '------------------------------------------------------------------------------- ' Put the following code in the KeyUp event of the ComboBox: ' ' Select Case KeyCode ' Case 32, &H30 To &H6F, Is > &H7F ' AutoComplete Combo1 ' End Select '------------------------------------------------------------------------------- Public Sub AutoComplete(ByRef CboBox As ComboBox) On Error Resume Next Dim ReturnValue As Long Dim lngPosition As Long With CboBox lngPosition = Len(.Text) If lngPosition <> 0 Then ReturnValue = SendMessage(.hWnd, &H14C, -1&, ByVal .Text) .ListIndex = ReturnValue .SelStart = lngPosition .SelLength = Len(.Text) - lngPosition End If End With End Sub 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX '=============================================================================================== ' RAS FUNCTIONS DOCUMENTATION '=============================================================================================== ' ' 'DWORD RasEnumEntries ( ' LPTSTR reserved, // Reserved, must be NULL ' LPTSTR lpszPhonebook, // Pointer to full path and filename of 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 '); ' 'DWORD RasEnumDevices( ' LPRASDEVINFO lpRasDevInfo, // Buffer to receive information about RAS devices ' LPDWORD lpcb, // Size, in bytes, of the buffer ' LPDWORD lpcDevices // Receives the number of entries written to the buffer '); ' 'DWORD RasGetErrorString ( ' UINT uErrorValue, // Error to get string for ' LPTSTR lpszErrorString, // Buffer to hold error string ' DWORD cBufSize // Size, in characters, of buffer '); ' 'DWORD RasGetEntryProperties( ' LPTSTR lpszPhonebook, // Pointer to full path and filename of phone-book file ' LPTSTR lpszEntry, // Pointer to an entry name ' LPRASENTRY lpRasEntry, // Buffer that receives entry information ' LPDWORD lpdwEntryInfoSize, // Size, in bytes, of the lpRasEntry buffer ' LPBYTE lpbDeviceInfo, // Buffer that receives device-specific configuration information ' LPDWORD lpdwDeviceInfoSize // Size, in bytes, of the lpbDeviceInfo buffer '); ' 'DWORD RasSetEntryProperties( ' LPTSTR lpszPhonebook, // Pointer to full path and filename of phone-book file ' LPTSTR lpszEntry, // Pointer to an entry name ' LPRASENTRY lpRasEntry, // Buffer that contains entry information ' DWORD dwEntryInfoSize, // Size, in bytes, of the lpRasEntry buffer ' LPBYTE lpbDeviceInfo, // Buffer that contains device-specific configuration information ' DWORD dwDeviceInfoSize // Size, in bytes, of the lpbDeviceInfo buffer '); ' 'DWORD RasCreatePhonebookEntry( ' HWND hwnd, // Handle to the parent window of the dialog box ' LPTSTR lpszPhonebook // Pointer to the full path and filename of the phone-book file '); ' 'DWORD RasEditPhonebookEntry( ' HWND hwnd, // Handle to the parent window of the dialog box ' LPTSTR lpszPhonebook, // Pointer to the full path and filename of the phone-book file ' LPTSTR lpszEntryName // Pointer to the phone-book entry name '); ' 'DWORD RasRenameEntry( ' LPTSTR lpszPhonebook, // Pointer to full path and filename of phone-book file ' LPTSTR lpszOldEntry, // Pointer to the old entry name ' LPTSTR lpszNewEntry // Pointer to the new entry name '); ' 'BOOL RasPhonebookDlg( [ * Windows NT Only * ] ' LPTSTR lpszPhonebook, // Pointer to the full path and filename of the phone-book file ' LPTSTR lpszEntry, // Pointer to the name of the phone-book entry to highlight ' LPRASPBDLG lpInfo // Pointer to a structure that contains additional parameters '); ' 'BOOL RasDialDlg( [ * Windows NT Only * ] ' LPTSTR lpszPhonebook, // Pointer to the full path and filename of the phone-book file ' LPTSTR lpszEntry, // Pointer to the name of the phone-book entry to dial ' LPTSTR lpszPhoneNumber, // Pointer to replacement phone number to dial ' LPRASDIALDLG lpInfo // Pointer to a structure that contains additional parameters '); ' 'BOOL RasMonitorDlg( [ * Windows NT Only * ] ' LPTSTR lpszDeviceName, // Pointer to the name of the device to display initially ' LPRASMONITORDLG lpInfo // Pointer to structure that contains input and output parameters '); ' 'BOOL RasEntryDlg( [ * Windows NT Only * ] ' LPTSTR lpszPhonebook, // Pointer to the full path and filename of the phone-book file ' LPTSTR lpszEntry, // Pointer to the name of the phone-book entry to edit, copy, or create ' LPRASENTRYDLG lpInfo // Pointer to a structure that contains additional parameters '); ' 'DWORD RasDial( ' LPRASDIALEXTENSIONS lpRasDialExtensions, // Pointer to function extensions data ' LPTSTR lpszPhonebook, // Pointer to full path and filename of phone-book file ' LPRASDIALPARAMS lpRasDialParams, // Pointer to calling parameters data ' DWORD dwNotifierType, // Specifies type of RasDial event handler ' LPVOID lpvNotifier, // Specifies a handler for RasDial events ' LPHRASCONN lphRasConn // Pointer to variable to receive connection handle '); ' 'VOID WINAPI RasDialFunc( * CALLBACK Function - Type 1 * ' UINT unMsg, // Type of event that has occurred ' RASCONNSTATE rasconnstate, // Connection state about to be entered ' DWORD dwError // Error that may have occurred '); ' 'VOID WINAPI RasDialFunc1( * CALLBACK Function - Type 2 * ' HRASCONN hrasconn, // Handle to RAS connection ' UINT unMsg, // Type of event that has occurred ' RASCONNSTATE rascs, // Connection state about to be entered ' DWORD dwError, // Error that may have occurred ' DWORD dwExtendedError // Extended error information for some errors '); ' 'DWORD WINAPI RasDialFunc2( * CALLBACK Function - Type 3 (Windows NT Only) * ' DWORD dwCallbackId, // User-defined value specified in RasDial call ' DWORD dwSubEntry, // Subentry index in multilink connection ' HRASCONN hrasconn, // Handle to RAS connection ' UINT unMsg, // Type of event that has occurred ' RASCONNSTATE rascs, // Connection state about to be entered ' DWORD dwError, // Error that may have occurred ' DWORD dwExtendedError // Extended error information for some errors ');