我发现 DotRas 是 RAS 的包装器。这就是我能够做到的
private void btnConnect_Click(object sender, EventArgs e)
{
RasDevice device = RasDevice.GetDeviceByName("ZTE Proprietary USB Modem", RasDeviceType.Modem);
if (device != null)
{
MessageBox.Show("Found "+device.Name.ToString()+device.DeviceType.ToString(), "hah!", MessageBoxButtons.OK);
}
else
{
MessageBox.Show("Device not found", "Error", MessageBoxButtons.OK);
}
this.rasPhoneBook1.Open();
RasEntry entry = RasEntry.CreateDialUpEntry("ZTE Proprietary USB Modem", "+880000000", device);
this.rasPhoneBook1.Entries.Add(entry);
this.rasDialer1.EntryName = "ZTE Proprietary USB Modem";
this.rasDialer1.PhoneBookPath = rasPhoneBook1.Path;
this.rasDialer1.DialAsync();
}
private void rasDialer1_StateChanged(object sender, StateChangedEventArgs e)
{
MessageBox.Show(e.State.ToString(), "Dial Status", MessageBoxButtons.OK);
}
private void rasDialer1_DialCompleted(object sender, DialCompletedEventArgs e)
{
if (e.Cancelled)
{
MessageBox.Show("Cancelled");
}
else if (e.TimedOut)
{
MessageBox.Show("Time out");
}
else if (e.Error != null)
{
MessageBox.Show(e.Error.ToString(),"Error");
}
else if (e.Connected)
{
MessageBox.Show("Connection successful!");
}
}
该代码尝试拨打调制解调器,但显示以下错误消息:
"The remote computer did not respond. To make sure that the server can be reached,ping the remote computer."}
错误在这里:
else if (e.Error != null)
{
MessageBox.Show(e.Error.ToString(),"Error");
}
我正在尝试连接 3g 调制解调器并通过调制解调器发送和接收短信。我如何使用 DotRas 实现这一目标?是的,我已经阅读了 API 文档并阅读了DOtRas 官方网站上的讨论,但我仍然迷路了。任何帮助将不胜感激。谢谢你。