[Cf. Skills] how to program Windows Mobile to implement hands-free Functions

Source: Internet
Author: User
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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.