我必须叫的电话号码并检测在相对侧调制解调器是接通。 我如何在C#中使用的SerialPort做到这一点?

有帮助吗?

解决方案

是, 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();

这不是测试,因为我不手边的调制解调器。

其他提示

您可以创建一个正确配置(所以你可以手动拨号的话)在窗口的连接。然后使用RAS API拨打的连接的检查结果。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top