C# 使用内置调制解调器拨打电话

发布于 2024-08-26 12:47:09 字数 61 浏览 6 评论 0原文

我必须拨打电话号码并检测对面的调制解调器是否挂机。 如何在 C# 中使用 SerialPort 执行此操作?

I have to call phone number and detect if the modem at the opposite side is hang-on.
How can I do this in C# with SerialPort?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

苦笑流年记忆 2024-09-02 12:47:10

是的,System.IO.Ports.SerialPort 是要使用的类。

像这样的事情:

// Set the port name, baud rate and other connection parameters you might need
SerialPort port = new SerialPort("COM1", 9600 );
port.Open();
port.ReadTimeout = 1000;
port.NewLine = "\r";
port.WriteLine("ATZ"); // reset the modem
port.ReadTo("OK\r\n"); // wait for "OK" from modem
port.WriteLine("ATDT 12345678"); // dial number with dialtone
string response = port.ReadTo("\r").Trim(); // read until first newline
port.Close();

它没有经过测试,因为我手边没有调制解调器。

Yes, System.IO.Ports.SerialPort is the class to use.

Something like this:

// Set the port name, baud rate and other connection parameters you might need
SerialPort port = new SerialPort("COM1", 9600 );
port.Open();
port.ReadTimeout = 1000;
port.NewLine = "\r";
port.WriteLine("ATZ"); // reset the modem
port.ReadTo("OK\r\n"); // wait for "OK" from modem
port.WriteLine("ATDT 12345678"); // dial number with dialtone
string response = port.ReadTo("\r").Trim(); // read until first newline
port.Close();

It's not tested as I don't have a modem at hand.

拥抱我好吗 2024-09-02 12:47:10

您可以在正确配置的 Windows 中创建连接(以便您可以手动拨号)。然后使用RAS API拨号连接并检查结果。

You could create a connection in windows that is configured correctly (so you could manually dial it). Then use the RAS API to dial the connection an check the result.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文