[CF.Skills]在.NET Compact Framework中获取来电号码和屏蔽来电

一个人的情人节,老婆不在身边,只有写写代码解解闷了。
这是一个有趣的程序,厄,就是自动挂电话,情人节专门挂情人的电话,专心陪老婆,呵呵。
其中挂断电话主要用到了keybd_event这个本地方法

     public   static   class  DropCall
    
{
        
#region private field
        
//End键的VK键值 F4
        private const int VK_F4 = 0x73;
        
private const int KEYEVENTF_KEYUP = 0x0002;
        
#endregion


        
#region public fiield
        
//封禁的电话号码单
        public static List<String> BannedList = new List<String>();

        
/// <summary>
        
/// 模拟一次按键操作
        
/// </summary>

        public static void Drop()
        
{
            MyRef.keybd_event(VK_F4, 
000);
            MyRef.keybd_event(VK_F4, 
0, KEYEVENTF_KEYUP, 0);
        }

        
#endregion

获得来电号码用到了SystemState类和SystemProperty类

             #region 挂载事件委托
            SystemState state 
= new SystemState(SystemProperty.PhoneIncomingCallerNumber);
            SystemState SS 
= new SystemState(SystemProperty.PhoneIncomingCall);
            SS.Changed 
+= new ChangeEventHandler(SS_Changed);
            state.Changed 
+= new ChangeEventHandler(state_Changed);
            
#endregion

我们利用蜂窝模拟器模拟来电

程序运行效果如下:


另外你可以设置一系列的不想接的电话,让程序替你挂断它们
比如

             初始化屏蔽号码名单

那么当你在Cellular Emulator中拨出号码13112132132后,模拟器会帮你挂断它
完成的程序点此处下载

PS:程序是基于.NET CF3.5的,如果要移植到CF2.0上可能还要稍做修改
PSS:您可能需要参考下列资料
Cellular Emulator的使用:
http://www.cnblogs.com/upto/archive/2007/02/14/cellular-emulater-in-wm6sdk.html
WM常用键值(VK)对应表:http://www.cnblogs.com/fox23/archive/2008/02/01/keyvalue.html
Lamda表达式:http://www.cnblogs.com/fox23/archive/2007/09/26/906581.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值