A person's Valentine's day, his wife is not around, only write code to relieve boredom.
This is an interesting program. Er, that is, automatic phone calls, Valentine's Day dedicated phone calls, dedicated to accompany his wife, huh, huh.
The local method of keybd_event is used to stop the call.
Public static class dropcall
{
Private field # region private field
// Vk key of the end key F4
Private const int vk_f4 = 0x73;
Private constint keyeventf_keyup = 0x0002;
# Endregion
Public fiield # Region Public fiield
// Banned phone number list
Public static list <string> bannedlist = new list <string> ();
/** // <Summary>
/// Simulate a key operation
/// </Summary>
Public static void drop ()
{
Myref. keybd_event (vk_f4, 0, 0, 0 );
Myref. keybd_event (vk_f4, 0, keyeventf_keyup, 0 );
}
# Endregion
The systemstate class and systemproperty class are used to obtain the incoming call number.
Mount event Delegate # region Mount event Delegate
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
We use the cellular simulator to simulate incoming calls.
The program running effect is as follows:
In addition, you can set up a series of phone numbers that you don't want to answer, so that the program will hang them up for you.
For example
Initialize the blocked number list # region initializes the blocked number list
Dropcall. bannedlist. Add ("1 (312) 132-132 ");
# Endregion
When you dial the number 13112132132 in cellular emulator, the simulator will help you stop it.
Click here to download the completed program.
PS: The program is based on. NET cf3.5. If you want to port the program to cf2.0, you may need to make some modifications.
Pss: you may need to refer to the following materials
Use of cellular emulator:
Http://www.cnblogs.com/upto/archive/2007/02/14/cellular-emulater-in-wm6sdk.html
WM common key value (VK) Table: http://www.cnblogs.com/fox23/archive/2008/02/01/keyvalue.html
Lamda expression: http://www.cnblogs.com/fox23/archive/2007/09/26/906581.html