I cant take credit for this. I found it on the internet ages ago:
use it like:
rasResult = ras.Connect("VadalsVPN")
______________________________________________________________
Imports System
Imports System.Runtime.InteropServices
Public Class RASDialup
Private Declare Auto Function InternetDial Lib "wininet" _
(ByVal hwndParent As IntPtr, _
ByVal lpszConnection As String, _
ByVal dwFlags As Integer, _
ByRef lpdwConnection As Integer, _
ByVal dwReserved As Integer) As Integer
'Public Declare Auto Function InternetDial Lib "wininet.dll" (ByVal hwnd As
IntPtr, <[In]()> ByVal lpszConnectoid As String, ByVal dwFlags As Long,
ByRef lpdwConnection As Integer, ByVal dwReserved As Long) As Integer
'Public Declare Auto Function InternetDial Lib "wininet.dll" (ByVal hwnd As
IntPtr, <[In]()> ByVal lpszConnectoid As String, ByVal dwFlags As
System.UInt32, ByRef lpdwConnection As Integer, ByVal dwReserved As
System.UInt32) As Integer
'ToDo: Unsigned Integers not supported
'ToDo: Unsigned Integers not supported
Public Declare Auto Function InternetHangUp Lib "wininet.dll" (ByVal
lpdwConnection As Integer, ByVal dwReserved As Long) As Integer 'ToDo:
Unsigned Integers not supported
'Public Declare Auto Function InternetHangUp Lib "wininet.dll" (ByVal
lpdwConnection As Integer, ByVal dwReserved As System.UInt32) As Integer
'ToDo: Unsigned Integers not supported
Public Enum DialUpOptions
INTERNET_AUTODIAL_FORCE_ONLINE = &H1
INTERNET_AUTODIAL_FORCE_UNATTENDED = &H2
INTERNET_DIAL_FORCE_PROMPT = &H2000
INTERNET_DIAL_SHOW_OFFLINE = &H4000
INTERNET_DIAL_UNATTENDED = &H8000
End Enum 'DialUpOptions
'
'
'INTERNET_AUTODIAL_FORCE_ONLINE Forces an online connection.
'
'INTERNET_AUTODIAL_FORCE_UNATTENDED Forces an unattended Internet dial-up.
If
'user intervention is required, the function will fail.
'
'INTERNET_DIAL_FORCE_PROMPT Ignores the "dial automatically" setting and
'forces the dialing user interface to be displayed.
'
'INTERNET_DIAL_UNATTENDED Connects to the Internet through a modem, without
'displaying a user interface, if possible. Otherwise, the function will wait
'for user input.
'
'INTERNET_DIAL_SHOW_OFFLINE
'
Private m_connectionnumber As Integer
Public ReadOnly Property ConnectionNumber() As Integer
Get
Return m_connectionnumber
End Get
End Property
Public Function Connect(ByVal m_ConnectionName As String) As Integer
Dim retVal As Integer
retVal = InternetDial(IntPtr.Zero, m_ConnectionName, &H8000,
m_connectionnumber, 0)
Return retVal
End Function 'Connect
Public Sub Disconnect()
InternetHangUp(m_connectionnumber, 0)
End Sub 'Disconnect
End Class 'RASDialup