The simplest way to make a call in windows mobile is by using the following
that is the WindowsMobile Managed Telephony api.
Microsoft.WindowsMobile.Telephony.Phone myPhone = new Microsoft.WindowsMobile.Telephony.Phone();
In this simple way the default phone manager appear and the call is managed by it.
If you want a more flexible way to manage the phone module in your windows mobile device you have to use the TAPIThe TAPI is an application interface for telephony application, and microsoft make available it also for windows mobile(http://msdn.microsoft.com/en-us/library/aa455190.aspx).
Ok, now if you want to simplify the interaction with the unmanaged tapi library, you must use a wrapper.
A nice wrapper that I can find is an OpenNetCf Wrapper.
You can download it and various example from http://tapi.codeplex.com/
Make a new smart device project, and add OpenNETCF.Telephony.dll in the references.
You can build the source code and obtaion the dll by the zip downloaded or find it in extracting TelephonySamples.zip file(makeCall -> bin -> Debug -> OpenNETCF.Telephony.dll)ù
Now, we insert the tapi init code in the load event of the Form1.
public partial class Form1 : Form
private Telephony tapi;
private Line line;
private void Form1_Load(object sender, EventArgs e)
// Open Tapi
tapi = new Telephony();
// Get the phone line in the specified media mode and with or not call privilege
line = tapi.CellularLine(MediaMode.InteractiveVoice, CallPrivilege.None);
}So now, add a textbox to the form for telephone number input and a button in order to permits the call.
In the click event of the call you have to add the following:
private void btMakeCall_Click(object sender, EventArgs e)
//the tbNumber is the textbox, and 39 is the country code of the called number, the third
//parameter is for suppressing or not the caller id
line.MakeCall(tbNumber.Text, 39, false);
remember to shutdown the tapi instance.
private void Form1_Closing(object sender, CancelEventArgs e)
When using tapi.CellularLine method the line returned can be null inspite the line exist and is activable.
I debug the OpenNETCF.Telephony and the problem is on
"if (dc.ProviderName == NativeMethods.CELLTSP_PROVIDERINFO_STRING)"
When using the .net compact framework 3.5 the dc.ProviderName string is suffixed with a different char.
Now I don't know the cause of this, but we can avoid this problem by using this matching: