封装短信猫,dell类库生成,在vs2008中建立类库项目.并在mobilesp中创建pulbic类型的gms类.

using System;ide

using System.Collections.Generic;spa

using System.Text;.net

using System.Runtime.InteropServices;code


namespace MobileSP内存

{字符串

    public class GMSstring

    {it

        //codego.net初始化gsm modem,并链接gsm modemio

        [DllImport("dllforvc.dll",class

             EntryPoint = "GSMModemInitNew",

             CharSet = CharSet.Ansi,

             CallingConvention = CallingConvention.StdCall)]

        public static extern bool GSMModemInitNew(

            string device,

            string baudrate,

            string initstring,

            string charset,

            bool swHandshake,

            string sn);


        //获取短信猫新的标识号码

        [DllImport("dllforvc.dll",

             EntryPoint = "GSMModemGetSnInfoNew",

             CharSet = CharSet.Ansi,

             CallingConvention = CallingConvention.StdCall)]

        public static extern string GSMModemGetSnInfoNew(string device, string baudrate);


        //获取当前通信端口

        [DllImport("dllforvc.dll",

             EntryPoint = "GSMModemGetDevice",

             CharSet = CharSet.Ansi,

             CallingConvention = CallingConvention.StdCall)]

        public static extern string GSMModemGetDevice();


        //获取当前通信波特率

        [DllImport("dllforvc.dll",

             EntryPoint = "GSMModemGetBaudrate",

             CharSet = CharSet.Ansi,

             CallingConvention = CallingConvention.StdCall)]

        public static extern string GSMModemGetBaudrate();


        //断开链接并释放内存空间

        [DllImport("dllforvc.dll",

             EntryPoint = "GSMModemRelease",

             CharSet = CharSet.Ansi,

             CallingConvention = CallingConvention.StdCall)]

        public static extern void GSMModemRelease();


        //取得错误信息

        [DllImport("dllforvc.dll",

             EntryPoint = "GSMModemGetErrorMsg",

             CharSet = CharSet.Ansi,

             CallingConvention = CallingConvention.StdCall)]

        public static extern string GSMModemGetErrorMsg();


        //发送短信息

        [DllImport("dllforvc.dll",

             EntryPoint = "GSMModemSMSsend",

             CharSet = CharSet.Ansi,

             CallingConvention = CallingConvention.StdCall)]

        public static extern bool GSMModemSMSsend(

            string serviceCenterAddress,

            int encodeval,

            string text,

            int textlen,

            string phonenumber,

            bool requestStatusReport);


        //接收短信息返回字符串格式为:手机号码|短信内容||手机号码|短信内容||codego.net/tags/11/1/

        //RD_opt为1接收短信息后不作任何处理,0为接收后删除信息

        [DllImport("dllforvc.dll",

             EntryPoint = "GSMModemSMSReadAll",

             CharSet = CharSet.Ansi,

             CallingConvention = CallingConvention.StdCall)]

        public static extern string GSMModemSMSReadAll(int RD_opt);

    }

}

相关文章
相关标签/搜索