回复:2楼 你动作好快...我还没发完呢... 代码片段:Create_PPPoE_Connection(sEntryName, sUsername, sPassword) recAdConn = AddConnection(TxtLJ.Text, "", "", TxtYHM.Text, TxtMM.Text, "") Public Function IsConnected() As Boolean Dim TRasCon(255) As RASCONN95 Dim lg As Long Dim lpcon As Long
Function Create_PPPoE_Connection(ByVal sEntryName As String, ByVal sUsername As String, ByVal sPassword As String) As Boolean Create_PPPoE_Connection = False
Dim re As RASENTRY Dim sDeviceName As String, sDeviceType As String sDeviceName = "WAN 微型端口 (PPPOE)" sDeviceType = "PPPoE" With re .dwSize = LenB(re) .dwCountryCode = 86 .dwCountryID = 86 .dwDialExtraPercent = 75 .dwDialExtraSampleSeconds = 120 .dwDialMode = 1 .dwEncryptionType = 3 .dwfNetProtocols = 4 .dwfOptions = 1024262928 .dwfOptions2 = 367 .dwFramingProtocol = 1 .dwHangUpExtraPercent = 10 .dwHangUpExtraSampleSeconds = 120 .dwRedialCount = 3 .dwRedialPause = 60 .dwType = 5 CopyMemory .szDeviceName(0), ByVal sDeviceName, Len(sDeviceName)
CopyMemory .szDeviceType(0), ByVal sDeviceType, Len(sDeviceType) End With
Dim rc As RASCREDENTIALS With rc .dwSize = LenB(rc) .dwMask = 11 CopyMemory .szUserName(0), ByVal sUsername, Len(sUsername) CopyMemory .szPassword(0), ByVal sPassword, Len(sPassword) End With
Dim rtn As Long If RasSetEntryProperties(vbNullString, sEntryName, re, LenB(re), 0, 0) = 0 Then If RasSetCredentials(vbNullString, sEntryName, rc, 0) = 0 Then Create_PPPoE_Connection = True End If End If End Function