短信猫接口调用
要实现短信的提醒功能,买了短信猫,看了对方给的文档:
1、Sms_Connection(Com_Port As Integer,Com_BaudRate As Integer, Mobile_Type As String) As Integer
Sms_Connection函数说明如下:
功能描述:用于初始化终端与串口的连接
Com_Port:串口号(0为红外接口,1,2,3,...为串口)
Com_BaudRate:波特率
Mobile_Type:返回终端型号
Sms_Connection:返回值(0:连接终端失败;1:连接终端成功)
2、Sms_Send(Sms_TelNum As String, Sms_Text As String) As Integer
Sms_Send函数说明如下:
功能描述:发送短信
Sms_TelNum:发送给的终端号码
Sms_Text:发送的短信内容
Sms_Send:返回值(0:发送短信失败;1:发送短信成功)
我在.net下这么写的:
//注册
[DllImport("sms.dll",EntryPoint = "Sms_Connection",CharSet = CharSet.Ansi,CallingConvention = CallingConvention.StdCall)]
public static extern int Sms_Connection(Int32 Com_Port, Int32 Com_BaudRate, string Mobile_Type);
//调用
try {
int aa = Sms_Connection(1, 57600, "M11");
}
catch (Exception ex)
{
Response.Write(ex.Message);
}
但是出错:
尝试读取或写入受保护的内存。这通常指示其他内存已损坏。
因为是第一次写这类东西,而且又没有参考示例,是不是我哪里写错了