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

📄 default.aspx.cs

📁 道信科技短信猫的控制源代码
💻 CS
字号:
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Runtime.InteropServices; 

public partial class _Default : System.Web.UI.Page 
{
    protected void Page_Load(object sender, EventArgs e)
    {
        SM_PARAM S = new SM_PARAM("13800311500","13784810275", "1", "4", "5", "6", "7");
        Response.Write(S.SCA+"<br>"+S.TPA+"<BR>"+S.TP_PID+"<BR>"+S.TP_DCS+"<BR>"+S.TP_SCTS+"<BR>"+S.TP_UD+"<BR>"+S.index);
        Response.Write("<br>"+SM_Founction.OpenComm("COM1",9600,0,8,1)+"<br>");
        Response.Write(SM_Founction.SetCenterNumber("13800311500") + "ZDF<br>");

        Response.Write(SM_Founction.SendShortMessage("13784810275", "周德峰", S)+"<br>");
        //SM_Founction.CloseComm();
    }
}
public struct SM_PARAM
{
    public string SCA;//  短消息服务中心号码(SMSC地址)16
    public string TPA;//目标号码或回复号码(TP-DA或TP-RA)
    public string TP_PID;//用户信息协议标识(TP-PID)
    public string TP_DCS;//用户信息编码方式(TP-DCS)
    public string TP_SCTS;//服务时间戳字符串(TP_SCTS), 接收时用到
    public string TP_UD;//原始用户信息(编码前或解码后的TP-UD)
    public string index;//短消息序号,在读取时用到
    public SM_PARAM(string SCA, string TPA, string TP_PID, string TP_DCS, string TP_SCTS, string TP_UD, string index)
    {
        this.SCA = SCA;
        this.TPA = TPA;
        this.TP_PID = TP_PID;
        this.TP_DCS = TP_DCS;
        this.TP_SCTS = TP_SCTS;
        this.TP_UD = TP_UD;
        this.index = index;
        SCA = "";
        TPA = "";
        TP_PID = "";
        TP_DCS = "";
        TP_SCTS = "";
        TP_UD = "";
        index = "";
    }
}
public class SM_Founction
{
    public SM_Founction()
    {
    }
    /// <summary>
    /// CloseComm关闭串口,返回bool值
    /// </summary>
    /// <returns></returns>
    [DllImport("smspdu.dll")]
    public static extern bool CloseComm();
    /// <summary>
    /// OpenComm打开串口, 返回bool值
    /// </summary>
    /// <param name="pPort">串口字符串如“COM1“</param>
    /// <param name="nBaudRate">波特率9600为CBR_9600</param>
    /// <param name="nParity">奇偶校验位,若无为NOPARITY</param>
    /// <param name="nByteSize">数据位,为8</param>
    /// <param name="nStopBits">停止位,若1位为ONESTOPBIT</param>
    /// <returns></returns>
    [DllImport("smspdu.dll")]
    public static extern bool OpenComm(string pPort, int nBaudRate, int nParity, int nByteSize, int nStopBits);

    /// <summary>
    /// SendShortMessage发送短消息,返回值为int
    /// </summary>
    /// <param name="send_number">目标手机号码字符串</param>
    /// <param name="send_msg">发送内容字符串</param>
    /// <param name="sm_param_temp">短消息参数</param>
    /// <returns></returns>
    //若返回0,则表示发送成功
    //若为1,则发送失败,失败原因是在发送短消息同时收到了新的短消息
    //若为2,则发送失败,失败原因是失去了无线链路连接,或没有收到短消息中心送来的确认,或没有收到基站送来的确认。
    //若为3,则发送失败,失败原因是短消息中心号码错误或目的号码错误
    //若为4,则发送失败,失败原因是MODEM在初始化期间或在指令执行过程中又接受到新的指令
    [DllImport("smspdu.dll")]
    public static extern int SendShortMessage(string send_number, string send_msg, SM_PARAM sm_param_temp);

    /// <summary>
    /// ReceiveMessage接收序号为INDEX的短消息
    /// </summary>
    /// <param name="sm_param_temp">返回的短消息结构指针</param>
    /// <param name="index"></param>
    /// <returns></returns>
    [DllImport("smspdu.dll")]
    public static extern int ReceiveMessage(SM_PARAM sm_param_temp, int index);

    /// <summary>
    /// 设置短信中心号码
    /// </summary>
    /// <param name="strCenterNumber"></param>
    /// <returns></returns>
    [DllImport("smspdu.dll")]
    public static extern bool SetCenterNumber(string strCenterNumber);

}

⌨️ 快捷键说明

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