'Declara las funciones de comunicacin con el dispositivo CAPI
Declare Function CAPI_REGISTER Lib "Capi2032.Dll" (ByVal D_MessageBuffersize As Long, ByVal D_maxLogicalConnection As Long, ByVal D_maxBDataBlocks As Long, ByVal D_maxBDataLen As Long, ByRef D_AppID As Long) As Long
Declare Function CAPI_RELEASE Lib "Capi2032.Dll" (ByVal D_AppID As Long) As Long
Declare Function CAPI_WAIT_FOR_SIGNAL Lib "Capi2032.Dll" (ByVal D_AppID As Long) As Long
Declare Function CAPI_PUT_MESSAGE Lib "Capi2032.Dll" (ByVal D_AppID As Long, pcapimessage As Any) As Long
Declare Function CAPI_GET_MESSAGE Lib "Capi2032.Dll" (ByVal D_AppID As Long, ByRef lpCapiBuffer As Long) As Long
'Funcin para llenar las variables con los mensajes CAPI
Declare Sub RtlMoveMemory Lib "Kernel32.Dll" (lpRecieve As Any, ByVal lpCapiBuffer As Long, ByVal iMaxLength As Long) 'Generell Verwendete Variable

Public AppId As Long 'Identificacin de la Aplicacin
Public lpCapiBuffer As Long

Public Const maxLogicalConnection As Long = 2
Public Const MessageBuffersize As Long = 1024 + (1024 * maxLogicalConnection)
Public Const maxBDataBlocks As Long = 7
Public Const maxBDataLen As Long = 2048
Public Const HeaderLength As Long = 8

'----- Comandos CAPI -----
Public Const CAPI_ALERT = &H1
Public Const CAPI_CONNECT = &H2
Public Const CAPI_CONNECT_ACTIVE = &H3
Public Const CAPI_CONNECT_B3_ACTIVE = &H83
Public Const CAPI_CONNECT_B3 = &H82
Public Const CAPI_CONNECT_B3_T90_ACTIVE = &H88
Public Const CAPI_DATA_B3 = &H86
Public Const CAPI_DISCONNECT_B3 = &H84
Public Const CAPI_DISCONNECT = &H4
Public Const CAPI_FACILITY = &H80
Public Const CAPI_INFO = &H8
Public Const CAPI_LISTEN = &H5
Public Const CAPI_MANUFACTURER = &HFF
Public Const CAPI_RESET_B3 = &H87
Public Const CAPI_SELECT_B_PROTOCOL = &H41

'----- Subcomandos CAPI-----
Public Const CAPI_REQ = &H80
Public Const CAPI_CONF = &H81
Public Const CAPI_IND = &H82
Public Const CAPI_RESP = &H83

'Estructura para las cabeceras de los mensajes
Type MessageHeader
    length As Integer
    AppId As Integer
    Command As Byte
    Subcommand As Byte
    Message_Number As Integer
End Type

'Estructura para el mensaje de indicacin de conexin
Type ConnectInd
    PLCI As Long
    CIP As Integer
    buffer As String * 100
End Type

'Estructura para la peticin de recepcin de mensajes
Type ListenREQ
    length As Integer
    AppId As Integer
    Command As Byte
    Subcommand As Byte
    Message_Number As Integer
    controller As Long
    InfoMask As Long
    CIPMask As Long
    CIPMas2 As Long
    CallingParty As Byte
    CallingPartySub As Byte
End Type
