网站虚拟主机,平江网页制作价格,网站开发公司前台模板,京网站建设开源项目地址#xff1a;http://dotras.codeplex.com/ 使用这个可以方便的操作ADSL拨号、断开。有详细的开发文档#xff0c;需要的可以自己去看。。 /// summary/// 创建或更新一个PPPOE连接(指定PPPOE名称)/// /summaryvoid CreateOrUpdatePPPOE(string up…开源项目地址http://dotras.codeplex.com/ 使用这个可以方便的操作ADSL拨号、断开。有详细的开发文档需要的可以自己去看。。 /// summary/// 创建或更新一个PPPOE连接(指定PPPOE名称)/// /summaryvoid CreateOrUpdatePPPOE(string updatePPPOEname){RasDialer dialer new RasDialer();RasPhoneBook allUsersPhoneBook new RasPhoneBook();string path RasPhoneBook.GetPhoneBookPath(RasPhoneBookType.AllUsers);allUsersPhoneBook.Open(path);// 如果已经该名称的PPPOE已经存在则更新这个PPPOE服务器地址if (allUsersPhoneBook.Entries.Contains(updatePPPOEname)){allUsersPhoneBook.Entries[updatePPPOEname].PhoneNumber ;// 不管当前PPPOE是否连接服务器地址的更新总能成功如果正在连接则需要PPPOE重启后才能起作用allUsersPhoneBook.Entries[updatePPPOEname].Update();}// 创建一个新PPPOEelse{string adds string.Empty;ReadOnlyCollectionRasDevice readOnlyCollection RasDevice.GetDevices();// foreach (var col in readOnlyCollection)// {// adds col.Name : col.DeviceType.ToString() |||;// }// _log.Info(Devices are : adds);// Find the device that will be used to dial the connection.RasDevice device RasDevice.GetDevices().Where(o o.DeviceType RasDeviceType.PPPoE).First();RasEntry entry RasEntry.CreateBroadbandEntry(updatePPPOEname, device); //建立宽带连接Entryentry.PhoneNumber ;allUsersPhoneBook.Entries.Add(entry);}}/// summary/// 断开 宽带连接/// /summarypublic void Disconnect(){ReadOnlyCollectionRasConnection conList RasConnection.GetActiveConnections();foreach (RasConnection con in conList){con.HangUp();}}/// summary/// 宽带连接成功返回true,失败返回 false/// /summary/// param namePPPOEname宽带连接名称/param/// param nameusername宽带账号/param/// param namepassword宽带密码/param/// returns/returnspublic bool Connect(string PPPOEname, string username, string password,ref string msg ){try{CreateOrUpdatePPPOE(PPPOEname);using (RasDialer dialer new RasDialer()){dialer.EntryName PPPOEname;dialer.AllowUseStoredCredentials true;dialer.Timeout 1000;dialer.PhoneBookPath RasPhoneBook.GetPhoneBookPath(RasPhoneBookType.AllUsers);dialer.Credentials new NetworkCredential(username, password);dialer.Dial();return true;}}catch (RasException re){msg re.ErrorCode re.Message;return false;}}} 转载于:https://www.cnblogs.com/cyberarmy/p/5428055.html