Foros Club Delphi

Foros Club Delphi (https://www.clubdelphi.com/foros/index.php)
-   API de Windows (https://www.clubdelphi.com/foros/forumdisplay.php?f=7)
-   -   Como obtener el callerID o numero de telefono (https://www.clubdelphi.com/foros/showthread.php?t=65375)

Oswaldo Nuñez 10-12-2009 01:54:34

Como obtener el callerID o numero de telefono
 
Hola amigos del foro.

Estoy desde hace varios dias que no puedo resolver este problema.
Resulta que quiero obtener el numero de telefono de la persona que llama, dado que una conocida libreria profesional (no voy a mencionarla), me falla al reconocer 3 de 10 numeros, entonces estoy haciendo mi propia rutina para reconocer el numero mediante la TAPI.

Bueno, todo marcha bien, hasta aqui, que hago mi callback, y llamo a la rutina que obtiene esa info.
r:=LineGetCallInfo(hCall, wLPCALLINFO);

Ya me asegure, que tiene memoria, porque antes el valor de dwNeededSize me reportaba que necesitaba 358 bytes para toda la estructura :
wLPCALLINFO: TLineCallInfo;
entonces, le asigne los 358 bytes, y me devuelve los siguientes resultados:
dw
dwCallerIDFlags retorna 8.
dwCallerIDSize retorna 7, este es el numero de telefono de 6 digitos, pero le aumenta 1 mas por el 00 supongo...
y dwCallerIDOffset el valor de 344

Esto significa que dentro de la estructura wLPCALLINFO, la posicion 344 contiene el numero de telefono ??? Alguien me puede ayudar por favor para obtener este numero. Supongo que es un puntero, supongo que es la direccion, pero no puedo obtener el numero callerID, Ayuda por favor.

Un gran saludo

Oswaldo

Posdata: Este es mi callback completo, disculpen lo extenso, pero quiero examinar bien los eventos:

procedure LineCallBack(hDevice, dwMsg, dwCallbackInstance,
dwParam1, dwParam2, dwParam3: LongInt); stdcall;
var
hCall: THCall;
wLPCALLINFO: TLineCallInfo;
wNum: Integer;
wPointer: Pchar;
wPointer2: Pointer;
wPointer3: Pointer;
www: String;
r: Integer;
wSize: Integer;
wFonoExtracted: Array[0..255] of char;
begin
//nop LogCallbackMsg(hDevice, dwMsg, dwParam1, MainForm.Memo1.Lines);
MainForm.WriteBugFile('*** LineCallBack() ***'+inttostr(hDevice)+'**'+inttostr(dwMsg)+'**'+inttostr(dwParam1)+'**'+inttostr(dwParam2)+'**'+int tostr(dwParam3));
hCall := hDevice;
if dwMsg = LINE_CALLINFO then begin
MainForm.WriteBugFile('***1.- Msg=LINE_CALLINFO');
case dwParam1 of
LINECALLINFOSTATE_CALLERID:
begin
MainForm.WriteBugFile( '** 1.1 Msg=LINECALLINFOSTATE_CALLERID '+inttostr(hCall));
if hCall <> 0 then begin
//MainForm.DisplayID(GetCallerIDInfo(hCall));
// se creara ???? wLPCALLINFO:=TLineCallInfo.create(self);
MainForm.WriteBugFile( '** 1.1.1 hay algo ...');
// reservo memoria ??
//wLPCALLINFO.dwTotalSize:=sizeof(TLINECALLINFO)+1000;
wSize:=Sizeof(TLineCallInfo); // +1000
wSize:=358; // fix 2009.12.09
MainForm.WriteBugFile( '** 1.1.1.1 el size es='+inttostr(wSize));
wPointer3:=AllocMem(wSize);
if MainForm.CheckBox1.checked=True then
FillChar(wLPCALLINFO, wSize, 0);

with wLPCALLINFO do begin
dwTotalSize := wSize;
dwNeededSize := wSize;
dwUsedSize := wSize;
end;
r:=-3;
r:=LineGetCallInfo(hCall, wLPCALLINFO);
MainForm.WriteBugFile( '** 1.1.2 retorna ... r='+inttostr(r));
MainForm.WriteBugFile( '** 1.1.2.1 r in hex='+IntToHex(LongInt(r),8));
// LINEERR_STRUCTURETOOSMALL = $8000004D;
if (( r<>0) and (r<>LINEERR_STRUCTURETOOSMALL)) then begin
MainForm.WriteBugFile( '** 1.1.2.2 struct too litle');
end;
MainForm.WriteBugFile( '** 1.1.2.2 dwTotalSize='+inttostr(wlpCallInfo.dwTotalSize)+' dwNeededSize='+inttostr(wlpCallInfo.dwNeededSize));

// como lo recupero ??
wNum:=wLPCALLINFO.dwCallID;
MainForm.WriteBugFile( '** dwCallID **'+inttostr(wNum));
//wLPCALLINFO.CallerIDAddress
wNum:=wLPCALLINFO.dwAddressID;
MainForm.WriteBugFile( '** dwAddressID **'+inttostr(wNum));
wNum:=wLPCALLINFO.dwCallerIDFlags;
// 2009.12.09 Sale = 8
MainForm.WriteBugFile( '** dwCallerIDFlags **'+inttostr(wNum));
wNum:=wLPCALLINFO.dwCallerIDSize; // aqui, tiene que haber algo
// 2009.12.09 sale = 7 len de telefono
MainForm.WriteBugFile( '** dwCallerIDSize **'+inttostr(wNum));
wNum:=wLPCALLINFO.dwCallerIDOffset; // aqui, tiene que haber algo, efectivamente
// 2009.12.09 sale = 344 OJOOOOO
MainForm.WriteBugFile( '** dwCallerIDOffset **'+inttostr(wNum));
wNum:=wLPCALLINFO.dwCallerIDNameSize;
MainForm.WriteBugFile( '** dwCallerIDNameSize **'+inttostr(wNum));
wNum:=wLPCALLINFO.dwCallerIDNameOffset;
MainForm.WriteBugFile( '** dwCallerIDNameOffset **'+inttostr(wNum));
//wPointer:=wLPCALLINFO.dwCallerIDNameOffset^;
wPointer2:=(@wLPCALLINFO .dwCallerIDOffset);
www:=copy(wLPCALLINFO,234,3);
wFonoExtracted:=copy(wLPCALLINFO,234,3);

//showmessage(wPointer2[0]);
//www:=string(Pointer);
www:=string(wPointer2^);
MainForm.WriteBugFile( '** www **'+www+'**');
// Metodo 2
www:=copy(StrPas(PChar(wLPCALLINFO.dwCallerIDOffset)+wLPCALLINFO.dwCallerIDOffset),1,wLPCALLINFO.dwC allerIDSize);
MainForm.WriteBugFile( '** segundo www **'+www+'**');
// 2009.12.04 no lo hace...
//' pLineDevice.CallerIDAddress$ = GetVarInfo(TempLineInfo.mem, (TempLineInfo.dwCallerIDOffset - LINECALLINFO_FIXEDSIZE + 1), TempLineInfo.dwCallerIDSize - 1)
//' pLineDevice.CallerIDAddress$ = GetVarInfo(TempLineInfo.mem, (TempLineInfo.dwCallerIDOffset - LINECALLINFO_FIXEDSIZE + 1), TempLineInfo.dwCallerIDSize - 1)

if wlpCallInfo.dwCallerIDFlags= LINECALLPARTYID_UNAVAIL then begin
// test
MainForm.WriteBugFile( '** LINECALLPARTYID_UNAVAIL **');
end;
LineDrop(hCall, nil, 0);
end;
end;
LINECALLINFOSTATE_OTHER:
begin
MainForm.WriteBugFile( '** 1.2 Msg=LINECALLINFOSTATE_OTHER');
end;
LINECALLINFOSTATE_RATE:
begin
MainForm.WriteBugFile( '** 1.3 Msg=LINECALLINFOSTATE_RATE');
end;
LINECALLINFOSTATE_CALLID:
begin
MainForm.WriteBugFile( '** 1.4 Msg=LINECALLINFOSTATE_CALLID');
end;
LINECALLINFOSTATE_RELATEDCALLID:
begin
MainForm.WriteBugFile( '** 1.5 Msg=LINECALLINFOSTATE_RELATEDCALLID');
end;
LINECALLINFOSTATE_ORIGIN:
begin
MainForm.WriteBugFile( '** 1.6 Msg=LINECALLINFOSTATE_ORIGIN');
end;
LINECALLINFOSTATE_REASON:
begin
MainForm.WriteBugFile( '** 1.7 Msg=LINECALLINFOSTATE_REASON');
end;
LINECALLINFOSTATE_COMPLETIONID:
begin
MainForm.WriteBugFile( '** 1.8 Msg=LINECALLINFOSTATE_COMPLETIONID');
end;
LINECALLINFOSTATE_NUMOWNERINCR:
begin
MainForm.WriteBugFile( '** 1.9 Msg=LINECALLINFOSTATE_NUMOWNERINCR');
end;
LINECALLINFOSTATE_NUMOWNERDECR:
begin
MainForm.WriteBugFile( '** 1.10 Msg=LINECALLINFOSTATE_NUMOWNERDECR');
end;
LINECALLINFOSTATE_NUMMONITORS:
begin
MainForm.WriteBugFile( '** 1.11 Msg=LINECALLINFOSTATE_NUMMONITORS');
end;
LINECALLINFOSTATE_TRUNK:
begin
MainForm.WriteBugFile( '** 1.12 Msg=LINECALLINFOSTATE_TRUNK');
end;
LINECALLINFOSTATE_CONNECTEDID:
begin
MainForm.WriteBugFile( '** 1.13 Msg=LINECALLINFOSTATE_CONNECTEDID');
end;
LINECALLINFOSTATE_REDIRECTIONID:
begin
MainForm.WriteBugFile( '** 1.14 Msg=LINECALLINFOSTATE_REDIRECTIONID');
end;
LINECALLINFOSTATE_REDIRECTINGID:
begin
MainForm.WriteBugFile( '** 1.15 Msg=LINECALLINFOSTATE_REDIRECTINGID');
end;
LINECALLINFOSTATE_DISPLAY:
begin
MainForm.WriteBugFile( '** 1.16 Msg=LINECALLINFOSTATE_DISPLAY');
end;
LINECALLINFOSTATE_USERUSERINFO:
begin
MainForm.WriteBugFile( '** 1.17 Msg=LINECALLINFOSTATE_USERUSERINFO');
end;
LINECALLINFOSTATE_DIALPARAMS:
begin
MainForm.WriteBugFile( '** 1.18 Msg=LINECALLINFOSTATE_DIALPARAMS');
end;
LINECALLINFOSTATE_MONITORMODES:
begin
MainForm.WriteBugFile( '** 1.19 Msg=LINECALLINFOSTATE_MONITORMODES');
end;
else
// los demas
end;
end else if dwMsg = LINE_CALLSTATE then begin
MainForm.WriteBugFile( '***2.- Msg=LINE_CALLSTATE');
// Aqui entra cuando va a colgar
case dwParam1 of
LINECALLSTATE_IDLE:
begin
MainForm.WriteBugFile( '** 2.1 Msg=LINECALLSTATE_IDLE');
if hCall <> 0 then begin
// entra aqui cuando realmente paso 21 segundos desde la no descolgada.
MainForm.WriteBugFile( '** 2.1.1');
LineDeallocateCall(hCall);
MainForm.WriteBugFile( '** 2.1.2');
end;
end;
LINECALLSTATE_OFFERING:
begin
MainForm.WriteBugFile( '** 2.2 Msg=LINECALLSTATE_OFFERING');
end;
LINECALLSTATE_ACCEPTED:
begin
MainForm.WriteBugFile( '** 2.3 Msg=LINECALLSTATE_ACCEPTED');
end;
LINECALLSTATE_DIALTONE:
begin
MainForm.WriteBugFile( '** 2.4 Msg=LINECALLSTATE_DIALTONE');
end;
LINECALLSTATE_DIALING:
begin
MainForm.WriteBugFile( '** 2.5 Msg=LINECALLSTATE_DIALING');
end;
LINECALLSTATE_RINGBACK:
begin
MainForm.WriteBugFile( '** 2.6 Msg=LINECALLSTATE_RINGBACK');
end;
LINECALLSTATE_BUSY:
begin
MainForm.WriteBugFile( '** 2.7 Msg=LINECALLSTATE_BUSY');
end;
LINECALLSTATE_SPECIALINFO:
begin
MainForm.WriteBugFile( '** 2.8 Msg=LINECALLSTATE_SPECIALINFO');
end;
LINECALLSTATE_CONNECTED:
begin
MainForm.WriteBugFile( '** 2.9 Msg=LINECALLSTATE_CONNECTED');
end;
LINECALLSTATE_PROCEEDING:
begin
MainForm.WriteBugFile( '** 2.10 Msg=LINECALLSTATE_PROCEEDING');
end;
LINECALLSTATE_ONHOLD:
begin
MainForm.WriteBugFile( '** 2.11 Msg=LINECALLSTATE_ONHOLD');
end;
LINECALLSTATE_CONFERENCED:
begin
MainForm.WriteBugFile( '** 2.12 Msg=LINECALLSTATE_CONFERENCED');
end;
LINECALLSTATE_ONHOLDPENDCONF:
begin
MainForm.WriteBugFile( '** 2.13 Msg=LINECALLSTATE_ONHOLDPENDCONF');
end;
LINECALLSTATE_ONHOLDPENDTRANSFER:
begin
MainForm.WriteBugFile( '** 2.14 Msg=LINECALLSTATE_ONHOLDPENDTRANSFER');
end;
LINECALLSTATE_DISCONNECTED:
begin
MainForm.WriteBugFile( '** 2.15 Msg=LINECALLSTATE_DISCONNECTED');
end;
LINECALLSTATE_UNKNOWN:
begin
MainForm.WriteBugFile( '** 2.16 Msg=LINECALLSTATE_UNKNOWN');
end;
else
begin
MainForm.WriteBugFile( '** 2.17 Msg=::OTHER::');
end;
end;
end else begin
MainForm.WriteBugFile( '***3.- Msg=OTHER...');
end;
end;


Y el resultado es este:
09.12.2009 10:32:12 Execute()
09.12.2009 10:32:12 size callparams=176
09.12.2009 10:32:13 nDevs=7
09.12.2009 10:32:13 ** el size es=324
09.12.2009 10:32:13 ** after fill
09.12.2009 10:32:13 ** after assign
09.12.2009 10:32:20 *** LineCallBack() ***65606**2**2**0**4
09.12.2009 10:32:20 ***2.- Msg=LINE_CALLSTATE
09.12.2009 10:32:20 ** 2.2 Msg=LINECALLSTATE_OFFERING
09.12.2009 10:32:20 *** LineCallBack() ***65606**1**32768**0**0
09.12.2009 10:32:20 ***1.- Msg=LINE_CALLINFO
09.12.2009 10:32:20 ** 1.1 Msg=LINECALLINFOSTATE_CALLERID 65606
09.12.2009 10:32:20 ** 1.1.1 hay algo ...
09.12.2009 10:32:20 ** 1.1.1.1 el size es=358
09.12.2009 10:32:20 ** 1.1.2 retorna ... r=0
09.12.2009 10:32:20 ** 1.1.2.1 r in hex=00000000
09.12.2009 10:32:20 ** 1.1.2.2 dwTotalSize=358 dwNeededSize=358
09.12.2009 10:32:20 ** dwCallID **0
09.12.2009 10:32:20 ** dwAddressID **0
09.12.2009 10:32:20 ** dwCallerIDFlags **8
09.12.2009 10:32:20 ** dwCallerIDSize **7
09.12.2009 10:32:20 ** dwCallerIDOffset **344
09.12.2009 10:32:20 ** dwCallerIDNameSize **0
09.12.2009 10:32:20 ** dwCallerIDNameOffset **0

Claro que me falla el programa, me da AV en
wPointer2:=(@wLPCALLINFO .dwCallerIDOffset);
porque no se manejar los pointers,

duilioisola 10-12-2009 14:59:39

Mira este link:
http://msdn.microsoft.com/en-us/libr...8VS.85%29.aspx
A ver si averiguas algo...

oswaldo77_77 12-12-2009 00:05:49

RE: ya lei
 
Ya lei eso, el problema es como acceder a ese registro. La ultima intentada fue de la siguiente manera:

www:=copy(StrPas(PChar(@wlpCallInfo)+wLPCALLINFO.dwCalledIDOffset),1,wLPCALLINFO.dwCalledIDSize);

pero, tampoco funciona, como dije, parece que el problema basicamente es el manejo del puntero dentro del registro. Me sale en blanco la variable.
Otra cosa, Uso D6, y la libreria TAPI.PAS segun leo, alcanza hasta la version Tapi 2.0

Ayuda por favor.

Oswaldo


La franja horaria es GMT +2. Ahora son las 13:11:38.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi