gsmmodem.cs

来自「GSM MODEM开发实例」· CS 代码 · 共 81 行

CS
81
字号
using System;
using System.Runtime.InteropServices;

namespace TestForCSharp
{
	/// <summary>
	/// GSMModem 的摘要说明。
	/// </summary>
	public class GSMModem
	{
		public GSMModem()
		{
			//
			// TODO: 在此处添加构造函数逻辑
			//
		}

		//初始化gsm modem,并连接gsm modem
		[DllImport("GSMMultiPort.dll",
			 EntryPoint="GSMModemInit",
			 CharSet=CharSet.Ansi,
			 CallingConvention=CallingConvention.StdCall)] 
		public static extern bool  GSMModemInit(
			string device, 
			string baudrate,
			string initstring, 
			string charset,
			bool swHandshake,
			string sn);

		//获取短信猫标识号码
		[DllImport("GSMMultiPort.dll",
			 EntryPoint="GSMModemGetSnInfo",
			 CharSet=CharSet.Ansi,
			 CallingConvention=CallingConvention.StdCall)] 
		public static extern string GSMModemGetSnInfo(string device, string baudrate);

		//获取设备的连接状态		
		[DllImport("GSMMultiPort.dll",
			 EntryPoint="GSMModemIsConn",
			 CharSet=CharSet.Ansi,
			 CallingConvention=CallingConvention.StdCall)] 
		public static extern bool GSMModemIsConn(string device);

		//断开连接并释放内存空间		
		[DllImport("GSMMultiPort.dll",
			 EntryPoint="GSMModemRelease",
			 CharSet=CharSet.Ansi,
			 CallingConvention=CallingConvention.StdCall)] 
		public static extern void GSMModemRelease(string device);

		//取得错误信息	
		[DllImport("GSMMultiPort.dll",
			 EntryPoint="GSMModemGetErrorMsg",
			 CharSet=CharSet.Ansi,
			 CallingConvention=CallingConvention.StdCall)] 
		public static extern string GSMModemGetErrorMsg(string device);

		//发送短信息
		[DllImport("GSMMultiPort.dll",
			 EntryPoint="GSMModemSMSsend",
			 CharSet=CharSet.Ansi,
			 CallingConvention=CallingConvention.StdCall)] 
		public static extern bool GSMModemSMSsend(
			string device,
			string serviceCenterAddress, 
			int	encodeval,
			string text, 
			int textlen,
			string phonenumber,
			bool requestStatusReport);

		//接收短信息
		[DllImport("GSMMultiPort.dll",
			 EntryPoint="GSMModemSMSReadAll",
			 CharSet=CharSet.Ansi,
			 CallingConvention=CallingConvention.StdCall)] 
		public static extern string GSMModemSMSReadAll(string device,int RD_opt);
	}
}

⌨️ 快捷键说明

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