I hope this helps. I haven't figured out how to hangup AND how to capture events (dialed a busy line or fax) from the modem yet. If you do please let me know.
This works if the modem is hooked up to the server. I am having problems writing this into .NET 2.0 web page as a javascript so the modem on the client machine will dial instead.
// you must referrence C:\windows\system32\tapi3.dll in your project
<asp:Label ID="lblModem" runat="server" Text="Label">
THIS DISPLAYS ALL YOU AVAILABLE MODEMS
</asp:Label>
<asp:TextBox ID="txtModem" runat="server">
CHANGE YOUR MODEM NAME YOU ARE GOING TO USE HERE
</asp:TextBox>
<asp:TextBox ID="txtPhoneNumber" runat="server">
CHANGE THE PHONE NUMBER YOU WANT TO DIAL
</asp:TextBox>
<%--TAPI_Phone.aspx--------------------------------------------------------------------%>
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="TAPI_Phone.aspx.cs" Inherits="TAPI_Phone" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<script runat="server">
</script>
<title>TAPI_Phone Test Page</title>
</head>
<body>
<form id="form1" runat="server">
<asp:Label ID="lblModem" runat="server" Text="Label"></asp:Label>
<asp:TextBox ID="txtModem" runat="server">BCM V.92 56K Modem</asp:TextBox>
<asp:TextBox ID="txtPhoneNumber" runat="server">5551212</asp:TextBox>
</form>
</body>
</html>
//TAPI_Phone.aspx.cs-------------------------------------------------------------------------
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Threading;
// you must referrence C:\windows\system32\tapi3.dll in your project
using TAPI3Lib;
public partial class TAPI_Phone : System.Web.UI.Page
{
uint ui;
string sModemName = "";
TAPI3Lib.TAPIClass pTAPI = new TAPI3Lib.TAPIClass();
//ITAddressPtr pAddress;
TAPI3Lib.ITAddress pAddress;
//IEnumAddressPtr pEnumAddress;
TAPI3Lib.IEnumAddress pEnumAddress;
//ITBasicCallControlPtr pCall;
TAPI3Lib.ITBasicCallControl pCall;
const int LINEADDRESSTYPE_PHONENUMBER = 1;
const int TAPIMEDIATYPE_AUDIO = 8;
protected void Page_Load(object sender, EventArgs e)
{
pTAPI.Initialize();
pEnumAddress = pTAPI.EnumerateAddresses();
lblModem.Text = "";
while (txtModem.Text != sModemName)
{
pEnumAddress.Next(1, out pAddress, ref ui);
sModemName = pAddress.AddressName.ToString();
lblModem.Text = lblModem.Text + "<li>" + sModemName;
}
If the line was found, then make a call
pCall = pAddress.CreateCall(txtPhoneNumber.Text,
LINEADDRESSTYPE_PHONENUMBER,
TAPIMEDIATYPE_AUDIO);
// Make the call
pCall.Connect(true);
// Wait a while - do something here while the call is ongoing
//Thread.Sleep(5000); // wait 5 seconds
// Hangup
pCall.Disconnect(DISCONNECT_CODE.DC_NORMAL);
// Shutdown TAPI
pTAPI.Shutdown();
}
}