{*******************************************************}
{                                                       }
{       nrCommLib Communication Library for Delphi      }
{       Win32 Telephone API definitions (VCL)           }
{       Copyright (c) 1997-2011 Roman Novgorodov        }
{       v9.27                                           }
{       last update: 6 Dec 2006                         }
{                                                       }
{       e-mail:noro@deepsoftware.com                    }
{       DeepSoftware                                    }
{       http://www.deepsoftware.com/                    }
{                                                       }
{*******************************************************}
{$I nrcommlib.inc}

//{$IFDEF WIN32}
{$DEFINE TAPI30}
{$DEFINE TAPI22}
{$DEFINE TAPI21}
{$DEFINE TAPI20}
//{$ENDIF}

{$A-}

unit nrtapi;

interface
uses sysutils,Messages,{$IFDEF WIN32} Windows;{$ELSE} WinTypes;

type
        WPARAM = Word;
        HInst = THandle;
{$ENDIF}

const

{$IFDEF TAPI30}
  TAPI_CURRENT_VERSION = $00030000;
{$ELSE}
{$IFDEF TAPI22}
  TAPI_CURRENT_VERSION = $00020002;
{$ELSE}
{$IFDEF TAPI20}
  TAPI_CURRENT_VERSION = $00020000;
{$ELSE}
  TAPI_CURRENT_VERSION = $00010004;
{$ENDIF}
{$ENDIF}
{$ENDIF}
{ #pragma pack(1) }

{ Type definitions of the data types used in tapi }

type
  LPHCall = ^THCall;
  THCall = Longint;
  LPHLine = ^THLine;
  THLine = Longint;
  LPHPhone = ^THPhone;
  THPhone = Longint;
  LPHLineApp = ^THLineApp;
  THLineApp = Longint;
	LPHPhoneApp = ^THPhoneApp;
  THPhoneApp = Longint;

  LPHIcon = ^HIcon;

{$IFDEF TAPI30}
  THHCallHub=Longint;                      // TAPI v3.0
  LPHCALLHUB=^THHCallHub;                  // TAPI v3.0
{$ENDIF}

{$IFDEF TAPI22}
  THAgentSession=Longint;                  // TAPI v2.2
  LPHAGENTSESSION=^THAgentSession;         // TAPI v2.2
  THAgent = Longint;
  LPHAGENT = ^THAgent;
{$ENDIF}

{$IFDEF TAPI30}
  THPrivateChannel=longint;                // TAPI v3.0
  LPHPRIVATECHANNEL=^THPrivateChannel;     // TAPI v3.0
{$ENDIF}



TLineCallback = procedure(hDevice, dwMessage, dwInstance,
		dwParam1, dwParam2, dwParam3: Longint);
{$IFDEF WIN32}
		stdcall;
{$ENDIF}
TPhoneCallback = procedure(hDevice, dwMessage, dwInstance,
		dwParam1, dwParam2, dwParam3: Longint);
{$IFDEF WIN32}
		stdcall;
{$ENDIF}

{ Messages for Phones and Lines }

const
  LINE_ADDRESSSTATE                       = 0;
  LINE_CALLINFO                           = 1;
  LINE_CALLSTATE                          = 2;
  LINE_CLOSE                              = 3;
  LINE_DEVSPECIFIC                        = 4;
  LINE_DEVSPECIFICFEATURE                 = 5;
  LINE_GATHERDIGITS                       = 6;
  LINE_GENERATE                           = 7;
  LINE_LINEDEVSTATE                       = 8;
  LINE_MONITORDIGITS                      = 9;
  LINE_MONITORMEDIA                       = 10;
  LINE_MONITORTONE                        = 11;
  LINE_REPLY                              = 12;
  LINE_REQUEST                            = 13;
  PHONE_BUTTON                            = 14;
  PHONE_CLOSE                             = 15;
  PHONE_DEVSPECIFIC                       = 16;
  PHONE_REPLY                             = 17;
  PHONE_STATE                             = 18;
  LINE_CREATE                             = 19;             { TAPI v1.4 }
  PHONE_CREATE                            = 20;             { TAPI v1.4 }
{$IFDEF TAPI20}
  LINE_AGENTSPECIFIC                      = 21;             { TAPI v2.0 }
  LINE_AGENTSTATUS                        = 22;             { TAPI v2.0 }
  LINE_APPNEWCALL                         = 23;             { TAPI v2.0 }
  LINE_PROXYREQUEST                       = 24;             { TAPI v2.0 }
  LINE_REMOVE                             = 25;             { TAPI v2.0 }
  PHONE_REMOVE                            = 26;             { TAPI v2.0 }
{$ENDIF}
{$IFDEF TAPI22}
  LINE_AGENTSESSIONSTATUS                 =27;             { TAPI v2.2}
  LINE_QUEUESTATUS                        =28;             { TAPI v2.2}
  LINE_AGENTSTATUSEX                      =29;             { TAPI v2.2}
  LINE_GROUPSTATUS                        =30;             { TAPI v2.2}
  LINE_PROXYSTATUS                        =31;             { TAPI v2.2}
{$ENDIF}
{$IFDEF TAPI30}
  LINE_APPNEWCALLHUB                      =32;             { TAPI v3.0}
  LINE_CALLHUBCLOSE                       =33;             { TAPI v3.0}
  LINE_DEVSPECIFICEX                      =34;             { TAPI v3.0}
{$ENDIF}



  INITIALIZE_NEGOTIATION                  = $FFFFFFFF;

  LINEADDRCAPFLAGS_FWDNUMRINGS            = $00000001;
  LINEADDRCAPFLAGS_PICKUPGROUPID          = $00000002;
  LINEADDRCAPFLAGS_SECURE                 = $00000004;
  LINEADDRCAPFLAGS_BLOCKIDDEFAULT         = $00000008;
  LINEADDRCAPFLAGS_BLOCKIDOVERRIDE        = $00000010;
  LINEADDRCAPFLAGS_DIALED                 = $00000020;
  LINEADDRCAPFLAGS_ORIGOFFHOOK            = $00000040;
  LINEADDRCAPFLAGS_DESTOFFHOOK            = $00000080;
  LINEADDRCAPFLAGS_FWDCONSULT             = $00000100;
  LINEADDRCAPFLAGS_SETUPCONFNULL          = $00000200;
  LINEADDRCAPFLAGS_AUTORECONNECT          = $00000400;
  LINEADDRCAPFLAGS_COMPLETIONID           = $00000800;
  LINEADDRCAPFLAGS_TRANSFERHELD           = $00001000;
  LINEADDRCAPFLAGS_TRANSFERMAKE           = $00002000;
  LINEADDRCAPFLAGS_CONFERENCEHELD         = $00004000;
  LINEADDRCAPFLAGS_CONFERENCEMAKE         = $00008000;
  LINEADDRCAPFLAGS_PARTIALDIAL            = $00010000;
  LINEADDRCAPFLAGS_FWDSTATUSVALID         = $00020000;
  LINEADDRCAPFLAGS_FWDINTEXTADDR          = $00040000;
  LINEADDRCAPFLAGS_FWDBUSYNAADDR          = $00080000;
  LINEADDRCAPFLAGS_ACCEPTTOALERT          = $00100000;
  LINEADDRCAPFLAGS_CONFDROP               = $00200000;
  LINEADDRCAPFLAGS_PICKUPCALLWAIT         = $00400000;
{$IFDEF TAPI20}
  LINEADDRCAPFLAGS_PREDICTIVEDIALER       = $00800000;      { TAPI v2.0 }
  LINEADDRCAPFLAGS_QUEUE                  = $01000000;      { TAPI v2.0 }
  LINEADDRCAPFLAGS_ROUTEPOINT             = $02000000;      { TAPI v2.0 }
  LINEADDRCAPFLAGS_HOLDMAKESNEW           = $04000000;      { TAPI v2.0 }
  LINEADDRCAPFLAGS_NOINTERNALCALLS        = $08000000;      { TAPI v2.0 }
  LINEADDRCAPFLAGS_NOEXTERNALCALLS        = $10000000;      { TAPI v2.0 }
  LINEADDRCAPFLAGS_SETCALLINGID           = $20000000;      { TAPI v2.0 }
{$ENDIF}
{$IFDEF TAPI22}
  LINEADDRCAPFLAGS_ACDGROUP               = $40000000;      { TAPI v2.2 }
{$ENDIF}
{$IFDEF TAPI30}
  LINEADDRCAPFLAGS_NOPSTNADDRESSTRANSLATION =$80000000;      { TAPI v3.0 }
{$ENDIF}

  LINEADDRESSMODE_ADDRESSID               = $00000001;
  LINEADDRESSMODE_DIALABLEADDR            = $00000002;

  LINEADDRESSSHARING_PRIVATE              = $00000001;
  LINEADDRESSSHARING_BRIDGEDEXCL          = $00000002;
  LINEADDRESSSHARING_BRIDGEDNEW           = $00000004;
  LINEADDRESSSHARING_BRIDGEDSHARED        = $00000008;
  LINEADDRESSSHARING_MONITORED            = $00000010;

  LINEADDRESSSTATE_OTHER                  = $00000001;
  LINEADDRESSSTATE_DEVSPECIFIC            = $00000002;
  LINEADDRESSSTATE_INUSEZERO              = $00000004;
  LINEADDRESSSTATE_INUSEONE               = $00000008;
  LINEADDRESSSTATE_INUSEMANY              = $00000010;
  LINEADDRESSSTATE_NUMCALLS               = $00000020;
  LINEADDRESSSTATE_FORWARD                = $00000040;
  LINEADDRESSSTATE_TERMINALS              = $00000080;
  LINEADDRESSSTATE_CAPSCHANGE             = $00000100;      { TAPI v1.4 }
{$IFDEF TAPI30}
  LINEADDRESSTYPE_PHONENUMBER             =$00000001;       { TAPI v3.0 }
  LINEADDRESSTYPE_SDP                     =$00000002;       { TAPI v3.0 }
  LINEADDRESSTYPE_EMAILNAME               =$00000004;       { TAPI v3.0 }
  LINEADDRESSTYPE_DOMAINNAME              =$00000008;       { TAPI v3.0 }
  LINEADDRESSTYPE_IPADDRESS               =$00000010;       { TAPI v3.0 }
{$ENDIF}

  LINEADDRFEATURE_FORWARD                 = $00000001;
  LINEADDRFEATURE_MAKECALL                = $00000002;
  LINEADDRFEATURE_PICKUP                  = $00000004;
  LINEADDRFEATURE_SETMEDIACONTROL         = $00000008;
  LINEADDRFEATURE_SETTERMINAL             = $00000010;
  LINEADDRFEATURE_SETUPCONF               = $00000020;
  LINEADDRFEATURE_UNCOMPLETECALL          = $00000040;
  LINEADDRFEATURE_UNPARK                  = $00000080;
{$IFDEF TAPI20}
  LINEADDRFEATURE_PICKUPHELD              = $00000100;      { TAPI v2.0 }
  LINEADDRFEATURE_PICKUPGROUP             = $00000200;      { TAPI v2.0 }
  LINEADDRFEATURE_PICKUPDIRECT            = $00000400;      { TAPI v2.0 }
  LINEADDRFEATURE_PICKUPWAITING           = $00000800;      { TAPI v2.0 }
  LINEADDRFEATURE_FORWARDFWD              = $00001000;      { TAPI v2.0 }
  LINEADDRFEATURE_FORWARDDND              = $00002000;      { TAPI v2.0 }
{$ENDIF}

{$IFDEF TAPI20}
  LINEAGENTFEATURE_SETAGENTGROUP          = $00000001;      { TAPI v2.0 }
  LINEAGENTFEATURE_SETAGENTSTATE          = $00000002;      { TAPI v2.0 }
  LINEAGENTFEATURE_SETAGENTACTIVITY       = $00000004;      { TAPI v2.0 }
  LINEAGENTFEATURE_AGENTSPECIFIC          = $00000008;      { TAPI v2.0 }
  LINEAGENTFEATURE_GETAGENTACTIVITYLIST   = $00000010;      { TAPI v2.0 }
  LINEAGENTFEATURE_GETAGENTGROUP          = $00000020;      { TAPI v2.0 }

  LINEAGENTSTATE_LOGGEDOFF                = $00000001;      { TAPI v2.0 }
  LINEAGENTSTATE_NOTREADY                 = $00000002;      { TAPI v2.0 }
  LINEAGENTSTATE_READY                    = $00000004;      { TAPI v2.0 }
  LINEAGENTSTATE_BUSYACD                  = $00000008;      { TAPI v2.0 }
  LINEAGENTSTATE_BUSYINCOMING             = $00000010;      { TAPI v2.0 }
  LINEAGENTSTATE_BUSYOUTBOUND             = $00000020;      { TAPI v2.0 }
  LINEAGENTSTATE_BUSYOTHER                = $00000040;      { TAPI v2.0 }
  LINEAGENTSTATE_WORKINGAFTERCALL         = $00000080;      { TAPI v2.0 }
  LINEAGENTSTATE_UNKNOWN                  = $00000100;      { TAPI v2.0 }
  LINEAGENTSTATE_UNAVAIL                  = $00000200;      { TAPI v2.0 }

  LINEAGENTSTATUS_GROUP                   = $00000001;      { TAPI v2.0 }
  LINEAGENTSTATUS_STATE                   = $00000002;      { TAPI v2.0 }
  LINEAGENTSTATUS_NEXTSTATE               = $00000004;      { TAPI v2.0 }
  LINEAGENTSTATUS_ACTIVITY                = $00000008;      { TAPI v2.0 }
  LINEAGENTSTATUS_ACTIVITYLIST            = $00000010;      { TAPI v2.0 }
  LINEAGENTSTATUS_GROUPLIST               = $00000020;      { TAPI v2.0 }
  LINEAGENTSTATUS_CAPSCHANGE              = $00000040;      { TAPI v2.0 }
  LINEAGENTSTATUS_VALIDSTATES             = $00000080;      { TAPI v2.0 }
  LINEAGENTSTATUS_VALIDNEXTSTATES         = $00000100;      { TAPI v2.0 }
{$ENDIF}


{$IFDEF TAPI22}
  LINEAGENTSTATEEX_NOTREADY               = $00000001;      // TAPI v2.2
  LINEAGENTSTATEEX_READY                  = $00000002;      // TAPI v2.2
  LINEAGENTSTATEEX_BUSYACD                = $00000004;      // TAPI v2.2
  LINEAGENTSTATEEX_BUSYINCOMING           = $00000008;      // TAPI v2.2
  LINEAGENTSTATEEX_BUSYOUTGOING           = $00000010;      // TAPI v2.2
  LINEAGENTSTATEEX_UNKNOWN                = $00000020;      // TAPI v2.2
  LINEAGENTSTATEEX_RELEASED               = $00000040;      // TAPI v2.2

  LINEAGENTSTATUSEX_NEWAGENT              = $00000001;      // TAPI v2.2
  LINEAGENTSTATUSEX_STATE                 = $00000002;      // TAPI v2.2
  LINEAGENTSTATUSEX_UPDATEINFO            = $00000004;      // TAPI v2.2
//  LINEAGENTSTATUSEX_DESTROYED             = $00000004      // TAPI v2.2

  LINEAGENTSESSIONSTATE_NOTREADY          = $00000001;      // TAPI v2.2
  LINEAGENTSESSIONSTATE_READY             = $00000002;      // TAPI v2.2
  LINEAGENTSESSIONSTATE_BUSYONCALL        = $00000004;      // TAPI v2.2
  LINEAGENTSESSIONSTATE_BUSYWRAPUP        = $00000008;      // TAPI v2.2
  LINEAGENTSESSIONSTATE_ENDED             = $00000010;      // TAPI v2.2
  LINEAGENTSESSIONSTATE_RELEASED          = $00000020;      // TAPI v2.2

  LINEAGENTSESSIONSTATUS_NEWSESSION       = $00000001;      // TAPI v2.2
  LINEAGENTSESSIONSTATUS_STATE            = $00000002;      // TAPI v2.2
  LINEAGENTSESSIONSTATUS_UPDATEINFO       = $00000004;      // TAPI v2.2

  LINEQUEUESTATUS_UPDATEINFO              = $00000001;      // TAPI v2.2
  LINEQUEUESTATUS_NEWQUEUE                = $00000002;      // TAPI v2.2
  LINEQUEUESTATUS_QUEUEREMOVED            = $00000004;      // TAPI v2.2

  LINEGROUPSTATUS_NEWGROUP                = $00000001;      // TAPI v2.2
  LINEGROUPSTATUS_GROUPREMOVED            = $00000002;      // TAPI v2.2

  LINEPROXYSTATUS_OPEN                    = $00000001;      // TAPI v2.2
  LINEPROXYSTATUS_CLOSE                   = $00000002;      // TAPI v2.2
  LINEPROXYSTATUS_ALLOPENFORACD           = $00000004;      // TAPI v2.2
{$ENDIF}


  LINEANSWERMODE_NONE                     = $00000001;
  LINEANSWERMODE_DROP                     = $00000002;
  LINEANSWERMODE_HOLD                     = $00000004;

  LINEBEARERMODE_VOICE                    = $00000001;
  LINEBEARERMODE_SPEECH                   = $00000002;
  LINEBEARERMODE_MULTIUSE                 = $00000004;
  LINEBEARERMODE_DATA                     = $00000008;
  LINEBEARERMODE_ALTSPEECHDATA            = $00000010;
  LINEBEARERMODE_NONCALLSIGNALING         = $00000020;
  LINEBEARERMODE_PASSTHROUGH              = $00000040;      { TAPI v1.4 }
{$IFDEF TAPI20}
  LINEBEARERMODE_RESTRICTEDDATA           = $00000080;      { TAPI v2.0 }
{$ENDIF}

  LINEBUSYMODE_STATION                    = $00000001;
  LINEBUSYMODE_TRUNK                      = $00000002;
  LINEBUSYMODE_UNKNOWN                    = $00000004;
  LINEBUSYMODE_UNAVAIL                    = $00000008;

  LINECALLCOMPLCOND_BUSY                  = $00000001;
  LINECALLCOMPLCOND_NOANSWER              = $00000002;

  LINECALLCOMPLMODE_CAMPON                = $00000001;
  LINECALLCOMPLMODE_CALLBACK              = $00000002;
  LINECALLCOMPLMODE_INTRUDE               = $00000004;
  LINECALLCOMPLMODE_MESSAGE               = $00000008;

  LINECALLFEATURE_ACCEPT                  = $00000001;
  LINECALLFEATURE_ADDTOCONF               = $00000002;
  LINECALLFEATURE_ANSWER                  = $00000004;
  LINECALLFEATURE_BLINDTRANSFER           = $00000008;
  LINECALLFEATURE_COMPLETECALL            = $00000010;
  LINECALLFEATURE_COMPLETETRANSF          = $00000020;
  LINECALLFEATURE_DIAL                    = $00000040;
  LINECALLFEATURE_DROP                    = $00000080;
  LINECALLFEATURE_GATHERDIGITS            = $00000100;
  LINECALLFEATURE_GENERATEDIGITS          = $00000200;
  LINECALLFEATURE_GENERATETONE            = $00000400;
  LINECALLFEATURE_HOLD                    = $00000800;
  LINECALLFEATURE_MONITORDIGITS           = $00001000;
  LINECALLFEATURE_MONITORMEDIA            = $00002000;
  LINECALLFEATURE_MONITORTONES            = $00004000;
  LINECALLFEATURE_PARK                    = $00008000;
  LINECALLFEATURE_PREPAREADDCONF          = $00010000;
  LINECALLFEATURE_REDIRECT                = $00020000;
  LINECALLFEATURE_REMOVEFROMCONF          = $00040000;
  LINECALLFEATURE_SECURECALL              = $00080000;
  LINECALLFEATURE_SENDUSERUSER            = $00100000;
  LINECALLFEATURE_SETCALLPARAMS           = $00200000;
  LINECALLFEATURE_SETMEDIACONTROL         = $00400000;
  LINECALLFEATURE_SETTERMINAL             = $00800000;
  LINECALLFEATURE_SETUPCONF               = $01000000;
  LINECALLFEATURE_SETUPTRANSFER           = $02000000;
  LINECALLFEATURE_SWAPHOLD                = $04000000;
  LINECALLFEATURE_UNHOLD                  = $08000000;
  LINECALLFEATURE_RELEASEUSERUSERINFO     = $10000000;      { TAPI v1.4 }
{$IFDEF TAPI20}
  LINECALLFEATURE_SETTREATMENT            = $20000000;      { TAPI v2.0 }
  LINECALLFEATURE_SETQOS                  = $40000000;      { TAPI v2.0 }
  LINECALLFEATURE_SETCALLDATA             = $80000000;      { TAPI v2.0 }
{$ENDIF}

{$IFDEF TAPI20}
  LINECALLFEATURE2_NOHOLDCONFERENCE       = $00000001;      { TAPI v2.0 }
  LINECALLFEATURE2_ONESTEPTRANSFER        = $00000002;      { TAPI v2.0 }
  LINECALLFEATURE2_COMPLCAMPON            = $00000004;      { TAPI v2.0 }
  LINECALLFEATURE2_COMPLCALLBACK          = $00000008;      { TAPI v2.0 }
  LINECALLFEATURE2_COMPLINTRUDE           = $00000010;      { TAPI v2.0 }
  LINECALLFEATURE2_COMPLMESSAGE           = $00000020;      { TAPI v2.0 }
  LINECALLFEATURE2_TRANSFERNORM           = $00000040;      { TAPI v2.0 }
  LINECALLFEATURE2_TRANSFERCONF           = $00000080;      { TAPI v2.0 }
  LINECALLFEATURE2_PARKDIRECT             = $00000100;      { TAPI v2.0 }
  LINECALLFEATURE2_PARKNONDIRECT          = $00000200;      { TAPI v2.0 }
{$ENDIF}

{$IFDEF TAPI30}
  LINECALLHUBTRACKING_NONE                = $00000000;      // TAPI v3.0
  LINECALLHUBTRACKING_PROVIDERLEVEL       = $00000001;      // TAPI v3.0
  LINECALLHUBTRACKING_ALLCALLS            = $00000002;      // TAPI v3.0
{$ENDIF}


  LINECALLINFOSTATE_OTHER                 = $00000001;
  LINECALLINFOSTATE_DEVSPECIFIC           = $00000002;
  LINECALLINFOSTATE_BEARERMODE            = $00000004;
  LINECALLINFOSTATE_RATE                  = $00000008;
  LINECALLINFOSTATE_MEDIAMODE             = $00000010;
  LINECALLINFOSTATE_APPSPECIFIC           = $00000020;
  LINECALLINFOSTATE_CALLID                = $00000040;
  LINECALLINFOSTATE_RELATEDCALLID         = $00000080;
  LINECALLINFOSTATE_ORIGIN                = $00000100;
  LINECALLINFOSTATE_REASON                = $00000200;
  LINECALLINFOSTATE_COMPLETIONID          = $00000400;
  LINECALLINFOSTATE_NUMOWNERINCR          = $00000800;
  LINECALLINFOSTATE_NUMOWNERDECR          = $00001000;
  LINECALLINFOSTATE_NUMMONITORS           = $00002000;
  LINECALLINFOSTATE_TRUNK                 = $00004000;
  LINECALLINFOSTATE_CALLERID              = $00008000;
  LINECALLINFOSTATE_CALLEDID              = $00010000;
  LINECALLINFOSTATE_CONNECTEDID           = $00020000;
  LINECALLINFOSTATE_REDIRECTIONID         = $00040000;
  LINECALLINFOSTATE_REDIRECTINGID         = $00080000;
  LINECALLINFOSTATE_DISPLAY               = $00100000;
  LINECALLINFOSTATE_USERUSERINFO          = $00200000;
  LINECALLINFOSTATE_HIGHLEVELCOMP         = $00400000;
  LINECALLINFOSTATE_LOWLEVELCOMP          = $00800000;
  LINECALLINFOSTATE_CHARGINGINFO          = $01000000;
  LINECALLINFOSTATE_TERMINAL              = $02000000;
  LINECALLINFOSTATE_DIALPARAMS            = $04000000;
  LINECALLINFOSTATE_MONITORMODES          = $08000000;
{$IFDEF TAPI20}
  LINECALLINFOSTATE_TREATMENT             = $10000000;      { TAPI v2.0 }
  LINECALLINFOSTATE_QOS                   = $20000000;      { TAPI v2.0 }
  LINECALLINFOSTATE_CALLDATA              = $40000000;      { TAPI v2.0 }
{$ENDIF}

  LINECALLORIGIN_OUTBOUND                 = $00000001;
  LINECALLORIGIN_INTERNAL                 = $00000002;
  LINECALLORIGIN_EXTERNAL                 = $00000004;
  LINECALLORIGIN_UNKNOWN                  = $00000010;
  LINECALLORIGIN_UNAVAIL                  = $00000020;
  LINECALLORIGIN_CONFERENCE               = $00000040;
  LINECALLORIGIN_INBOUND                  = $00000080;      { TAPI v1.4 }

  LINECALLPARAMFLAGS_SECURE               = $00000001;
  LINECALLPARAMFLAGS_IDLE                 = $00000002;
  LINECALLPARAMFLAGS_BLOCKID              = $00000004;
  LINECALLPARAMFLAGS_ORIGOFFHOOK          = $00000008;
  LINECALLPARAMFLAGS_DESTOFFHOOK          = $00000010;
{$IFDEF TAPI20}
  LINECALLPARAMFLAGS_NOHOLDCONFERENCE     = $00000020;      { TAPI v2.0 }
  LINECALLPARAMFLAGS_PREDICTIVEDIAL       = $00000040;      { TAPI v2.0 }
  LINECALLPARAMFLAGS_ONESTEPTRANSFER      = $00000080;      { TAPI v2.0 }
{$ENDIF}

  LINECALLPARTYID_BLOCKED                 = $00000001;
  LINECALLPARTYID_OUTOFAREA               = $00000002;
  LINECALLPARTYID_NAME                    = $00000004;
  LINECALLPARTYID_ADDRESS                 = $00000008;
  LINECALLPARTYID_PARTIAL                 = $00000010;
  LINECALLPARTYID_UNKNOWN                 = $00000020;
  LINECALLPARTYID_UNAVAIL                 = $00000040;

  LINECALLPRIVILEGE_NONE                  = $00000001;
  LINECALLPRIVILEGE_MONITOR               = $00000002;
  LINECALLPRIVILEGE_OWNER                 = $00000004;

  LINECALLREASON_DIRECT                   = $00000001;
  LINECALLREASON_FWDBUSY                  = $00000002;
  LINECALLREASON_FWDNOANSWER              = $00000004;
  LINECALLREASON_FWDUNCOND                = $00000008;
  LINECALLREASON_PICKUP                   = $00000010;
  LINECALLREASON_UNPARK                   = $00000020;
  LINECALLREASON_REDIRECT                 = $00000040;
  LINECALLREASON_CALLCOMPLETION           = $00000080;
  LINECALLREASON_TRANSFER                 = $00000100;
  LINECALLREASON_REMINDER                 = $00000200;
  LINECALLREASON_UNKNOWN                  = $00000400;
  LINECALLREASON_UNAVAIL                  = $00000800;
  LINECALLREASON_INTRUDE                  = $00001000;      { TAPI v1.4 }
  LINECALLREASON_PARKED                   = $00002000;      { TAPI v1.4 }
{$IFDEF TAPI20}
  LINECALLREASON_CAMPEDON                 = $00004000;      { TAPI v2.0 }
  LINECALLREASON_ROUTEREQUEST             = $00008000;      { TAPI v2.0 }
{$ENDIF}

  LINECALLSELECT_LINE                     = $00000001;
  LINECALLSELECT_ADDRESS                  = $00000002;
  LINECALLSELECT_CALL                     = $00000004;
{$IFDEF TAPI21}
  LINECALLSELECT_DEVICEID                 = $00000008;      // TAPI v2.1
{$ENDIF}
{$IFDEF TAPI30}
  LINECALLSELECT_CALLID                   = $00000010;      // TAPI v3.0
{$ENDIF}

  LINECALLSTATE_IDLE                      = $00000001;
  LINECALLSTATE_OFFERING                  = $00000002;
  LINECALLSTATE_ACCEPTED                  = $00000004;
  LINECALLSTATE_DIALTONE                  = $00000008;
  LINECALLSTATE_DIALING                   = $00000010;
  LINECALLSTATE_RINGBACK                  = $00000020;
  LINECALLSTATE_BUSY                      = $00000040;
  LINECALLSTATE_SPECIALINFO               = $00000080;
  LINECALLSTATE_CONNECTED                 = $00000100;
  LINECALLSTATE_PROCEEDING                = $00000200;
  LINECALLSTATE_ONHOLD                    = $00000400;
  LINECALLSTATE_CONFERENCED               = $00000800;
  LINECALLSTATE_ONHOLDPENDCONF            = $00001000;
  LINECALLSTATE_ONHOLDPENDTRANSFER        = $00002000;
  LINECALLSTATE_DISCONNECTED              = $00004000;
  LINECALLSTATE_UNKNOWN                   = $00008000;

{$IFDEF TAPI20}
  LINECALLTREATMENT_SILENCE               = $00000001;      { TAPI v2.0 }
  LINECALLTREATMENT_RINGBACK              = $00000002;      { TAPI v2.0 }
  LINECALLTREATMENT_BUSY                  = $00000003;      { TAPI v2.0 }
  LINECALLTREATMENT_MUSIC                 = $00000004;      { TAPI v2.0 }
{$ENDIF}

  LINECARDOPTION_PREDEFINED               = $00000001;      { TAPI v1.4 }
  LINECARDOPTION_HIDDEN                   = $00000002;      { TAPI v1.4 }

  LINECONNECTEDMODE_ACTIVE                = $00000001;      { TAPI v1.4 }
  LINECONNECTEDMODE_INACTIVE              = $00000002;      { TAPI v1.4 }
{$IFDEF TAPI20}
  LINECONNECTEDMODE_ACTIVEHELD            = $00000004;      { TAPI v2.0 }
  LINECONNECTEDMODE_INACTIVEHELD          = $00000008;      { TAPI v2.0 }
  LINECONNECTEDMODE_CONFIRMED             = $00000010;      { TAPI v2.0 }
{$ENDIF}

  LINEDEVCAPFLAGS_CROSSADDRCONF           = $00000001;
  LINEDEVCAPFLAGS_HIGHLEVCOMP             = $00000002;
  LINEDEVCAPFLAGS_LOWLEVCOMP              = $00000004;
  LINEDEVCAPFLAGS_MEDIACONTROL            = $00000008;
  LINEDEVCAPFLAGS_MULTIPLEADDR            = $00000010;
  LINEDEVCAPFLAGS_CLOSEDROP               = $00000020;
  LINEDEVCAPFLAGS_DIALBILLING             = $00000040;
  LINEDEVCAPFLAGS_DIALQUIET               = $00000080;
  LINEDEVCAPFLAGS_DIALDIALTONE            = $00000100;
{$IFDEF TAPI30}
  LINEDEVCAPFLAGS_MSP                     = $00000200;      // TAPI v3.0
  LINEDEVCAPFLAGS_CALLHUB                 = $00000400;      // TAPI v3.0
  LINEDEVCAPFLAGS_CALLHUBTRACKING         = $00000800;      // TAPI v3.0
  LINEDEVCAPFLAGS_PRIVATEOBJECTS          = $00001000;      // TAPI v3.0
{$ENDIF}

  LINEDEVSTATE_OTHER                      = $00000001;
  LINEDEVSTATE_RINGING                    = $00000002;
  LINEDEVSTATE_CONNECTED                  = $00000004;
  LINEDEVSTATE_DISCONNECTED               = $00000008;
  LINEDEVSTATE_MSGWAITON                  = $00000010;
  LINEDEVSTATE_MSGWAITOFF                 = $00000020;
  LINEDEVSTATE_INSERVICE                  = $00000040;
  LINEDEVSTATE_OUTOFSERVICE               = $00000080;
  LINEDEVSTATE_MAINTENANCE                = $00000100;
  LINEDEVSTATE_OPEN                       = $00000200;
  LINEDEVSTATE_CLOSE                      = $00000400;
  LINEDEVSTATE_NUMCALLS                   = $00000800;
  LINEDEVSTATE_NUMCOMPLETIONS             = $00001000;
  LINEDEVSTATE_TERMINALS                  = $00002000;
  LINEDEVSTATE_ROAMMODE                   = $00004000;
  LINEDEVSTATE_BATTERY                    = $00008000;
  LINEDEVSTATE_SIGNAL                     = $00010000;
  LINEDEVSTATE_DEVSPECIFIC                = $00020000;
  LINEDEVSTATE_REINIT                     = $00040000;
  LINEDEVSTATE_LOCK                       = $00080000;
  LINEDEVSTATE_CAPSCHANGE                 = $00100000;      { TAPI v1.4 }
  LINEDEVSTATE_CONFIGCHANGE               = $00200000;      { TAPI v1.4 }
  LINEDEVSTATE_TRANSLATECHANGE            = $00400000;      { TAPI v1.4 }
  LINEDEVSTATE_COMPLCANCEL                = $00800000;      { TAPI v1.4 }
  LINEDEVSTATE_REMOVED                    = $01000000;      { TAPI v1.4 }

  LINEDEVSTATUSFLAGS_CONNECTED            = $00000001;
  LINEDEVSTATUSFLAGS_MSGWAIT              = $00000002;
  LINEDEVSTATUSFLAGS_INSERVICE            = $00000004;
  LINEDEVSTATUSFLAGS_LOCKED               = $00000008;

  LINEDIALTONEMODE_NORMAL                 = $00000001;
  LINEDIALTONEMODE_SPECIAL                = $00000002;
  LINEDIALTONEMODE_INTERNAL               = $00000004;
  LINEDIALTONEMODE_EXTERNAL               = $00000008;
  LINEDIALTONEMODE_UNKNOWN                = $00000010;
  LINEDIALTONEMODE_UNAVAIL                = $00000020;

  LINEDIGITMODE_PULSE                     = $00000001;
  LINEDIGITMODE_DTMF                      = $00000002;
  LINEDIGITMODE_DTMFEND                   = $00000004;

  LINEDISCONNECTMODE_NORMAL               = $00000001;
  LINEDISCONNECTMODE_UNKNOWN              = $00000002;
  LINEDISCONNECTMODE_REJECT               = $00000004;
  LINEDISCONNECTMODE_PICKUP               = $00000008;
  LINEDISCONNECTMODE_FORWARDED            = $00000010;
  LINEDISCONNECTMODE_BUSY                 = $00000020;
  LINEDISCONNECTMODE_NOANSWER             = $00000040;
  LINEDISCONNECTMODE_BADADDRESS           = $00000080;
  LINEDISCONNECTMODE_UNREACHABLE          = $00000100;
  LINEDISCONNECTMODE_CONGESTION           = $00000200;
  LINEDISCONNECTMODE_INCOMPATIBLE         = $00000400;
  LINEDISCONNECTMODE_UNAVAIL              = $00000800;
  LINEDISCONNECTMODE_NODIALTONE           = $00001000;      { TAPI v1.4 }
{$IFDEF TAPI20}
  LINEDISCONNECTMODE_NUMBERCHANGED        = $00002000;      { TAPI v2.0 }
  LINEDISCONNECTMODE_OUTOFORDER           = $00004000;      { TAPI v2.0 }
  LINEDISCONNECTMODE_TEMPFAILURE          = $00008000;      { TAPI v2.0 }
  LINEDISCONNECTMODE_QOSUNAVAIL           = $00010000;      { TAPI v2.0 }
  LINEDISCONNECTMODE_BLOCKED              = $00020000;      { TAPI v2.0 }
  LINEDISCONNECTMODE_DONOTDISTURB         = $00040000;      { TAPI v2.0 }
  LINEDISCONNECTMODE_CANCELLED            = $00080000;      { TAPI v2.0 }
{$ENDIF}

  LINEERR_ALLOCATED                       = $80000001;
  LINEERR_BADDEVICEID                     = $80000002;
  LINEERR_BEARERMODEUNAVAIL               = $80000003;
  LINEERR_CALLUNAVAIL                     = $80000005;
  LINEERR_COMPLETIONOVERRUN               = $80000006;
  LINEERR_CONFERENCEFULL                  = $80000007;
  LINEERR_DIALBILLING                     = $80000008;
  LINEERR_DIALDIALTONE                    = $80000009;
  LINEERR_DIALPROMPT                      = $8000000A;
  LINEERR_DIALQUIET                       = $8000000B;
  LINEERR_INCOMPATIBLEAPIVERSION          = $8000000C;
  LINEERR_INCOMPATIBLEEXTVERSION          = $8000000D;
  LINEERR_INIFILECORRUPT                  = $8000000E;
  LINEERR_INUSE                           = $8000000F;
  LINEERR_INVALADDRESS                    = $80000010;
  LINEERR_INVALADDRESSID                  = $80000011;
  LINEERR_INVALADDRESSMODE                = $80000012;
  LINEERR_INVALADDRESSSTATE               = $80000013;
  LINEERR_INVALAPPHANDLE                  = $80000014;
  LINEERR_INVALAPPNAME                    = $80000015;
  LINEERR_INVALBEARERMODE                 = $80000016;
  LINEERR_INVALCALLCOMPLMODE              = $80000017;
  LINEERR_INVALCALLHANDLE                 = $80000018;
  LINEERR_INVALCALLPARAMS                 = $80000019;
  LINEERR_INVALCALLPRIVILEGE              = $8000001A;
  LINEERR_INVALCALLSELECT                 = $8000001B;
  LINEERR_INVALCALLSTATE                  = $8000001C;
  LINEERR_INVALCALLSTATELIST              = $8000001D;
  LINEERR_INVALCARD                       = $8000001E;
  LINEERR_INVALCOMPLETIONID               = $8000001F;
  LINEERR_INVALCONFCALLHANDLE             = $80000020;
  LINEERR_INVALCONSULTCALLHANDLE          = $80000021;
  LINEERR_INVALCOUNTRYCODE                = $80000022;
  LINEERR_INVALDEVICECLASS                = $80000023;
  LINEERR_INVALDEVICEHANDLE               = $80000024;
  LINEERR_INVALDIALPARAMS                 = $80000025;
  LINEERR_INVALDIGITLIST                  = $80000026;
  LINEERR_INVALDIGITMODE                  = $80000027;
  LINEERR_INVALDIGITS                     = $80000028;
  LINEERR_INVALEXTVERSION                 = $80000029;
  LINEERR_INVALGROUPID                    = $8000002A;
  LINEERR_INVALLINEHANDLE                 = $8000002B;
  LINEERR_INVALLINESTATE                  = $8000002C;
  LINEERR_INVALLOCATION                   = $8000002D;
  LINEERR_INVALMEDIALIST                  = $8000002E;
  LINEERR_INVALMEDIAMODE                  = $8000002F;
  LINEERR_INVALMESSAGEID                  = $80000030;
  LINEERR_INVALPARAM                      = $80000032;
  LINEERR_INVALPARKID                     = $80000033;
  LINEERR_INVALPARKMODE                   = $80000034;
  LINEERR_INVALPOINTER                    = $80000035;
  LINEERR_INVALPRIVSELECT                 = $80000036;
  LINEERR_INVALRATE                       = $80000037;
  LINEERR_INVALREQUESTMODE                = $80000038;
  LINEERR_INVALTERMINALID                 = $80000039;
  LINEERR_INVALTERMINALMODE               = $8000003A;
  LINEERR_INVALTIMEOUT                    = $8000003B;
  LINEERR_INVALTONE                       = $8000003C;
  LINEERR_INVALTONELIST                   = $8000003D;
  LINEERR_INVALTONEMODE                   = $8000003E;
  LINEERR_INVALTRANSFERMODE               = $8000003F;
  LINEERR_LINEMAPPERFAILED                = $80000040;
  LINEERR_NOCONFERENCE                    = $80000041;
  LINEERR_NODEVICE                        = $80000042;
  LINEERR_NODRIVER                        = $80000043;
  LINEERR_NOMEM                           = $80000044;
  LINEERR_NOREQUEST                       = $80000045;
  LINEERR_NOTOWNER                        = $80000046;
  LINEERR_NOTREGISTERED                   = $80000047;
  LINEERR_OPERATIONFAILED                 = $80000048;
  LINEERR_OPERATIONUNAVAIL                = $80000049;
  LINEERR_RATEUNAVAIL                     = $8000004A;
  LINEERR_RESOURCEUNAVAIL                 = $8000004B;
  LINEERR_REQUESTOVERRUN                  = $8000004C;
  LINEERR_STRUCTURETOOSMALL               = $8000004D;
  LINEERR_TARGETNOTFOUND                  = $8000004E;
  LINEERR_TARGETSELF                      = $8000004F;
  LINEERR_UNINITIALIZED                   = $80000050;
  LINEERR_USERUSERINFOTOOBIG              = $80000051;
  LINEERR_REINIT                          = $80000052;
  LINEERR_ADDRESSBLOCKED                  = $80000053;
  LINEERR_BILLINGREJECTED                 = $80000054;
  LINEERR_INVALFEATURE                    = $80000055;
  LINEERR_NOMULTIPLEINSTANCE              = $80000056;
{$IFDEF TAPI20}
  LINEERR_INVALAGENTID                    = $80000057;      { TAPI v2.0 }
  LINEERR_INVALAGENTGROUP                 = $80000058;      { TAPI v2.0 }
  LINEERR_INVALPASSWORD                   = $80000059;      { TAPI v2.0 }
  LINEERR_INVALAGENTSTATE                 = $8000005A;      { TAPI v2.0 }
  LINEERR_INVALAGENTACTIVITY              = $8000005B;      { TAPI v2.0 }
  LINEERR_DIALVOICEDETECT                 = $8000005C;      { TAPI v2.0 }
{$ENDIF}

{$IFDEF TAPI22}
  LINEERR_USERCANCELLED                   = $8000005D;      // TAPI v2.2
{$ENDIF}
{$IFDEF TAPI30}
  LINEERR_INVALADDRESSTYPE                = $8000005E;      // TAPI v3.0
{$ENDIF}
{$IFDEF TAPI22}
  LINEERR_INVALAGENTSESSIONSTATE          = $8000005F;      // TAPI v2.2
  LINEERR_DISCONNECTED                    = $80000060;
{$ENDIF}

  LINEFEATURE_DEVSPECIFIC                 = $00000001;
  LINEFEATURE_DEVSPECIFICFEAT             = $00000002;
  LINEFEATURE_FORWARD                     = $00000004;
  LINEFEATURE_MAKECALL                    = $00000008;
  LINEFEATURE_SETMEDIACONTROL             = $00000010;
  LINEFEATURE_SETTERMINAL                 = $00000020;
{$IFDEF TAPI20}
  LINEFEATURE_SETDEVSTATUS                = $00000040;      { TAPI v2.0 }
  LINEFEATURE_FORWARDFWD                  = $00000080;      { TAPI v2.0 }
  LINEFEATURE_FORWARDDND                  = $00000100;      { TAPI v2.0 }
{$ENDIF}

  LINEFORWARDMODE_UNCOND                  = $00000001;
  LINEFORWARDMODE_UNCONDINTERNAL          = $00000002;
  LINEFORWARDMODE_UNCONDEXTERNAL          = $00000004;
  LINEFORWARDMODE_UNCONDSPECIFIC          = $00000008;
  LINEFORWARDMODE_BUSY                    = $00000010;
  LINEFORWARDMODE_BUSYINTERNAL            = $00000020;
  LINEFORWARDMODE_BUSYEXTERNAL            = $00000040;
  LINEFORWARDMODE_BUSYSPECIFIC            = $00000080;
  LINEFORWARDMODE_NOANSW                  = $00000100;
  LINEFORWARDMODE_NOANSWINTERNAL          = $00000200;
  LINEFORWARDMODE_NOANSWEXTERNAL          = $00000400;
  LINEFORWARDMODE_NOANSWSPECIFIC          = $00000800;
  LINEFORWARDMODE_BUSYNA                  = $00001000;
  LINEFORWARDMODE_BUSYNAINTERNAL          = $00002000;
  LINEFORWARDMODE_BUSYNAEXTERNAL          = $00004000;
  LINEFORWARDMODE_BUSYNASPECIFIC          = $00008000;
  LINEFORWARDMODE_UNKNOWN                 = $00010000;      { TAPI v1.4 }
  LINEFORWARDMODE_UNAVAIL                 = $00020000;      { TAPI v1.4 }

  LINEGATHERTERM_BUFFERFULL               = $00000001;
  LINEGATHERTERM_TERMDIGIT                = $00000002;
  LINEGATHERTERM_FIRSTTIMEOUT             = $00000004;
  LINEGATHERTERM_INTERTIMEOUT             = $00000008;
  LINEGATHERTERM_CANCEL                   = $00000010;

  LINEGENERATETERM_DONE                   = $00000001;
  LINEGENERATETERM_CANCEL                 = $00000002;

{$IFDEF TAPI20}
{
 These constants are mutually exclusive - there's no way to specify more
 than one at a time (and it doesn't make sense, either) so they're
 ordinal rather than bits.
}
  LINEINITIALIZEEXOPTION_USEHIDDENWINDOW      = $00000001; { TAPI v2.0 }
  LINEINITIALIZEEXOPTION_USEEVENT             = $00000002; { TAPI v2.0 }
  LINEINITIALIZEEXOPTION_USECOMPLETIONPORT    = $00000003; { TAPI v2.0 }
{$ENDIF}

{$IFDEF TAPI30}
  LINEINITIALIZEEXOPTION_CALLHUBTRACKING      = $80000000;  // TAPI v3.0
{$ENDIF}

  LINELOCATIONOPTION_PULSEDIAL            = $00000001;     { TAPI v1.4 }

  LINEMAPPER                              = $FFFFFFFF;

  LINEMEDIACONTROL_NONE                   = $00000001;
  LINEMEDIACONTROL_START                  = $00000002;
  LINEMEDIACONTROL_RESET                  = $00000004;
  LINEMEDIACONTROL_PAUSE                  = $00000008;
  LINEMEDIACONTROL_RESUME                 = $00000010;
  LINEMEDIACONTROL_RATEUP                 = $00000020;
  LINEMEDIACONTROL_RATEDOWN               = $00000040;
  LINEMEDIACONTROL_RATENORMAL             = $00000080;
  LINEMEDIACONTROL_VOLUMEUP               = $00000100;
  LINEMEDIACONTROL_VOLUMEDOWN             = $00000200;
  LINEMEDIACONTROL_VOLUMENORMAL           = $00000400;

  LINEMEDIAMODE_UNKNOWN                   = $00000002;
  LINEMEDIAMODE_INTERACTIVEVOICE          = $00000004;
  LINEMEDIAMODE_AUTOMATEDVOICE            = $00000008;
  LINEMEDIAMODE_DATAMODEM                 = $00000010;
  LINEMEDIAMODE_G3FAX                     = $00000020;
  LINEMEDIAMODE_TDD                       = $00000040;
  LINEMEDIAMODE_G4FAX                     = $00000080;
  LINEMEDIAMODE_DIGITALDATA               = $00000100;
  LINEMEDIAMODE_TELETEX                   = $00000200;
  LINEMEDIAMODE_VIDEOTEX                  = $00000400;
  LINEMEDIAMODE_TELEX                     = $00000800;
  LINEMEDIAMODE_MIXED                     = $00001000;
  LINEMEDIAMODE_ADSI                      = $00002000;
  LINEMEDIAMODE_VOICEVIEW                 = $00004000;      { TAPI v1.4 }
  LAST_LINEMEDIAMODE                      = $00004000;

  LINEOFFERINGMODE_ACTIVE                 = $00000001;      { TAPI v1.4 }
  LINEOFFERINGMODE_INACTIVE               = $00000002;      { TAPI v1.4 }

{$IFDEF TAPI20}
  LINEOPENOPTION_SINGLEADDRESS            = $80000000;      { TAPI v2.0 }
  LINEOPENOPTION_PROXY                    = $40000000;      { TAPI v2.0 }
{$ENDIF}

  LINEPARKMODE_DIRECTED                   = $00000001;
  LINEPARKMODE_NONDIRECTED                = $00000002;

{$IFDEF TAPI20}
  LINEPROXYREQUEST_SETAGENTGROUP          = $00000001;      { TAPI v2.0 }
  LINEPROXYREQUEST_SETAGENTSTATE          = $00000002;      { TAPI v2.0 }
  LINEPROXYREQUEST_SETAGENTACTIVITY       = $00000003;      { TAPI v2.0 }
  LINEPROXYREQUEST_GETAGENTCAPS           = $00000004;      { TAPI v2.0 }
  LINEPROXYREQUEST_GETAGENTSTATUS         = $00000005;      { TAPI v2.0 }
  LINEPROXYREQUEST_AGENTSPECIFIC          = $00000006;      { TAPI v2.0 }
  LINEPROXYREQUEST_GETAGENTACTIVITYLIST   = $00000007;      { TAPI v2.0 }
  LINEPROXYREQUEST_GETAGENTGROUPLIST      = $00000008;      { TAPI v2.0 }
{$ENDIF}

{$IFDEF TAPI22}
  LINEPROXYREQUEST_CREATEAGENT                = $00000009;  // TAPI v2.2
  LINEPROXYREQUEST_SETAGENTMEASUREMENTPERIOD  = $0000000A;  // TAPI v2.2
  LINEPROXYREQUEST_GETAGENTINFO               = $0000000B;  // TAPI v2.2
  LINEPROXYREQUEST_CREATEAGENTSESSION         = $0000000C;  // TAPI v2.2
  LINEPROXYREQUEST_GETAGENTSESSIONLIST        = $0000000D;  // TAPI v2.2
  LINEPROXYREQUEST_SETAGENTSESSIONSTATE       = $0000000E;  // TAPI v2.2
  LINEPROXYREQUEST_GETAGENTSESSIONINFO        = $0000000F;  // TAPI v2.2
  LINEPROXYREQUEST_GETQUEUELIST               = $00000010;  // TAPI v2.2
  LINEPROXYREQUEST_SETQUEUEMEASUREMENTPERIOD  = $00000011;  // TAPI v2.2
  LINEPROXYREQUEST_GETQUEUEINFO               = $00000012;  // TAPI v2.2
  LINEPROXYREQUEST_GETGROUPLIST               = $00000013;  // TAPI v2.2
  LINEPROXYREQUEST_SETAGENTSTATEEX            = $00000014;  // TAPI v2.2
{$ENDIF}


  LINEREMOVEFROMCONF_NONE                 = $00000001;
  LINEREMOVEFROMCONF_LAST                 = $00000002;
  LINEREMOVEFROMCONF_ANY                  = $00000003;

  LINEREQUESTMODE_MAKECALL                = $00000001;
  LINEREQUESTMODE_MEDIACALL               = $00000002;
  LINEREQUESTMODE_DROP                    = $00000004;
  LAST_LINEREQUESTMODE                    = LINEREQUESTMODE_MEDIACALL;

  LINEROAMMODE_UNKNOWN                    = $00000001;
  LINEROAMMODE_UNAVAIL                    = $00000002;
  LINEROAMMODE_HOME                       = $00000004;
  LINEROAMMODE_ROAMA                      = $00000008;
  LINEROAMMODE_ROAMB                      = $00000010;

  LINESPECIALINFO_NOCIRCUIT               = $00000001;
  LINESPECIALINFO_CUSTIRREG               = $00000002;
  LINESPECIALINFO_REORDER                 = $00000004;
  LINESPECIALINFO_UNKNOWN                 = $00000008;
  LINESPECIALINFO_UNAVAIL                 = $00000010;

  LINETERMDEV_PHONE                       = $00000001;
  LINETERMDEV_HEADSET                     = $00000002;
  LINETERMDEV_SPEAKER                     = $00000004;

  LINETERMMODE_BUTTONS                    = $00000001;
  LINETERMMODE_LAMPS                      = $00000002;
  LINETERMMODE_DISPLAY                    = $00000004;
  LINETERMMODE_RINGER                     = $00000008;
  LINETERMMODE_HOOKSWITCH                 = $00000010;
  LINETERMMODE_MEDIATOLINE                = $00000020;
  LINETERMMODE_MEDIAFROMLINE              = $00000040;
  LINETERMMODE_MEDIABIDIRECT              = $00000080;

  LINETERMSHARING_PRIVATE                 = $00000001;
  LINETERMSHARING_SHAREDEXCL              = $00000002;
  LINETERMSHARING_SHAREDCONF              = $00000004;

  LINETOLLLISTOPTION_ADD                  = $00000001;
  LINETOLLLISTOPTION_REMOVE               = $00000002;

  LINETONEMODE_CUSTOM                     = $00000001;
  LINETONEMODE_RINGBACK                   = $00000002;
  LINETONEMODE_BUSY                       = $00000004;
  LINETONEMODE_BEEP                       = $00000008;
  LINETONEMODE_BILLING                    = $00000010;

  LINETRANSFERMODE_TRANSFER               = $00000001;
  LINETRANSFERMODE_CONFERENCE             = $00000002;

  LINETRANSLATEOPTION_CARDOVERRIDE        = $00000001;
  LINETRANSLATEOPTION_CANCELCALLWAITING   = $00000002;      { TAPI v1.4 }
  LINETRANSLATEOPTION_FORCELOCAL          = $00000004;      { TAPI v1.4 }
  LINETRANSLATEOPTION_FORCELD             = $00000008;      { TAPI v1.4 }

  LINETRANSLATERESULT_CANONICAL           = $00000001;
  LINETRANSLATERESULT_INTERNATIONAL       = $00000002;
  LINETRANSLATERESULT_LONGDISTANCE        = $00000004;
  LINETRANSLATERESULT_LOCAL               = $00000008;
  LINETRANSLATERESULT_INTOLLLIST          = $00000010;
  LINETRANSLATERESULT_NOTINTOLLLIST       = $00000020;
  LINETRANSLATERESULT_DIALBILLING         = $00000040;
  LINETRANSLATERESULT_DIALQUIET           = $00000080;
  LINETRANSLATERESULT_DIALDIALTONE        = $00000100;
  LINETRANSLATERESULT_DIALPROMPT          = $00000200;
{$IFDEF TAPI20}
  LINETRANSLATERESULT_VOICEDETECT         = $00000400;      { TAPI v2.0 }
{$ENDIF}

{$IFDEF TAPI30}
  LINETRANSLATERESULT_NOTRANSLATION       = $00000800;      // TAPI v3.0
{$ENDIF}

  PHONEBUTTONFUNCTION_UNKNOWN             = $00000000;
  PHONEBUTTONFUNCTION_CONFERENCE          = $00000001;
  PHONEBUTTONFUNCTION_TRANSFER            = $00000002;
  PHONEBUTTONFUNCTION_DROP                = $00000003;
  PHONEBUTTONFUNCTION_HOLD                = $00000004;
  PHONEBUTTONFUNCTION_RECALL              = $00000005;
  PHONEBUTTONFUNCTION_DISCONNECT          = $00000006;
  PHONEBUTTONFUNCTION_CONNECT             = $00000007;
  PHONEBUTTONFUNCTION_MSGWAITON           = $00000008;
  PHONEBUTTONFUNCTION_MSGWAITOFF          = $00000009;
  PHONEBUTTONFUNCTION_SELECTRING          = $0000000A;
  PHONEBUTTONFUNCTION_ABBREVDIAL          = $0000000B;
  PHONEBUTTONFUNCTION_FORWARD             = $0000000C;
  PHONEBUTTONFUNCTION_PICKUP              = $0000000D;
  PHONEBUTTONFUNCTION_RINGAGAIN           = $0000000E;
  PHONEBUTTONFUNCTION_PARK                = $0000000F;
  PHONEBUTTONFUNCTION_REJECT              = $00000010;
  PHONEBUTTONFUNCTION_REDIRECT            = $00000011;
  PHONEBUTTONFUNCTION_MUTE                = $00000012;
  PHONEBUTTONFUNCTION_VOLUMEUP            = $00000013;
  PHONEBUTTONFUNCTION_VOLUMEDOWN          = $00000014;
  PHONEBUTTONFUNCTION_SPEAKERON           = $00000015;
  PHONEBUTTONFUNCTION_SPEAKEROFF          = $00000016;
  PHONEBUTTONFUNCTION_FLASH               = $00000017;
  PHONEBUTTONFUNCTION_DATAON              = $00000018;
  PHONEBUTTONFUNCTION_DATAOFF             = $00000019;
  PHONEBUTTONFUNCTION_DONOTDISTURB        = $0000001A;
  PHONEBUTTONFUNCTION_INTERCOM            = $0000001B;
  PHONEBUTTONFUNCTION_BRIDGEDAPP          = $0000001C;
  PHONEBUTTONFUNCTION_BUSY                = $0000001D;
  PHONEBUTTONFUNCTION_CALLAPP             = $0000001E;
  PHONEBUTTONFUNCTION_DATETIME            = $0000001F;
  PHONEBUTTONFUNCTION_DIRECTORY           = $00000020;
  PHONEBUTTONFUNCTION_COVER               = $00000021;
  PHONEBUTTONFUNCTION_CALLID              = $00000022;
  PHONEBUTTONFUNCTION_LASTNUM             = $00000023;
  PHONEBUTTONFUNCTION_NIGHTSRV            = $00000024;
  PHONEBUTTONFUNCTION_SENDCALLS           = $00000025;
  PHONEBUTTONFUNCTION_MSGINDICATOR        = $00000026;
  PHONEBUTTONFUNCTION_REPDIAL             = $00000027;
  PHONEBUTTONFUNCTION_SETREPDIAL          = $00000028;
  PHONEBUTTONFUNCTION_SYSTEMSPEED         = $00000029;
  PHONEBUTTONFUNCTION_STATIONSPEED        = $0000002A;
  PHONEBUTTONFUNCTION_CAMPON              = $0000002B;
  PHONEBUTTONFUNCTION_SAVEREPEAT          = $0000002C;
  PHONEBUTTONFUNCTION_QUEUECALL           = $0000002D;
  PHONEBUTTONFUNCTION_NONE                = $0000002E;

  PHONEBUTTONMODE_DUMMY                   = $00000001;
  PHONEBUTTONMODE_CALL                    = $00000002;
  PHONEBUTTONMODE_FEATURE                 = $00000004;
  PHONEBUTTONMODE_KEYPAD                  = $00000008;
  PHONEBUTTONMODE_LOCAL                   = $00000010;
  PHONEBUTTONMODE_DISPLAY                 = $00000020;

  PHONEBUTTONSTATE_UP                     = $00000001;
  PHONEBUTTONSTATE_DOWN                   = $00000002;
  PHONEBUTTONSTATE_UNKNOWN                = $00000004;      { TAPI v1.4 }
  PHONEBUTTONSTATE_UNAVAIL                = $00000008;      { TAPI v1.4 }

  PHONEERR_ALLOCATED                      = $90000001;
  PHONEERR_BADDEVICEID                    = $90000002;
  PHONEERR_INCOMPATIBLEAPIVERSION         = $90000003;
  PHONEERR_INCOMPATIBLEEXTVERSION         = $90000004;
  PHONEERR_INIFILECORRUPT                 = $90000005;
  PHONEERR_INUSE                          = $90000006;
  PHONEERR_INVALAPPHANDLE                 = $90000007;
  PHONEERR_INVALAPPNAME                   = $90000008;
  PHONEERR_INVALBUTTONLAMPID              = $90000009;
  PHONEERR_INVALBUTTONMODE                = $9000000A;
  PHONEERR_INVALBUTTONSTATE               = $9000000B;
  PHONEERR_INVALDATAID                    = $9000000C;
  PHONEERR_INVALDEVICECLASS               = $9000000D;
  PHONEERR_INVALEXTVERSION                = $9000000E;
  PHONEERR_INVALHOOKSWITCHDEV             = $9000000F;
  PHONEERR_INVALHOOKSWITCHMODE            = $90000010;
  PHONEERR_INVALLAMPMODE                  = $90000011;
  PHONEERR_INVALPARAM                     = $90000012;
  PHONEERR_INVALPHONEHANDLE               = $90000013;
  PHONEERR_INVALPHONESTATE                = $90000014;
  PHONEERR_INVALPOINTER                   = $90000015;
  PHONEERR_INVALPRIVILEGE                 = $90000016;
  PHONEERR_INVALRINGMODE                  = $90000017;
  PHONEERR_NODEVICE                       = $90000018;
  PHONEERR_NODRIVER                       = $90000019;
  PHONEERR_NOMEM                          = $9000001A;
  PHONEERR_NOTOWNER                       = $9000001B;
  PHONEERR_OPERATIONFAILED                = $9000001C;
  PHONEERR_OPERATIONUNAVAIL               = $9000001D;
  PHONEERR_RESOURCEUNAVAIL                = $9000001F;
  PHONEERR_REQUESTOVERRUN                 = $90000020;
  PHONEERR_STRUCTURETOOSMALL              = $90000021;
  PHONEERR_UNINITIALIZED                  = $90000022;
  PHONEERR_REINIT                         = $90000023;


{$IFDEF TAPI20}
  PHONEFEATURE_GETBUTTONINFO              = $00000001;      { TAPI v2.0 }
  PHONEFEATURE_GETDATA                    = $00000002;      { TAPI v2.0 }
  PHONEFEATURE_GETDISPLAY                 = $00000004;      { TAPI v2.0 }
  PHONEFEATURE_GETGAINHANDSET             = $00000008;      { TAPI v2.0 }
  PHONEFEATURE_GETGAINSPEAKER             = $00000010;      { TAPI v2.0 }
  PHONEFEATURE_GETGAINHEADSET             = $00000020;      { TAPI v2.0 }
  PHONEFEATURE_GETHOOKSWITCHHANDSET       = $00000040;      { TAPI v2.0 }
  PHONEFEATURE_GETHOOKSWITCHSPEAKER       = $00000080;      { TAPI v2.0 }
  PHONEFEATURE_GETHOOKSWITCHHEADSET       = $00000100;      { TAPI v2.0 }
  PHONEFEATURE_GETLAMP                    = $00000200;      { TAPI v2.0 }
  PHONEFEATURE_GETRING                    = $00000400;      { TAPI v2.0 }
  PHONEFEATURE_GETVOLUMEHANDSET           = $00000800;      { TAPI v2.0 }
  PHONEFEATURE_GETVOLUMESPEAKER           = $00001000;      { TAPI v2.0 }
  PHONEFEATURE_GETVOLUMEHEADSET           = $00002000;      { TAPI v2.0 }
  PHONEFEATURE_SETBUTTONINFO              = $00004000;      { TAPI v2.0 }
  PHONEFEATURE_SETDATA                    = $00008000;      { TAPI v2.0 }
  PHONEFEATURE_SETDISPLAY                 = $00010000;      { TAPI v2.0 }
  PHONEFEATURE_SETGAINHANDSET             = $00020000;      { TAPI v2.0 }
  PHONEFEATURE_SETGAINSPEAKER             = $00040000;      { TAPI v2.0 }
  PHONEFEATURE_SETGAINHEADSET             = $00080000;      { TAPI v2.0 }
  PHONEFEATURE_SETHOOKSWITCHHANDSET       = $00100000;      { TAPI v2.0 }
  PHONEFEATURE_SETHOOKSWITCHSPEAKER       = $00200000;      { TAPI v2.0 }
  PHONEFEATURE_SETHOOKSWITCHHEADSET       = $00400000;      { TAPI v2.0 }
  PHONEFEATURE_SETLAMP                    = $00800000;      { TAPI v2.0 }
  PHONEFEATURE_SETRING                    = $01000000;      { TAPI v2.0 }
  PHONEFEATURE_SETVOLUMEHANDSET           = $02000000;      { TAPI v2.0 }
  PHONEFEATURE_SETVOLUMESPEAKER           = $04000000;      { TAPI v2.0 }
  PHONEFEATURE_SETVOLUMEHEADSET           = $08000000;      { TAPI v2.0 }
{$ENDIF}

  PHONEHOOKSWITCHDEV_HANDSET              = $00000001;
  PHONEHOOKSWITCHDEV_SPEAKER              = $00000002;
  PHONEHOOKSWITCHDEV_HEADSET              = $00000004;

  PHONEHOOKSWITCHMODE_ONHOOK              = $00000001;
  PHONEHOOKSWITCHMODE_MIC                 = $00000002;
  PHONEHOOKSWITCHMODE_SPEAKER             = $00000004;
  PHONEHOOKSWITCHMODE_MICSPEAKER          = $00000008;
  PHONEHOOKSWITCHMODE_UNKNOWN             = $00000010;

{$IFDEF TAPI20}
  PHONEINITIALIZEEXOPTION_USEHIDDENWINDOW     = $00000001;  { TAPI v2.0 }
  PHONEINITIALIZEEXOPTION_USEEVENT            = $00000002;  { TAPI v2.0 }
  PHONEINITIALIZEEXOPTION_USECOMPLETIONPORT   = $00000003;  { TAPI v2.0 }
{$ENDIF}

  PHONELAMPMODE_DUMMY                     = $00000001;
  PHONELAMPMODE_OFF                       = $00000002;
  PHONELAMPMODE_STEADY                    = $00000004;
  PHONELAMPMODE_WINK                      = $00000008;
  PHONELAMPMODE_FLASH                     = $00000010;
  PHONELAMPMODE_FLUTTER                   = $00000020;
  PHONELAMPMODE_BROKENFLUTTER             = $00000040;
  PHONELAMPMODE_UNKNOWN                   = $00000080;

  PHONEPRIVILEGE_MONITOR                  = $00000001;
  PHONEPRIVILEGE_OWNER                    = $00000002;

  PHONESTATE_OTHER                        = $00000001;
  PHONESTATE_CONNECTED                    = $00000002;
  PHONESTATE_DISCONNECTED                 = $00000004;
  PHONESTATE_OWNER                        = $00000008;
  PHONESTATE_MONITORS                     = $00000010;
  PHONESTATE_DISPLAY                      = $00000020;
  PHONESTATE_LAMP                         = $00000040;
  PHONESTATE_RINGMODE                     = $00000080;
  PHONESTATE_RINGVOLUME                   = $00000100;
  PHONESTATE_HANDSETHOOKSWITCH            = $00000200;
  PHONESTATE_HANDSETVOLUME                = $00000400;
  PHONESTATE_HANDSETGAIN                  = $00000800;
  PHONESTATE_SPEAKERHOOKSWITCH            = $00001000;
  PHONESTATE_SPEAKERVOLUME                = $00002000;
  PHONESTATE_SPEAKERGAIN                  = $00004000;
  PHONESTATE_HEADSETHOOKSWITCH            = $00008000;
  PHONESTATE_HEADSETVOLUME                = $00010000;
  PHONESTATE_HEADSETGAIN                  = $00020000;
  PHONESTATE_SUSPEND                      = $00040000;
  PHONESTATE_RESUME                       = $00080000;
  PHONESTATE_DEVSPECIFIC                  = $00100000;
  PHONESTATE_REINIT                       = $00200000;
  PHONESTATE_CAPSCHANGE                   = $00400000;      { TAPI v1.4 }
  PHONESTATE_REMOVED                      = $00800000;      { TAPI v1.4 }

  PHONESTATUSFLAGS_CONNECTED              = $00000001;
  PHONESTATUSFLAGS_SUSPENDED              = $00000002;

  STRINGFORMAT_ASCII                      = $00000001;
  STRINGFORMAT_DBCS                       = $00000002;
  STRINGFORMAT_UNICODE                    = $00000003;
  STRINGFORMAT_BINARY                     = $00000004;

  TAPI_REPLY                              = WM_USER + 99;

  TAPIERR_CONNECTED                       = 0;
  TAPIERR_DROPPED                         = -1;
  TAPIERR_NOREQUESTRECIPIENT              = -2;
  TAPIERR_REQUESTQUEUEFULL                = -3;
  TAPIERR_INVALDESTADDRESS                = -4;
  TAPIERR_INVALWINDOWHANDLE               = -5;
  TAPIERR_INVALDEVICECLASS                = -6;
  TAPIERR_INVALDEVICEID                   = -7;
  TAPIERR_DEVICECLASSUNAVAIL              = -8;
  TAPIERR_DEVICEIDUNAVAIL                 = -9;
  TAPIERR_DEVICEINUSE                     = -10;
  TAPIERR_DESTBUSY                        = -11;
  TAPIERR_DESTNOANSWER                    = -12;
  TAPIERR_DESTUNAVAIL                     = -13;
  TAPIERR_UNKNOWNWINHANDLE                = -14;
  TAPIERR_UNKNOWNREQUESTID                = -15;
  TAPIERR_REQUESTFAILED                   = -16;
  TAPIERR_REQUESTCANCELLED                = -17;
  TAPIERR_INVALPOINTER                    = -18;


  TAPIMAXDESTADDRESSSIZE                  = 80;
  TAPIMAXAPPNAMESIZE                      = 40;
  TAPIMAXCALLEDPARTYSIZE                  = 40;
  TAPIMAXCOMMENTSIZE                      = 80;
  TAPIMAXDEVICECLASSSIZE                  = 40;
  TAPIMAXDEVICEIDSIZE                     = 40;



type
  LPLineAddressCaps = ^TLineAddressCaps;
  TLineAddressCaps = record
    dwTotalSize,
    dwNeededSize,
    dwUsedSize,
    dwLineDeviceID,
    dwAddressSize,
    dwAddressOffset,
    dwDevSpecificSize,
    dwDevSpecificOffset,
    dwAddressSharing,
    dwAddressStates,
    dwCallInfoStates,
    dwCallerIDFlags,
    dwCalledIDFlags,
    dwConnectedIDFlags,
    dwRedirectionIDFlags,
    dwRedirectingIDFlags,
    dwCallStates,
    dwDialToneModes,
    dwBusyModes,
    dwSpecialInfo,
    dwDisconnectModes,
    dwMaxNumActiveCalls,
    dwMaxNumOnHoldCalls,
    dwMaxNumOnHoldPendingCalls,
    dwMaxNumConference,
    dwMaxNumTransConf,
    dwAddrCapFlags,
    dwCallFeatures,
    dwRemoveFromConfCaps,
    dwRemoveFromConfState,
    dwTransferModes,
    dwParkModes,
    dwForwardModes,
    dwMaxForwardEntries,
    dwMaxSpecificEntries,
    dwMinFwdNumRings,
    dwMaxFwdNumRings,
    dwMaxCallCompletions,
    dwCallCompletionConds,
    dwCallCompletionModes,
    dwNumCompletionMessages,
    dwCompletionMsgTextEntrySize,
    dwCompletionMsgTextSize,
    dwCompletionMsgTextOffset,

    dwAddressFeatures: Longint;                     { TAPI v1.4 }

{$IFDEF TAPI20}
    dwPredictiveAutoTransferStates,                 { TAPI v2.0 }
    dwNumCallTreatments,                            { TAPI v2.0 }
    dwCallTreatmentListSize,                        { TAPI v2.0 }
    dwCallTreatmentListOffset,                      { TAPI v2.0 }
    dwDeviceClassesSize,                            { TAPI v2.0 }
    dwDeviceClassesOffset,                          { TAPI v2.0 }
    dwMaxCallDataSize,                              { TAPI v2.0 }
    dwCallFeatures2,                                { TAPI v2.0 }
    dwMaxNoAnswerTimeout,                           { TAPI v2.0 }
    dwConnectedModes,                               { TAPI v2.0 }
    dwOfferingModes,                                { TAPI v2.0 }
    dwAvailableMediaModes: Longint;                 { TAPI v2.0 }
{$ENDIF}
  end;

  LPLineAddressStatus = ^TLineAddressStatus;
  TLineAddressStatus = record
    dwTotalSize,
    dwNeededSize,
    dwUsedSize,
    dwNumInUse,
    dwNumActiveCalls,
    dwNumOnHoldCalls,
    dwNumOnHoldPendCalls,
    dwAddressFeatures,
    dwNumRingsNoAnswer,
    dwForwardNumEntries,
    dwForwardSize,
    dwForwardOffset,
    dwTerminalModesSize,
    dwTerminalModesOffset,
    dwDevSpecificSize,
    dwDevSpecificOffset: Longint;
  end;

{$IFDEF TAPI20}
  LPLineAgentActivityEntry = ^TLineAgentActivityEntry;
  TLineAgentActivityEntry = record
    dwID,                                           { TAPI v2.0 }
    dwNameSize,                                     { TAPI v2.0 }
    dwNameOffset: Longint;                          { TAPI v2.0 }
  end;

  LPLineAgentActivityList = ^TLineAgentActivityList;
  TLineAgentActivityList = record
    dwTotalSize,                                    { TAPI v2.0 }
    dwNeededSize,                                   { TAPI v2.0 }
    dwUsedSize,                                     { TAPI v2.0 }
    dwNumEntries,                                   { TAPI v2.0 }
    dwListSize,                                     { TAPI v2.0 }
    dwListOffset: Longint;                          { TAPI v2.0 }
  end;

  LPLineAgentCaps = ^TLineAgentCaps;
  TLineAgentCaps = record
    dwTotalSize,                                    { TAPI v2.0 }
    dwNeededSize,                                   { TAPI v2.0 }
    dwUsedSize,                                     { TAPI v2.0 }
    dwAgentHandlerInfoSize,                         { TAPI v2.0 }
    dwAgentHandlerInfoOffset,                       { TAPI v2.0 }
    dwCapsVersion,                                  { TAPI v2.0 }
    dwFeatures,                                     { TAPI v2.0 }
    dwStates,                                       { TAPI v2.0 }
    dwNextStates,                                   { TAPI v2.0 }
    dwMaxNumGroupEntries,                           { TAPI v2.0 }
    dwAgentStatusMessages,                          { TAPI v2.0 }
    dwNumAgentExtensionIDs,                         { TAPI v2.0 }
    dwAgentExtensionIDListSize,                     { TAPI v2.0 }
    dwAgentExtensionIDListOffset: Longint;          { TAPI v2.0 }
  end;

  LPLineAgentGroupEntry = ^TLineAgentGroupEntry;
  TLineAgentGroupEntry = record
    GroupID: record
      dwGroupID1,                                   { TAPI v2.0 }
      dwGroupID2,                                   { TAPI v2.0 }
      dwGroupID3,                                   { TAPI v2.0 }
      dwGroupID4: Longint;                          { TAPI v2.0 }
    end;
    dwNameSize,                                     { TAPI v2.0 }
    dwNameOffset: Longint;                          { TAPI v2.0 }
  end;

  LPLineAgentGroupList = ^TLineAgentGroupList;
  TLineAgentGroupList = record
    dwTotalSize,                                    { TAPI v2.0 }
    dwNeededSize,                                   { TAPI v2.0 }
    dwUsedSize,                                     { TAPI v2.0 }
    dwNumEntries,                                   { TAPI v2.0 }
    dwListSize,                                     { TAPI v2.0 }
    dwListOffset: Longint;                          { TAPI v2.0 }
  end;

  LPLineAgentStatus = ^TLineAgentStatus;
  TLineAgentStatus = record
    dwTotalSize,                                    { TAPI v2.0 }
    dwNeededSize,                                   { TAPI v2.0 }
    dwUsedSize,                                     { TAPI v2.0 }
    dwNumEntries,                                   { TAPI v2.0 }
    dwGroupListSize,                                { TAPI v2.0 }
    dwGroupListOffset,                              { TAPI v2.0 }
    dwState,                                        { TAPI v2.0 }
    dwNextState,                                    { TAPI v2.0 }
    dwActivityID,                                   { TAPI v2.0 }
    dwActivitySize,                                 { TAPI v2.0 }
    dwActivityOffset,                               { TAPI v2.0 }
    dwAgentFeatures,                                { TAPI v2.0 }
    dwValidStates,                                  { TAPI v2.0 }
    dwValidNextStates: Longint;                     { TAPI v2.0 }
  end;

  LPLineAppInfo = ^TLineAppInfo;
  TLineAppInfo = record
    dwMachineNameSize,                              { TAPI v2.0 }
    dwMachineNameOffset,                            { TAPI v2.0 }
    dwUserNameSize,                                 { TAPI v2.0 }
    dwUserNameOffset,                               { TAPI v2.0 }
    dwModuleFilenameSize,                           { TAPI v2.0 }
    dwModuleFilenameOffset,                         { TAPI v2.0 }
    dwFriendlyNameSize,                             { TAPI v2.0 }
    dwFriendlyNameOffset,                           { TAPI v2.0 }
    dwMediaModes,                                   { TAPI v2.0 }
    dwAddressID: Longint;                           { TAPI v2.0 }
  end;
{$ENDIF}

{$IFDEF TAPI22}
  PLineAgentEntry=^TLineAgentEntry;
  TLineAgentEntry = record
    hAgent,                                         // TAPI v2.2
    dwNameSize,                                     // TAPI v2.2
    dwNameOffset,                                   // TAPI v2.2
    dwIDSize,                                       // TAPI v2.2
    dwIDOffset,                                     // TAPI v2.2
    dwPINSize,                                      // TAPI v2.2
    dwPINOffset:Longint;                                    // TAPI v2.2
  end;

  PLineAgentList=^TLineAgentList;
  TLineAgentList = record
    dwTotalSize,                                    // TAPI v2.2
    dwNeededSize,                                   // TAPI v2.2
    dwUsedSize,                                     // TAPI v2.2
    dwNumEntries,                                   // TAPI v2.2
    dwListSize,                                     // TAPI v2.2
    dwListOffset:Longint;                           // TAPI v2.2
  end;

  LPLineAgentInfo =^TLineAgentInfo;
  TLineAgentInfo = record
    dwTotalSize,                                    // TAPI v2.2
    dwNeededSize,                                   // TAPI v2.2
    dwUsedSize,                                     // TAPI v2.2
    dwAgentState,                                   // TAPI v2.2
    dwNextAgentState,                               // TAPI v2.2
    dwMeasurementPeriod:Longint;                    // TAPI v2.2
    cyOverallCallRate:array[0..8]of byte;          // TAPI v2.2
    dwNumberOfACDCalls,                             // TAPI v2.2
    dwNumberOfIncomingCalls,                        // TAPI v2.2
    dwNumberOfOutgoingCalls,                        // TAPI v2.2
    dwTotalACDTalkTime,                             // TAPI v2.2
    dwTotalACDCallTime,                             // TAPI v2.2
    dwTotalACDWrapUpTime:longint;                   // TAPI v2.2
  end;

  LPLineAgentSessionEntry=^TLineAgentSessionEntry;
  TLineAgentSessionEntry = record
    hAgentSession,                                  // TAPI v2.2
    hAgent:longint;                                 // TAPI v2.2
    GroupID:TGUID;                                  // TAPI v2.2
    dwWorkingAddressID:longint                      // TAPI v2.2
  end;

  LPLineAgentSessionList=^TLineAgentSessionList;
  TLineAgentSessionList= record
    dwTotalSize,                                    // TAPI v2.2
    dwNeededSize,                                   // TAPI v2.2
    dwUsedSize,                                     // TAPI v2.2
    dwNumEntries,                                   // TAPI v2.2
    dwListSize,                                     // TAPI v2.2
    dwListOffset:longint;                                   // TAPI v2.2
  end;

  LPLineAgentSessionInfo=^TLineAgentSessionInfo;
  TLineAgentSessionInfo = record
    dwTotalSize,                                   // TAPI v2.2
    dwNeededSize,                                   // TAPI v2.2
    dwUsedSize,                                     // TAPI v2.2
    dwAgentSessionState,                            // TAPI v2.2
    dwNextAgentSessionState:longint;                // TAPI v2.2
    dateSessionStartTime:TDateTime;                 // TAPI v2.2
    dwSessionDuration,                              // TAPI v2.2
    dwNumberOfCalls,                                // TAPI v2.2
    dwTotalTalkTime,                                // TAPI v2.2
    dwAverageTalkTime,                              // TAPI v2.2
    dwTotalCallTime,                                // TAPI v2.2
    dwAverageCallTime,                              // TAPI v2.2
    dwTotalWrapUpTime,                              // TAPI v2.2
    dwAverageWrapUpTime,                            // TAPI v2.2
    cyACDCallRate:array[0..8]of byte;              // TAPI v2.2
    dwLongestTimeToAnswer,                          // TAPI v2.2
    dwAverageTimeToAnswer:longint;                  // TAPI v2.2
  end;

  LPLineQueueEntry=^TLineQueueEntry;
  TLineQueueEntry= record
    dwQueueID,                                      // TAPI v2.2
    dwNameSize,                                     // TAPI v2.2
    dwNameOffset:longint;                           // TAPI v2.2
  end;

  LPLineQueueList = ^TLineQueueList;
  TLineQueueList = record
    dwTotalSize,                                    // TAPI v2.2
    dwNeededSize,                                   // TAPI v2.2
    dwUsedSize,                                     // TAPI v2.2
    dwNumEntries,                                   // TAPI v2.2
    dwListSize,                                     // TAPI v2.2
    dwListOffset:longint;                           // TAPI v2.2
  end;

  LPLineQueueInfo = ^TLineQueueInfo;
  TLineQueueInfo = record
    dwTotalSize,                                    // TAPI v2.2
    dwNeededSize,                                   // TAPI v2.2
    dwUsedSize,                                     // TAPI v2.2
    dwMeasurementPeriod,                            // TAPI v2.2
    dwTotalCallsQueued,                             // TAPI v2.2
    dwCurrentCallsQueued,                           // TAPI v2.2
    dwTotalCallsAbandoned,                          // TAPI v2.2
    dwTotalCallsFlowedIn,                           // TAPI v2.2
    dwTotalCallsFlowedOut,                          // TAPI v2.2
    dwLongestEverWaitTime,                          // TAPI v2.2
    dwCurrentLongestWaitTime,                       // TAPI v2.2
    dwAverageWaitTime,                              // TAPI v2.2
    dwFinalDisposition:longint;                     // TAPI v2.2
  end;

  LPLINEPROXYREQUESTLIST=^TLineProxyRequestList;
  TLineProxyRequestList = record
    dwTotalSize,                                    // TAPI v2.2
    dwNeededSize,                                   // TAPI v2.2
    dwUsedSize,                                     // TAPI v2.2
    dwNumEntries,                                   // TAPI v2.2
    dwListSize,                                     // TAPI v2.2
    dwListOffset:LongInt;                           // TAPI v2.2
  end;
{$ENDIF}

{$IFDEF TAPI30}
  TLineCallHubTrackingInfo = record
    dwTotalSize,                                    // TAPI v3.0
    dwNeededSize,                                   // TAPI v3.0
    dwUsedSize,                                     // TAPI v3.0
    dwAvailableTracking,                            // TAPI v3.0
    dwCurrentTracking:Longint;                      // TAPI v3.0
  end;
{$ENDIF}

  LPLineDialParams = ^TLineDialParams;
  TLineDialParams = record
    dwDialPause,
    dwDialSpeed,
    dwDigitDuration,
    dwWaitForDialtone: Longint;
  end;

  PLineCallInfo = ^TLineCallInfo;
  TLineCallInfo = record
    dwTotalSize,
    dwNeededSize,
    dwUsedSize: Longint;
    hLine: THLine;
    dwLineDeviceID,
    dwAddressID,
    dwBearerMode,
    dwRate,
    dwMediaMode,
    dwAppSpecific,
    dwCallID,
    dwRelatedCallID,
    dwCallParamFlags,
    dwCallStates,
    dwMonitorDigitModes,
    dwMonitorMediaModes: Longint;
    DialParams: TLineDialParams;
    dwOrigin,
    dwReason,
    dwCompletionID,
    dwNumOwners,
    dwNumMonitors,
    dwCountryCode,
    dwTrunk,
    dwCallerIDFlags,
    dwCallerIDSize,
    dwCallerIDOffset,
    dwCallerIDNameSize,
    dwCallerIDNameOffset,
    dwCalledIDFlags,
    dwCalledIDSize,
    dwCalledIDOffset,
    dwCalledIDNameSize,
    dwCalledIDNameOffset,
    dwConnectedIDFlags,
    dwConnectedIDSize,
    dwConnectedIDOffset,
    dwConnectedIDNameSize,
    dwConnectedIDNameOffset,
    dwRedirectionIDFlags,
    dwRedirectionIDSize,
    dwRedirectionIDOffset,
    dwRedirectionIDNameSize,
    dwRedirectionIDNameOffset,
    dwRedirectingIDFlags,
    dwRedirectingIDSize,
    dwRedirectingIDOffset,
    dwRedirectingIDNameSize,
    dwRedirectingIDNameOffset,
    dwAppNameSize,
    dwAppNameOffset,
    dwDisplayableAddressSize,
    dwDisplayableAddressOffset,
    dwCalledPartySize,
    dwCalledPartyOffset,
    dwCommentSize,
    dwCommentOffset,
    dwDisplaySize,
    dwDisplayOffset,
    dwUserUserInfoSize,
    dwUserUserInfoOffset,
    dwHighLevelCompSize,
    dwHighLevelCompOffset,
    dwLowLevelCompSize,
    dwLowLevelCompOffset,
    dwChargingInfoSize,
    dwChargingInfoOffset,
    dwTerminalModesSize,
    dwTerminalModesOffset,
    dwDevSpecificSize,
    dwDevSpecificOffset: Longint;

{$IFDEF TAPI20}
    dwCallTreatment,                                { TAPI v2.0 }
    dwCallDataSize,                                 { TAPI v2.0 }
    dwCallDataOffset,                               { TAPI v2.0 }
    dwSendingFlowspecSize,                          { TAPI v2.0 }
    dwSendingFlowspecOffset,                        { TAPI v2.0 }
    dwReceivingFlowspecSize,                        { TAPI v2.0 }
    dwReceivingFlowspecOffset: Longint;             { TAPI v2.0 }
{$ENDIF}
{$IFDEF TAPI30}
    dwCallerIDAddressType,                          // TAPI v3.0
    dwCalledIDAddressType,                          // TAPI v3.0
    dwConnectedIDAddressType,                       // TAPI v3.0
    dwRedirectionIDAddressType,                     // TAPI v3.0
    dwRedirectingIDAddressType:longint;             // TAPI v3.0
{$ENDIF}
  end;


  LPLineCallList = ^TLineCallList;
  TLineCallList = record
    dwTotalSize,
    dwNeededSize,
    dwUsedSize,
    dwCallsNumEntries,
    dwCallsSize,
    dwCallsOffset: Longint;
  end;

  LPLineCallParams = ^TLineCallParams;
  TLineCallParams = record            { Defaults:        }
    dwTotalSize,                    { ---------        }
    dwBearerMode,                   { voice            }
    dwMinRate,                      { (3.1kHz)         }
    dwMaxRate,                      { (3.1kHz)         }
    dwMediaMode,                    { interactiveVoice }
    dwCallParamFlags,               { 0                }
    dwAddressMode,                  { addressID        }
    dwAddressID: Longint;           { (any available)  }
    DialParams: TLineDialParams;    { (0, 0, 0, 0)     }
    dwOrigAddressSize,              { 0                }
    dwOrigAddressOffset,
    dwDisplayableAddressSize,
    dwDisplayableAddressOffset,
    dwCalledPartySize,              { 0                }
    dwCalledPartyOffset,
    dwCommentSize,                  { 0                }
    dwCommentOffset,
    dwUserUserInfoSize,             { 0                }
    dwUserUserInfoOffset,
    dwHighLevelCompSize,            { 0                }
    dwHighLevelCompOffset,
    dwLowLevelCompSize,             { 0                }
    dwLowLevelCompOffset,
    dwDevSpecificSize,              { 0                }
    dwDevSpecificOffset: Longint;

{$IFDEF TAPI20}
    dwPredictiveAutoTransferStates,                 { TAPI v2.0 }
    dwTargetAddressSize,                            { TAPI v2.0 }
    dwTargetAddressOffset,                          { TAPI v2.0 }
    dwSendingFlowspecSize,                          { TAPI v2.0 }
    dwSendingFlowspecOffset,                        { TAPI v2.0 }
    dwReceivingFlowspecSize,                        { TAPI v2.0 }
    dwReceivingFlowspecOffset,                      { TAPI v2.0 }
    dwDeviceClassSize,                              { TAPI v2.0 }
    dwDeviceClassOffset,                            { TAPI v2.0 }
    dwDeviceConfigSize,                             { TAPI v2.0 }
    dwDeviceConfigOffset,                           { TAPI v2.0 }
    dwCallDataSize,                                 { TAPI v2.0 }
    dwCallDataOffset,                               { TAPI v2.0 }
    dwNoAnswerTimeout,                              { TAPI v2.0 }
    dwCallingPartyIDSize,                           { TAPI v2.0 }
    dwCallingPartyIDOffset: Longint;                { TAPI v2.0 }
{$ENDIF}
{$IFDEF TAPI30}
    dwAddressType:longint;                          // TAPI v3.0
{$ENDIF}
  end;

  LPLineCallStatus = ^TLineCallStatus;
  TLineCallStatus = record
    dwTotalSize,
    dwNeededSize,
    dwUsedSize,
    dwCallState,
    dwCallStateMode,
    dwCallPrivilege,
    dwCallFeatures,
    dwDevSpecificSize,
    dwDevSpecificOffset: Longint;

{$IFDEF TAPI20}
    dwCallFeatures2: Longint;                       { TAPI v2.0 }
  {$IFDEF WIN32}
    tStateEntryTime: TSystemTime;                   { TAPI v2.0 }
  {$ELSE}
    tStateEntryTime: array[0..7] of Word;           { TAPI v2.0 }
  {$ENDIF}
{$ENDIF}
  end;


{$IFDEF TAPI20}
  LPLineCallTreatmentEntry = ^TLineCallTreatmentEntry;
  TLineCallTreatmentEntry = record
    dwCallTreatmentID,                              { TAPI v2.0 }
    dwCallTreatmentNameSize,                        { TAPI v2.0 }
    dwCallTreatmentNameOffset: Longint;             { TAPI v2.0 }
  end;
{$ENDIF}


  LPLineCardEntry = ^TLineCardEntry;
  TLineCardEntry = record
    dwPermanentCardID,
    dwCardNameSize,
    dwCardNameOffset,
    dwCardNumberDigits,                             { TAPI v1.4 }
    dwSameAreaRuleSize,                             { TAPI v1.4 }
    dwSameAreaRuleOffset,                           { TAPI v1.4 }
    dwLongDistanceRuleSize,                         { TAPI v1.4 }
    dwLongDistanceRuleOffset,                       { TAPI v1.4 }
    dwInternationalRuleSize,                        { TAPI v1.4 }
    dwInternationalRuleOffset,                      { TAPI v1.4 }
    dwOptions: Longint;                             { TAPI v1.4 }
  end;

  LPLineCountryEntry = ^TLineCountryEntry;
  TLineCountryEntry = record
    dwCountryID,                                    { TAPI v1.4 }
    dwCountryCode,                                  { TAPI v1.4 }
    dwNextCountryID,                                { TAPI v1.4 }
    dwCountryNameSize,                              { TAPI v1.4 }
    dwCountryNameOffset,                            { TAPI v1.4 }
    dwSameAreaRuleSize,                             { TAPI v1.4 }
    dwSameAreaRuleOffset,                           { TAPI v1.4 }
    dwLongDistanceRuleSize,                         { TAPI v1.4 }
    dwLongDistanceRuleOffset,                       { TAPI v1.4 }
    dwInternationalRuleSize,                        { TAPI v1.4 }
    dwInternationalRuleOffset: Longint;             { TAPI v1.4 }
  end;

  LPLineCountryList = ^TLineCountryList;
  TLineCountryList = record
    dwTotalSize,                                    { TAPI v1.4 }
    dwNeededSize,                                   { TAPI v1.4 }
    dwUsedSize,                                     { TAPI v1.4 }
    dwNumCountries,                                 { TAPI v1.4 }
    dwCountryListSize,                              { TAPI v1.4 }
    dwCountryListOffset: Longint;                   { TAPI v1.4 }
  end;

  LPLineDevCaps = ^TLineDevCaps;
  TLineDevCaps = record
    dwTotalSize,
    dwNeededSize,
    dwUsedSize,
    dwProviderInfoSize,
    dwProviderInfoOffset,
    dwSwitchInfoSize,
    dwSwitchInfoOffset,
    dwPermanenTLineID,
    dwLineNameSize,
    dwLineNameOffset,
    dwStringFormat,
    dwAddressModes,
    dwNumAddresses,
    dwBearerModes,
    dwMaxRate,
    dwMediaModes,
    dwGenerateToneModes,
    dwGenerateToneMaxNumFreq,
    dwGenerateDigitModes,
    dwMonitorToneMaxNumFreq,
    dwMonitorToneMaxNumEntries,
    dwMonitorDigitModes,
    dwGatherDigitsMinTimeout,
    dwGatherDigitsMaxTimeout,
    dwMedCtlDigitMaxListSize,
    dwMedCtlMediaMaxListSize,
    dwMedCtlToneMaxListSize,
    dwMedCtlCallStateMaxListSize,
    dwDevCapFlags,
    dwMaxNumActiveCalls,
    dwAnswerMode,
    dwRingModes,
    dwLineStates,
    dwUUIAcceptSize,
    dwUUIAnswerSize,
    dwUUIMakeCallSize,
    dwUUIDropSize,
    dwUUISendUserUserInfoSize,
    dwUUICallInfoSize: Longint;
    MinDialParams,
    MaxDialParams,
    DefaultDialParams: TLineDialParams;
    dwNumTerminals,
    dwTerminalCapsSize,
    dwTerminalCapsOffset,
    dwTerminalTextEntrySize,
    dwTerminalTextSize,
    dwTerminalTextOffset,
    dwDevSpecificSize,
    dwDevSpecificOffset,

    dwLineFeatures: Longint;                        { TAPI v1.4 }

{$IFDEF TAPI20}
    dwSettableDevStatus,                            { TAPI v2.0 }
    dwDeviceClassesSize,                            { TAPI v2.0 }
    dwDeviceClassesOffset: Longint;                 { TAPI v2.0 }
{$ENDIF}
{$IFDEF TAPI22}
    PermanentLineGuid:TGUID;                        // TAPI v2.2
{$ENDIF}
{$IFDEF TAPI30}
    dwAddressTypes:longint;                         // TAPI v3.0
    ProtocolGuid:TGUID;                             // TAPI v3.0
    dwAvailableTracking:longint;                    // TAPI v3.0
{$ENDIF}
  end;

  LPLineDevStatus = ^TLineDevStatus;
  TLineDevStatus = record
    dwTotalSize,
    dwNeededSize,
    dwUsedSize,
    dwNumOpens,
    dwOpenMediaModes,
    dwNumActiveCalls,
    dwNumOnHoldCalls,
    dwNumOnHoldPendCalls,
    dwLineFeatures,
    dwNumCallCompletions,
    dwRingMode,
    dwSignalLevel,
    dwBatteryLevel,
    dwRoamMode,
    dwDevStatusFlags,
    dwTerminalModesSize,
    dwTerminalModesOffset,
    dwDevSpecificSize,
    dwDevSpecificOffset: Longint;

{$IFDEF TAPI20}
    dwAvailableMediaModes,                          { TAPI v2.0 }
    dwAppInfoSize,                                  { TAPI v2.0 }
    dwAppInfoOffset: Longint;                       { TAPI v2.0 }
{$ENDIF}
  end;

  LPLineExtensionID = ^TLineExtensionID;
  TLineExtensionID = record
    dwExtensionID0,
    dwExtensionID1,
    dwExtensionID2,
    dwExtensionID3: Longint;
  end;

  LPLineForward = ^TLineForward;
  TLineForward = record
    dwForwardMode,
    dwCallerAddressSize,
    dwCallerAddressOffset,
    dwDestCountryCode,
    dwDestAddressSize,
    dwDestAddressOffset: Longint;
  end;

  LPLineForwardList = ^TLineForwardList;
  TLineForwardList = record
    dwTotalSize,
    dwNumEntries: Longint;
  end;

  LPLineGenerateTone = ^TLineGenerateTone;
  PLINEGENERATETONE = ^TLineGENERATETONE;
  TLineGenerateTone = record
    dwFrequency,
    dwCadenceOn,
    dwCadenceOff,
    dwVolume: Longint;
  end;

{$IFDEF TAPI20}
  THandleUnion = record
    case Integer of
      0: (hEvent: THandle);
      1: (hCompletionPort: THandle);
  end;

  LPLineInitializeExParams = ^TLineInitializeExParams;
  TLineInitializeExParams = record
    dwTotalSize,                                    { TAPI v2.0 }
    dwNeededSize,                                   { TAPI v2.0 }
    dwUsedSize,                                     { TAPI v2.0 }
    dwOptions: Longint;                             { TAPI v2.0 }

    Handles: THandleUnion;

    dwCompletionKey: Longint;                       { TAPI v2.0 }
  end;
{$ENDIF}

  LPLineLocationEntry = ^TLineLocationEntry;
  TLineLocationEntry = record
    dwPermanentLocationID,
    dwLocationNameSize,
    dwLocationNameOffset,
    dwCountryCode,
    dwCityCodeSize,
    dwCityCodeOffset,
    dwPreferredCardID,

    dwLocalAccessCodeSize,                          { TAPI v1.4 }
    dwLocalAccessCodeOffset,                        { TAPI v1.4 }
    dwLongDistanceAccessCodeSize,                   { TAPI v1.4 }
    dwLongDistanceAccessCodeOffset,                 { TAPI v1.4 }
    dwTollPrefixListSize,                           { TAPI v1.4 }
    dwTollPrefixListOffset,                         { TAPI v1.4 }
    dwCountryID,                                    { TAPI v1.4 }
    dwOptions,                                      { TAPI v1.4 }
    dwCancelCallWaitingSize,                        { TAPI v1.4 }
    dwCancelCallWaitingOffset: Longint;             { TAPI v1.4 }
  end;

  LPLineMediaControlCallState = ^TLineMediaControlCallState;
  TLineMediaControlCallState = record
    dwCallStates,
    dwMediaControl: Longint;
  end;

  LPLineMediaControlDigit = ^TLineMediaControlDigit;
  TLineMediaControlDigit = record
    dwDigit,
    dwDigitModes,
    dwMediaControl: Longint;
  end;

  LPLineMediaControlMedia = ^TLineMediaControlMedia;
  TLineMediaControlMedia = record
    dwMediaModes,
    dwDuration,
    dwMediaControl: Longint;
  end;

  LPLineMediaControlTone = ^TLineMediaControlTone;
  TLineMediaControlTone = record
    dwAppSpecific,
    dwDuration,
    dwFrequency1,
    dwFrequency2,
    dwFrequency3,
    dwMediaControl: Longint;
  end;

{$IFDEF TAPI20}
  LPLineMessage = ^TLineMessage;
  TLineMessage = record
    hDevice,                                        { TAPI v2.0 }
    dwMessageID,                                    { TAPI v2.0 }
    dwCallbackInstance,                             { TAPI v2.0 }
    dwParam1,                                       { TAPI v2.0 }
    dwParam2,                                       { TAPI v2.0 }
    dwParam3: Longint;                              { TAPI v2.0 }
  end;
{$ENDIF}

  LPLineMonitorTone = ^TLineMonitorTone;
  TLineMonitorTone = record
    dwAppSpecific,
    dwDuration,
    dwFrequency1,
    dwFrequency2,
    dwFrequency3: Longint;
  end;

  LPLineProviderEntry = ^TLineProviderEntry;
  TLineProviderEntry = record
    dwPermanentProviderID,                          { TAPI v1.4 }
    dwProviderFilenameSize,                         { TAPI v1.4 }
    dwProviderFilenameOffset: Longint;              { TAPI v1.4 }
  end;

  LPLineProviderList = ^TLineProviderList;
  TLineProviderList = record
    dwTotalSize,                                    { TAPI v1.4 }
    dwNeededSize,                                   { TAPI v1.4 }
    dwUsedSize,                                     { TAPI v1.4 }
    dwNumProviders,                                 { TAPI v1.4 }
    dwProviderListSize,                             { TAPI v1.4 }
    dwProviderListOffset: Longint;                  { TAPI v1.4 }
  end;

{$IFDEF TAPI20}
{
  LPLineProxyRequest = ^TLineProxyRequest;
  TLineProxyRequest = record
    dwSize,                                         // TAPI v2.0 
    dwClientMachineNameSize,                        // TAPI v2.0 
    dwClientMachineNameOffset,                      // TAPI v2.0 
    dwClientUserNameSize,                           // TAPI v2.0 
    dwClientUserNameOffset,                         // TAPI v2.0 
    dwClientAppAPIVersion,                          // TAPI v2.0 
    dwRequestType: Longint;                         // TAPI v2.0 

    case Integer of
      0: (
        SetAgentGroup: record
          dwAddressID: Longint;                     // TAPI v2.0 
          GroupList: TLineAgentGroupList;           // TAPI v2.0 
        end;
        );
      1: (
        SetAgentState: record
          dwAddressID,                              // TAPI v2.0 
          dwAgentState,                             // TAPI v2.0 
          dwNextAgentState: Longint;                // TAPI v2.0 
        end;
        );
      2: (
        SetAgentActivity: record
          dwAddressID: Longint;                    // TAPI v2.0 
          dwActivityID: Longint;                   // TAPI v2.0 
        end;
        );
      3: (
        GetAgentCaps: record
          dwAddressID: Longint;                     // TAPI v2.0 
          AgentCaps: TLineAgentCaps;                // TAPI v2.0 
        end;
        );
      4: (
        GetAgentStatus: record
          dwAddressID: Longint;                     // TAPI v2.0 
          AgentStatus: TLineAgentStatus;            // TAPI v2.0 
        end;
        );
      5: (
        AgentSpecific: record
          dwAddressID,                              // TAPI v2.0 
          dwAgentExtensionIDIndex,                  //TAPI v2.0 
          dwSize: Longint;                          // TAPI v2.0 
          Params: array[0..0] of Byte;              //TAPI v2.0 
        end;
        );
      6: (
        GetAgentActivityList: record
          dwAddressID: Longint;                     // TAPI v2.0 
          ActivityList: TLineAgentActivityList;     // TAPI v2.0 
        end;
        );
      7: (
        GetAgentGroupList: record
          dwAddressID: Longint;                     //TAPI v2.0 
          GroupList: TLineAgentGroupList;          // TAPI v2.0 
        end;                                                   
        );
 
$IFDEF TAPI22
      8:(
        CreateAgent: record
          hAgent,                         // TAPI v2.2
          dwAgentIDSize,                  // TAPI v2.2
          dwAgentIDOffset,                // TAPI v2.2
          dwAgentPINSize,                 // TAPI v2.2
          dwAgentPINOffset:longint;
        end;
        );
      9:(
        SetAgentStateEx:record
          hAgent,                         // TAPI v2.2
          dwAgentState,                   // TAPI v2.2
          dwNextAgentState:Longint;       // TAPI v2.2
        end;
        );
      10:(
        SetAgentMeasurementPeriod:record
          hAgent,                         // TAPI v2.2
          dwMeasurementPeriod:longint;   // TAPI v2.2
        end;
        );
      11:(
        GetAgentInfo:record
          hAgent,                         // TAPI v2.2
          AgentInfo:longint;              // TAPI v2.2
        end;
        );
      12:(
        CreateAgentSession:record
          hAgentSession,                  // TAPI v2.2
          dwAgentPINSize,
          dwAgentPINOffset,
          hAgent:longint;                // TAPI v2.2
          GroupID:TGUID;                  // TAPI v2.2
          dwWorkingAddressID:longint;    // TAPI v2.2
        end;
        );
      13:(
        GetAgentSessionList : record
          hAgent:longint;                     // TAPI v2.2
          SessionList:TLineAgentSessionList;  // TAPI v2.2
        end;
        );
      14:(
        GetAgentSessionInfo : record
          hAgentSession:longint;                  // TAPI v2.2
          SessionInfo:TLINEAGENTSESSIONINFO;      // TAPI v2.2
        end;
        );
      15:(
        SetAgentSessionState:record
          hAgentSession,                  // TAPI v2.2
          dwAgentSessionState,            // TAPI v2.2
          dwNextAgentSessionState:longint;// TAPI v2.2
        end;
        );
      16:(
        GetQueueList: record
          GroupID:TGUID;                        // TAPI v2.2
          QueueList:TLINEQUEUELIST;             // TAPI v2.2
        end;
        );
      17:(
        SetQueueMeasurementPeriod:record
          dwQueueID,                      // TAPI v2.2
          dwMeasurementPeriod:longint;    // TAPI v2.2
        end;
        );
      18:(
        GetQueueInfo:record
          dwQueueID:longint;                // TAPI v2.2
          QueueInfo:TLINEQUEUEINFO;         // TAPI v2.2
        end;
        );
      19:(
        GetGroupList:record
          GroupList:TLINEAGENTGROUPLIST;    // TAPI v2.2
        end;
        );

     $ENDIF

  end;
}
{$ENDIF}


  LPLineReqMakeCall = ^TLineReqMakeCall;
  TLineReqMakeCall = record
    szDestAddress: array[0..TAPIMAXDESTADDRESSSIZE - 1] of Char;
    szAppName: array[0..TAPIMAXAPPNAMESIZE - 1] of Char;
    szCalledParty: array[0..TAPIMAXCALLEDPARTYSIZE - 1] of Char;
    szComment: array[0..TAPIMAXCOMMENTSIZE - 1] of Char;
  end;

{$IFDEF TAPI20}
  LPLineReqMakeCallW = ^TLineReqMakeCallW;
  TLineReqMakeCallW = record
    szDestAddress: array[0..TAPIMAXDESTADDRESSSIZE - 1] of WideChar;
    szAppName: array[0..TAPIMAXAPPNAMESIZE - 1] of WideChar;
    szCalledParty: array[0..TAPIMAXCALLEDPARTYSIZE - 1] of WideChar;
    szComment: array[0..TAPIMAXCOMMENTSIZE - 1] of WideChar;
  end;
{$ENDIF}


  LPLineReqMediaCall = ^TLineReqMediaCall;
  TLineReqMediaCall = record
    HWnd: HWnd;
		wRequestID: WPARAM;
    szDeviceClass: array[0..TAPIMAXDEVICECLASSSIZE - 1] of Char;
    ucDeviceID: array[0..TAPIMAXDEVICEIDSIZE - 1] of Byte;
    dwSize,
    dwSecure: Longint;
    szDestAddress: array[0..TAPIMAXDESTADDRESSSIZE] of Char;
    szAppName: array[0..TAPIMAXAPPNAMESIZE] of Char;
    szCalledParty: array[0..TAPIMAXCALLEDPARTYSIZE] of Char;
    szComment: array[0..TAPIMAXCOMMENTSIZE] of Char;
  end;

{$IFDEF TAPI20}
  LPLineReqMediaCallW = ^TLineReqMediaCallW;
  TLineReqMediaCallW = record
    HWnd: HWnd;
    wRequestID: WPARAM;
    szDeviceClass: array[0..TAPIMAXDEVICECLASSSIZE - 1] of WideChar;
    ucDeviceID: array[0..TAPIMAXDEVICEIDSIZE - 1] of Byte;
    dwSize,
    dwSecure: Longint;
    szDestAddress: array[0..TAPIMAXDESTADDRESSSIZE] of WideChar;
    szAppName: array[0..TAPIMAXAPPNAMESIZE] of WideChar;
    szCalledParty: array[0..TAPIMAXCALLEDPARTYSIZE] of WideChar;
    szComment: array[0..TAPIMAXCOMMENTSIZE] of WideChar;
  end;
{$ENDIF}


  LPLineTermCaps = ^TLineTermCaps;
  TLineTermCaps = record
    dwTermDev,
    dwTermModes,
    dwTermSharing: Longint;
  end;

  LPLineTranslateCaps = ^TLineTranslateCaps;
  TLineTranslateCaps = record
    dwTotalSize,
    dwNeededSize,
    dwUsedSize,
    dwNumLocations,
    dwLocationListSize,
    dwLocationListOffset,
    dwCurrentLocationID,
    dwNumCards,
    dwCardListSize,
    dwCardListOffset,
    dwCurrentPreferredCardID: Longint;
  end;

  LPLineTranslateOutput = ^TLineTranslateOutput;
  TLineTranslateOutput = record
    dwTotalSize,
    dwNeededSize,
    dwUsedSize,
    dwDialableStringSize,
    dwDialableStringOffset,
    dwDisplayableStringSize,
    dwDisplayableStringOffset,
    dwCurrentCountry,
    dwDestCountry,
    dwTranslateResults: Longint;
  end;

  LPPhoneButtonInfo = ^TPhoneButtonInfo;
  TPhoneButtonInfo = record
    dwTotalSize,
    dwNeededSize,
    dwUsedSize,
    dwButtonMode,
    dwButtonFunction,
    dwButtonTextSize,
    dwButtonTextOffset,
    dwDevSpecificSize,
    dwDevSpecificOffset,

    dwButtonState: Longint;                         { TAPI v1.4 }
  end;

  LPPhoneCaps = ^TPhoneCaps;
  TPhoneCaps = record
    dwTotalSize,
    dwNeededSize,
    dwUsedSize,
    dwProviderInfoSize,
    dwProviderInfoOffset,
    dwPhoneInfoSize,
    dwPhoneInfoOffset,
    dwPermanenTPhoneID,
    dwPhoneNameSize,
    dwPhoneNameOffset,
    dwStringFormat,
    dwPhoneStates,
    dwHookSwitchDevs,
    dwHandsetHookSwitchModes,
    dwSpeakerHookSwitchModes,
    dwHeadsetHookSwitchModes,
    dwVolumeFlags,
    dwGainFlags,
    dwDisplayNumRows,
    dwDisplayNumColumns,
    dwNumRingModes,
    dwNumButtonLamps,
    dwButtonModesSize,
    dwButtonModesOffset,
    dwButtonFunctionsSize,
    dwButtonFunctionsOffset,
    dwLampModesSize,
    dwLampModesOffset,
    dwNumSetData,
    dwSetDataSize,
    dwSetDataOffset,
    dwNumGetData,
    dwGetDataSize,
    dwGetDataOffset,
    dwDevSpecificSize,
    dwDevSpecificOffset: Longint;

{$IFDEF TAPI20}
    dwDeviceClassesSize,                            { TAPI v2.0 }
    dwDeviceClassesOffset,                          { TAPI v2.0 }
    dwPhoneFeatures,                                { TAPI v2.0 }
    dwSettableHandsetHookSwitchModes,               { TAPI v2.0 }
    dwSettableSpeakerHookSwitchModes,               { TAPI v2.0 }
    dwSettableHeadsetHookSwitchModes,               { TAPI v2.0 }
    dwMonitoredHandsetHookSwitchModes,              { TAPI v2.0 }
    dwMonitoredSpeakerHookSwitchModes,              { TAPI v2.0 }
    dwMonitoredHeadsetHookSwitchModes: Longint;     { TAPI v2.0 }
{$ENDIF}
{$IFDEF TAPI22}
    PermanentPhoneGuid:TGUID;                       // TAPI v2.2
{$ENDIF}
  end;

  LPPhoneExtensionId = ^TPhoneExtensionId;
  TPhoneExtensionId = record
    dwExtensionID0,
    dwExtensionID1,
    dwExtensionID2,
    dwExtensionID3: Longint;
  end;

{$IFDEF TAPI20}
  LPPhoneInitializeExParams = ^TPhoneInitializeExParams;
  TPhoneInitializeExParams = record
    dwTotalSize,                                    { TAPI v2.0 }
    dwNeededSize,                                   { TAPI v2.0 }
    dwUsedSize,                                     { TAPI v2.0 }
    dwOptions: Longint;                             { TAPI v2.0 }

    Handles: THandleUnion;

    dwCompletionKey: Longint;                       { TAPI v2.0 }
  end;

  LPPhoneMessage = ^TPhoneMessage;
  TPhoneMessage = record
    hDevice,                                        { TAPI v2.0 }
    dwMessageID,                                    { TAPI v2.0 }
    dwCallbackInstance,                             { TAPI v2.0 }
    dwParam1,                                       { TAPI v2.0 }
    dwParam2,                                       { TAPI v2.0 }
    dwParam3: Longint;                              { TAPI v2.0 }
  end;
{$ENDIF}

  LPPhoneStatus = ^TPhoneStatus;
  TPhoneStatus = record
    dwTotalSize,
    dwNeededSize,
    dwUsedSize,
    dwStatusFlags,
    dwNumOwners,
    dwNumMonitors,
    dwRingMode,
    dwRingVolume,
    dwHandsetHookSwitchMode,
    dwHandsetVolume,
    dwHandsetGain,
    dwSpeakerHookSwitchMode,
    dwSpeakerVolume,
    dwSpeakerGain,
    dwHeadsetHookSwitchMode,
    dwHeadsetVolume,
    dwHeadsetGain,
    dwDisplaySize,
    dwDisplayOffset,
    dwLampModesSize,
    dwLampModesOffset,
    dwOwnerNameSize,
    dwOwnerNameOffset,
    dwDevSpecificSize,
    dwDevSpecificOffset: Longint;

{$IFDEF TAPI20}
    dwPhoneFeatures: Longint;                       { TAPI v2.0 }
{$ENDIF}
  end;

{$IFDEF VER100}
  PCommConfig = ^TCommConfig;
  _COMMCONFIG = record
    dwSize: DWORD;
    wVersion: Word;
    wReserved: Word;
    dcb: TDCB;
    dwProviderSubType: DWORD;
    dwProviderOffset: DWORD;
    dwProviderSize: DWORD;
    wcProviderData: array[0..0] of WCHAR;
  end;

  TCommConfig = _COMMCONFIG;
  COMMCONFIG = _COMMCONFIG;

{$ENDIF}

  LPVarString = ^TVarString;
  TVarString = record
    dwTotalSize,
    dwNeededSize,
    dwUsedSize,
    dwStringFormat,
    dwStringSize,
    dwStringOffset: Longint;
  end;

  TModemDevCaps=packed record
    dwActualSize:cardinal;
    dwRequiredSize:cardinal;
    dwDevSpecificOffset:cardinal;
    dwDevSpecificSize:cardinal;
    // product and version identification
    dwModemProviderVersion:cardinal;
    dwModemManufacturerOffset:cardinal;
    dwModemManufacturerSize:cardinal;
    dwModemModelOffset:cardinal;
    dwModemModelSize:cardinal;
    dwModemVersionOffset:cardinal;
    dwModemVersionSize:cardinal;
    // local option capabilities
    dwDialOptions:cardinal;          // bitmap of supported values
    dwCallSetupFailTimer:cardinal;   // maximum in seconds
    dwInactivityTimeout:cardinal;    // maximum in seconds
    dwSpeakerVolume:cardinal;        // bitmap of supported values
    dwSpeakerMode:cardinal;          // bitmap of supported values
    dwModemOptions:cardinal;         // bitmap of supported values
    dwMaxDTERate:cardinal;           // maximum value in bit/s
    dwMaxDCERate:cardinal;           // maximum value in bit/s
    // Variable portion for proprietary expansion
    abVariablePortion:byte;
  end;
  _MODEMDEVCAPS = TModemDevCaps;
  MODEMDEVCAPS = TModemDevCaps;
  PMODEMDEVCAPS = ^TModemDevCaps;
  LPMODEMDEVCAPS = ^TModemDevCaps;

  TModemSettings =packed record
    dwActualSize:cardinal;
    dwRequiredSize:cardinal;
    dwDevSpecificOffset:cardinal;
    dwDevSpecificSize:cardinal;
    // static local options (read/write)
    dwCallSetupFailTimer:cardinal;       // seconds
    dwInactivityTimeout:cardinal;        // seconds
    dwSpeakerVolume:cardinal;            // level
    dwSpeakerMode:cardinal;              // mode
    dwPreferredModemOptions:cardinal;    // bitmap
    // negotiated options (read only) for current or last call
    dwNegotiatedModemOptions:cardinal;   // bitmap
    dwNegotiatedDCERate:cardinal;        // bit/s
    // Variable portion for proprietary expansion
    abVariablePortion:char;
  end;

  MODEMSETTINGS=TModemSettings;
  PMODEMSETTINGS=^TModemSettings;
  LPMODEMSETTINGS=^TModemSettings;

  // Device setting information
  TDevCfgDr = packed record
    dwSize:cardinal;
    dwVersion:cardinal;
    fwOptions:word;
    wWaitBong:word;
  end;

  TDevCfg = packed record
    vs:TVARSTRING;
    dfgHdr:TDevCfgDr;
    commconfig:COMMCONFIG;
  end;

  TnrCommConfig = record
    dwSize: DWORD;
    wVersion: Word;
    wReserved: Word;
    dcb: TDCB;
    dwProviderSubType: DWORD;
    dwProviderOffset: DWORD;
    dwProviderSize: DWORD;
    ModemSettings:TModemSettings;
  end;


  TModemDeviceConfig=packed record
    vs:TVARSTRING;
    dfgHdr:TDevCfgDr;
    CommConfig:TnrCommConfig;
  end;


{$IFDEF GEN3}
Type
  WAVEOUTCAPS = record
    wMid: Word;                 { manufacturer ID }
    wPid: Word;                 { product ID }
    vDriverVersion: UINT;       { version of the driver }
    szPname: array[0..31] of AnsiChar;  { product name (NULL terminated string) }
    dwFormats: DWORD;          { formats supported }
    wChannels: Word;            { number of sources supported }
    dwSupport: DWORD;          { functionality supported by driver }
  end;

  WAVEINCAPS = record
    wMid: Word;                   { manufacturer ID }
    wPid: Word;                   { product ID }
    vDriverVersion: UINT;         { version of the driver }
    szPname: array[0..31-1] of AnsiChar;    { product name (NULL terminated string) }
    dwFormats: DWORD;             { formats supported }
    wChannels: Word;              { number of channels supported }
    wReserved1: Word;             { structure packing }
  end;
  {$ENDIF}

Const
  // Dial Options
  DIALOPTION_BILLING  =$00000040;  // Supports wait for bong "$"
  DIALOPTION_QUIET    =$00000080;  // Supports wait for quiet "@"
  DIALOPTION_DIALTONE =$00000100;  // Supports wait for dial tone "W"

  // SpeakerVolume for MODEMDEVCAPS
  MDMVOLFLAG_LOW      =$00000001;
  MDMVOLFLAG_MEDIUM   =$00000002;
  MDMVOLFLAG_HIGH     =$00000004;

  // SpeakerVolume for MODEMSETTINGS
  MDMVOL_LOW          =$00000000;
  MDMVOL_MEDIUM       =$00000001;
  MDMVOL_HIGH         =$00000002;

  // SpeakerMode for MODEMDEVCAPS
  MDMSPKRFLAG_OFF         =$00000001;
  MDMSPKRFLAG_DIAL        =$00000002;
  MDMSPKRFLAG_ON          =$00000004;
  MDMSPKRFLAG_CALLSETUP   =$00000008;

  // SpeakerMode for MODEMSETTINGS
  MDMSPKR_OFF         =$00000000;
  MDMSPKR_DIAL        =$00000001;
  MDMSPKR_ON          =$00000002;
  MDMSPKR_CALLSETUP   =$00000003;

  // Modem Options
  MDM_COMPRESSION      =$00000001;
  MDM_ERROR_CONTROL    =$00000002;
  MDM_FORCED_EC        =$00000004;
  MDM_CELLULAR         =$00000008;
  MDM_FLOWCONTROL_HARD =$00000010;    // RTS/CTS  stream control
  MDM_FLOWCONTROL_SOFT =$00000020;    // Xon/xOff stream control
  MDM_CCITT_OVERRIDE   =$00000040;    //
  MDM_SPEED_ADJUST     =$00000080;    //
  MDM_TONE_DIAL        =$00000100;    // tone
  MDM_BLIND_DIAL       =$00000200;    //
  MDM_V23_OVERRIDE     =$00000400;
  MDM_DIAGNOSTICS      =$00000800;

  WAVE_FORMAT_QUERY         =$0001;
  WAVE_ALLOWSYNC            =$0002;
  WAVE_MAPPED               =$0004;
  WAVE_FORMAT_DIRECT        =$0008;
  WAVE_FORMAT_DIRECT_QUERY  = (WAVE_FORMAT_QUERY + WAVE_FORMAT_DIRECT);

  {$IFNDEF VER100}
  {$EXTERNALSYM DIALOPTION_DIALTONE}
  {$EXTERNALSYM DIALOPTION_BILLING}
  {$EXTERNALSYM DIALOPTION_QUIET}
  {$EXTERNALSYM MDMVOLFLAG_LOW}
  {$EXTERNALSYM MDMVOLFLAG_MEDIUM}
  {$EXTERNALSYM MDMVOLFLAG_HIGH}
  {$EXTERNALSYM MDMVOL_LOW}
  {$EXTERNALSYM MDMVOL_MEDIUM}
  {$EXTERNALSYM MDMVOL_HIGH}
  {$EXTERNALSYM MDMSPKRFLAG_OFF}
  {$EXTERNALSYM MDMSPKRFLAG_DIAL}
  {$EXTERNALSYM MDMSPKRFLAG_ON}
  {$EXTERNALSYM MDMSPKRFLAG_CALLSETUP}
  {$EXTERNALSYM MDMSPKR_OFF}
  {$EXTERNALSYM MDMSPKR_DIAL}
  {$EXTERNALSYM MDMSPKR_ON}
  {$EXTERNALSYM MDMSPKR_CALLSETUP}
  {$EXTERNALSYM MDM_COMPRESSION}
  {$EXTERNALSYM MDM_ERROR_CONTROL}
  {$EXTERNALSYM MDM_FORCED_EC}
  {$EXTERNALSYM MDM_CELLULAR}
  {$EXTERNALSYM MDM_FLOWCONTROL_HARD}
  {$EXTERNALSYM MDM_FLOWCONTROL_SOFT}
  {$EXTERNALSYM MDM_CCITT_OVERRIDE}
  {$EXTERNALSYM MDM_SPEED_ADJUST}
  {$EXTERNALSYM MDM_TONE_DIAL}
  {$EXTERNALSYM MDM_BLIND_DIAL}
  {$EXTERNALSYM MDM_V23_OVERRIDE}
  {$EXTERNALSYM MDM_DIAGNOSTICS}

  {$EXTERNALSYM WAVE_FORMAT_QUERY}
  {$EXTERNALSYM WAVE_ALLOWSYNC}
  {$EXTERNALSYM WAVE_MAPPED}
  {$EXTERNALSYM WAVE_FORMAT_DIRECT}
  {$EXTERNALSYM WAVE_FORMAT_DIRECT_QUERY}
  {$ENDIF}

function lineInitialize(
	var lphLineApp: THLineApp;
	hInstance: HInst;
	lpfnCallback: TLineCallback;
	lpszAppName: PChar;
	var lpdwNumDevs: Longint): Longint;

function lineInitializeEx(
	var lphLineApp: THLineApp;
	hInstance: HInst;
	lpfnCallback: TLineCallback;
	lpszFriendlyAppName: PChar;
	var lpdwNumDevs: Longint;
	var lpdwAPIVersion: Longint;
	var lpLineInitializeExParams: TLineInitializeExParams): Longint;

function lineShutdown(var hLineApp: THLineApp): Longint;

function lineNegotiateAPIVersion(
  hLineApp: THLineApp;
  dwDeviceID: Longint;
  dwAPILowVersion: Longint;
  dwAPIHighVersion: Longint;
  var lpdwAPIVersion: Longint;
  var lpExtensionID: TLineExtensionID): Longint;

function lineGetID(
  hLine: THLine;
  dwAddressID: Longint;
  hCall: THCall;
  dwSelect: Longint;
  var lpDeviceID: TVarString;
  lpszDeviceClass: PChar): Longint;

function lineOpen(
  hLineApp: THLineApp;
  dwDeviceID: Longint;
  var lphLine: THLine;
  dwAPIVersion: Longint;
  dwExtVersion: Longint;
  dwCallbackInstance: Longint;
  dwPrivileges: Longint;
  dwMediaModes: Longint;
  lpCallParams: LPLineCallParams): Longint;

function lineGetCallStatus(
  hCall: THCall;
  var lpCallStatus: TLineCallStatus): Longint;

function lineDrop(
  hCall: THCall;
  lpsUserUserInfo: PChar;
  dwSize: Longint): Longint;

function lineDeallocateCall(
    hCall: THCall): Longint;

function lineClose(
  hLine: THLine): Longint;

function lineMakeCall(
  hLine: THLine;
  var lphCall: THCall;
  lpszDestAddress: PChar;
  dwCountryCode: Longint;
  lpCallParams: LPLineCallParams): Longint;

function lineAnswer(
  hCall: THCall;
  lpsUserUserInfo: PChar;
  dwSize: Longint): Longint;

function lineConfigDialog(
  dwDeviceID: Longint;
  hwndOwner: HWnd;
  lpszDeviceClass: PChar): Longint;

function lineGetDevConfig(
  dwDeviceID: Longint;
  var lpDeviceConfig: TVarString;
  lpszDeviceClass: PChar): Longint;

function lineGetDevCaps(
  hLineApp: THLineApp;
  dwDeviceID:integer;
  dwAPIVersion:integer;
  dwExtVersion:integer;
  lpLineDevCaps:LPLINEDEVCAPS):longint;

function lineSetDevConfig(
  dwDeviceID: Longint;
  lpDeviceConfig: Pointer;
  dwSize: Longint;
  lpszDeviceClass: PChar): Longint;

function lineGetIcon(
  dwDeviceID: Longint;
  lpszDeviceClass: PChar;
  var lphIcon: HIcon): Longint;

function lineTranslateDialog(
  hLineApp: THLineApp;  dwDeviceID:integer;
  dwAPIVersion:integer; hWnd:integer; pcNumber:PChar):longint;

function lineTranslateAddress(
  hLineApp: THLineApp;  dwDeviceID:integer;
  dwAPIVersion:integer; lpszAddressIn:PChar;
  dwCard:integer; dwTranslateOptions:integer;
  lpTranslateOutput:LPLINETRANSLATEOUTPUT):longint;

function lineGetAddressID(
  hLine:THLine;var lpdwAddressID:integer;
  dwAddressMode:integer;lpsAddress:PChar;
  dwSize:integer
):longint;


function lineUncompleteCall(
    hLine: THLine;Cd:integer): Longint;


function lineGenerateDigits(
  hCall:THCall;
  dwDigitMode:longint;
  lpszDigits:PChar;
  dwDuration:longint):longint;

function lineMonitorDigits(
  hCall:THCall;
  dwDigitModes:longint):longint;

function lineMonitorTones(
  hCall:THCall;
  lpToneList:LPLINEMONITORTONE;
  dwNumEntries:integer
  ):longint;

function lineGenerateTone(
  hCall:THCall;
  dwToneMode,dwDuration,dwNumTones:Cardinal;
  lpTones:LPLINEGENERATETONE
):longint;

function lineGetCallInfo(
  hCall:THCall;
  lpInfo:PLineCallInfo
):longint;

function lineSetCallParams(
  hCall:THCall;
  dwBearerMode,dwMinRate,dwMaxRate:dword;
  lpDialParams:LPLINEDIALPARAMS
):longint;

function lineSetStatusMessages(hLine: THLine;dwLineStates,
   dwAddressStates: DWORD):longint;

function lineMonitorMedia(hCall: THCall; dwMediaModes : DWORD):longint;

function lineGetMessage(hLineApp:THLineApp;var lpMessage:TLINEMESSAGE;
         dwTimeout: DWORD):longint;

function lineSetCallPrivilege(hCall : THCall; dwCallPrivilege:DWORD):longint;

function TAPIERROR_FORMATMESSAGE (ErrCode: cardinal): Longint;
function GetTapiErrorString(ErrCode:cardinal):string;

Var
  hTAPIDLL   : THandle = 0;
  hTAPIUIDLL : THandle = 0;


implementation
uses nrwin32;

Const
  FileNameTAPIDLL = 'tapi32.dll';
  FileNameTAPIUIDLL = 'tapiui.dll';
  ErrorBufferSize = 1024;


function TAPIERROR_FORMATMESSAGE (ErrCode: cardinal): Longint;
begin
  case (ErrCode and $F0000000)of
    $90000000: Result:=ErrCode - $90000000 + $F000;  //PHONEERR
    $80000000: Result:=ErrCode - $80000000 + $E000;  //LINEERR
    else Result:=ErrCode and $FFFF0000;              //TAPIERR
  end;
end;

function GetTapiErrorString(ErrCode:cardinal):string;
begin
  if hTAPIUIDLL = 0 then hTAPIUIDLL := LoadLibrary(FileNameTAPIUIDLL);
  if hTAPIUIDLL <> 0 then begin
    SetLength(Result,ErrorBufferSize);
    SetLength(Result,FormatMessage(FORMAT_MESSAGE_FROM_HMODULE,Pointer(hTAPIUIDLL),
                    TAPIERROR_FORMATMESSAGE(ErrCode),0,
                    PChar(Result),ErrorBufferSize,nil));
  end else Result:='Unknown error. Can''t load '+FileNameTAPIUIDLL;
end;

function AllocTAPIDLL:boolean;
begin
  if hTAPIDLL=0 then hTAPIDLL:=LoadLibrary(FileNameTAPIDLL);
  Result:=(hTAPIDLL<>0);
end;

function FreeTAPIDLL:boolean;
begin
  Result:=FreeLibrary(hTAPIDLL);
  if Result then hTAPIDLL:=0;
end;


function lineInitialize(
	var lphLineApp: THLineApp;
	hInstance: HInst;
	lpfnCallback: TLineCallback;
	lpszAppName: PChar;
	var lpdwNumDevs: Longint): Longint;

var p:function(var lphLineApp: THLineApp;
               hInstance: HInst;
	       lpfnCallback: TLineCallback;
	       lpszAppName: PChar;
	       var lpdwNumDevs: Longint): Longint; stdcall;
begin
  Result:=-1;
  if not AllocTAPIDLL then exit;
  @p:=GetProcAddress(hTAPIDLL,'lineInitialize');
  if @p=nil then exit;
  Result:=p(lphLineApp, hInstance,lpfnCallback,lpszAppName, lpdwNumDevs);
end;

function lineInitializeEx(
	var lphLineApp: THLineApp;
	hInstance: HInst;
	lpfnCallback: TLineCallback;
	lpszFriendlyAppName: PChar;
	var lpdwNumDevs: Longint;
	var lpdwAPIVersion: Longint;
	var lpLineInitializeExParams: TLineInitializeExParams): Longint;

var p:function(var lphLineApp: THLineApp;
	hInstance: HInst;
	lpfnCallback: TLineCallback;
	lpszFriendlyAppName: PChar;
	var lpdwNumDevs: Longint;
	var lpdwAPIVersion: Longint;
	var lpLineInitializeExParams: TLineInitializeExParams): Longint; stdcall;
begin
  Result:=-1;
  if not AllocTAPIDLL then exit;
  @p:=GetProcAddress(hTAPIDLL,'lineInitializeExA');
  if @p=nil then exit;
  Result:=p(lphLineApp,hInstance,lpfnCallback,lpszFriendlyAppName,
	lpdwNumDevs,lpdwAPIVersion,lpLineInitializeExParams);
end;

function lineShutdown(var hLineApp: THLineApp): Longint;
var p:function (hLineApp: THLineApp): Longint; stdcall;
begin
  Result:=-1;
  if not AllocTAPIDLL then exit;
  @p:=GetProcAddress(hTAPIDLL,'lineShutdown');
  if @p=nil then exit;
  Result:=p(hLineApp);
  hLineApp:=0;
  FreeTAPIDLL;
end;

function lineNegotiateAPIVersion(
  hLineApp: THLineApp;
  dwDeviceID: Longint;
  dwAPILowVersion: Longint;
  dwAPIHighVersion: Longint;
  var lpdwAPIVersion: Longint;
  var lpExtensionID: TLineExtensionID): Longint;

var p:function (
  hLineApp: THLineApp;
  dwDeviceID: Longint;
  dwAPILowVersion: Longint;
  dwAPIHighVersion: Longint;
  var lpdwAPIVersion: Longint;
  var lpExtensionID: TLineExtensionID): Longint; stdcall;

begin
  Result:=-1;
  if not AllocTAPIDLL then exit;
  @p:=GetProcAddress(hTAPIDLL,'lineNegotiateAPIVersion');
  if @p=nil then exit;
  Result:=p(hLineApp,dwDeviceID,dwAPILowVersion,dwAPIHighVersion,
            lpdwAPIVersion,lpExtensionID);
end;


function lineGetID(
  hLine: THLine;
  dwAddressID: Longint;
  hCall: THCall;
  dwSelect: Longint;
  var lpDeviceID: TVarString;
  lpszDeviceClass: PChar): Longint;

var p:function (
  hLine: THLine;
  dwAddressID: Longint;
  hCall: THCall;
  dwSelect: Longint;
  var lpDeviceID: TVarString;
  lpszDeviceClass: PChar): Longint; stdcall;

begin
  Result := -1;
  if not AllocTAPIDLL then exit;
  @p := GetProcAddress(hTAPIDLL, GetW32Name('lineGetIDA'));
  if @p = nil then exit;
  Result := p(hLine, dwAddressID, hCall, dwSelect, lpDeviceID, lpszDeviceClass);
end;

function lineOpen(
  hLineApp: THLineApp;
  dwDeviceID: Longint;
  var lphLine: THLine;
  dwAPIVersion: Longint;
  dwExtVersion: Longint;
  dwCallbackInstance: Longint;
  dwPrivileges: Longint;
  dwMediaModes: Longint;
  lpCallParams: LPLineCallParams): Longint;

var p:function (
  hLineApp: THLineApp;
  dwDeviceID: Longint;
  var lphLine: THLine;
  dwAPIVersion: Longint;
  dwExtVersion: Longint;
  dwCallbackInstance: Longint;
  dwPrivileges: Longint;
  dwMediaModes: Longint;
  lpCallParams: LPLineCallParams): Longint; stdcall;

begin
  Result:=-1;
  if not AllocTAPIDLL then exit;
  @p:=GetProcAddress(hTAPIDLL,'lineOpen');
  if @p=nil then exit;
  Result:=p(hLineApp,dwDeviceID,lphLine,dwAPIVersion,dwExtVersion,
            dwCallbackInstance,dwPrivileges,dwMediaModes,lpCallParams);
end;

function lineGetCallStatus(
  hCall: THCall;
  var lpCallStatus: TLineCallStatus): Longint;

var p:function (hCall: THCall;
               var lpCallStatus: TLineCallStatus): Longint; stdcall;
begin
  Result:=-1;
  if not AllocTAPIDLL then exit;
  @p:=GetProcAddress(hTAPIDLL,'lineGetCallStatus');
  if @p=nil then exit;
  Result:=p(hCall,lpCallStatus);
end;

function lineDrop(
  hCall: THCall;
  lpsUserUserInfo: PChar;
  dwSize: Longint): Longint;
var p:function (
  hCall: THCall;
  lpsUserUserInfo: PChar;
  dwSize: Longint): Longint; stdcall;
begin
  Result:=-1;
  if not AllocTAPIDLL then exit;
  @p:=GetProcAddress(hTAPIDLL,'lineDrop');
  if @p=nil then exit;
  Result:=p(hCall,lpsUserUserInfo,dwSize);
end;

function lineDeallocateCall(
    hCall: THCall): Longint;
var p:function (hCall: THCall): Longint; stdcall;
begin
  Result:=-1;
  if not AllocTAPIDLL then exit;
  @p:=GetProcAddress(hTAPIDLL,'lineDeallocateCall');
  if @p=nil then exit;
  Result:=p(hCall);
end;

function lineClose( hLine: THLine): Longint;
var p:function( hLine: THLine): Longint; stdcall;
begin
  Result:=-1;
  if not AllocTAPIDLL then exit;
  @p:=GetProcAddress(hTAPIDLL,'lineClose');
  if @p=nil then exit;
  Result:=p(hLine);
end;

function lineMakeCall(
  hLine: THLine;
  var lphCall: THCall;
  lpszDestAddress: PChar;
  dwCountryCode: Longint;
  lpCallParams: LPLineCallParams): Longint;

var p:function(
  hLine: THLine;
  var lphCall: THCall;
  lpszDestAddress: PChar;
  dwCountryCode: Longint;
  lpCallParams: LPLineCallParams): Longint; stdcall;
begin
  Result:=-1;
  if not AllocTAPIDLL then exit;
  @p:=GetProcAddress(hTAPIDLL,GetW32Name('lineMakeCallA'));
  if @p=nil then exit;
  Result:=p(hLine,lphCall,lpszDestAddress,dwCountryCode,lpCallParams);
end;

function lineAnswer(
  hCall: THCall;
  lpsUserUserInfo: PChar;
  dwSize: Longint): Longint;
var p:function (
  hCall: THCall;
  lpsUserUserInfo: PChar;
  dwSize: Longint): Longint;  stdcall;
begin
  Result:=-1;
  if not AllocTAPIDLL then exit;
  @p:=GetProcAddress(hTAPIDLL,'lineAnswer');
  if @p=nil then exit;
  Result:=p(hCall,lpsUserUserInfo,dwSize);
end;

function lineConfigDialog(
  dwDeviceID: Longint;
  hwndOwner: HWnd;
  lpszDeviceClass: PChar): Longint;
var p:function(
  dwDeviceID: Longint;
  hwndOwner: HWnd;
  lpszDeviceClass: PChar): Longint;  stdcall;
begin
  Result := -1;
  if not AllocTAPIDLL then exit;
  @p := GetProcAddress(hTAPIDLL,GetW32Name('lineConfigDialogA'));
  if @p = nil then exit;
  Result := p(dwDeviceID,hwndOwner,lpszDeviceClass);
end;

function lineGetDevConfig(
  dwDeviceID: Longint;
  var lpDeviceConfig: TVarString;
  lpszDeviceClass: PChar): Longint;

var p:function (
  dwDeviceID: Longint;
  var lpDeviceConfig: TVarString;
  lpszDeviceClass: PChar): Longint; stdcall;

begin
  Result:=-1;
  if not AllocTAPIDLL then exit;
  @p:=GetProcAddress(hTAPIDLL,GetW32Name('lineGetDevConfigA'));
  if @p=nil then exit;
  Result:=p(dwDeviceID,lpDeviceConfig,lpszDeviceClass);
end;

function lineSetDevConfig(
  dwDeviceID: Longint;
  lpDeviceConfig: Pointer;
  dwSize: Longint;
  lpszDeviceClass: PChar): Longint;
var p:function(
  dwDeviceID: Longint;
  lpDeviceConfig: Pointer;
  dwSize: Longint;
  lpszDeviceClass: PChar): Longint; stdcall;
begin
  Result:=-1;
  if not AllocTAPIDLL then exit;
  @p:=GetProcAddress(hTAPIDLL,GetW32Name('lineSetDevConfigA'));
  if @p=nil then exit;
  Result:=p(dwDeviceID,lpDeviceConfig,dwSize,lpszDeviceClass);
end;

function lineGetIcon(
  dwDeviceID: Longint;
  lpszDeviceClass: PChar;
  var lphIcon: HIcon): Longint;
var p:function (
  dwDeviceID: Longint;
  lpszDeviceClass: PChar;
  var lphIcon: HIcon): Longint;
  stdcall;
begin
  Result:=-1;
  if not AllocTAPIDLL then exit;
  @p:=GetProcAddress(hTAPIDLL,GetW32Name('lineGetIconA'));
  if @p=nil then exit;
  Result:=p(dwDeviceID,lpszDeviceClass,lphIcon);
end;

function lineGetDevCaps(
  hLineApp: THLineApp;
  dwDeviceID:integer;
  dwAPIVersion:integer;
  dwExtVersion:integer;
  lpLineDevCaps:LPLINEDEVCAPS):longint;
var p:function (
  hApp: THLineApp;
  idDevice:integer;
  APIVersion:integer;
  ExtVersion:integer;
  pLineDevCaps:pointer):longint;
  stdcall;
begin
  Result := -1;
  if not AllocTAPIDLL then exit;
  @p := GetProcAddress(hTAPIDLL, GetW32Name('lineGetDevCapsA'));
  if @p = nil then exit;
  Result := p(hLineApp,dwDeviceID,dwAPIVersion,dwExtVersion,
    lpLineDevCaps);
end;

function lineTranslateDialog(
  hLineApp: THLineApp;
  dwDeviceID:integer;
  dwAPIVersion:integer;
  hWnd:integer;
  pcNumber:PChar):longint;
var p:function (
  hApp: THLineApp;
  idDevice:integer;
  APIVersion:integer;
  wnd:integer;
  s:pointer):longint;
  stdcall;
begin
  Result:=-1;
  if not AllocTAPIDLL then exit;
  @p:=GetProcAddress(hTAPIDLL,GetW32Name('lineTranslateDialogA'));
  if @p=nil then exit;
  Result:=p(hLineApp,dwDeviceID,dwAPIVersion,hWnd,
    pcNumber);
end;

function lineTranslateAddress(
  hLineApp: THLineApp;  dwDeviceID:integer;
  dwAPIVersion:integer; lpszAddressIn:PChar;
  dwCard:integer; dwTranslateOptions:integer;
  lpTranslateOutput:LPLINETRANSLATEOUTPUT):longint;
var p:function (
  hApp: THLineApp;  idDevice:integer;
  dwAPIVer:integer; lpAddress:PChar;
  dwC:integer; dwOptions:integer;
  lpOutput:LPLINETRANSLATEOUTPUT):longint; stdcall;
begin
  Result:=-1;
  if not AllocTAPIDLL then exit;
  @p:=GetProcAddress(hTAPIDLL,GetW32Name('lineTranslateAddressA'));
  if @p=nil then exit;
  Result:=p(hLineApp,dwDeviceID,dwAPIVersion,
      lpszAddressIn,dwCard,dwTranslateOptions,
      lpTranslateOutput);
end;


function lineGetAddressID(
  hLine:THLine;var lpdwAddressID:integer;
  dwAddressMode:integer;lpsAddress:PChar;
  dwSize:integer
):longint;
var p:function (
  hL: THCall;var lpdwAddID:integer;
  dwAddrMode:integer;lpsAdd:PChar;
  dwSz:integer
  ):longint; stdcall;
begin
  Result:=-1;
  if not AllocTAPIDLL then exit;
  @p:=GetProcAddress(hTAPIDLL,GetW32Name('lineGetAddressIDA'));
  if @p=nil then exit;
  Result:=p(hLine,lpdwAddressID,dwAddressMode,
          lpsAddress,dwSize);
end;

function lineUncompleteCall(
    hLine: THLine;Cd:integer): Longint;
var p:function (hLine: THCall;Cd:integer): Longint; stdcall;
begin
  Result:=-1;
  if not AllocTAPIDLL then exit;
  @p:=GetProcAddress(hTAPIDLL,'lineUncompleteCall');
  if @p=nil then exit;
  Result:=p(hLine,Cd);
end;


function lineGenerateDigits(
  hCall:THCall;
  dwDigitMode:longint;
  lpszDigits:PChar;
  dwDuration:longint):longint;
var p:function(
  hC:ThCall;
  dwMod:longint;
  pcS:PChar;
  dwDur:longint
  ):longint;stdcall;
begin
  Result:=-1;
  if not AllocTAPIDLL then exit;
  @p:=GetProcAddress(hTAPIDLL,GetW32Name('lineGenerateDigitsA'));
  if @p=nil then exit;
  Result:=p(hCall,dwDigitMode,lpszDigits,dwDuration);
end;

function lineMonitorDigits(
  hCall:THCall;
  dwDigitModes:longint):longint;
var p:function(
  hC:THCall;
  dwDig:longint):longint;stdcall;
begin
  Result:=-1;
  if not AllocTAPIDLL then exit;
  @p:=GetProcAddress(hTAPIDLL,'lineMonitorDigits');
  if @p=nil then exit;
  Result:=p(hCall,dwDigitModes);
end;

function lineMonitorTones(
  hCall:THCall;
  lpToneList:LPLINEMONITORTONE;
  dwNumEntries:integer
):longint;
var p:function(
  hC:THCall;
  lpTL:LPLINEMONITORTONE;
  dwCnt:integer):longint;stdcall;
begin
  Result:=-1;
  if not AllocTAPIDLL then exit;
  @p:=GetProcAddress(hTAPIDLL,'lineMonitorTones');
  if @p=nil then exit;
  Result:=p(hCall,lpToneList,dwNumEntries);
end;

function lineGenerateTone(
  hCall:THCall;
  dwToneMode,dwDuration,dwNumTones:Cardinal;
  lpTones:LPLINEGENERATETONE
):longint;
var p:function(
  hC:THCall;
  dwTone,dwDur,dwNum:Cardinal;
  lpT:LPLINEGENERATETONE
):longint;stdcall;
begin
  Result:=-1;
  if not AllocTAPIDLL then exit;
  @p:=GetProcAddress(hTAPIDLL,'lineGenerateTone');
  if @p=nil then exit;
  Result:=p(hCall,dwToneMode,dwDuration,dwNumTones,lpTones);
end;

function lineGetCallInfo(
  hCall:THCall;
  lpInfo:PLineCallInfo
):longint;
var p:function(
  hC:THCall;
  lpInf:PLineCallInfo
):longint;stdcall;
begin
  Result:=-1;
  if not AllocTAPIDLL then exit;
  @p:=GetProcAddress(hTAPIDLL,GetW32Name('lineGetCallInfoA'));
  if @p=nil then exit;
  Result:=p(hCall,lpInfo);
end;

function lineSetCallParams(
  hCall:THCall;
  dwBearerMode,dwMinRate,dwMaxRate:dword;
  lpDialParams:LPLINEDIALPARAMS
):longint;
var p:function(
  hCall:THCall;
  dwBearerMode,dwMinRate,dwMaxRate:dword;
  lpDialParams:LPLINEDIALPARAMS
):longint; stdcall;
begin
  Result:=-1;
  if not AllocTAPIDLL then exit;
  @p:=GetProcAddress(hTAPIDLL,'lineSetCallParams');
  if @p=nil then exit;
  Result:=p(hCall,dwBearerMode,dwMinRate,dwMaxRate,lpDialParams);
end;

function lineSetStatusMessages(
  hLine: THLine;dwLineStates, dwAddressStates: DWORD
):longint;
var p:function (hLine: THLine;dwLineStates,
               dwAddressStates: DWORD):longint; stdcall;
begin
  Result:=-1;
  if not AllocTAPIDLL then exit;
  @p:=GetProcAddress(hTAPIDLL,'lineSetStatusMessages');
  if @p=nil then exit;
  Result:=p(hLine,dwLineStates,dwAddressStates);
end;

function lineMonitorMedia(hCall: THCall; dwMediaModes : DWORD):longint;
var p: function (hCall: THCall; dwMediaModes : DWORD):longint; stdcall;
begin
  Result:=-1;
  if not AllocTAPIDLL then exit;
  @p:=GetProcAddress(hTAPIDLL,'lineMonitorMedia');
  if @p=nil then exit;
  Result:=p(hCall, dwMediaModes);
end;

function lineGetMessage(hLineApp:THLineApp;var lpMessage:TLINEMESSAGE;
         dwTimeout: DWORD):longint;
var p: function (hLineApp:THLineApp;var lpMessage:TLINEMESSAGE;
         dwTimeout: DWORD):longint; stdcall;
begin
  Result:=-1;
  if not AllocTAPIDLL then exit;
  @p := GetProcAddress(hTAPIDLL,'lineGetMessage');
  if @p = nil then exit;
  Result:=p(hLineApp, lpMessage, dwTimeout);
end;

function lineSetCallPrivilege(hCall : THCall; dwCallPrivilege:DWORD):longint;
var p: function (hCall : THCall; dwCallPrivilege:DWORD):longint; stdcall;
begin
  Result := -1;
  if not AllocTAPIDLL then exit;
  @p := GetProcAddress(hTAPIDLL,'lineSetCallPrivilege');
  if @p = nil then exit;
  Result:=p(hCall, dwCallPrivilege);
end;

initialization

finalization
  if hTAPIUIDLL <> 0 then FreeLibrary(hTAPIUIDLL);
  if hTAPIDLL <> 0 then FreeLibrary(hTAPIDLL);

end.




