/// <summary> /// Make a voice call to the specified number optionally prompting the user before dialling. /// </summary> /// <param name="destination">A valid phone number to be dialled.</param> /// <param name="prompt">If True user will be prompted before call is made, else call will be made without user intervention.</param> /// <param name="calledParty">A display name for the party being called.</param> /// <returns>True if successful else False</returns> public static bool MakeCall(string destination, bool prompt, string calledParty) { //setup structure for native call MakeCallInfo mci = new MakeCallInfo(); mci.cbSize = 24; mci.pszDestAddress = OpenNETCF.Runtime.InteropServices.MarshalEx.StringToHGlobalUni(destination); if (calledParty != null) { mci.pszCalledParty = OpenNETCF.Runtime.InteropServices.MarshalEx.StringToHGlobalUni(calledParty); } if (prompt) { mci.dwFlags = CallFlags.PromptBeforeCalling; } else { mci.dwFlags = CallFlags.Default; } //call native function int result = PhoneMakeCall(ref mci); //free strings if (mci.pszDestAddress != IntPtr.Zero) { MarshalEx.FreeHGlobal(mci.pszDestAddress); } if (mci.pszCalledParty != IntPtr.Zero) { MarshalEx.FreeHGlobal(mci.pszCalledParty); } //check return value if (result == 0) { return(true); } else { return(false); } }
/// <summary> /// Make a voice call to the specified number optionally prompting the user before dialling. /// </summary> /// <param name="destination">A valid phone number to be dialled.</param> /// <param name="prompt">If True user will be prompted before call is made, else call will be made without user intervention.</param> /// <param name="calledParty">A display name for the party being called.</param> /// <returns>True if successful else False</returns> public static bool MakeCall(string destination, bool prompt, string calledParty) { //setup structure for native call MakeCallInfo mci = new MakeCallInfo(); mci.cbSize = 24; mci.pszDestAddress = OpenNETCF.Runtime.InteropServices.MarshalEx.StringToHGlobalUni(destination); if(calledParty!=null) { mci.pszCalledParty = OpenNETCF.Runtime.InteropServices.MarshalEx.StringToHGlobalUni(calledParty); } if(prompt) { mci.dwFlags = CallFlags.PromptBeforeCalling; } else { mci.dwFlags = CallFlags.Default; } //call native function int result = PhoneMakeCall(ref mci); //free strings if(mci.pszDestAddress!=IntPtr.Zero) { MarshalEx.FreeHGlobal(mci.pszDestAddress); } if(mci.pszCalledParty!=IntPtr.Zero) { MarshalEx.FreeHGlobal(mci.pszCalledParty); } //check return value if(result==0) { return true; } else { return false; } }
private static extern int PhoneMakeCall(ref MakeCallInfo ppmci);