TAPI program design (TAPI API) under Windows WITL (Telephony API) is a specification that Intel and Microsoft to control the phone communication for the computer, and the highest TAPI version of all version of Windows basically support. First, the detail below: Windows version TAPI C / C API 16bit TAPI C / C API 32bit TAPI COM / COM API WINDOWS 3.1 1.3 (TAPI 1.0) N / A N / A Windows 95 / OSR2 Windows 98 1.4 (TAPI 1.4) 2.0 for 32 bit. (95 Need to Install Tapi 2.x To Support Tapi 2.0) N / A Windows NT 4.0 2.0 Windows XP 2.3 3.1 The TAPI programming concept below is set over TAPI 2.x Some of the part, 3.x is COM / COM , more complicated.
Because the tool used is Delphi, Delphi itself does not have a built-in TAPI function declaration, here, I use OpenSource's Project Jedi TAPI declaration file, as the Delphi declaration of this program. Detailed download path is ftp://delphi-jedi.org/api/tapi.zip
If you have other Win32 APIs that Win32 API you want to write in the original Delphi, you can also go to Project Jedi to see if there is a warm program designer, which has helped you to convert a good declaration. Website is http://www.delphi -jedi.org/jedi :HomePage:0, but inologumes In order to facilitate the introduction of TAPI functions, all functions are declared (except Callback), which is still in accordance with Microsoft in Tapi32.h, and did not change to Delphi. Form.
Assisted Telephony Function
In the call TAPI program, it can be divided into simplified Assisted Telephony Function (hereinafter referred to as ATF) and a relatively complete formal TAPI program.
ATF can be used in a PIM software, etc., simply only want to make a simple dialing action, in the Win32 system, only two functions belong to ATF,
TapirequestMakeCall requires a telephone number to all.
TapiGetLocationInfo achieves current country and program settings
In Windows 3.1 has two other ATF functions, currently no longer support in the Win32 environment
TapirequestmediacAcon requires all multimedia phones
TapirequestDrop requires a dial-out program to hang up
Long TapirequestMakeCall (LPCSTR LPSZDESTADRALL (LPCSTR LPSZAPPNAME, LPCSTR LPSZCALLEDPARTY, LPCSTR LPSZCOMMENT);
When you call the TapirequestMakeCall this API, you will call the computer that is responsible for dialing, starting dialing action, using Windows 95/98 / ME / NT 4 / 2K / XP as an example, is a Phone Dialr. To handle the entire outlet action.
Long TapiGetLocationInfo (LPCSTR LPSZCOUNTRY, / / 8-byte buffer lpcstr lpszcitycode // 8-byte buffer);
TapiGetLocationInfo is a very simple to achieve the current Windows country setting and program of the telephone, which is more important for notebooks that will move in different words. Because of the settings, TAPI can be judged, should be What kind of way to call .Generic Telephony Function, through the ATF, you can make a very simple computer-dial phone, but for a general telephone response, or a telephone transfer system, these is not enough.
The general TAPI program does not simply control the line through the ATF, and usually use more complicated ways. We have to start the TAPI before calling any TAPI function. We must TAPI pointed out a callback function for TAPI to use some events when returning some events, the Callback function C / C protest is
Void Far Pascal LineCallbackFunc (DWORD HDEvice, DWORD DWMSG, DWORD DWCALLBACKINSTANCE, DWORD DWPARAM1, DWORD DWPARAM2, DWORD DWPARAM3);
The original shape translated in JEDI is.
PROCEDURE LINECALLBACK (HDevice, dwmessage: dword; dwinstance, dwparam1, dwparam2, dwparam3: dword_ptr) stdcall;
After writing a simple LineCallback function, we can call the start TAPI function. TAPI 1.3 / 1.4 (Generally used for Windows 95/98) The function used by LineInitialize
Long LineInitialize (LPHlineApp LPhlineApp, Hinstance Hinstance, LineCallback LPFNCALLBACK, LPCSTR LPSZAPNAME, LPDWORD LPDWNUMDEVS);
LineInitializeex must be used after TAPI 2.x
LONG lineInitializeEx (LPHLINEAPP lphLineApp, HINSTANCE hInstance, LINECALLBACK lpfnCallback, LPCSTR lpszFriendlyAppName, LPDWORD lpdwNumDevs, LPDWORD lpdwAPIVersion, LPLINEINITIALIZEEXPARAMS lpLineInitializeExParams);
After the operation of TAPI start, all events are sent to the Callback function, and we will acquire, the current sum of the lines available, and the number of TAPI Application (LPHLINEAPP). After the start of TAPI, all The TAPI program has to be a version coordination (Negotiation) action. Basic program may support TAPI 1.3 / 1.4 / 2.0, original Windows 95 support TAPI 1.3 / 1.4, if used, the driver TSP (Telephony Service Provider) support TAPI 1.3, the last coordinated version is 1.3.
Since the driver version of each line may be provided by different vendors, the highest version of each line can be operated in practice is not necessarily the same.
For example, the Windows 2000SP2 Pro Admore Talks 4G of my computer is an example, the return version is as follows.
Get Device Caps: 0 VERSION: 00010003 LineName: RAS VPN line 0Get Device Caps: 1 VERSION: 00020002 LineName: WAN mini port (L2TP) Get Device Caps: 2 VERSION: 00020002 LineName: LPT1TGet Device Caps: 3 VERSION: 00020002 LineName: IPCONF line Get Device Caps: 4 VERSION: 00020002 LineName: H323 line Get Device Caps: 5 VERSION: 00020000 LineName: Talks Plus Line1Get Device Caps: 6 VERSION: 00020000 LineName: Talks Plus Line2Get Device Caps: 7 VERSION: 00020000 LineName: Talks Plus Line3Get Device Caps: 8 Version: 00020000 LINENAME: TALKS PLUS LINE4 version of the reading is 00020000 is version 2.0, 00020001 is version 2.3, the reasonable 00010003 is version 1.3, when you know the highest TAPI version supported by each line, we will The TAPI function that can be used and the type of TAPI can be used can be determined in accordance with the feature of this version. If the line supports the TAPI version. If you want to know the characteristics of the line and the line name, the manufacturer is provided, you must call LinegetDevCaps. In the call LinegetDevCaps, first introducing a multi-function that TAPIs uses a data structure VLS (Variable length structure), in TAPI, due to some of the information, but the length is not necessarily, so TAPI uses one Dynamic operational data structure manages how dynamic length strings are placed in a fixed space. So some functions use VLS to pass into the size of the buffer, and then determine how to place it by the underlying TSP The space of the whole string. For example, we have to take the LineName in PLINEDEVCAPS
Displace Attribute Value 0 .... Dwlinenamesize 18 dwlinenameoffset 292 ... 292 RAS VPN line 0 We can take this shift by displacement, take Delphi as an example.
procedure TfrmMain.GetDeviceCaps (nNumber: Integer); const STR_SIZE = 1023; var LDC: PLineDevCaps; Buffer: array [0..STR_SIZE] of char; iCounter: integer; StrPointer: PChar; Buffer2: array [0..STR_SIZE] of CHAR; Begin / / Remove the entire Buffer information for iCOUNTER: = 0 to str_size do buffer [iCOUNTER]: = char (0);
// Align the starting point of the two indicators LDC: = @Buffer; // Fill in buffer size. Ldc.dwtotalsize: = str_size; logstring ('get device Caps:' INTOSTR (NRETURN: = LinegetDevcaps (LineApp) , NNumber, Tapiversion, 0, LDC);
// Function Success if (nreturn = 0) THEN BEGIN
StrPointer: = @Buffer [LDC.dwLineNameOffset]; StrCopy (Buffer2, 'LineName:'); StrCat (Buffer2, StrPointer); LogString (Buffer2); end else begin LogString ( 'Line Get Device Caps Error:' LineErrorStateToStr (nReturn )); End; logstring ('');
C / C can also get information on the length of change in a similar manner, in the entire TAPI 2.x, such VLS functions, usually in the entire return data type, will set the size of the entire buffer After filling DWTOTALSIZE, and if necessary, TAPI will prepare the return information. When using TAPI, I will prepare two examples here is a foreign dial. After using LineOpen, after opening a line, use linemakecall to dial A phone. When you accept the dial, you will modify the parameters of LineOpen, use the monitoring method to prepare. LINESETSTATUSMESSAGE is a Message (current full monitoring) that is wanting to monitor, and other movements are concentrated in the callback function. deal with .