Here's some code I put together in response to a thread int he General VB Questions forum, I thought people might find it useful.
The attached code demonstrates how to use the RAS API to create Dial-Up Network connections,
it also allows you to get a list (delimited string) of Modems currently installed.
Example Usage:VB Code:
Option Explicit Private Sub Command1_Click() Dim oDUN As New cDUN With oDUN .Description = "Connection Created with VB." ' Same as default setting for class. .DeviceName = _ IIf(Len(.GetModemListString()) = 0, _ "No Modem Installed", _ Split(.GetModemListString(), ";")(0)) .DeviceType = rasMODEM .FramingProtocol = rasPPP .Protocols = rasTCPIP .LocalPhone = "555-5555" .Options = _ rasSwCompression Or rasIpHeaderCompression Or _ rasRemoteDefaultGateway Or rasSpecificNameServers .PrimaryDNS = "192.168.0.1" .SecondaryDNS = "192.168.0.2" If Not .Create() Then MsgBox "Failed to Create Dial-Up Connection:" & vbCrLf & .LastError Else MsgBox "Connection Created." End If End With Set oDUN = Nothing End Sub




Reply With Quote