Dialing and sending DTMF codes

harisis
harisis used Ask the Experts™
on
How i can make a routine that dials a number to the phone, then sends some DTMF codes and then hungs up the line?
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
just a rough sketch

var
  MyModemStr[255];

f1 := createfile( 'com2'........);
MyModemStr := 'ATDT5551234';
writefile( f1, MyModemStr[1], length(MYModemStr) )

if you want connection message from other side - read from com2 and wait for 'connect xxxxx' string, if you don't want just send after short pause any tones you need:

MyModemStr := 'ATX1DT1234';
writefile( f1, MyModemStr[1], length(MYModemStr) )

you must have a modem by the way ;-))

Author

Commented:
I made the following routine but the modem dosn't dial. It does nothing... Is there a problem with the routine?:

----------------------------------------
procedure TForm1.Button1Click(Sender: TObject);
var
 MyModemStr:pchar;
 i:dword;
 ol:Toverlapped;
begin
 FillChar(ol, Sizeof(ol), 0);
 f1 := createfile( 'com2',GENERIC_WRITE,FILE_SHARE_WRITE,nil,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,0);
 MyModemStr := 'ATDT5551234';
 writefile( f1, MyModemStr, length(MYModemStr),i,@ol )
end;

Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

this is my code I just tested - dialing fine

var
  ComH : THandle;
  MyDCB : TDCB;
  i : dword;
begin
    ComH := CreateFile( 'COM1', GENERIC_READ or GENERIC_WRITE,
                      0, Nil, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0 );
    if ComH = THandle(-1) then exit;
    GetCommState( ComH, MyDCB );
    MyDCB.BaudRate := 19200;
    MyDCB.ByteSize := 8;
    MyDCB.Parity := NOPARITY;
    MyDCB.StopBits := ONESTOPBIT;
    MyDCB.Flags := $2021;             // hardware flow control
    SetCommState( ComH, MyDCB );           { set new state       }
    s1 := 'ATx1dt12345678'#13#10;
    writefile( ComH, s1[1], length(s1), i, nil );
sorry, I forgot

var
  s1: String[255];

Commented:
heyy thank u all! u great helped me!
do u know how to make delphi aoutamaticly answer the incoming calls? or can i detect a incoming call?
thanx beforehand
auto answer is a modem feature, not delphi :-)
just send 'ats0=1' string to modem, it will answer then to incoming calls

Commented:
thank u Alisher_N ! is there any link or have u got a tutorial that can help me to learn modem programming?
thanx!

Commented:
thank u Alisher_N ! is there any link or have u got a tutorial that can help me to learn modem programming?
thanx!

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial