我試圖通過C#程序撥打手機。下面顯示我的程序。在這裏,當我點擊我的撥號按鈕時,它撥打我在我的程序中給出的號碼(目的地號碼)。但是在一兩秒後它消失了&它沒有連接到那個目的地號碼。下面顯示我的C#代碼。請幫我解決這個問題。謝謝.......通過C#程序撥打手機
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO.Ports;
namespace WindowsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
SerialPort sp = new SerialPort();
sp.PortName = "COM10";
sp.BaudRate = 9600;
sp.Parity = Parity.None;
sp.DataBits = 8;
sp.StopBits = StopBits.One;
sp.Handshake = Handshake.XOnXOff;
sp.DtrEnable = true;
sp.RtsEnable = true;
sp.Open();
if (!sp.IsOpen)
{
MessageBox.Show("Serial port is not opened");
return;
}
sp.WriteLine("AT" + Environment.NewLine);
sp.WriteLine("ATD=\"" + "Destination Number" + "\"" + Environment.NewLine);
}
}
}
最後我找到了解決辦法。我們應該在目標號碼的末尾添加分號。那麼它的工作。
sp.WriteLine("ATD=\"" + "Destination Number;" + "\"" + Environment.NewLine);
如果您的手機接受Hayes調制解調器命令,那麼我認爲它只是'ATDT2125551234`,不等於或引號。 – Rup 2011-01-24 18:46:03