<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>守望轩 &#187; net cf</title>
	<atom:link href="http://www.watch-life.net/tag/net-cf/feed" rel="self" type="application/rss+xml" />
	<link>http://www.watch-life.net</link>
	<description>关注IT,审视自我,守望生活, 宁静雅致的小轩馆.</description>
	<lastBuildDate>Mon, 23 Aug 2010 15:08:58 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>windows moblie 5.0在托管程序中实现短信接收和拦截</title>
		<link>http://www.watch-life.net/windows-mobile/windows-mobile-sms-received-mapirule.html</link>
		<comments>http://www.watch-life.net/windows-mobile/windows-mobile-sms-received-mapirule.html#comments</comments>
		<pubDate>Sat, 12 Jan 2008 03:26:52 +0000</pubDate>
		<dc:creator>xjb</dc:creator>
				<category><![CDATA[windows mobile]]></category>
		<category><![CDATA[MAPI]]></category>
		<category><![CDATA[net cf]]></category>
		<category><![CDATA[sms]]></category>
		<category><![CDATA[vs2005]]></category>
		<category><![CDATA[windows moblie]]></category>
		<category><![CDATA[拦截]]></category>
		<category><![CDATA[接收]]></category>
		<category><![CDATA[短信]]></category>

		<guid isPermaLink="false">http://www.watch-life.net/window-mobile/windows-mobile-sms-received-maiprule.html</guid>
		<description><![CDATA[曾经尝试只用.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 =&#8221;发件人：&#8221;+msg.From.Address +&#8221;,内容：&#8221; +msg.Body +&#8221;时间:&#8221;+msg.Received.ToString(&#8220;yyyy年MM月dd日 MM时mm分ss秒&#8221;)   } 上述程序是通过在窗体加载时委托一个拦截短信事件，虽然实现我想要的功能，但有个确定，当应用程序不处于被激活的状态，就无效了。后来在ms的网站上找到一份资料：Receiving SMS Messages Inside [...]]]></description>
			<content:encoded><![CDATA[<p>曾经尝试只用.net cf 在手机（windows moblie 5.0）中实现短信的接收，而同时拦截手机本身的短信提示，代码如下：</p>
<p>private void Form1_Load(object sender, EventArgs e)<br />
       {          </p>
<p>           interceptor = new MessageInterceptor();<br />
           interceptor.InterceptionAction = InterceptionAction.NotifyAndDelete;<br />
           interceptor.MessageReceived += new MessageInterceptorEventHandler(interceptor_MessageReceived);<br />
       }</p>
<p>void interceptor_MessageReceived(object sender, MessageInterceptorEventArgs e)<br />
       {<br />
           SmsMessage msg = e.Message as SmsMessage;<br />
this.txtMessage.Text =&#8221;发件人：&#8221;+msg.From.Address +&#8221;,内容：&#8221; +msg.Body +&#8221;时间:&#8221;+msg.Received.ToString(&#8220;yyyy年MM月dd日 MM时mm分ss秒&#8221;)</p>
<p>  }</p>
<p>上述程序是通过在窗体加载时委托一个拦截短信事件，虽然实现我想要的功能，但有个确定，当应用程序不处于被激活的状态，就无效了。后来在ms的网站上找到一份资料：<a href="http://msdn2.microsoft.com/en-us/library/aa446561.aspx">Receiving SMS Messages Inside a Managed Application</a>，可以来实现我想要的这个功能,原理简单来说是修改手机的注册表，手机短信程序启动后加载dll文件，把拦截规则注入，然后通过.net cf  程序来获得拦截的短信。本质上说，不是“拦截”，只是把短信直接删除到“废件箱”，仿佛“拦截”了<br />
实现条件:</p>
<p>1、安装Windows Mobile 5.0 Pocket PC SDK</p>
<p>2、 开发工具 vs2005</p>
<p>3、安装实例程序：<a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=98CCF3D4-DB7C-4A7D-A323-53BBDBBE0420&amp;displaylang=en">http://www.microsoft.com/downloads/details.aspx?FamilyId=98CCF3D4-DB7C-4A7D-A323-53BBDBBE0420&amp;displaylang=en</a></p>
<p>方法：</p>
<p>1、用vs ++ 2005  打开实例程序中的Mapirule（在D:\Program Files\.NET Compact Framework Samples\Receiving SMS Messages\Code\Mapirule中，假定你的安装目录是D:\Program Files），在这个提供的c++中只实现了“短信内容中”包含“zzz”字符的短信拦截，我修改了一下，可以实现对所有短信的拦截：<br />
源代码 ：<a href="http://www.cnblogs.com/Files/xjb/mapirule.rar">mapirule.cpp</a></p>
<p>不过要这个c++的项目编译通过，并生成一个setup文件，还必须安装一个微软提供的一个证书文件，在</p>
<p>安装Windows Mobile 5.0 Pocket PC SDK后会在D:\Program Files\Windows CE Tools\wce500\Windows</p>
<p>Mobile 5.0 Pocket PC SDK\Tools 下有个SDKSamplePrivDeveloper.pfx，直接双击安装，安装过程很简</p>
<p>单（安装过程中有个提示需要输入密码，不必理会，直接点下一步就可以了），这个证书是ms对开发者</p>
<p>用作测试用的，有效期到2009年。编译通过后，在手机上运行setup.exe文件，安装完成后注意一定要重</p>
<p>启手机。</p>
<p>2.编写net cf程序 ：参考（D:\Program Files\.NET Compact Framework Samples\Receiving SMS</p>
<p>Messages\Code\CaptureSMS）<br />
源文件：<a href="http://www.cnblogs.com/Files/xjb/SMSListener.rar"></a><a href="http://www.cnblogs.com/Files/xjb/SMSListener.rar"></a><a href="http://www.cnblogs.com/Files/xjb/SMSListener.rar">SMSListener.cs</a><br />
源文件：<a href="http://www.cnblogs.com/Files/xjb/frmHProcess.rar">frmHProcess.cs</a></p>
<p>上述程序，改造一下，可以拦截垃圾短信<br />
环境：在vs2005+windows mobile 5.0 ＋多普达818测试通过。</p>
<p>本文地址：<a href="http://www.watch-life.net/windows-mobile/windows-mobile-sms-received-mapirule.html">http://www.watch-life.net/windows-mobile/windows-mobile-sms-received-mapirule.html</a></p>
<p class="akst_link">
</p>
	<h4>你可能也会喜欢以下文章：</h4>
	<ul class="st-related-posts">
	<li><a href="http://www.watch-life.net/visual-studio/vs2008-sp1-intellisense.html" title="中文版Visual Studio 2008  SP1 智能提示为英文的补丁发布 (2008-11-28)">中文版Visual Studio 2008  SP1 智能提示为英文的补丁发布</a> (3)</li>
	<li><a href="http://www.watch-life.net/it-review/visual-studio-2008-ambition.html" title="&#8220;Visual Studio 2008&#8243;背后的勃勃野心 (2008-02-10)">&#8220;Visual Studio 2008&#8243;背后的勃勃野心</a> (0)</li>
	<li><a href="http://www.watch-life.net/windows-mobile/process-window-form-system-manager.html" title="windows mobile 5.0 进程管理、窗体管理、重启和关闭操作系统 (2008-02-02)">windows mobile 5.0 进程管理、窗体管理、重启和关闭操作系统</a> (5)</li>
	<li><a href="http://www.watch-life.net/vs2005/vss2005-internet.html" title="vss2005，支持internet访问，进步不大？ (2006-09-29)">vss2005，支持internet访问，进步不大？</a> (2)</li>
	<li><a href="http://www.watch-life.net/visual-studio/use-vs2005-to-debug-with-ie8.html" title="web developer tips (51):使用vs2005和IE8进行调试 (2009-09-25)">web developer tips (51):使用vs2005和IE8进行调试</a> (0)</li>
	<li><a href="http://www.watch-life.net/vs2005/vss2005-internet-suport.html" title="设置VSS2005使支持通过Internet访问（转） (2007-07-09)">设置VSS2005使支持通过Internet访问（转）</a> (0)</li>
	<li><a href="http://www.watch-life.net/aspnet/aspnet-textbox-readonly.html" title="比较郁闷的textbox（asp.net 2.0）控件 (2007-11-07)">比较郁闷的textbox（asp.net 2.0）控件</a> (0)</li>
	<li><a href="http://www.watch-life.net/it-review/ms-innovate-day.html" title="微软创新日，激情安在？ (2008-10-17)">微软创新日，激情安在？</a> (3)</li>
</ul>

转载请注明作者，出处，以及原始超链接。<br />评论数：1 | <b><a href='http://www.watch-life.net/windows-mobile/windows-mobile-sms-received-mapirule.html#comment'>评论这篇文章</a></b>|关注作者最近动态,欢迎 follow me <a href='https://twitter.com/xjb' target='_blank'>xjb@twitter.com</a>|联络作者：iamxjb@gmail.com<br/>© 2010 守望轩 <a href='http://www.watch-life.net/windows-mobile/windows-mobile-sms-received-mapirule.html'>www.watch-life.net</a>]]></content:encoded>
			<wfw:commentRss>http://www.watch-life.net/windows-mobile/windows-mobile-sms-received-mapirule.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/


Served from: www.watch-life.net @ 2010-09-07 01:32:41 -->