windows moblie 5.0在托管程序中实现短信接收和拦截

 

曾经尝试只用.net cf 在手机(windows moblie 5.0)中实现短信的接收,而同时拦截手机本身的短信提示,代码如下:

private void Form1_Load(object sender, EventArgs e)
       {          

           interceptor = new MessageInterceptor();
           interceptor.InterceptionAction = InterceptionAction.NotifyAndDelete;
           interceptor.MessageReceived += new MessageInterceptorEventHandler(interceptor_MessageReceived);
       }

void interceptor_MessageReceived(object sender, MessageInterceptorEventArgs e)
       {
           SmsMessage msg = e.Message as SmsMessage;
this.txtMessage.Text =”发件人:”+msg.From.Address +”,内容:” +msg.Body +”时间:”+msg.Received.ToString(”yyyy年MM月dd日 MM时mm分ss秒”)

  }

上述程序是通过在窗体加载时委托一个拦截短信事件,虽然实现我想要的功能,但有个确定,当应用程序不处于被激活的状态,就无效了。后来在ms的网站上找到一份资料:Receiving SMS Messages Inside a Managed Application ,可以来实现我想要的这个功能,原理简单来说是修改手机的注册表,手机短信程序启动后加载dll文件,把拦截规则注入,然后通过.net cf  程序来获得拦截的短信。本质上说,不是“拦截”,只是把短信直接删除到“废件箱”,仿佛“拦截”了

原文地址:https://www.cnblogs.com/xyzlmn/p/3168459.html