Ver Mensaje Individual
  #5  
Antiguo 11-04-2006
Avatar de seoane
[seoane] seoane is offline
Miembro Premium
 
Registrado: feb 2004
Ubicación: A Coruña, España
Posts: 3.717
Reputación: 24
seoane Va por buen camino
Si solo quieres realizar la llamada puedes usar el comando ATD. Aqui te dejo una funcion con la que podras marcar un numero de telefono, desde un moden o un telefono movil conectado a un puerto serie.

Código Delphi [-]
function Marcar(Puerto: String; Telefono: String): Boolean;
var
  hPort: THandle;
  DCB: TDCB;
  Comando: String;
  Escritos: Cardinal;
begin
  Result:= FALSE;
  Puerto:= Uppercase(Puerto);
  // Cambiar esto si es necesario un puerto diferente
  if (Puerto<>'COM1') and (Puerto<>'COM2') then
    exit;
  hPort:= CreateFile(PChar('\\.\'+Puerto), GENERIC_READ or GENERIC_WRITE,0, nil,
    OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,0);
  if hPort<>INVALID_HANDLE_VALUE then
  begin
    DCB.DCBlength:= sizeof(DCB);
    if GetCommState(hPort,DCB) then
    begin
      // Cambiar esto para una configuracion del puerto diferente
      with DCB do
      begin
        BaudRate := CBR_9600;
        ByteSize := 8;
        Parity   := NOPARITY;
        StopBits := ONESTOPBIT;
        Flags    := $01;
      end;
      if SetCommState(hPort, DCB) then
      begin
        PurgeComm(hPort, PURGE_TXABORT or PURGE_RXABORT or PURGE_TXCLEAR or
          PURGE_RXCLEAR);
        Comando:= 'ATD'+Telefono+#13;
        Result := WriteFile(hPort, PChar(Comando)^, Length(Comando), Escritos, nil);
      end;
    end;
    CloseHandle(hPort);
  end;
end;

En cuanto a lo de detectar la llamada, eso depende de lo que quieras decir con detectar. La mayoria de los modem mandan el texto 'RING' a traves del puerto serie cuando estan recibiendo una llamada ( Algo asi como el timbre del telefono pero en modo texto) si solo necesitas eso solo tienes que esperar a que mande esa cadena por el puerto. Si por el contrario quieres identificar el numero del que llama ya es mas complicado, y seguiria el consejo que te dieron de que te buscaras algun componente apropiado.
Responder Con Cita