Open Source project Address: http://dotras.codeplex.com/
Using this can be convenient to operate ADSL dial, disconnect. There are detailed development documentation that you need to see for yourself.
/// <summary> ///Create or update a PPPoE connection (specify PPPoE name)/// </summary> voidCreateorupdatepppoe (stringupdatepppoename) {Rasdialer Dialer=NewRasdialer (); Rasphonebook Allusersphonebook=NewRasphonebook (); stringPath =Rasphonebook.getphonebookpath (rasphonebooktype.allusers); Allusersphonebook.open (path); //If PPPoE already exists for that name, update the PPPoE server address if(AllUsersPhoneBook.Entries.Contains (updatepppoename)) {ALLUSERSPHONEBOOK.ENTRIES[UPDATEPPP Oename]. PhoneNumber=" "; //the update of the server address is always successful regardless of whether the current PPPoE is connected, and if it is connected, it will require a PPPoE reboot to functionAllusersphonebook.entries[updatepppoename]. Update (); } //Create a new PPPoE Else { stringAdds =string. Empty; ReadOnlyCollection<RasDevice> ReadOnlyCollection =rasdevice.getdevices (); //foreach (var col in ReadOnlyCollection)// { //adds + = Col. Name + ":" + Col. Devicetype.tostring () + "| | |"; // } //_log. Info ("Devices is:" + adds); //Find the device that'll be a used to dial the connection.Rasdevice device = Rasdevice.getdevices (). Where (o = O.devicetype = =Rasdevicetype.pppoe). First (); Rasentry entry= Rasentry.createbroadbandentry (updatepppoename, device);//Establish broadband connection entryEntry. PhoneNumber =" "; ALLUSERSPHONEBOOK.ENTRIES.ADD (entry); } } /// <summary> ///disconnecting from a broadband connection/// </summary> Public voidDisconnect () {ReadOnlyCollection<RasConnection> conlist =rasconnection.getactiveconnections (); foreach(Rasconnection coninchconlist) {con. Hangup (); } } /// <summary> ///Broadband Connection, Success returns TRUE, Failure returns false/// </summary> /// <param name= "Pppoename" >Broadband Connection Name</param> /// <param name= "username" >Broadband Account</param> /// <param name= "password" >Broadband Password</param> /// <returns></returns> Public BOOLConnect (stringPppoename,stringUsernamestringPasswordref stringmsg) { Try{Createorupdatepppoe (pppoename); using(Rasdialer dialer =NewRasdialer ()) {Dialer. EntryName=Pppoename; Dialer. Allowusestoredcredentials=true; Dialer. Timeout= +; Dialer. Phonebookpath=Rasphonebook.getphonebookpath (rasphonebooktype.allusers); Dialer. Credentials=Newnetworkcredential (username, password); Dialer. Dial (); return true; } } Catch(Rasexception re) {msg= Re. ErrorCode +" "+Re. Message; return false; } } }
C # uses Dotras to operate ADSL