When developing an incoming call firewall or incoming call daemon, you must first intercept incoming calls and analyze them. The method to intercept incoming calls is generally the API functions provided by TAPI. These functions are used in TAPI. h.
1. initialize the line and open the line
DWORD linehandlecount;
Hline * linehandles;
Hlineapp lineapp;
If (lineinitialize (& lineapp, theapp. m_hinstance, (linecallback) linecallback, l "video", & linehandlecount) = 0)
{
Linehandles = new hline [linehandlecount];
For (DWORD I = 0; I <linehandlecount; I ++)
{
Int RC;
DWORD ver;
Lineextensionid extensionid;
If (linenegotiateapiversion (lineapp, I, 0x00010000, 0x00020000, & Ver, & extensionid) = 0)
{
Rc = lineopen (lineapp, I, & linehandles [I], Ver, 0, (DWORD) 0, linecallprivilege_monitor | linecallprivilege_owner, linemediamode_interactivevoice, null );
}
}
}
2. Compile the callback function to implement the function in this function.
Void callback linecallback (DWORD hdevice, DWORD dwmsg, DWORD dwcallbackinstance, DWORD dwparam1, DWORD dwparam2, DWORD dwparam3)
{
// Dwmsg is a line message
// Dwparam1 and dwparam2 are specific events
}
3. When it endsProgramClose the line
For (DWORD I = 0; I <linehandlecount; I ++)
Lineclose (linehandles [I]);
Delete [] linehandles;
Lineshudown (lineapp );