The RASEntry structure is used in the RASGetEntryProperties and RASSetEntryProperties functions. From the PlatformSDK, the structure is defined as follows:
typedef struct tagRASENTRY {
DWORD dwSize;
DWORD dwfOptions;
//
// Location/phone number.
//
DWORD dwCountryID;
DWORD dwCountryCode;
TCHAR szAreaCode[ RAS_MaxAreaCode + 1 ];
TCHAR szLocalPhoneNumber[ RAS_MaxPhoneNumber + 1 ];
DWORD dwAlternateOffset;
//
// PPP/Ip
//
RASIPADDR ipaddr;
RASIPADDR ipaddrDns;
RASIPADDR ipaddrDnsAlt;
RASIPADDR ipaddrWins;
RASIPADDR ipaddrWinsAlt;
//
// Framing
//
DWORD dwFrameSize;
DWORD dwfNetProtocols;
DWORD dwFramingProtocol;
//
// Scripting
//
TCHAR szScript[ MAX_PATH ];
//
// AutoDial
//
TCHAR szAutodialDll[ MAX_PATH ];
TCHAR szAutodialFunc[ MAX_PATH ];
//
// Device
//
TCHAR szDeviceType[ RAS_MaxDeviceType + 1 ];
TCHAR szDeviceName[ RAS_MaxDeviceName + 1 ];
//
// X.25
//
TCHAR szX25PadType[ RAS_MaxPadType + 1 ];
TCHAR szX25Address[ RAS_MaxX25Address + 1 ];
TCHAR szX25Facilities[ RAS_MaxFacilities + 1 ];
TCHAR szX25UserData[ RAS_MaxUserData + 1 ];
DWORD dwChannels;
//
// Reserved
//
DWORD dwReserved1;
DWORD dwReserved2;
#if (WINVER >= 0x401)
//
// Multilink and BAP
//
DWORD dwSubEntries;
DWORD dwDialMode;
DWORD dwDialExtraPercent;
DWORD dwDialExtraSampleSeconds;
DWORD dwHangUpExtraPercent;
DWORD dwHangUpExtraSampleSeconds;
//
// Idle timeout
//
DWORD dwIdleDisconnectSeconds;
#endif
#if (WINVER >= 0x500)
DWORD dwType; // entry type
DWORD dwEncryptionType; // type of encryption to use
DWORD dwCustomAuthKey; // authentication key for EAP
GUID guidId; // guid that represents
// the phone-book entry
TCHAR szCustomDialDll[MAX_PATH]; // DLL for custom dialing
DWORD dwVpnStrategy; // specifies type of VPN protocol
#endif
} RASENTRY;
Note how it has seven extra members if the Windows Version is &H401 or greater (NT4 enhancements) and another six members for windows 2000 (Version >=&H500). Also the RAS_MaxDeviceName constant is different for different platforms. For windows 95/98 and NT4 or later, it's value is 256. For earlier versions of NT (eg 3.51) it's value is 33. This gives us a possible 4 different sized structures for the RASENTRY structure, being 2088 (win2000), 1796 (NT4 enhancements), 1768 (win 95/98/NT4), or 1672 (NT3.51)
A common approach to this problem is to declare 4 different structures, check the windows version by calling the GetVersionEX() API function, then pass our values to and from the appropriate structure. I call this the SDKtoVB approach. The problem with that approach is it is difficult to update in the future, and the structures themselves are not really VB friendly - strings are stored as fixed length byte arrays , etc. Also we are relying on the windows platform and not the actual version of RASAPI on the system.
Another approach, is to start from the VB end and work towards the SDK format. I call this the VBtoSDK approach. The first step in this approach is to define the information we want as we would handle it in VB.
For the RASENTRY structure, our VB declaration with all the relevant substructures and enums would be as follows:
Public Type RASIPADDR
a As Byte
b As Byte
c As Byte
d As Byte
End Type
Public Enum RasEntryOptions
RASEO_UseCountryAndAreaCodes = &H1
RASEO_SpecificIpAddr = &H2
RASEO_SpecificNameServers = &H4
RASEO_IpHeaderCompression = &H8
RASEO_RemoteDefaultGateway = &H10
RASEO_DisableLcpExtensions = &H20
RASEO_TerminalBeforeDial = &H40
RASEO_TerminalAfterDial = &H80
RASEO_ModemLights = &H100
RASEO_SwCompression = &H200
RASEO_RequireEncryptedPw = &H400
RASEO_RequireMsEncryptedPw = &H800
RASEO_RequireDataEncryption = &H1000
RASEO_NetworkLogon = &H2000
RASEO_UseLogonCredentials = &H4000
RASEO_PromoteAlternates = &H8000
RASEO_SecureLocalFiles = &H10000
RASEO_RequireEAP = &H20000
RASEO_RequirePAP = &H40000
RASEO_RequireSPAP = &H80000
RASEO_Custom = &H100000
RASEO_PreviewPhoneNumber = &H200000
RASEO_SharedPhoneNumbers = &H800000
RASEO_PreviewUserPw = &H1000000
RASEO_PreviewDomain = &H2000000
RASEO_ShowDialingProgress = &H4000000
RASEO_RequireCHAP = &H8000000
RASEO_RequireMsCHAP = &H10000000
RASEO_RequireMsCHAP2 = &H20000000
RASEO_RequireW95MSCHAP = &H40000000
RASEO_CustomScript = &H80000000
End Enum
Public Enum RASNetProtocols
RASNP_NetBEUI = &H1
RASNP_Ipx = &H2
RASNP_Ip = &H4
End Enum
Public Enum RasFramingProtocols
RASFP_Ppp = &H1
RASFP_Slip = &H2
RASFP_Ras = &H4
End Enum
Public Type VBRasEntry Options As RasEntryOptions CountryID As Long CountryCode As Long AreaCode As String LocalPhoneNumber As String AlternateNumbers As String ipAddr As RASIPADDR ipAddrDns As RASIPADDR ipAddrDnsAlt As RASIPADDR ipAddrWins As RASIPADDR ipAddrWinsAlt As RASIPADDR FrameSize As Long fNetProtocols As RASNetProtocols FramingProtocol As RasFramingProtocols ScriptName As String AutodialDll As String AutodialFunc As String DeviceType As String DeviceName As String X25PadType As String X25Address As String X25Facilities As String X25UserData As String Channels As Long NT4En_SubEntries As Long NT4En_DialMode As Long NT4En_DialExtraPercent As Long NT4En_DialExtraSampleSeconds As Long NT4En_HangUpExtraPercent As Long NT4En_HangUpExtraSampleSeconds As Long NT4En_IdleDisconnectSeconds As Long Win2000_Type As Long Win2000_EncryptionType As Long Win2000_CustomAuthKey As Long Win2000_guidId(0 To 15) As Byte Win2000_CustomDialDll As String Win2000_VpnStrategy As Long End Type
In our structure above, note how we have declared the strings as variable length strings (the" VB way") , used Enums for our Options, FramingProtocols and fNetProtocols. Also note how the members near the end have a NT4En_ or Win2000_ prefix to remind us these members are only for those platforms. (the NT4En_ members are available on NT4 enhancements and windows 2000) .
The SDK declaration for dwAlternateOffset has been changed to AlternateNumbers as a String in our VB declaration - so instead of having a offset pointer to a string, we now have a string that can be a set of numbers separated by chr$(0). The AlternateNumbers doesn't have any effect on win 95/98.
To see how we can use our VB structure with the RASAPI functions see the code on using the RASGetEntryProperties and RASSetEntryProperties functions.
For information on getting device information see RasEnumDevices.
For information on country IDs and Codes, see RasGetCountryInfo
See Also: Contents, Introduction, RASGetEntryProperties, RASSetEntryProperties, RasEnumDevices, RasEnumEntries, RasGetCountryInfo