vpn 掩藏连接问题
该列子是在网上找的,可以使用,但是想把连接的时候掩藏掉了。不要弹出来连接框,只要点击一个按钮就可以连接成功。
不知道如何设置。希望得到朋友的帮助。
创建连接是用
Function Create_Vpn_Connection(ByVal sDeviceType As String, ByVal sEntryName As String, ByVal sUsername As String, ByVal sPassword As String, ByVal IP As String) As Boolean
Create_Vpn_Connection = False
Dim re As RASENTRY
Dim sDeviceName As String ', sDeviceType As String
sDeviceName = "WAN 微型端口 (PPTP)"
With re '请大家解释下这个各个值的含义。比如我想隐藏拨号界面,想不保存密码,想用普通的pptp而不用l2tp,想不加密或者先加密后不加密,等应该怎么写?
.dwSize = LenB(re)
.dwCountryCode = 86
.dwCountryID = 86
.dwDialExtraPercent = 75
.dwDialExtraSampleSeconds = 120
.dwDialMode = 1
.dwVpnStrategy = 1 'vpn类型 0 默认 1仅pptp 2先pptp 3仅l2tp 4先l2tp
.dwEncryptionType = 3 '加密类型
.dwfNetProtocols = 4
.dwfOptions = 1024262928
.dwfOptions2 = 367
.dwFramingProtocol = 1
.dwHangUpExtraPercent = 10
.dwHangUpExtraSampleSeconds = 120
.dwRedialCount = 3
.dwRedialPause = 60
.dwType = 3 '3 直连4 管理5 宽带7 普通
CopyMemory .szLocalPhoneNumber(0), ByVal IP, Len(IP)
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_Vpn_Connection = True
End If
End If
End Function
'拨号
Public Function DialUp(LinkName As String) As Boolean
InternetDial 0, LinkName, INTERNET_AUTODIAL_FORCE_UNATTENDED, Handle, 0
DialUp = (Handle <> 0)
End Function
Private Sub Command2_Click() '启动连接
If DialUp("vpn") Then
Shell "explorer http://www.baidu.com"
MsgBox "成功连接,正在启动IE……"
Else
MsgBox "连接失败!"
End If
End Sub --------------------编程问答-------------------- 现在都没有人搞VB了吗
补充:VB , API