Josette Posted March 27, 2009 Share Posted March 27, 2009 (edited) here's the codes: can anybody convert it to au3 expandcollapse popupPrivate 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 Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As Long) 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 Dim sServer As String sServer = "[url="http://www.vpnserver.com"]www.vpnserver.com[/url]" sEntryName = "ThisIsAVpn" sUsername = "username" sPassword = "password" If Create_VPN_Connection(sEntryName, sServer, sUsername, sPassword) Then MsgBox "Sucessed" Else MsgBox "Failed" End If End Sub Function Create_VPN_Connection(ByVal sEntryName As String, ByVal sServer As String, ByVal sUsername As String, ByVal sPassword As String) As Boolean Create_VPN_Connection = False Dim re As RASENTRY Dim sDeviceName As String, sDeviceType As String sDeviceName = "WAN MINIPORT (L2TP)" sDeviceType = "vpn" With re .dwSize = LenB(re) .dwCountryCode = 86 .dwCountryID = 86 .dwDialExtraPercent = 75 .dwDialExtraSampleSeconds = 120 .dwDialMode = 1 .dwfNetProtocols = 4 .dwfOptions = 1024262928 .dwfOptions2 = 367 .dwFramingProtocol = 1 .dwHangUpExtraPercent = 10 .dwHangUpExtraSampleSeconds = 120 .dwRedialCount = 3 .dwRedialPause = 60 .dwType = RASET_Vpn CopyMemory .szDeviceName(0), ByVal sDeviceName, Len(sDeviceName) CopyMemory .szDeviceType(0), ByVal sDeviceType, Len(sDeviceType) CopyMemory .szLocalPhoneNumber(0), ByVal sServer, Len(sServer) .dwVpnStrategy = VS_Default .dwEncryptionType = ET_Optional 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 Edited March 27, 2009 by Josette Link to comment Share on other sites More sharing options...
rajeshontheweb Posted March 27, 2009 Share Posted March 27, 2009 (edited) pls edit your code and add [ code ] to the start of your code and[ /code ] to end of the function it would make it more readable:0 Edited March 27, 2009 by rajeshontheweb Started late is much better than having never started it!!!!Failure is another step towards success. I've been messing around with: Adding Entry to 'Hosts'File Information Lister (Logger)Yet Another AutoIT Error Handler Yet Another AutoIT Error Handler & Debugger Control your App's TaskBar Button YCurrency Ticker (Latest Release : 16 Apr 2009)_WinInetInternetCheckConnection UDF Symantec Definitions Lister UDF _GetLocalIPAddresses UDF UDF to get Special Folder Information WMI_NetworkAdapterConfiguration2Array WMI_CDRomDriveCapabilities _ScriptExists - Check if your au3 script is running!! Uninstaller UDF Get Version for your application (at script level or compiled stage) Uninstaller Pro - faster alternative to windows application removal applet Link to comment Share on other sites More sharing options...
jvanegmond Posted March 27, 2009 Share Posted March 27, 2009 http://www.autoitscript.com/forum/index.ph...12143&hl=VB github.com/jvanegmond Link to comment Share on other sites More sharing options...
Josette Posted March 27, 2009 Author Share Posted March 27, 2009 Hmm.... THX... now it looks like more readable Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now