Abstract: This article describes how to use managed service on a Windows mobile device. Code The speaker is triggered during incoming calls to indirectly implement the hands-free function.
Keywords
Windows Mobile,. Net compactframework, speaker, keybd_event, C #
RelatedArticle
Http://www.cnblogs.com/fox23/archive/2008/02/15/phoneincoming.html
Http://www.cnblogs.com/fox23/archive/2008/03/12/phonestate1.html
Prerequisites
Your WM device must support speakers. The simulator will not work.
First, you need to import the local function used to send the key message Class Nativehelper
{
Private Const Int Keyeventf_keyup = Zero X 0002 ;
[Dllimport ( " Coredll. dll " )]
Private Static Extern Void Keybd_event ( Byte Bvk, Byte Bscan, Int Dwflags, Int Dwextrainfo );
/**/ /// <Summary>
///Analog button-triggered speaker
/// </Summary>
Public Static Void Trigglespeaker ()
{
Keybd_event (( Byte ) Keys. F16, 0 , 0 , 0 );
Thread. Sleep ( 500 );
Keybd_event (( Byte ) Keys. F16, 0 , Keyeventf_keyup, 0 );
}
/**/ /// <Summary>
///Simulate button call
/// </Summary>
Public Static Void Acceptcall ()
{
Keybd_event (( Byte ) Keys. F3, 0 , 0 , 0 );
Thread. Sleep ( 500 );
Keybd_event (( Byte ) Keys. F3, 0 , Keyeventf_keyup, 0 );
}
}
When calling: Systemstate phonestate = New Systemstate (systemproperty. phoneincomingcall );
Phonestate. Changed + = New Changeeventhandler (phonestate_changed );
Void Phonestate_changed ( Object Sender, changeeventargs ARGs)
{
Nativehelper. acceptcall ();
Nativehelper. trigglespeaker ();
}
There are also related questions on the Forum. You are welcome to discuss them further:
Http://forums.microsoft.com/china/ShowPost.aspx? Postid = 3210021 & siteid = 15
Http://www.winbile.net/bbs/forums/threads/1036681.aspx
Enjoy it!
Freesc Huang
Yellow winter<Fox23> @ HUST
2008.04.27