quique
asked on
Find modem
How can I find where the modem is installed in any Windows operating system and then make a call to a phone number?
QUIQUE.
QUIQUE.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
hi, try to open com port!
somethin like this:
procedure InitModem;
Var CommPortTimeOuts: TCommTimeouts;
DCB: TDCB;
hCommFile : THandle;
ReadBuffer: array[0..100] of char;
NumberRead: DWord;
begin
{ Open the comm port. }
hCommFile := CreateFile(PChar('COM1'),G ENERIC_REA D +
GENERIC_WRITE,0,nil,OPEN_E XISTING,FI LE_FLAG_WR ITE_THROUG H,0);
if hCommFile = INVALID_HANDLE_VALUE then
begin
ShowMessage('Unable to open COM1!');
exit;
end;
{ Set Timeout values for the comm port. }
CommPortTimeOuts.ReadInter valTimeout := 100;
CommPortTimeOuts.ReadTotal TimeoutMul tiplier := 100;
CommPortTimeOuts.ReadTotal TimeoutCon stant := 0;
CommPortTimeOuts.WriteTota lTimeoutMu ltiplier := 0;
CommPortTimeOuts.WriteTota lTimeoutCo nstant := 0;
SetCommTimeOuts(hCommFile, CommPortTi meOuts);
{ Set the comm port parameters. }
GetCommState(hCommFile,DCB );
DCB.BaudRate := 1200;
DCB.ByteSize := 7;
DCB.StopBits := ONESTOPBIT;
DCB.Parity := EVENPARITY;
SetCommState(hCommFile,DCB );
{ Send initialization string to the port. }
ReadBuffer := '';
StrPCopy(ReadBuffer,'ATZ' + #13 + #10);
WriteFile(hCommFile,ReadBu ffer,Lengt h(ReadBuff er),Number Read,NIL);
{ Get a response from the port. }
ReadBuffer := '';
ReadFile(hCommFile,ReadBuf fer,100,Nu mberRead,N IL);
{ Close the port. }
CloseHandle(hCommFile);
end;
somethin like this:
procedure InitModem;
Var CommPortTimeOuts: TCommTimeouts;
DCB: TDCB;
hCommFile : THandle;
ReadBuffer: array[0..100] of char;
NumberRead: DWord;
begin
{ Open the comm port. }
hCommFile := CreateFile(PChar('COM1'),G
GENERIC_WRITE,0,nil,OPEN_E
if hCommFile = INVALID_HANDLE_VALUE then
begin
ShowMessage('Unable to open COM1!');
exit;
end;
{ Set Timeout values for the comm port. }
CommPortTimeOuts.ReadInter
CommPortTimeOuts.ReadTotal
CommPortTimeOuts.ReadTotal
CommPortTimeOuts.WriteTota
CommPortTimeOuts.WriteTota
SetCommTimeOuts(hCommFile,
{ Set the comm port parameters. }
GetCommState(hCommFile,DCB
DCB.BaudRate := 1200;
DCB.ByteSize := 7;
DCB.StopBits := ONESTOPBIT;
DCB.Parity := EVENPARITY;
SetCommState(hCommFile,DCB
{ Send initialization string to the port. }
ReadBuffer := '';
StrPCopy(ReadBuffer,'ATZ' + #13 + #10);
WriteFile(hCommFile,ReadBu
{ Get a response from the port. }
ReadBuffer := '';
ReadFile(hCommFile,ReadBuf
{ Close the port. }
CloseHandle(hCommFile);
end;
Thank you for the points !
Would it be possible to se how you solve the problem (some code samples) ??
I have code some samples very similar what you asked about, but i think it could be done much better.
Ragards
Peter
Would it be possible to se how you solve the problem (some code samples) ??
I have code some samples very similar what you asked about, but i think it could be done much better.
Ragards
Peter
ASKER