Results 1 to 1 of 1

Thread: VB - Creating DUN Connections

  1. #1

    Thread Starter
    Guru Aaron Young's Avatar
    Join Date
    Jun 1999
    Location
    Red Wing, MN, USA
    Posts
    2,177

    VB - Creating DUN Connections

    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:
    1. Option Explicit
    2.  
    3. Private Sub Command1_Click()
    4.   Dim oDUN As New cDUN
    5.  
    6.   With oDUN
    7.     .Description = "Connection Created with VB."
    8.    
    9.     ' Same as default setting for class.
    10.     .DeviceName = _
    11.       IIf(Len(.GetModemListString()) = 0, _
    12.         "No Modem Installed", _
    13.         Split(.GetModemListString(), ";")(0))
    14.        
    15.     .DeviceType = rasMODEM
    16.     .FramingProtocol = rasPPP
    17.     .Protocols = rasTCPIP
    18.     .LocalPhone = "555-5555"
    19.    
    20.     .Options = _
    21.       rasSwCompression Or rasIpHeaderCompression Or _
    22.       rasRemoteDefaultGateway Or rasSpecificNameServers
    23.      
    24.     .PrimaryDNS = "192.168.0.1"
    25.     .SecondaryDNS = "192.168.0.2"
    26.    
    27.     If Not .Create() Then
    28.       MsgBox "Failed to Create Dial-Up Connection:" & vbCrLf & .LastError
    29.     Else
    30.       MsgBox "Connection Created."
    31.     End If
    32.   End With
    33.  
    34.   Set oDUN = Nothing
    35. End Sub
    Attached Files Attached Files

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width