c#:使用dotras拨打调制解调器

时间:2016-12-04 00:28:37

标签: c# modem 3g dial-up dotras

我正在使用huawei e359

您好我正在创建一个简单的程序。我的代码将3g调制解调器连接到互联网。因为我的程序的一部分需要访问互联网。 我做了一些搜索如何使用c#

执行此操作

这是我添加条目的代码

string deviceName = null;
                path = RasPhoneBook.GetPhoneBookPath(RasPhoneBookType.User);
                using (RasPhoneBook pbk = new RasPhoneBook())
                {
                    pbk.Open(path);
                    foreach (var item in RasDevice.GetDevices())
                    {
                        if (item.DeviceType.ToString().ToLower() == "modem")
                        {
                            deviceName = item.Name;
                        }
                    }
                    RasDevice device = RasDevice.GetDevices().Where(o => o.Name == deviceName && o.DeviceType == RasDeviceType.Modem).First();
                    if (!RasEntry.Exists("Your Entry", path))
                    {
                        RasEntry entry = RasEntry.CreateDialUpEntry("Your Entry", "+00000000000", device);
                        pbk.Entries.Add(entry);
                    }
                }

这是拨打设备的代码

using (RasDialer dialer = new RasDialer())
                {
                    dialer.EntryName = "Your Entry";
                    dialer.PhoneBookPath = path;
                    dialer.AllowUseStoredCredentials = true;
                    dialer.Dial();
                }

这是错误,当我拨打设备时会提示

The remote computer did not respond. To make sure that the server can be reached, ping the remote computer.

0 个答案:

没有答案