⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 form1.cs

📁 [SMS SDK V1.7 测试说明] 1)“接口库”为SDK库包其中: Release —— 发布的稳定库 Debug —— 为调试库 2)“演示代码”为测试代码目录。
💻 CS
📖 第 1 页 / 共 2 页
字号:
																					this.Button5,
																					this.Label7,
																					this.jsnr,
																					this.Label6});
			this.GroupBox3.Location = new System.Drawing.Point(16, 376);
			this.GroupBox3.Name = "GroupBox3";
			this.GroupBox3.Size = new System.Drawing.Size(592, 128);
			this.GroupBox3.TabIndex = 7;
			this.GroupBox3.TabStop = false;
			this.GroupBox3.Text = "接收短信测试";
			// 
			// Button5
			// 
			this.Button5.Location = new System.Drawing.Point(504, 24);
			this.Button5.Name = "Button5";
			this.Button5.TabIndex = 8;
			this.Button5.Text = "接收短信";
			this.Button5.Click += new System.EventHandler(this.Button5_Click);
			// 
			// Label7
			// 
			this.Label7.BackColor = System.Drawing.Color.AliceBlue;
			this.Label7.ForeColor = System.Drawing.Color.Black;
			this.Label7.Location = new System.Drawing.Point(40, 104);
			this.Label7.Name = "Label7";
			this.Label7.Size = new System.Drawing.Size(448, 16);
			this.Label7.TabIndex = 7;
			this.Label7.Text = "*接收短信息返回字符串格式为:手机号码|短信内容||手机号码|短信内容||";
			// 
			// jsnr
			// 
			this.jsnr.Location = new System.Drawing.Point(112, 24);
			this.jsnr.Multiline = true;
			this.jsnr.Name = "jsnr";
			this.jsnr.Size = new System.Drawing.Size(376, 72);
			this.jsnr.TabIndex = 1;
			this.jsnr.Text = "";
			// 
			// Label6
			// 
			this.Label6.Location = new System.Drawing.Point(32, 24);
			this.Label6.Name = "Label6";
			this.Label6.Size = new System.Drawing.Size(72, 23);
			this.Label6.TabIndex = 0;
			this.Label6.Text = "接收内容:";
			// 
			// Button4
			// 
			this.Button4.Location = new System.Drawing.Point(280, 512);
			this.Button4.Name = "Button4";
			this.Button4.TabIndex = 6;
			this.Button4.Text = "退出";
			this.Button4.Click += new System.EventHandler(this.Button4_Click);
			// 
			// GroupBox2
			// 
			this.GroupBox2.Controls.AddRange(new System.Windows.Forms.Control[] {
																					this.Label12,
																					this.Button3,
																					this.fsnr,
																					this.jshm,
																					this.Label5,
																					this.Label4});
			this.GroupBox2.Location = new System.Drawing.Point(16, 224);
			this.GroupBox2.Name = "GroupBox2";
			this.GroupBox2.Size = new System.Drawing.Size(592, 144);
			this.GroupBox2.TabIndex = 5;
			this.GroupBox2.TabStop = false;
			this.GroupBox2.Text = "发送短信测试";
			// 
			// Button3
			// 
			this.Button3.Location = new System.Drawing.Point(504, 24);
			this.Button3.Name = "Button3";
			this.Button3.TabIndex = 5;
			this.Button3.Text = "发送短信";
			this.Button3.Click += new System.EventHandler(this.Button3_Click);
			// 
			// fsnr
			// 
			this.fsnr.Location = new System.Drawing.Point(112, 56);
			this.fsnr.Multiline = true;
			this.fsnr.Name = "fsnr";
			this.fsnr.Size = new System.Drawing.Size(376, 56);
			this.fsnr.TabIndex = 3;
			this.fsnr.Text = "";
			// 
			// jshm
			// 
			this.jshm.Location = new System.Drawing.Point(112, 24);
			this.jshm.Name = "jshm";
			this.jshm.Size = new System.Drawing.Size(376, 21);
			this.jshm.TabIndex = 2;
			this.jshm.Text = "";
			// 
			// Label5
			// 
			this.Label5.Location = new System.Drawing.Point(32, 56);
			this.Label5.Name = "Label5";
			this.Label5.Size = new System.Drawing.Size(72, 32);
			this.Label5.TabIndex = 1;
			this.Label5.Text = "发送内容:";
			// 
			// Label4
			// 
			this.Label4.Location = new System.Drawing.Point(32, 32);
			this.Label4.Name = "Label4";
			this.Label4.Size = new System.Drawing.Size(72, 24);
			this.Label4.TabIndex = 0;
			this.Label4.Text = "接收号码:";
			// 
			// Label1
			// 
			this.Label1.Anchor = (((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
				| System.Windows.Forms.AnchorStyles.Left) 
				| System.Windows.Forms.AnchorStyles.Right);
			this.Label1.BackColor = System.Drawing.Color.LightSteelBlue;
			this.Label1.Font = new System.Drawing.Font("方正姚体", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
			this.Label1.Location = new System.Drawing.Point(16, 8);
			this.Label1.Name = "Label1";
			this.Label1.Size = new System.Drawing.Size(592, 40);
			this.Label1.TabIndex = 8;
			this.Label1.Text = "短信接口C#测试";
			this.Label1.TextAlign = System.Drawing.ContentAlignment.TopCenter;
			// 
			// Label12
			// 
			this.Label12.BackColor = System.Drawing.Color.AliceBlue;
			this.Label12.Location = new System.Drawing.Point(32, 120);
			this.Label12.Name = "Label12";
			this.Label12.Size = new System.Drawing.Size(456, 16);
			this.Label12.TabIndex = 7;
			this.Label12.Text = "小灵通格式:本地:106+区号+号码;外地:106+0+区号+号码";
			// 
			// TestGSM
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.ClientSize = new System.Drawing.Size(624, 541);
			this.Controls.AddRange(new System.Windows.Forms.Control[] {
																		  this.Label1,
																		  this.GroupBox3,
																		  this.Button4,
																		  this.GroupBox2,
																		  this.GroupBox1});
			this.Name = "TestGSM";
			this.Text = "Form1";
			this.GroupBox1.ResumeLayout(false);
			this.GroupBox3.ResumeLayout(false);
			this.GroupBox2.ResumeLayout(false);
			this.ResumeLayout(false);

		}

		#endregion
		/// <summary>
		/// 应用程序的主入口点。
		/// </summary>
		[STAThread]
		static void Main() 
		{
			Application.Run(new TestGSM());
		}

		private void Button1_Click(object sender, System.EventArgs e)
		{
			jqhm.Text = GSMModem.GSMModemGetSnInfoNew(Device.Text,Baud.Text);
			Device.Text = GSMModem.GSMModemGetDevice();
			Baud.Text = GSMModem.GSMModemGetBaudrate();
	        cwxx.Text = GSMModem.GSMModemGetErrorMsg();
		}

		private void Button5_Click(object sender, System.EventArgs e)
		{
			//1)连接设备
			if(GSMModem.GSMModemInitNew(Device.Text, Baud.Text, null, null, false, sqhm.Text) ==true)
				MessageBox.Show("GSMModemInit: 连接成功!", "提示", MessageBoxButtons.OK);
			else
			{
				MessageBox.Show("GSMModemInit: 连接失败!" + GSMModem.GSMModemGetErrorMsg(), "提示", MessageBoxButtons.OK);
				return;
			}

			Device.Text = GSMModem.GSMModemGetDevice();
			Baud.Text = GSMModem.GSMModemGetBaudrate();	
			cwxx.Text = GSMModem.GSMModemGetErrorMsg();

			//2)接收短信
			jsnr.Text = GSMModem.GSMModemSMSReadAll(0);
			cwxx.Text = GSMModem.GSMModemGetErrorMsg();

			//3) 显示错误信息
			cwxx.Text = GSMModem.GSMModemGetErrorMsg();
		}

		private void Button4_Click(object sender, System.EventArgs e)
		{
			this.Close();
		}

		private void Button3_Click(object sender, System.EventArgs e)
		{
			int smslen;

			//0) 格式检查
			if(jshm.Text == "") 
			{
				MessageBox.Show("手机号码不能为空!","提示", MessageBoxButtons.OK);
				jshm.Focus();
				return;
			}
			smslen = jshm.Text.Length;
			//if(smslen != 11)
			//{
			//	MessageBox.Show("手机号码长度不对!", "提示", MessageBoxButtons.OK);
			//	jshm.Focus();
			//	return;
			//}
			if(fsnr.Text == "")
			{
				MessageBox.Show("短信内容不能为空!", "提示", MessageBoxButtons.OK);
				fsnr.Focus();
				return;
			}

			//1)连接设备
			if(GSMModem.GSMModemInitNew(Device.Text, Baud.Text, null, null, false, sqhm.Text)==true)
				MessageBox.Show("GSMModemInit: 连接成功!","提示", MessageBoxButtons.OK);
			else
			{
				MessageBox.Show("GSMModemInit: 连接失败!" + GSMModem.GSMModemGetErrorMsg(),"提示", MessageBoxButtons.OK);
				return;
			}
			Device.Text = GSMModem.GSMModemGetDevice();
			Baud.Text = GSMModem.GSMModemGetBaudrate();
			cwxx.Text =GSMModem.GSMModemGetErrorMsg();

			//2) 发送短信
			smslen = System.Text.Encoding.Default.GetByteCount(fsnr.Text);
			if(GSMModem.GSMModemSMSsend(null, 8, fsnr.Text, smslen, jshm.Text, false) == true)
				MessageBox.Show("GSMModemSMSsend: 短信发送成功!", "提示", MessageBoxButtons.OK);
			else
				MessageBox.Show("GSMModemSMSsend: 短信发送失败!" + GSMModem.GSMModemGetErrorMsg(), "提示", MessageBoxButtons.OK);
				
			//3) 显示错误信息
			cwxx.Text =GSMModem.GSMModemGetErrorMsg();

		}
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -