decrypt Posted May 16, 2005 Posted May 16, 2005 Ok I have my phone connected up to the modem in my computer. What I want to do is dial a phone number automatically, when I get a connection I hit a button and it dials the extension. here is what I have found: using System; using System.Text; using System.Runtime.InteropServices; namespace MyPhone { /// /// A very simple class just to show how to make a call from C# /// public class Phone { private static long PMCF_DEFAULT = 0x00000001; private static long PMCF_PROMPTBEFORECALLING = 0x00000002; private struct PhoneMakeCallInfo { public IntPtr cbSize; public IntPtr dwFlags; public IntPtr pszDestAddress; public IntPtr pszAppName; public IntPtr pszCalledParty; public IntPtr pszComment; } [DllImport("phone.dll")] private static extern IntPtr PhoneMakeCall(ref PhoneMakeCallInfo ppmci); /// /// Dials the specified phone number. /// /// Phone number /// sets whether Prompts the user before the call is placed. unsafe public static void MakeCall(string PhoneNumber, bool PromptBeforeCall) { IntPtr res; PhoneNumber += '\0'; char[] cPhoneNumber = PhoneNumber.ToCharArray(); fixed (char* pAddr = cPhoneNumber) { PhoneMakeCallInfo info = new PhoneMakeCallInfo(); info.cbSize = (IntPtr)Marshal.SizeOf(info); info.pszDestAddress = (IntPtr)pAddr; if (PromptBeforeCall) { info.dwFlags = (IntPtr)PMCF_PROMPTBEFORECALLING; } else { info.dwFlags = (IntPtr)PMCF_DEFAULT; } res = PhoneMakeCall(ref info); } } } } http://dotnet.org.za/ruari/archive/2004/11/10/6254.aspx?Pending=true Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.