Windows Mobile text message interception)

Source: Internet
Author: User

Http://www.cnblogs.com/simalone/archive/2010/03/14/1601211.html

After a recent search on the Internet, I finally achieved some results this afternoon:

There are two ways to intercept text messages on Windows Mobile:

C ++: the Microsoft SDK provides a mapirule example. After mapirule. dll is compiled, you can modify the registry. Because I use C #, I did not try this method.

C #: implemented through the messageinterceptor class. C ++ can also use this method. This method is much more convenient, but it cannot be intercepted after the program loses focus.

You can search online to find a solution to the program's loss of focus:

See msdn: http://msdn.microsoft.com/en-us/bb932385.aspx

By setting up a persistent Message notification in the registry, you can also intercept text messages when the application exits!

The code is roughly as follows:

Messageinterceptor _ smsinterceptor = NULL;
2 const string _ persistentidentifier = "contoso. Pharmaceuticals. messagehandlerapp ";
3
4 private void form1_load (Object sender, eventargs E)
5 {
6 if (! Messageinterceptor. isapplicationlauncherenabled (_ persistentidentifier ))
7 {
8 // persistent notification does not yet exist-must explicitly create
9 _ smsinterceptor = new messageinterceptor (interceptionaction. policyanddelete, false );
10 _ smsinterceptor. messagecondition = new messagecondition (messageproperty. Body,
11 messagepropertycomparisontype. startswith, "contoso data:", false );
12 // make the interceptor persistent
13 _ smsinterceptor. enableapplicationlauncher (_ persistentidentifier );
14}
15 else
16 {
17 // persistent notification already defined-create this instance using
18 // same characteristics
19 _ smsinterceptor = new messageinterceptor (_ persistentidentifier, false );
20}
21
22 // once the interceptor is created, add event handler. Whether the interceptor is constructed
23 // explicitly or constructed from the persistent notification identifier,
24 // The event handling behavior is the same.
25 _ smsinterceptor. messagereceived + = smsinterceptor_messagereceived_onthread;
26
27}
28
29 // notification runs on the message-interceptor thread, not the main
30 // Application Thread
31 void smsinterceptor_messagereceived_onthread (Object sender, messageinterceptoreventargs E)
32 {
33 smsmessage newmessage = E. Message as smsmessage;
34 if (newmessage! = NULL)
35 {
36 // cannot interact directly with user interface-in this case
37 // using an anonymous delegate with the begininvoke method
38 // to transfer control to the main application thread to update
39 // the status bar
40 statusbar1.begininvoke (
41 (methodinvoker) delegate {
42 statusbar1.text = "from:" + newmessage. From. address;
43 });
44 Debug. writeline (string. Format ("Sender: {0}-body: {1}", newmessage. From. Address, newmessage. Body ));
45}
46}
47
48
49 // remove persistent notification
50 private void menudisablepersistentnotification_click (Object sender, eventargs E)
51 {
52 // confirm that _ smsinterceptor is a valid reference, that the current
53 // _ smsinterceptor instance is associated with the correct persistent
54 // notification identifier, and that a persistent notification exists
55 // that has the specified identifier
56 If (_ smsinterceptor! = NULL &&
57 _ smsinterceptor. applicationlaunchid = _ persistentidentifier &&
58 messageinterceptor. isapplicationlauncherenabled (_ persistentidentifier ))
59 {
60_smsinterceptor. disableapplicationlauncher ();
61}
62}

For possible Filtering Problems, refer:

Messageinterceptor is simply a joke, Master cainiao to see: http://topic.csdn.net/u/20071204/17/c8946432-a979-4e8d-ba8d-f881a15bb7a0.html? Seed = 1883745506

For information on writing unblocked messages to Sim after intercept, refer

Http://www.cnblogs.com/appleseeker/archive/2008/03/29/1129031.html

Although I have read many articles about Windows Mobile SMS firewall, I have not found a complete solution for C. Cuptools!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.