vb建立 VPN 拨号连接
来源:互联网 发布:java飞机大战添加boss 编辑:程序博客网 时间:2024/04/30 12:28
建立 VPN 拨号全部代码如下:
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As Long)
Private Type GUID
Data1 As Long
Data2 As Integer
Data3 As Integer
Data4(7) As Byte
End Type
Private Type RASIPADDR
a As Byte
b As Byte
c As Byte
d As Byte
End Type
Private Type RASENTRY
dwSize As Long
dwfOptions As Long
dwCountryID As Long
dwCountryCode As Long
szAreaCode(10) As Byte
szLocalPhoneNumber(128) As Byte
dwAlternateOffset As Long
ipaddr As RASIPADDR
ipaddrDns As RASIPADDR
ipaddrDnsAlt As RASIPADDR
ipaddrWins As RASIPADDR
ipaddrWinsAlt As RASIPADDR
dwFrameSize As Long
dwfNetProtocols As Long
dwFramingProtocol As Long
szScript(259) As Byte
szAutodialDll(259) As Byte
szAutodialFunc(259) As Byte
szDeviceType(16) As Byte
szDeviceName(128) As Byte
szX25PadType(32) As Byte
szX25Address(200) As Byte
szX25Facilities(200) As Byte
szX25UserData(200) As Byte
dwChannels As Long
dwReserved1 As Long
dwReserved2 As Long
dwSubEntries As Long
dwDialMode As Long
dwDialExtraPercent As Long
dwDialExtraSampleSeconds As Long
dwHangUpExtraPercent As Long
dwHangUpExtraSampleSeconds As Long
dwIdleDisconnectSeconds As Long
dwType As Long
dwEncryptionType As Long
dwCustomAuthKey As Long
guidId As GUID
szCustomDialDll(259) As Byte
dwVpnStrategy As Long
dwfOptions2 As Long
dwfOptions3 As Long
szDnsSuffix(255) As Byte
dwTcpWindowSize As Long
szPrerequisitePbk(259) As Byte
szPrerequisiteEntry(256) As Byte
dwRedialCount As Long
dwRedialPause As Long
End Type
Private Type RASCREDENTIALS
dwSize As Long
dwMask As Long
szUserName(256) As Byte
szPassword(256) As Byte
szDomain(15) As Byte
End Type
Private Declare Function RasSetEntryProperties Lib "rasapi32" Alias "RasSetEntryPropertiesA" (ByVal lpszPhonebook As String, ByVal lpszEntry As String, 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, lpCredentials As RASCREDENTIALS, ByVal fClearCredentials As Long) As Long
Private Sub Command1_Click()
Dim sEntryName As String, sUsername As String, sPassword As String
sEntryName = "VPN"
sUsername = "super"
sPassword = "greenbean"
If Create_PPPoE_Connection("VPN", sEntryName, sUsername, sPassword) Then
MsgBox "连接建立成功!"
Else
MsgBox "连接建立失败!"
End If
End Sub
Function Create_PPPoE_Connection(ByVal sDeviceType As String, 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 微型端口 (PPTP)"
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 '3 直连4 管理5 宽带7 普通
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
- vb建立 VPN 拨号连接
- vb建立 VPN 拨号连接
- c#实现建立拨号连接-PPOE,VPN(异步方式)
- ubuntu下建立PPTP-VPN客户端拨号连接 [已删除]
- ubuntu下建立PPTP-VPN客户端拨号连接
- ubuntu下建立PPTP-VPN客户端拨号连接(绝对可用)
- 使用VB创建PPPoE以及VPN拨号连接的核心代码
- 使用VB创建PPPoE以及VPN拨号连接的核心代码
- VPN 建立和连接
- VPN连接:win7下建立VPN连接
- VPN连接:win7下建立VPN连接
- xp不能建立拨号连接
- 如何创建VPN的拨号连接
- VPN拨号连接报789错误解决方法
- VPN拨号
- D-LINK DI-804HV使用PPPOE拨号建立VPN
- WinCE 下 RAS 拨号连接的建立和拨号过程
- WinCE 下 RAS 拨号连接的建立和拨号过程
- asp如何调试错误
- typedef定义函数指针
- MD5算法描述[转百度百科]
- 位图文件结构
- RS.OPEN是什么意思
- vb建立 VPN 拨号连接
- MCS-51单片机主要应用特性
- PL/SQL表--table()函数用法
- 编写程序输出1000以内的所有奇数
- 怎样判读当前日期是这个月的第几个星期的星期几[WEB学习示例]
- Adobe Dreamweaver CS4序列号破解与序列号过期解决办法
- 检查重复的数据
- 成员函数隐含的this指针
- 第16课 数据与通信之JSON