SoFunction
Updated on 2025-03-07

C#.NET to obtain broadband connection method for dial-up connection

This article describes the broadband connection method of C#.NET to obtain dial-up connection. Share it for your reference. The details are as follows:

This code works directly, I tested it on XP VS2010 NET3.5.

First, the ASDL package

class SinASDL
{
  //The storage location of ASDL in the registry is for WinXP.  //I don't know if Win7 is this, waiting to be verified  private static String _adlskeys = @"RemoteAccess\Profile";
  public static String adlskeys
  {
    get
    {
      return _adlskeys;
    }
  }
  /// <summary>
  /// Get the dial name of the machine, that is, all dialing numbers on the machine  /// </summary>
  /// <returns></returns>
  public static String[] GetASDLNames()
  {
    RegistryKey RegKey = (adlskeys);
    if (RegKey != null)
      return ();
    else
      return null;
  }
  private String _asdlname = null;
  private ProcessWindowStyle _windowstyle = ;
  /// <summary>
  /// Instantiate an ASDL connection  /// </summary>
  /// <param name="asdlname">ASDL name, such as "Broadband Connection"</param>  /// <param name="username">username</param>  /// <param name="password">Password</param>  /// <param name="windowsstyle">Window display mode, default is therefore dialing process</param>  public SinASDL(String asdlname, String username = null, String password = null, ProcessWindowStyle windowstyle = )
  {
     = asdlname;
     = username;
     = password;
     = windowstyle;
  }
  /// &lt;summary&gt;
  /// dial name  /// &lt;/summary&gt;
  public String ASDLName
  {
    get
    {
      return this._asdlname;
    }
    set
    {
      this._asdlname = value;
    }
  }
  /// &lt;summary&gt;
  /// window method of dialing process  /// &lt;/summary&gt;
  public ProcessWindowStyle WindowStyle
  {
    get
    {
      return this._windowstyle;
    }
    set
    {
      this._windowstyle = value;
    }
  }
  private String _username = null;  //username  private String _password = null;  //password  /// &lt;summary&gt;
  /// username  /// &lt;/summary&gt;
  public String Username
  {
    get
    {
      return this._username;
    }
    set
    {
      this._username = value;
    }
  }
  /// &lt;summary&gt;
  /// password  /// &lt;/summary&gt;
  public String Password
  {
    get
    {
      return this._password;
    }
    set
    {
      this._password = value;
    }
  }
  /// &lt;summary&gt;
  /// Start dialing  /// &lt;/summary&gt;
  /// <returns>Returns the return value of the dialing process</returns>  public int Connect()
  {
    Process pro = new Process();
     = "";
     =  + " " +  + " " + ;
     = ;
    ();
    ();
    return ;
  }
  /// &lt;summary&gt;
  /// Port connection  /// &lt;/summary&gt;
  /// &lt;returns&gt;&lt;/returns&gt;
  public int Disconnect()
  {
    Process pro = new Process();
     = "";
     =  + " /DISCONNECT";
     = ;
    ();
    ();
    return ;
  }
}

Here is the usage test:

//SinASDL asdl = new SinASDL("Broadband Connection", "08793312221", "123456");//Broadband connection//Dialize using the first enumerationSinASDL asdl = new SinASDL(()[0], "08793312221", "123456", );
if (() == 0)
{
  ("Success");
}
else
{
  ("Fail");
}

I passed the test myself.

If there is more than one dialer on the computer, you can enumerate it with().

I hope this article will be helpful to everyone's C# programming.