今天接到一個特殊任務...在 Windows Mobile 中獲得來電號碼,其實它本身就有個來電顯示,可現在要求就是要自己寫程式來完成這個來電顯示...
沒辦法...雖然沒搞過...但是這個東東好像比較重要哦...所以還是蒙頭搞咯..上網找資料...耶耶!~~~
方法如下:
自動掛來電
其中掛斷電話主要用到了keybd_event這個本地方法
public static class DropCall
{
#region 私人欄位
//End鍵的VK索引值 F4
private const int VK_F4 = 0x73;
private const int KEYEVENTF_KEYUP = 0x0002;
#endregion
#region 公有欄位
//封鎖的電話號碼單
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
我們利用蜂窩模擬器類比來電
程式運行效果如下:
另外你可以設定一系列的不想接的電話,讓程式替你掛斷它們
比如:
#region 初始化屏蔽號碼名單
DropCall.BannedList.Add("1 (312) 132-132");
#endregion
那麼當你在Cellular Emulator中撥出號碼13112132132後,模擬器會幫你掛斷它
完整程式下載: dropcallDemo.rar
要求環境: Windows Mobile 6 Professional SDK .Net Compact Framework 3.5
Windows Mobile 6 Professional SDK :
http://www.microsoft.com/downloads/details.aspx?familyid=06111A3A-A651-4745-88EF-3D48091A390B&displaylang=en
您可能需要參考下列資料:
Cellular Emulator的使用: http://www.cnblogs.com/sukiwqy/archive/2009/12/06/1618192.html
Windows Mobile 常用索引值(VK)對應表: http://www.cnblogs.com/sukiwqy/archive/2009/12/06/1618204.html