自动挂来电
其中挂断电话主要用到了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, 0, 0, 0);
MyRef.keybd_event(VK_F4, 0, KEYEVENTF_KEYUP, 0);
}
#endregion
{
#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, 0, 0, 0);
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
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
我们利用蜂窝模拟器模拟来电
程序运行效果如下:
另外你可以设置一系列的不想接的电话,让程序替你挂断它们
比如
#region 初始化屏蔽号码名单
DropCall.BannedList.Add("1 (312) 132-132");
#endregion
那么当你在Cellular Emulator中拨出号码13112132132后,模拟器会帮你挂断它DropCall.BannedList.Add("1 (312) 132-132");
#endregion
完成的程序点此处下载
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