using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;using System.Runtime.InteropServices;using System.IO.Ports;namespace SmsServer{ public partial class Form1 : Form { [DllImport("GSM.dll")] public static extern int LinkModem(int iPort); [DllImport("GSM.dll")] public static extern int CloseModem(); [DllImport("GSM.dll")] public static extern int CheckModem(); [DllImport("GSM.dll")] public static extern string GetService(); [DllImport("GSM.dll")] public static extern int SendSMS(String smsCenter, String phone, String msg); [DllImport("GSM.dll")] public static extern int NewMessageToWhere(int iSaveType); [DllImport("GSM.dll")] public static extern string GetNewMessage(); [DllImport("GSM.dll")] public static extern string GetMessage(int Index); [DllImport("GSM.dll")] public static extern int DeleteSMSByNo(int Index); [DllImport("GSM.dll")] public static extern int DeleteAllSMS(); [DllImport("GSM.dll")] public static extern string myTest(); public Form1() { InitializeComponent(); } private void 连接设备ToolStripMenuItem_Click(object sender, EventArgs e) { if (this.comboBox1.Text.Trim() != "") { if (LinkModem(int.Parse(comboBox1.Text.Trim().Substring(3,1))) > 0) MessageBox.Show("连接设备成功!"); else MessageBox.Show("连接设备失败!"); } else MessageBox.Show("请先选择串口号!"); } private void toolStripMenuItem1_Click(object sender, EventArgs e) { panel2.Visible = true; panel2.Dock = DockStyle.Fill; foreach (string vPortName in SerialPort.GetPortNames()) { this.comboBox1.Items.Add(vPortName); } } private void 发送短信ToolStripMenuItem_Click(object sender, EventArgs e) { string Service = GetService(); MessageBox.Show(Service); } }}
评论