Question

How to get caller phone number via TAPI

Asked by: alexey_gusev

I need to detect the phone number of the other party for incoming and outgoing calls using TAPI (ie the number of the caller in case of incoming call or the number being dialled for the outgoing call). I don't want to use SNAPI or rely on registry values (ie SystemState is out of scope) as it is not reliable for some reason. I often get the notifications too late.

I open the cellular line in 'monitor' mode and can receive the messages when it is connected and disconnected, but I don't know how to get the number.

Is there any sample available? I don't care if it will be in C++ or cf.net languages

This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.

Subscribe now for full access to Experts Exchange and get

Instant Access to this Solution

  • Plus...
  • 30 Day FREE access, no risk, no obligation
  • Collaborate with the world's top tech experts
  • Unlimited access to our exclusive solution database
  • Never be left without tech help again

Subscribe Now

Asked On
2009-06-26 at 13:02:32ID24526231
Tags

TAPI

,

WIndows Mobile

Topics

Windows MobileProgramming

,

Handheld and PDA Programming

Participating Experts
1
Points
0
Comments
5

Trusted by hundreds of thousands everyday for fast, accurate and reliable tech support.

  • "The time we save is the biggest benefit of Experts Exchange to Warner Bros. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange." Mike Kapnisakis, Warner Bros.
  • "Our team likes having a resource that is more secure than just using Google and most experts using this service really know their stuff. It's nice to look here first versus using Google." Dayna Sellner, Lockheed Martin
  • "Anytime that I've been stumped with a problem, 9 out of 10 times Experts Exchange has either the accepted solution or an open discussion of the potential solution to the problem." Kenny Red, eBay Inc.

See what Experts Exchange can do for you.

Got a question?

We've got the answer.

Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.

Screenshot of Experts Exchange Knowledgebase

Need individual assistance?

Our experts are ready to help.

If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.

Screenshot of Experts Exchange Knowledgebase

Want to learn from the best?

Read articles from industry experts.

Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.

Screenshot of an Article

Working on a long term project?

Store your work and research.

Save solutions to your questions, answers you’ve discovered through searching plus helpful articles in your personal knowledgebase for easy future access.

Screenshot of Experts Exchange Knowledgebase

Access the answers to your technology questions today.

Subscribe Now

30-day free trial. Register in 60 seconds.

What Makes Experts Exchange Unique?

Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Trusted by the world's most respected brands.

image of each brand's logo

Faithfully serving IT professionals since 1996.

Experts Exchange Logo

Try it out and discover for yourself.

Subscribe Now

30-day free trial. Register in 60 seconds.

Related Solutions

  1. Tapi
    I'm building a Tapi application. When a call comes in, tapi sends a message to the application (a line_callState message). How do i know when tapi sent such a message ? Is there a procedure started at that time ?
  2. TAPI telephony & Caller ID
    Hey all...I'm writing a telephony component using TAPI. Currently I have implemented dialling using a name and phone number. However I need to implement a OnIncomingCall event which can extract an incoming call's number which can then be used in an event handler...kind of li...
  3. Tapi caller id
    Can anyone tell me how to get the caller id using vb and tapi, i will be using modems and telephones that are tapi devices. I have no tapi knowledge but a good vb background. Thanks Debs
  4. tapi implementation
    i have to implement tapi specifically VOIP in my office. Please suggest the codes in details also the file requirements(e.g. header file) if any. Our application should be like this - if caller press 1 he can talk to the management, 2 for the client complains, 3 for the new o...

Free Tech Articles

  1. WARNING: 5 Reasons why you should NEVER fix a computer for free.
    It is in our nature to love the puzzle. We are obsessed. The lot of us. We love puzzles. We love the challenge. We thrive on finding the answer. We hate disarray. It bothers us deep in our soul. W...
  2. SCCM OSD Basic troubleshooting
    SCCM 2007 OSD is a fantastic way to deploy operating systems, however, like most things SCCM issues can sometimes be difficult to resolve due to the sheer volume of logs to sift through and the dispe...
  3. Migrate Small Business Server 2003 to Exchange 2010 and Windows 2008 R2
    This guide is intended to provide step by step instructions on how to migrate from Small Business Server 2003 to Windows 2008 R2 with Exchange 2010. For this migration to work you will need the fo...
  4. Create a Win7 Gadget
    This article shows you how to create a simple "Gadget" -- a sort of mini-application supported by Windows 7 and Vista. Gadgets can be dropped anywhere on the desktop to provide instant information, ...
  5. Outlook continually prompting for username and password
    There have been a lot of questions recently regarding Outlook prompting for a username and password whilst using Exchange 2007. There are a few reasons why this would happen and I will try to cover t...
  6. Backup Exchange 2010 Information Store using Windows Backup
    There seems to be quite a lot of confusion around the ability to backup Exchange 2010 using the built in Windows Backup feature. This stems from the omission of this feature prior to Exchange 2007 s...

Cloud Class Webinars

  1. Avoiding Bugs in Microsoft Access
    Alison Balter takes and in-depth look at avoiding bugs in Access. In this webinar you will learn about using the immediate window to debug your applications, invoking the debugger, using breakpoints to troubleshoot, stepping through code, setting the next statement to execute, ...
  2. Top 10 Best New Features in Visio 2010
    Scott Helmers gives live demonstrations of the top 10 new features in Visio 2010. This webinar will teach you how to create compelling diagrams by adding shapes to the page with a single click, linking the shapes in a diagram to data in Excel (or SQL Server, or SharePoint), ...
  3. IT Consultant Business Secrets Revealed
    Michael Munger, Experts Exchange tech pro and IT consultant, pulls back the curtain on his very successful businesses and answers question on every IT consultant and business owner should know about. He shares secrets on what he did to solve the 5 most common problems in IT, ...
  4. Disaster Recovery and Business Continuity
    Quest CTO, Mike Billon, gives an overview of the steps involved in building a dunamic disaster recovery plan. Through case studies and an examination of software/hardware tooles for monitoring and testing, you'll gain a better understandin of where you are, where you want ...
  5. Organize Your Visio Diagrams with Containers and Lists
    Scott Helmers uses cross functional flowcharts, wireframe diagrams, data graphic legends and seating charts to teach you: how to ustilize all three new structured diagram components in Visio 2010, the best practices for organizeing shapes in previous version of Visio, how to organize ...
  6. How to Us Objects, Properties, Events and Methods in Microsoft Access
    Alison Dalter gives an in-depbth look at objects, properties, events and methods in Microsoft Access. In this webinar you will learn about using the object browser, referring to objects, working with properties and methods, working with object variables, understanding the ...

Join the Community

Give a Little. Get a Lot.

Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.

Join the Community

Answers

 

by: alexey_gusevPosted on 2009-06-26 at 14:15:22ID: 24724776

solved the problem myself (or at least I see the numbers :) )

 

by: srikanthkanchariPosted on 2009-09-08 at 12:23:48ID: 25285253

i am writing a library, i will give you soon the library and methods to get the data using TAPI.

 

by: alexey_gusevPosted on 2009-09-08 at 12:27:36ID: 25285292

cool, thanks, looking forward to it!

 

by: srikanthkanchariPosted on 2009-09-08 at 12:46:23ID: 25285474

check the website: http://softlancers.in    Windows Mobile forum will be started soon in oct 2009 from here.
sample Codes will be uploaded there. you can check from there also.
   

// TapiCall.h: interface for the CTapiCall class.
//
//////////////////////////////////////////////////////////////////////
 
#if !defined(AFX_TAPILINE_H__64E4FCD7_09C8_419D_ABF4_6D864361094B__INCLUDED_)
#define AFX_TAPILINE_H__64E4FCD7_09C8_419D_ABF4_6D864361094B__INCLUDED_
 
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
 
//#define TAPI_CURRENT_VERSION 0x00010004
#define TAPI_CURRENT_VERSION 0x00020000
#include <tapi.h>
 
 
 
 
class CTapiLine  
{
protected:
	HLINEAPP	m_hLineApp; // application's usage handle for TAPI
	HPHONEAPP	m_hPhoneApp; // application's usage handle for TAPI
	HLINE		m_hLine;
	HPHONE		m_hPhone;
	HCALL		m_hCall;
	
	int			m_nDevID;
	int         m_PhoneID;
 
	HANDLE		m_hLineEvent; // line change events
 
	DWORD		m_dwLineMsg;
 
	bool		m_bConnected;
 
	HANDLE	m_hEventFromThread;
	
 
	HANDLE	m_hLineMsgThread;   // TAPI Event monitoring thread.
	bool	m_bStopLineEventThread;
	static DWORD WINAPI LineEventThread(LPVOID lpVoid);
	long	m_lEventThreadResult;
 
	TCHAR* m_szCallerID;
	bool m_bdebug;
	
 
public:
	HWND        m_hWnd; // Window to send messages to
	HANDLE GetHandle(const TCHAR *szClassType, long *lError);
	int PickupIncomingCall();
	void GetErrorString(int nError, TCHAR *&szErrText);
	int MakeOutgoingCall(const TCHAR *szAddress);
	int GetIncomingCall();
	int AnswerCall();
    int HangUp();
	int Close();
	int PreparePhone();
	int Open(int nMode, bool bdebug, HWND hWnd);
	CTapiLine();
	virtual ~CTapiLine();
	enum
	{
	  line_offering,
	  line_callerid,
	  line_connected,
      line_disconnected,
	  line_dialing,
	  line_dialtone,
	  line_proceeding,
	  line_ringback,
	  line_default
	};
 
};
 
#endif // !defined(AFX_TAPILINE_H__64E4FCD7_09C8_419D_ABF4_6D864361094B__INCLUDED_)
 
 
// TapiLine.cpp: implementation of the CTapiLine class.
// Author: T.Yogaramanan
// Include this header if you use any part of the code from this file 
/////////////////////////////////////////////////////////////////////////////
 
#include "stdafx.h"
 
#include "TapiLine.h"
 
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
 
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
 
 
CTapiLine::CTapiLine()
{
	m_hEventFromThread = NULL;
	m_hLineMsgThread = NULL;   // TAPI Event monitoring thread.
	m_bStopLineEventThread = true; 
	m_lEventThreadResult = 0; 
	m_dwLineMsg= 0;
	m_nDevID = 0;
	m_hLineApp = NULL;
	m_hLine = NULL;
	m_hCall = NULL;
	m_bConnected = false;
	m_szCallerID = NULL;
	m_bdebug = false;
 
}
 
CTapiLine::~CTapiLine()
{
	Close();
}
 
// if nMode = 0 then it is data/fax calls
//    nMode = 1 then it is data/fax/voice calls
int CTapiLine::Open(int nMode, bool bdebug ,HWND hWnd)
{
	LINEINITIALIZEEXPARAMS stInitParams;
	LINEDEVCAPS *lpDevCaps =NULL;
	LONG lRet;
	m_szCallerID = new TCHAR[1000]; // must be enough
	m_bdebug = bdebug;
	CString szerror;
	DWORD dwMediaMode;
	DWORD dwNumDevs =0;
	DWORD dwTAPIVer =TAPI_CURRENT_VERSION;;
	DWORD dwTmpVer =0;
	LINEEXTENSIONID stExtID;
 
	if(hWnd!=NULL) m_hWnd = hWnd;
 
	if(!nMode)
		dwMediaMode = LINEMEDIAMODE_DATAMODEM; // data/fax this should be
	else
		dwMediaMode = LINEMEDIAMODE_INTERACTIVEVOICE ;// for voice this should be it
 
	memset(&stInitParams, 0, sizeof(LINEINITIALIZEEXPARAMS));
	// set the options...
	stInitParams.dwTotalSize = sizeof(LINEINITIALIZEEXPARAMS);
	stInitParams.dwOptions = LINEINITIALIZEEXOPTION_USEEVENT;
	
	// Initialize TAPI.
	lRet = lineInitializeEx(&m_hLineApp, NULL, NULL, L"CallAnswer", &dwNumDevs, &dwTAPIVer, &stInitParams);
	
	if(lRet)  //error
	{
		szerror.Format(L"lineInitializeEx Error:%i",lRet);
		//AfxMessageBox(szerror);
		return lRet;
    }
	else // Number of devices found:
	{
	    szerror.Format(L"lineInitializeEx numDev %i",dwNumDevs);
		//AfxMessageBox(szerror);
	}
	// Got the event handle...
	m_hLineEvent = stInitParams.Handles.hEvent;
 
	m_nDevID = -1;
	// go through the device list and select the appropriate device to transfer voice
	for(int i=0;i<dwNumDevs;i++)
	{
		lRet = lineNegotiateAPIVersion(m_hLineApp, i, dwTAPIVer, dwTAPIVer,	&dwTmpVer, &stExtID);
		if(lRet != 0)
			continue;
				
		lpDevCaps = (LINEDEVCAPS *)malloc(sizeof(LINEDEVCAPS)+1024);// Allocate a little extra memory...
 
		memset(lpDevCaps, 0, sizeof(LINEDEVCAPS)+1024);
		lpDevCaps->dwTotalSize = sizeof(LINEDEVCAPS)+1024;
 
		lRet = lineGetDevCaps(m_hLineApp, i, dwTmpVer, 0, lpDevCaps);
		
		if(lRet)  //error
		{
			free(lpDevCaps);
			lpDevCaps=NULL;
			continue;
		}
		
		char* szText = ((char*)lpDevCaps) + lpDevCaps->dwLineNameOffset;// FOR DEBUGGING
		// for more refer LINEMEDIAMODE_ Constants in MSDN
 
		
 
		if(lpDevCaps->dwMediaModes & dwMediaMode) 
		{
			free(lpDevCaps);
			m_nDevID = i;
			//break;
		}
		free(lpDevCaps);
		
	}
	if(m_nDevID < 0)
		return LINEERR_BADDEVICEID; // no device available
 
	// Open the line...
	lRet = lineOpen(m_hLineApp, m_nDevID, &m_hLine, dwTAPIVer, 0x00000000, 1,LINECALLPRIVILEGE_OWNER,dwMediaMode,NULL);
	if(lRet)
	{
		lineShutdown(m_hLineApp);
		return lRet;
	}
	
	// We want to be notified for everything
	lRet = lineSetStatusMessages(m_hLine, 0x1ffffff, 0);
	if(lRet)
	{	
		lineShutdown(m_hLineApp);
		return lRet;	
	}
	m_bStopLineEventThread = false;
	m_hLineMsgThread = CreateThread(NULL,NULL,LineEventThread,this,NULL,0);
	m_hEventFromThread = CreateEvent(NULL,0,0,NULL);
	return 0;
}
int CTapiLine::PreparePhone()
{
    PHONEINITIALIZEEXPARAMS stInitParams;
	PHONECAPS *lpDevCaps =NULL;
	LONG lRet;
	m_szCallerID = new TCHAR[1000]; // must be enough
	
	CString szerror;
	DWORD dwMediaMode;
	DWORD dwNumDevs =0;
	DWORD dwTAPIVer =TAPI_CURRENT_VERSION;;
	DWORD dwTmpVer =0;
	PHONEEXTENSIONID stExtID;
 
	
 
	memset(&stInitParams, 0, sizeof(PHONEINITIALIZEEXPARAMS));
	// set the options...
	stInitParams.dwTotalSize = sizeof(PHONEINITIALIZEEXPARAMS);
	stInitParams.dwOptions = PHONEINITIALIZEEXOPTION_USEEVENT;
	
	// Initialize TAPI.
	lRet = phoneInitializeEx(&m_hPhoneApp, NULL, NULL, L"CallAnswer", &dwNumDevs, &dwTAPIVer, &stInitParams);
	
	if(lRet)  //error
	{
		szerror.Format(L"lineInitializeEx Error:%i",lRet);
		//AfxMessageBox(szerror);
		return lRet;
    }
	else // Number of devices found:
	{
	    szerror.Format(L"lineInitializeEx numDev %i",dwNumDevs);
		//AfxMessageBox(szerror);
	}
	// Got the event handle...
	//m_hLineEvent = stInitParams.Handles.hEvent;
 
     
	m_nDevID = -1;
	// go through the device list and select the appropriate device to transfer voice
	for(int i=0;i<dwNumDevs;i++)
	{
		lRet = phoneNegotiateAPIVersion(m_hPhoneApp, i, dwTAPIVer, dwTAPIVer,	&dwTmpVer, &stExtID);
		if(lRet != 0)
			continue;
				
		lpDevCaps = (PHONECAPS *)malloc(sizeof(PHONECAPS)+1024);// Allocate a little extra memory...
 
		memset(lpDevCaps, 0, sizeof(PHONECAPS)+1024);
		lpDevCaps->dwTotalSize = sizeof(PHONECAPS)+1024;
 
		lRet = phoneGetDevCaps(m_hPhoneApp, i, dwTmpVer, 0, lpDevCaps);
		
		if(lRet)  //error
		{
			free(lpDevCaps);
			lpDevCaps=NULL;
			continue;
		}
		
		char* szText = ((char*)lpDevCaps) + lpDevCaps->dwPhoneNameOffset;// FOR DEBUGGING
		// for more refer LINEMEDIAMODE_ Constants in MSDN
        m_nDevID = i;  
		
 
	
		
	}
	if(m_nDevID < 0)
		return LINEERR_BADDEVICEID; // no device available
 
	// Open the line...
	lRet = phoneOpen(m_hPhoneApp, m_PhoneID, &m_hPhone, dwTAPIVer, 0x00000000, 1,PHONEPRIVILEGE_OWNER);
	if(lRet)
	{
		szerror.Format(L"Error Line ID %i",dwNumDevs);
		//AfxMessageBox(szerror);
		phoneShutdown(m_hPhoneApp);
		return lRet;
	}
 
	DWORD dwHookswitch = 0;
 
	lRet = phoneGetHookSwitch(m_hPhone,&dwHookswitch );
    if(lRet<0)
	{	
		//AfxMessageBox(L"phoneGetHookSwitch error");
	}
	
	szerror.Format(L"phoneGetHookSwitch:%i",dwHookswitch);
 
	//AfxMessageBox(szerror);
 
	LPDWORD dwVol;
	lRet=phoneGetVolume(m_hPhone,PHONEHOOKSWITCHDEV_HANDSET,dwVol);
 
	lRet = phoneSetVolume(m_hPhone, PHONEHOOKSWITCHDEV_HANDSET, 0x0000FFFF);
	
 
 
	//lRet = phoneSetHookSwitch(m_hPhone,PHONEHOOKSWITCHDEV_HANDSET,PHONEHOOKSWITCHMODE_MICSPEAKER );
 
	
	if(lRet>0)
	{	
		//AfxMessageBox(L"Hookswitch success");
	}
	else
	{
	   switch(lRet)
	   {
	   case PHONEERR_INVALPHONEHANDLE:
		   AfxMessageBox(L"PHONEERR_INVALPHONEHANDLE");
       break;
       case PHONEERR_OPERATIONUNAVAIL:
		   AfxMessageBox(L"PHONEERR_OPERATIONUNAVAIL");
       break;
	   case PHONEERR_NOTOWNER:
		   AfxMessageBox(L"PHONEERR_NOTOWNER");
       break;
	   case PHONEERR_NOMEM:
		   AfxMessageBox(L"PHONEERR_NOMEM");
       break;
	   case PHONEERR_INVALHOOKSWITCHDEV:
		   AfxMessageBox(L"PHONEERR_INVALHOOKSWITCHDEV");
       break;
	   case PHONEERR_INVALHOOKSWITCHMODE:
		   AfxMessageBox(L"PHONEERR_INVALHOOKSWITCHMODE");
       break;
	   case PHONEERR_OPERATIONFAILED:
		   AfxMessageBox(L"PHONEERR_OPERATIONFAILED");
       break;
	   case PHONEERR_INVALPHONESTATE:
		   AfxMessageBox(L"PHONEERR_INVALPHONESTATE");
       break;
	   case PHONEERR_UNINITIALIZED:
		   AfxMessageBox(L"PHONEERR_UNINITIALIZED");
       break;
	   
	   
	   }
		
		
		
		// Wenn ein Fehler aufgetreten ist
	    szerror.Format(L"Error phoneSetHookSwitch %i",lRet);
	    AfxMessageBox(szerror);
        phoneShutdown(m_hPhoneApp);
	}
	// We want to be notified for everything
	//lRet = lineSetStatusMessages(m_hLine, 0x1ffffff, 0);
	/*
	if(lRet)
	{	
		lineShutdown(m_hLineApp);
		return lRet;	
	}
	*/
 
	//m_bStopLineEventThread = false;
	//m_hLineMsgThread = CreateThread(NULL,NULL,LineEventThread,this,NULL,0);
	//m_hEventFromThread = CreateEvent(NULL,0,0,NULL);
	return 0;
 
}
 
int CTapiLine::Close()
{
	LINECALLSTATUS stLineStatus;
	LONG lRet;
	delete m_szCallerID;
 
	if(m_hCall)  // Call might be in progress...
	{
		memset(&stLineStatus, 0, sizeof(LINECALLSTATUS));
 
		lRet = lineGetCallStatus(m_hCall, &stLineStatus); 
			// Technically, lineGetCallStatus returns more info than 
			// there is in the structure.  Since we don't care about it,
			// We just go on our merry way...
		if(!lRet) // If it didn't fail, there's at least a call that needs to be droped.
			lineDrop(m_hCall, NULL, 0);
	}
	m_hCall = NULL;
 
	if(m_hLine)
		lineClose(m_hLine);
	m_hLine = NULL;
 
	if(m_hLineMsgThread)
	{
		m_bStopLineEventThread = true;  // stop the event waiting thread
		WaitForSingleObject(m_hLineMsgThread, INFINITE); // Wait for it to comit suicide..
		CloseHandle(m_hLineMsgThread);
		CloseHandle(m_hEventFromThread);
	}
	if(m_hLineApp)	
		lineShutdown(m_hLineApp);
	m_hLineApp = NULL;
 
	m_hLineMsgThread = NULL;
	m_hEventFromThread = NULL;
	m_hLineMsgThread = NULL;
 
	m_lEventThreadResult = 0; 
	m_dwLineMsg= 0;
	m_nDevID = -1;
	m_bConnected= false;
	return 0;
}
 
 
 
int CTapiLine::GetIncomingCall()
{
	long lRet;
	
	// set the ring b4 receiving the call
	lRet = lineSetNumRings(m_hLine,0,5);
	if(lRet)
		return lRet;
	
	// Now we wait for notification.
	switch(WaitForSingleObject(m_hEventFromThread, INFINITE))
	{
	case WAIT_OBJECT_0:
		if(m_dwLineMsg == LINECALLSTATE_OFFERING)
		{
			
			lRet = lineAnswer(m_hCall, NULL, 0);
			lRet = (lRet>0)?0:lRet;
 
			if(lRet)
				Close();
			return lRet;
		}
		break;
	case WAIT_TIMEOUT:
		return ERROR_TIMEOUT;
	};
	return 0xffffffff; // unknown error
}
 
int CTapiLine::AnswerCall()
{
   PlaySound(NULL,NULL,SND_ASYNC|SND_LOOP|SND_FILENAME);
   int lRet = lineAnswer(m_hCall, NULL, 0);
   return lRet;
}
 
int CTapiLine::PickupIncomingCall()
{
	long lRet;
 
	lRet = linePickup(m_hLine,0,&m_hCall,NULL,NULL);
 
	return (lRet>=0)?0:lRet;
}
 
 
int CTapiLine::MakeOutgoingCall(const TCHAR *szAddress)
{
	long lRet;
 
	LPLINECALLPARAMS lpCallParams;
 
	lpCallParams = (LPLINECALLPARAMS)malloc(sizeof(LINECALLPARAMS)+1024);
	
	memset(lpCallParams,0,sizeof(LINECALLPARAMS)+1024);
 
	lpCallParams->dwTotalSize = sizeof(LINECALLPARAMS)+1024;
 
	    // This is where we configure the line for DATAMODEM usage.
    lpCallParams->dwBearerMode = LINEBEARERMODE_VOICE;
    lpCallParams->dwMediaMode  = LINEMEDIAMODE_INTERACTIVEVOICE;
 
    // This specifies that we want to use only IDLE calls and
    // don't want to cut into a call that might not be IDLE (ie, in use).
    lpCallParams->dwCallParamFlags = LINECALLPARAMFLAGS_IDLE;
                                    
    // if there are multiple addresses on line, use first anyway.
    // It will take a more complex application than a simple tty app
    // to use multiple addresses on a line anyway.
    lpCallParams->dwAddressMode = LINEADDRESSMODE_ADDRESSID;
    lpCallParams->dwAddressID = 0;
 
    // Address we are dialing.
    lpCallParams->dwDisplayableAddressOffset = sizeof(LINECALLPARAMS);
    lpCallParams->dwDisplayableAddressSize = wcslen(szAddress) *2;
    wcscpy((LPTSTR)lpCallParams+sizeof(LINECALLPARAMS), szAddress);
	
	lRet = lineMakeCall(m_hLine, &m_hCall,szAddress, 0, lpCallParams);
 
	return (lRet>=0)?0:lRet;
}
 
int CTapiLine::HangUp()
{
    LINECALLSTATUS stLineStatus;
	LONG lRet;
	
	
	//if(m_hCall)  // Call might be in progress...
	//{
		memset(&stLineStatus, 0, sizeof(LINECALLSTATUS));
 
		lRet = lineGetCallStatus(m_hCall, &stLineStatus); 
			// Technically, lineGetCallStatus returns more info than 
			// there is in the structure.  Since we don't care about it,
			// We just go on our merry way...
		//if(!lRet) // If it didn't fail, there's at least a call that needs to be droped.
		lineDrop(m_hCall, NULL, 0);
	//}
	m_hCall = NULL;
 
	return lRet;
}
 
//Author: Ramanan.T
HANDLE CTapiLine::GetHandle(const TCHAR *szClassType, long *lError)
{
	if(!m_bConnected)
	{
		*lError = ERROR_DEVICE_NOT_CONNECTED;
		return NULL;
	}
 
	VARSTRING *pvarStrDevID = (VARSTRING *)malloc(sizeof(VARSTRING)+255);
 
	memset(pvarStrDevID,0,sizeof(VARSTRING)+255);
	pvarStrDevID->dwTotalSize = sizeof(VARSTRING)+255;
	
	long lRet = lineGetID(m_hLine,0,m_hCall,LINECALLSELECT_LINE,pvarStrDevID,szClassType);
	if(lRet)
	{
		*lError = lRet;
		return NULL;
	}
 
	*lError = 0;
 
	return *((LPHANDLE)((BYTE *)pvarStrDevID + pvarStrDevID->dwStringOffset));
}
 
//Author: Ramanan.T
DWORD WINAPI CTapiLine::LineEventThread(LPVOID lpVoid)
{
	CTapiLine *pcTapiLine = (CTapiLine *)lpVoid;
	long lRet;
	LINEMESSAGE stLineMsg;
	LINECALLINFO *lpCallInfo;
	bool retval = FALSE;
	//AfxMessageBox(L"LineEventThread");
 
	while(!pcTapiLine->m_bStopLineEventThread)
	{
		// Get a TAPI event if available, wait for 10ms just enough to give up quontum
		switch(WaitForSingleObject(pcTapiLine->m_hLineEvent, 10))
		{
		case WAIT_OBJECT_0:
			//TAPI's got something
			if ((lRet = lineGetMessage(pcTapiLine->m_hLineApp, &stLineMsg, 0)) != 0)
			{
				pcTapiLine->m_lEventThreadResult = lRet;
				return lRet;
			}
			// Process the retruned msg
			switch (stLineMsg.dwMessageID)
			{
			case LINE_REPLY: // Sent after lineMakeCall or lineDrop				
				pcTapiLine->m_lEventThreadResult = (LONG)stLineMsg.dwParam2;
				break;
 
			case LINE_CALLSTATE:  // Sent after change of call state
				switch (stLineMsg.dwParam1)
				{
				    case LINECALLSTATE_DIALTONE: 
						SendMessage(pcTapiLine->m_hWnd,WM_PHONE,line_dialtone,0);
				    break;
 
					case LINECALLSTATE_PROCEEDING:
						SendMessage(pcTapiLine->m_hWnd,WM_PHONE,line_proceeding,0);
                    break;
				 
				    case LINECALLSTATE_DIALING:
					 SendMessage(pcTapiLine->m_hWnd,WM_PHONE,line_dialing,0);
					break;
								
				    case LINECALLSTATE_OFFERING:	//Incoming call is offering.
						//  Get the call handle
						SendMessage(pcTapiLine->m_hWnd,WM_PHONE,line_offering,0);
						 retval = PlaySound(L"\\Windows\\Alarm1.wav",NULL,SND_ASYNC|SND_LOOP|SND_FILENAME);
						pcTapiLine->m_hCall = (HCALL)stLineMsg.hDevice;
 
						pcTapiLine->m_dwLineMsg = LINECALLSTATE_OFFERING;
						SetEvent(pcTapiLine->m_hEventFromThread);
						break;
 
					case LINECALLSTATE_IDLE:
						//PlaySound(NULL,NULL,SND_ASYNC|SND_LOOP|SND_FILENAME);
						lineDrop(pcTapiLine->m_hCall, NULL, 0);
						pcTapiLine->m_hCall = NULL;
						break;
 
					case LINECALLSTATE_RINGBACK: 
						SendMessage(pcTapiLine->m_hWnd,WM_PHONE,line_ringback,0);
                    break;
 
 
					case LINECALLSTATE_CONNECTED:
						
						SendMessage(pcTapiLine->m_hWnd,WM_PHONE,line_connected,0);
						if(stLineMsg.dwCallbackInstance == 1)
						{
							pcTapiLine->m_dwLineMsg = LINECALLSTATE_CONNECTED;
							SetEvent(pcTapiLine->m_hEventFromThread);
							pcTapiLine->m_bConnected = true;
						}
 
						break;
 
					case LINECALLSTATE_DISCONNECTED:
						
						SendMessage(pcTapiLine->m_hWnd,WM_PHONE,line_disconnected,stLineMsg.dwParam2);
						switch (stLineMsg.dwParam2) 
						{// currently these r not handled separately
							case LINEDISCONNECTMODE_NORMAL:
							case LINEDISCONNECTMODE_UNKNOWN:
							case LINEDISCONNECTMODE_REJECT:
							case LINEDISCONNECTMODE_PICKUP:
							case LINEDISCONNECTMODE_FORWARDED:
							case LINEDISCONNECTMODE_BUSY:
							case LINEDISCONNECTMODE_NOANSWER:
							case LINEDISCONNECTMODE_BADADDRESS:
							case LINEDISCONNECTMODE_UNREACHABLE:
							case LINEDISCONNECTMODE_CONGESTION:
							case LINEDISCONNECTMODE_INCOMPATIBLE:
							case LINEDISCONNECTMODE_UNAVAIL:
							case LINEDISCONNECTMODE_NODIALTONE:
							default:
								// Got disconnected, so drop the call
								lineDrop((HCALL)stLineMsg.hDevice, NULL, 0);
								PlaySound(NULL,NULL,SND_ASYNC|SND_LOOP|SND_FILENAME);
								pcTapiLine->m_bConnected = false;
								break;
						}					
						break;
 
					default:
						SendMessage(pcTapiLine->m_hWnd,WM_PHONE,line_default,stLineMsg.dwParam2);
						break;
				}
				break;
 
			case LINE_CALLINFO: //  Call Info is available
				
				if(stLineMsg.dwParam1 == LINECALLINFOSTATE_CALLERID)
				{  //Caller ID became available.
					lpCallInfo = (LINECALLINFO *)malloc(sizeof(LINECALLINFO)+1000);
					memset(lpCallInfo, 0, sizeof(LINECALLINFO)+1024);
					lpCallInfo->dwTotalSize = sizeof(LINECALLINFO)+1024;
					lineGetCallInfo(pcTapiLine->m_hCall, lpCallInfo);
					if (lpCallInfo->dwTotalSize < lpCallInfo->dwNeededSize)
					{
						lpCallInfo = (LINECALLINFO *)realloc(lpCallInfo, lpCallInfo->dwNeededSize);
						lineGetCallInfo(pcTapiLine->m_hCall, lpCallInfo);
 
						    
					}
					memset(pcTapiLine->m_szCallerID,0,2000);
					wsprintf(pcTapiLine->m_szCallerID,_T("%s"),(LPCTSTR)((LPBYTE)lpCallInfo + lpCallInfo->dwCallerIDOffset));
                    SendMessage(pcTapiLine->m_hWnd,WM_PHONE, line_callerid,(WPARAM)pcTapiLine->m_szCallerID);
				} 
 
				break;
 
			default:
				break;
			};
			break;
 
		case WAIT_TIMEOUT:
			//PlaySound(NULL,NULL,SND_ASYNC|SND_LOOP|SND_FILENAME);
			break;;
			
		default:
			continue;
		};
	}
	return 0;
}
 
//Author: Ramanan.T
void CTapiLine::GetErrorString(int nError, TCHAR *&szErrText)
{
	szErrText = (TCHAR*)malloc(255);
	switch(nError)
	{
	case LINEERR_ALLOCATED:
		wcscpy(szErrText,L"LINEERR_ALLOCATED");
		break;
	case LINEERR_BADDEVICEID:
		wcscpy(szErrText,L"LINEERR_BADDEVICEID");
		break;
	case LINEERR_BEARERMODEUNAVAIL:
		wcscpy(szErrText,L"LINEERR_BEARERMODEUNAVAIL");
		break;
	case LINEERR_CALLUNAVAIL:
		wcscpy(szErrText,L"LINEERR_CALLUNAVAIL");
		break;
	case LINEERR_COMPLETIONOVERRUN:
		wcscpy(szErrText,L"LINEERR_COMPLETIONOVERRUN");
		break;
	case LINEERR_CONFERENCEFULL:
		wcscpy(szErrText,L"LINEERR_CONFERENCEFULL");
		break;
	case LINEERR_DIALBILLING:
		wcscpy(szErrText,L"LINEERR_DIALBILLING");
		break;
	case LINEERR_DIALDIALTONE:
		wcscpy(szErrText,L"LINEERR_DIALDIALTONE");
		break;
	case LINEERR_DIALPROMPT:
		wcscpy(szErrText,L"LINEERR_DIALPROMPT");
		break;
	case LINEERR_DIALQUIET:
		wcscpy(szErrText,L"LINEERR_DIALQUIET");
		break;
	case LINEERR_INCOMPATIBLEAPIVERSION:
		wcscpy(szErrText,L"LINEERR_INCOMPATIBLEAPIVERSION");
		break;
	case LINEERR_INCOMPATIBLEEXTVERSION:
		wcscpy(szErrText,L"LINEERR_INCOMPATIBLEEXTVERSION");
		break;          
	case LINEERR_INIFILECORRUPT:
		wcscpy(szErrText,L"LINEERR_INIFILECORRUPT");
		break;                  
	case LINEERR_INUSE:
		wcscpy(szErrText,L"LINEERR_INUSE");
		break;                           
	case LINEERR_INVALADDRESS:
		wcscpy(szErrText,L"LINEERR_INVALADDRESS");
		break;                    
	case LINEERR_INVALADDRESSID:
		wcscpy(szErrText,L"LINEERR_INVALADDRESSID");
		break;                  
	case LINEERR_INVALADDRESSMODE:
		wcscpy(szErrText,L"LINEERR_INVALADDRESSMODE");
		break;                
	case LINEERR_INVALADDRESSSTATE:
		wcscpy(szErrText,L"LINEERR_INVALADDRESSSTATE");
		break;               
	case LINEERR_INVALAPPHANDLE:
		wcscpy(szErrText,L"LINEERR_INVALAPPHANDLE");
		break;                  
	case LINEERR_INVALAPPNAME:
		wcscpy(szErrText,L"LINEERR_INVALAPPNAME");
		break;                    
	case LINEERR_INVALBEARERMODE:
		wcscpy(szErrText,L"LINEERR_INVALBEARERMODE");
		break;                 
	case LINEERR_INVALCALLCOMPLMODE:
		wcscpy(szErrText,L"LINEERR_INVALCALLCOMPLMODE");
		break;              
	case LINEERR_INVALCALLHANDLE:
		wcscpy(szErrText,L"LINEERR_INVALCALLHANDLE");
		break;                 
	case LINEERR_INVALCALLPARAMS:
		wcscpy(szErrText,L"LINEERR_INVALCALLPARAMS");
		break;                 
	case LINEERR_INVALCALLPRIVILEGE:
		wcscpy(szErrText,L"LINEERR_INVALCALLPRIVILEGE");
		break;              
	case LINEERR_INVALCALLSELECT:
		wcscpy(szErrText,L"LINEERR_INVALCALLSELECT");
		break;                 
	case LINEERR_INVALCALLSTATE:
		wcscpy(szErrText,L"LINEERR_INVALCALLSTATE");
		break;                  
	case LINEERR_INVALCALLSTATELIST:
		wcscpy(szErrText,L"LINEERR_INVALCALLSTATELIST");
		break;              
	case LINEERR_INVALCARD:
		wcscpy(szErrText,L"LINEERR_INVALCARD");
		break;                       
	case LINEERR_INVALCOMPLETIONID:
		wcscpy(szErrText,L"LINEERR_INVALCOMPLETIONID");
		break;               
	case LINEERR_INVALCONFCALLHANDLE:
		wcscpy(szErrText,L"LINEERR_INVALCONFCALLHANDLE");
		break;             
	case LINEERR_INVALCONSULTCALLHANDLE:
		wcscpy(szErrText,L"LINEERR_INVALCONSULTCALLHANDLE");
		break;          
	case LINEERR_INVALCOUNTRYCODE:
		wcscpy(szErrText,L"LINEERR_INVALCOUNTRYCODE");
		break;                
	case LINEERR_INVALDEVICECLASS:
		wcscpy(szErrText,L"LINEERR_INVALDEVICECLASS");
		break;                
	case LINEERR_INVALDEVICEHANDLE:
		wcscpy(szErrText,L"LINEERR_INVALDEVICEHANDLE");
		break;               
	case LINEERR_INVALDIALPARAMS:
		wcscpy(szErrText,L"LINEERR_INVALDIALPARAMS");
		break;                 
	case LINEERR_INVALDIGITLIST:
		wcscpy(szErrText,L"LINEERR_INVALDIGITLIST");
		break;                  
	case LINEERR_INVALDIGITMODE:
		wcscpy(szErrText,L"LINEERR_INVALDIGITMODE");
		break;                  
	case LINEERR_INVALDIGITS:
		wcscpy(szErrText,L"LINEERR_INVALDIGITS");
		break;                    
	case LINEERR_INVALEXTVERSION:
		wcscpy(szErrText,L"LINEERR_INVALEXTVERSION");
		break;                 
	case LINEERR_INVALGROUPID:
		wcscpy(szErrText,L"LINEERR_INVALGROUPID");
		break;                    
	case LINEERR_INVALLINEHANDLE:
		wcscpy(szErrText,L"LINEERR_INVALLINEHANDLE");
		break;                
	case LINEERR_INVALLINESTATE:
		wcscpy(szErrText,L"LINEERR_INVALLINESTATE");
		break;                  
	case LINEERR_INVALLOCATION:
		wcscpy(szErrText,L"LINEERR_INVALLOCATION");
		break;                   
	case LINEERR_INVALMEDIALIST:
		wcscpy(szErrText,L"LINEERR_INVALMEDIALIST");
		break;                  
	case LINEERR_INVALMEDIAMODE:
		wcscpy(szErrText,L"LINEERR_INVALMEDIAMODE");
		break;                  
	case LINEERR_INVALMESSAGEID:
		wcscpy(szErrText,L"LINEERR_INVALMESSAGEID");
		break;                  
	case LINEERR_INVALPARAM:
		wcscpy(szErrText,L"LINEERR_INVALPARAM");
		break;                      
	case LINEERR_INVALPARKID:
		wcscpy(szErrText,L"LINEERR_INVALPARKID");
		break;                     
	case LINEERR_INVALPARKMODE:
		wcscpy(szErrText,L"LINEERR_INVALPARKMODE");
		break;                   
	case LINEERR_INVALPOINTER:
		wcscpy(szErrText,L"LINEERR_INVALPOINTER");
		break;                    
	case LINEERR_INVALPRIVSELECT:
		wcscpy(szErrText,L"LINEERR_INVALPRIVSELECT");
		break;                 
	case LINEERR_INVALRATE:
		wcscpy(szErrText,L"LINEERR_INVALRATE");
		break;                       
	case LINEERR_INVALREQUESTMODE:
		wcscpy(szErrText,L"LINEERR_INVALREQUESTMODE");
		break;                
	case LINEERR_INVALTERMINALID:
		wcscpy(szErrText,L"LINEERR_INVALTERMINALID");
		break;                 
	case LINEERR_INVALTERMINALMODE:
		wcscpy(szErrText,L"LINEERR_INVALTERMINALMODE");
		break;               
	case LINEERR_INVALTIMEOUT:
		wcscpy(szErrText,L"LINEERR_INVALTIMEOUT");
		break;                    
	case LINEERR_INVALTONE:
		wcscpy(szErrText,L"LINEERR_INVALTONE");
		break;                       
	case LINEERR_INVALTONELIST:
		wcscpy(szErrText,L"LINEERR_INVALTONELIST");
		break;                   
	case LINEERR_INVALTONEMODE:
		wcscpy(szErrText,L"LINEERR_INVALTONEMODE");
		break;                   
	case LINEERR_INVALTRANSFERMODE:
		wcscpy(szErrText,L"LINEERR_INVALTRANSFERMODE");
		break;               
	case LINEERR_LINEMAPPERFAILED:
		wcscpy(szErrText,L"LINEERR_LINEMAPPERFAILED");
		break;                
	case LINEERR_NOCONFERENCE:
		wcscpy(szErrText,L"LINEERR_NOCONFERENCE");
		break;                    
	case LINEERR_NODEVICE:
		wcscpy(szErrText,L"LINEERR_NODEVICE");
		break;                        
	case LINEERR_NODRIVER:
		wcscpy(szErrText,L"LINEERR_NODRIVER");
		break;                        
	case LINEERR_NOMEM:
		wcscpy(szErrText,L"LINEERR_NOMEM");
		break;                           
	case LINEERR_NOREQUEST:
		wcscpy(szErrText,L"LINEERR_NOREQUEST");
		break;                       
	case LINEERR_NOTOWNER:
		wcscpy(szErrText,L"LINEERR_NOTOWNER");
		break;                        
	case LINEERR_NOTREGISTERED:
		wcscpy(szErrText,L"LINEERR_NOTREGISTERED");
		break;                   
	case LINEERR_OPERATIONFAILED:
		wcscpy(szErrText,L"LINEERR_OPERATIONFAILED");
		break;                 
	case LINEERR_OPERATIONUNAVAIL:
		wcscpy(szErrText,L"LINEERR_OPERATIONUNAVAIL");
		break;                
	case LINEERR_RATEUNAVAIL:
		wcscpy(szErrText,L"LINEERR_RATEUNAVAIL");
		break;                     
	case LINEERR_RESOURCEUNAVAIL:
		wcscpy(szErrText,L"LINEERR_RESOURCEUNAVAIL");
		break;                 
	case LINEERR_REQUESTOVERRUN:
		wcscpy(szErrText,L"LINEERR_REQUESTOVERRUN");
		break;                  
	case LINEERR_STRUCTURETOOSMALL:
		wcscpy(szErrText,L"LINEERR_STRUCTURETOOSMALL");
		break;               
	case LINEERR_TARGETNOTFOUND:
		wcscpy(szErrText,L"LINEERR_TARGETNOTFOUND");
		break;                  
	case LINEERR_TARGETSELF:
		wcscpy(szErrText,L"LINEERR_TARGETSELF");
		break;                      
	case LINEERR_UNINITIALIZED:
		wcscpy(szErrText,L"LINEERR_UNINITIALIZED");
		break;                   
	case LINEERR_USERUSERINFOTOOBIG:
		wcscpy(szErrText,L"LINEERR_USERUSERINFOTOOBIG");
		break;           
	case LINEERR_REINIT:
		wcscpy(szErrText,L"LINEERR_REINIT");
		break;
	case LINEERR_ADDRESSBLOCKED:
		wcscpy(szErrText,L"LINEERR_ADDRESSBLOCKED");
		break;
	case LINEERR_BILLINGREJECTED:
		wcscpy(szErrText,L"LINEERR_BILLINGREJECTED");
		break;
	case LINEERR_INVALFEATURE:
		wcscpy(szErrText,L"LINEERR_INVALFEATURE");
		break;
	case LINEERR_NOMULTIPLEINSTANCE:
		wcscpy(szErrText,L"LINEERR_NOMULTIPLEINSTANCE");
		break;
	case LINEERR_INVALAGENTID:
		wcscpy(szErrText,L"LINEERR_INVALAGENTID");
		break;
	case LINEERR_INVALAGENTGROUP:
		wcscpy(szErrText,L"LINEERR_INVALAGENTGROUP");
		break;
	case LINEERR_INVALPASSWORD:
		wcscpy(szErrText,L"LINEERR_INVALPASSWORD");
		break;
	case LINEERR_INVALAGENTSTATE:
		wcscpy(szErrText,L"LINEERR_INVALAGENTSTATE");
		break;
	case LINEERR_INVALAGENTACTIVITY:
		wcscpy(szErrText,L"LINEERR_INVALAGENTACTIVITY");
		break;
	case LINEERR_DIALVOICEDETECT:
		wcscpy(szErrText,L"LINEERR_DIALVOICEDETECT");
		break;
	default:
		free(szErrText);
		FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER|FORMAT_MESSAGE_FROM_SYSTEM|FORMAT_MESSAGE_IGNORE_INSERTS,NULL,nError,0,(LPTSTR)&szErrText,0,NULL);
	};
}
 
 
// TAPIPhonelDlg.h : header file
//
// Author: Srikanth Kanchari
// Include this header if you use any part of the code from this file 
/////////////////////////////////////////////////////////////////////////////
 
 
#pragma once
#include "afxwin.h"
 
// CTAPIPhonelDlg dialog
class CTAPIPhonelDlg : public CDialog
{
// Construction
public:
	CTAPIPhonelDlg(CWnd* pParent = NULL);	// standard constructor
 
	CTapiLine m_line;
// Dialog Data
	enum { IDD = IDD_TAPIPHONEL_DIALOG };
 
 
	protected:
	virtual void DoDataExchange(CDataExchange* pDX);	// DDX/DDV support
 
// Implementation
protected:
	HICON m_hIcon;
 
	// Generated message map functions
	virtual BOOL OnInitDialog();
#if defined(_DEVICE_RESOLUTION_AWARE) && !defined(WIN32_PLATFORM_WFSP)
	afx_msg void OnSize(UINT /*nType*/, int /*cx*/, int /*cy*/);
		afx_msg HRESULT OnPhone(WPARAM wParam, LPARAM lParam);
#endif
	DECLARE_MESSAGE_MAP()
public:
	afx_msg void OnBnClickedButton1();
	CListBox m_lBox;
	afx_msg void OnBnClickedButton2();
	afx_msg void OnBnClickedButton3();
};
// TAPIPhonelDlg.cpp : implementation file
//
// Author: Srikanth Kanchari
// Include this header if you use any part of the code from this file 
/////////////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "TAPIPhonel.h"
#include "TAPIPhonelDlg.h"
 
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
 
// CTAPIPhonelDlg dialog
 
CTAPIPhonelDlg::CTAPIPhonelDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CTAPIPhonelDlg::IDD, pParent)
{
	m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
 
void CTAPIPhonelDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	DDX_Control(pDX, IDC_LIST1, m_lBox);
}
 
BEGIN_MESSAGE_MAP(CTAPIPhonelDlg, CDialog)
#if defined(_DEVICE_RESOLUTION_AWARE) && !defined(WIN32_PLATFORM_WFSP)
	ON_WM_SIZE()
#endif
	//}}AFX_MSG_MAP
	ON_BN_CLICKED(IDC_BUTTON1, &CTAPIPhonelDlg::OnBnClickedButton1)
	ON_MESSAGE(WM_PHONE,CTAPIPhonelDlg::OnPhone)
	ON_BN_CLICKED(IDC_BUTTON2, &CTAPIPhonelDlg::OnBnClickedButton2)
	ON_BN_CLICKED(IDC_BUTTON3, &CTAPIPhonelDlg::OnBnClickedButton3)
 
END_MESSAGE_MAP()
 
 
// CTAPIPhonelDlg message handlers
 
BOOL CTAPIPhonelDlg::OnInitDialog()
{
	CDialog::OnInitDialog();
 
	// Set the icon for this dialog.  The framework does this automatically
	//  when the application's main window is not a dialog
	SetIcon(m_hIcon, TRUE);			// Set big icon
	SetIcon(m_hIcon, FALSE);		// Set small icon
 
 
	  m_line.PreparePhone(); 
	m_line.Open(1,true, this->GetSafeHwnd());
	// TODO: Add extra initialization here
	
	return TRUE;  // return TRUE  unless you set the focus to a control
}
void CTAPIPhonelDlg::OnBnClickedButton1()
{
	m_lBox.AddString(L"drop");
    int icount = m_lBox.GetCount();
    m_lBox.SetTopIndex(icount-1);
	
	
	m_line.HangUp();
	// TODO: Add your control notification handler code here
}
HRESULT CTAPIPhonelDlg::OnPhone(WPARAM wParam, LPARAM lParam)
{
   int icount;
   CString szins;
	switch(wParam)
   {
   case CTapiLine::line_offering:
	    szins = L"offerring";
   break;
   case CTapiLine::line_callerid:
	    szins = (TCHAR*)lParam;
  
   break;
   case CTapiLine::line_connected:
	    szins = L"connected";
   break;
   case CTapiLine::line_disconnected:
	   szins = L"disconnected";
   break;
 
   case CTapiLine::line_dialing:
	   szins = L"line dialing";
   break;
   case CTapiLine::line_dialtone:
       szins = L"line tone";
	   break;
   case CTapiLine::line_proceeding:
	   szins = L"line proceeding";
	   break;
   case CTapiLine::line_ringback:
	   szins = L"line ringback";
   break;
   case CTapiLine::line_default:
	   szins = L"line default";
	   break;
   default:
	   szins = L"nix passiert";
   break;
 
   }
 
   m_lBox.AddString(szins);
    icount = m_lBox.GetCount();
    m_lBox.SetTopIndex(icount-1);
	
   
   UpdateData(FALSE);
 
 
 return true;
}
void CTAPIPhonelDlg::OnBnClickedButton2()
{
	m_lBox.AddString(L"answer");
    int icount = m_lBox.GetCount();
    m_lBox.SetTopIndex(icount-1);
	
	
	m_line.AnswerCall();
	
	// TODO: Add your control notification handler code here
}
 
void CTAPIPhonelDlg::OnBnClickedButton3()
{
	m_line.MakeOutgoingCall(L"9811270686");
	// TODO: Add your control notification handler code here
}
#if defined(_DEVICE_RESOLUTION_AWARE) && !defined(WIN32_PLATFORM_WFSP)
void CTAPIPhonelDlg::OnSize(UINT /*nType*/, int /*cx*/, int /*cy*/)
{
	if (AfxIsDRAEnabled())
	{
		DRA::RelayoutDialog(
			AfxGetResourceHandle(), 
			this->m_hWnd, 
			DRA::GetDisplayMode() != DRA::Portrait ? 
			MAKEINTRESOURCE(IDD_TAPIPHONEL_DIALOG_WIDE) : 
			MAKEINTRESOURCE(IDD_TAPIPHONEL_DIALOG));
	}
}
#endif
                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
145:
146:
147:
148:
149:
150:
151:
152:
153:
154:
155:
156:
157:
158:
159:
160:
161:
162:
163:
164:
165:
166:
167:
168:
169:
170:
171:
172:
173:
174:
175:
176:
177:
178:
179:
180:
181:
182:
183:
184:
185:
186:
187:
188:
189:
190:
191:
192:
193:
194:
195:
196:
197:
198:
199:
200:
201:
202:
203:
204:
205:
206:
207:
208:
209:
210:
211:
212:
213:
214:
215:
216:
217:
218:
219:
220:
221:
222:
223:
224:
225:
226:
227:
228:
229:
230:
231:
232:
233:
234:
235:
236:
237:
238:
239:
240:
241:
242:
243:
244:
245:
246:
247:
248:
249:
250:
251:
252:
253:
254:
255:
256:
257:
258:
259:
260:
261:
262:
263:
264:
265:
266:
267:
268:
269:
270:
271:
272:
273:
274:
275:
276:
277:
278:
279:
280:
281:
282:
283:
284:
285:
286:
287:
288:
289:
290:
291:
292:
293:
294:
295:
296:
297:
298:
299:
300:
301:
302:
303:
304:
305:
306:
307:
308:
309:
310:
311:
312:
313:
314:
315:
316:
317:
318:
319:
320:
321:
322:
323:
324:
325:
326:
327:
328:
329:
330:
331:
332:
333:
334:
335:
336:
337:
338:
339:
340:
341:
342:
343:
344:
345:
346:
347:
348:
349:
350:
351:
352:
353:
354:
355:
356:
357:
358:
359:
360:
361:
362:
363:
364:
365:
366:
367:
368:
369:
370:
371:
372:
373:
374:
375:
376:
377:
378:
379:
380:
381:
382:
383:
384:
385:
386:
387:
388:
389:
390:
391:
392:
393:
394:
395:
396:
397:
398:
399:
400:
401:
402:
403:
404:
405:
406:
407:
408:
409:
410:
411:
412:
413:
414:
415:
416:
417:
418:
419:
420:
421:
422:
423:
424:
425:
426:
427:
428:
429:
430:
431:
432:
433:
434:
435:
436:
437:
438:
439:
440:
441:
442:
443:
444:
445:
446:
447:
448:
449:
450:
451:
452:
453:
454:
455:
456:
457:
458:
459:
460:
461:
462:
463:
464:
465:
466:
467:
468:
469:
470:
471:
472:
473:
474:
475:
476:
477:
478:
479:
480:
481:
482:
483:
484:
485:
486:
487:
488:
489:
490:
491:
492:
493:
494:
495:
496:
497:
498:
499:
500:
501:
502:
503:
504:
505:
506:
507:
508:
509:
510:
511:
512:
513:
514:
515:
516:
517:
518:
519:
520:
521:
522:
523:
524:
525:
526:
527:
528:
529:
530:
531:
532:
533:
534:
535:
536:
537:
538:
539:
540:
541:
542:
543:
544:
545:
546:
547:
548:
549:
550:
551:
552:
553:
554:
555:
556:
557:
558:
559:
560:
561:
562:
563:
564:
565:
566:
567:
568:
569:
570:
571:
572:
573:
574:
575:
576:
577:
578:
579:
580:
581:
582:
583:
584:
585:
586:
587:
588:
589:
590:
591:
592:
593:
594:
595:
596:
597:
598:
599:
600:
601:
602:
603:
604:
605:
606:
607:
608:
609:
610:
611:
612:
613:
614:
615:
616:
617:
618:
619:
620:
621:
622:
623:
624:
625:
626:
627:
628:
629:
630:
631:
632:
633:
634:
635:
636:
637:
638:
639:
640:
641:
642:
643:
644:
645:
646:
647:
648:
649:
650:
651:
652:
653:
654:
655:
656:
657:
658:
659:
660:
661:
662:
663:
664:
665:
666:
667:
668:
669:
670:
671:
672:
673:
674:
675:
676:
677:
678:
679:
680:
681:
682:
683:
684:
685:
686:
687:
688:
689:
690:
691:
692:
693:
694:
695:
696:
697:
698:
699:
700:
701:
702:
703:
704:
705:
706:
707:
708:
709:
710:
711:
712:
713:
714:
715:
716:
717:
718:
719:
720:
721:
722:
723:
724:
725:
726:
727:
728:
729:
730:
731:
732:
733:
734:
735:
736:
737:
738:
739:
740:
741:
742:
743:
744:
745:
746:
747:
748:
749:
750:
751:
752:
753:
754:
755:
756:
757:
758:
759:
760:
761:
762:
763:
764:
765:
766:
767:
768:
769:
770:
771:
772:
773:
774:
775:
776:
777:
778:
779:
780:
781:
782:
783:
784:
785:
786:
787:
788:
789:
790:
791:
792:
793:
794:
795:
796:
797:
798:
799:
800:
801:
802:
803:
804:
805:
806:
807:
808:
809:
810:
811:
812:
813:
814:
815:
816:
817:
818:
819:
820:
821:
822:
823:
824:
825:
826:
827:
828:
829:
830:
831:
832:
833:
834:
835:
836:
837:
838:
839:
840:
841:
842:
843:
844:
845:
846:
847:
848:
849:
850:
851:
852:
853:
854:
855:
856:
857:
858:
859:
860:
861:
862:
863:
864:
865:
866:
867:
868:
869:
870:
871:
872:
873:
874:
875:
876:
877:
878:
879:
880:
881:
882:
883:
884:
885:
886:
887:
888:
889:
890:
891:
892:
893:
894:
895:
896:
897:
898:
899:
900:
901:
902:
903:
904:
905:
906:
907:
908:
909:
910:
911:
912:
913:
914:
915:
916:
917:
918:
919:
920:
921:
922:
923:
924:
925:
926:
927:
928:
929:
930:
931:
932:
933:
934:
935:
936:
937:
938:
939:
940:
941:
942:
943:
944:
945:
946:
947:
948:
949:
950:
951:
952:
953:
954:
955:
956:
957:
958:
959:
960:
961:
962:
963:
964:
965:
966:
967:
968:
969:
970:
971:
972:
973:
974:
975:
976:
977:
978:
979:
980:
981:
982:
983:
984:
985:
986:
987:
988:
989:
990:
991:
992:
993:
994:
995:
996:
997:
998:
999:
1000:
1001:
1002:
1003:
1004:
1005:
1006:
1007:
1008:
1009:
1010:
1011:
1012:
1013:
1014:
1015:
1016:
1017:
1018:
1019:
1020:
1021:
1022:
1023:
1024:
1025:
1026:
1027:
1028:
1029:
1030:
1031:
1032:
1033:
1034:
1035:
1036:
1037:
1038:
1039:
1040:
1041:
1042:
1043:
1044:
1045:
1046:
1047:
1048:
1049:
1050:
1051:
1052:
1053:
1054:
1055:
1056:
1057:
1058:
1059:
1060:
1061:
1062:
1063:
1064:
1065:
1066:
1067:
1068:
1069:
1070:
1071:
1072:
1073:
1074:
1075:
1076:
1077:
1078:
1079:
1080:
1081:
1082:
1083:
1084:
1085:
1086:
1087:
1088:
1089:
1090:
1091:
1092:
1093:
1094:
1095:
1096:
1097:
1098:
1099:
1100:
1101:
1102:
1103:
1104:
1105:
1106:
1107:
1108:
1109:
1110:
1111:
1112:
1113:
1114:
1115:
1116:
1117:
1118:
1119:
1120:
1121:
1122:
1123:
1124:
1125:
1126:
1127:
1128:
1129:
1130:
1131:
1132:
1133:
1134:
1135:
1136:
1137:
1138:
1139:
1140:
1141:
1142:
1143:
1144:
1145:
1146:
1147:
1148:
1149:
1150:
1151:
1152:
1153:
1154:
1155:
1156:
1157:
1158:
1159:
1160:
1161:
1162:
1163:
1164:
1165:
1166:
1167:
1168:
1169:
1170:
1171:
1172:
1173:
1174:
1175:
1176:
1177:
1178:
1179:
1180:
1181:
1182:
1183:
1184:
1185:
1186:
1187:
1188:
1189:
1190:
1191:
1192:
1193:
1194:

Select allOpen in new window

 

by: srikanthkanchariPosted on 2009-09-08 at 12:48:49ID: 25285494

#define WM_PHONE WM_USER +1231
if you have any more questions , do post me

20120131-EE-VQP-002

3 Ways to Join

30-Day Free Trial

The Experts

98% positive feedback on 31,087 answers since March 2000. angeliii is a Microsoft Most Valuable Professional for his work with MS SQL Server & Develoment.

He has also proven his knowledge of Visual Basic Programming, PHP Scripting and Oracle Databases.

The Experts

97% positive feedback on 10,752 answers since July 2000. lrmoore has more than 18 years experience in the networking industry.

The six-time Mircosoft MVPs specialties include firewalls, virtual private networking, and network management.

Testimonials

"...and excellent source for support... Kind of like having your very own IT dept." Electriciansnet

Testimonials

"I was apprehensive at signing up at first. However... it has already made my life as an IT administrator much easier." JaCrews

Testimonials

"WOW! You guys have great, active, and knowledgeable people on here." moore50

Business Clients

Business Clients

In the Press

"If you’ve got a question... Experts Exchange can supply an answer.”

In the Press

"...an invaluable aid for both IT professionals and those who require tech support."

In the Press

"where IT professionals provide quick answers on just about any topic"

Business Account Plans

Loading Advertisement...