请大家帮忙改一下的!

rainmansky2008 2008-06-26 03:48:35
Option Explicit On
Imports Microsoft.VisualBasic.Compatibility.VB6
Imports Microsoft.VisualBasic
Imports System.IO
Imports System
Imports System.Text
Public Class Form1
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (ByVal Destination As Object, ByVal Source As Object, ByVal Length As Long)
Private Structure GUID
Public Data1 As Long
Public Data2 As Integer
Public Data3 As Integer
Dim Data4() As Byte
Public Sub Initialize()
ReDim Data4(7)
End Sub
End Structure
Private Structure RASIPADDR
Public a As Byte
Public b As Byte
Public c As Byte
Public d As Byte
End Structure
Private Structure RASENTRY
Public dwSize As Long
Public dwfOptions As Long
Public dwCountryID As Long
Public dwCountryCode As Long
Public dwAlternateOffset As Long
Public ipaddr As RASIPADDR
Public ipaddrDns As RASIPADDR
Public ipaddrDnsAlt As RASIPADDR
Public ipaddrWins As RASIPADDR
Public ipaddrWinsAlt As RASIPADDR
Public dwFrameSize As Long
Public dwfNetProtocols As Long
Public dwFramingProtocol As Long
Dim szAreaCode() As Byte
Dim szLocalPhoneNumber() As Byte
Dim szScript() As Byte
Dim szAutodialDll() As Byte
Dim szAutodialFunc() As Byte
Dim szDeviceType() As Byte
Dim szDeviceName() As Byte
Dim szX25PadType() As Byte
Dim szX25Address() As Byte
Dim szX25Facilities() As Byte
Dim szX25UserData() As Byte
Dim szPrerequisitePbk() As Byte
Dim szPrerequisiteEntry() As Byte
Dim szDnsSuffix() As Byte
Dim szCustomDialDll() As Byte
Public dwChannels As Long
Public dwReserved1 As Long
Public dwReserved2 As Long
Public dwSubEntries As Long
Public dwDialMode As Long
Public dwDialExtraPercent As Long
Public dwDialExtraSampleSeconds As Long
Public dwHangUpExtraPercent As Long
Public dwHangUpExtraSampleSeconds As Long
Public dwIdleDisconnectSeconds As Long
Public dwType As Long
Public dwEncryptionType As Long
Public dwCustomAuthKey As Long
Public guidId As GUID
Public dwVpnStrategy As Long
Public dwfOptions2 As Long
Public dwfOptions3 As Long
Public dwTcpWindowsize As Long
Public dwRedialCount As Long
Public dwRedialPause As Long

Public Sub Initialize()
ReDim szAreaCode(10)
ReDim szLocalPhoneNumber(128)
ReDim szScript(259)
ReDim szAutodialDll(259)
ReDim szAutodialFunc(259)
ReDim szDeviceType(16)
ReDim szDeviceName(128)
ReDim szX25PadType(32)
ReDim szX25Address(200)
ReDim szX25Facilities(200)
ReDim szX25UserData(200)
ReDim szPrerequisitePbk(259)
ReDim szPrerequisiteEntry(256)
ReDim szDnsSuffix(255)
ReDim szCustomDialDll(259)
End Sub

End Structure
Private Structure RASCREDENTIALS
Public dwSize As Long
Public dwMask As Long
Dim szUserName() As Byte
Dim szPassword() As Byte
Dim szDomain() As Byte
Public Sub Initialize()
ReDim szUserName(256)
ReDim szPassword(256)
ReDim szDomain(15)
End Sub
End Structure
Private Structure RASDIALPARAMS''''''''''''''''我想做自定义号码的modem电话号码拨号上网,就是类似windows
Dim szEntryName As String''''''''''''''''''自带的那个拨号。这段是一位高手老大指点的(再次感谢),请
Dim szPhoneNumber As String''''''''''''''''大家帮我看看怎么修改后面的代码,实现自定义号码,modem拨号
End Structure''''''''''''''''''''''''''''''''''上网
Private Const ET_None As Long = 0 ' No encryption
Private Const ET_Require As Long = 1 ' Require Encryption
Private Const ET_RequireMax As Long = 2 ' Require max encryption
Private Const ET_Optional As Long = 3 ' Do encryption if possible. None Ok.
Private Const VS_Default As Long = 0 ' default (PPTP for now)
Private Const VS_PptpOnly As Long = 1 ' Only PPTP is attempted.
Private Const VS_PptpFirst As Long = 2 ' PPTP is tried first.
Private Const VS_L2tpOnly As Long = 3 ' Only L2TP is attempted.
Private Const VS_L2tpFirst As Long = 4 ' L2TP is tried first.
Private Const RASET_Phone As Long = 1 ' Phone lines: modem, ISDN, X.25, etc
Private Const RASET_Vpn As Long = 2 ' Virtual private network
Private Const RASET_Direct As Long = 3 ' Direct connect: serial, parallel
Private Const RASET_Internet As Long = 4 ' BaseCamp internet
Private Const RASET_Broadband As Long = 5 ' Broadband
Private Declare Function RasSetEntryProperties Lib "rasapi32" Alias "RasSetEntryPropertiesA" (ByVal lpszPhonebook As String, ByVal lpszEntry As String, ByVal lpRasEntry As RASENTRY, ByVal dwEntryInfoSize As Long, ByVal lpbDeviceInfo As Long, ByVal dwDeviceInfoSize As Long) As Long
Private Declare Function RasSetCredentials Lib "rasapi32" Alias "RasSetCredentialsA" (ByVal lpszPhonebook As String, ByVal lpszEntry As String, ByVal lpCredentials As RASCREDENTIALS, ByVal fClearCredentials As Long) As Long
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim sEntryName As String, sUsername As String, sPassword As String

'创建PPPoE
sEntryName = "宽带连接"
sUsername = "16900"
sPassword = "16900"

If Create_PPPoE_Connection(sEntryName, sUsername, sPassword) Then
MsgBox("连接建立成功!")
Else
MsgBox("连接建立失败!")
End If
End Sub
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 New RASENTRY, rp As New RASDIALPARAMS
Dim sDeviceName As String, sDeviceType As String
sDeviceName = "Smart Link 56K Voice Modem"
sDeviceType = "PPPoE"
Dim instance As Encoding = Encoding.Unicode
Dim aa() As Byte
aa = instance.GetBytes(sDeviceName)
Dim bb() As Byte
bb = instance.GetBytes(sDeviceType)
re.Initialize()
rp.szEntryName = "Smart Link 56K Voice Modem"
rp.szPhoneNumber = "0,16900"
With re
.dwSize = Len(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 = RASET_Broadband
CopyMemory(.szDeviceName, aa, Len(sDeviceName))
CopyMemory(.szDeviceType, bb, Len(sDeviceType))
End With
Dim rc As RASCREDENTIALS
rc.Initialize()
With rc
.dwSize = Len(rc)
.dwMask = 11
CopyMemory(.szUserName, sUsername, Len(sUsername))
CopyMemory(.szPassword, sPassword, Len(sPassword))
End With
Dim rtn As Long
If RasSetEntryProperties(rp.szPhoneNumber, sEntryName, re, Len(re), 0, 0) = 0 Then
If RasSetCredentials(rp.szPhoneNumber, sEntryName, rc, 0) = 0 Then
Create_PPPoE_Connection = True
End If
End If
End Function
...全文
72 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
只在此山中 2008-06-27
  • 打赏
  • 举报
回复
这个
Private Structure RASDIALPARAMS''''''''''''''''我想做自定义号码的modem电话号码拨号上网,就是类似windows
Dim szEntryName As String''''''''''''''''''自带的那个拨号。这段是一位高手老大指点的(再次感谢),请
Dim szPhoneNumber As String''''''''''''''''大家帮我看看怎么修改后面的代码,实现自定义号码,modem拨号
End Structure''''''''''''''''''''''''''''''''''上网

没定义完啊!

16,556

社区成员

发帖
与我相关
我的任务
社区描述
VB技术相关讨论,主要为经典vb,即VB6.0
社区管理员
  • VB.NET
  • 水哥阿乐
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧