如何用delphi 控制modem进行拨号?(100分)

  • 主题发起人 主题发起人 gggg
  • 开始时间 开始时间
G

gggg

Unregistered / Unconfirmed
GUEST, unregistred user!
下面程序为什么没有反映?
procedure TForm1.Button1Click(Sender: TObject);
var
hCommFile : THandle;
i:integer;
PhoneNumber : string;
CommPort : string;
NumberWritten, ModemStat : dword;
begin
PhoneNumber := 'ATDT 2918615' + #13 + #10;
CommPort := 'COM1';
{Open the comm port}
hCommFile := CreateFile(PChar(CommPort),
GENERIC_WRITE,
FILE_SHARE_WRITE,
nil,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL,
0);
if hCommFile=INVALID_HANDLE_VALUE then
begin
ShowMessage('Unable to open '+ CommPort);
exit;
end
else
showmessage('open'+CommPort);
{Get the Modem Status}
if GetCommModemStatus(hCommFile, ModemStat) <> false then
begin
if ModemStat and MS_CTS_ON <> 0 then
ShowMessage('The CTS (clear-to-send) is on.');
if ModemStat and MS_DSR_ON <> 0 then
ShowMessage('The DSR (data-set-ready) is on.');
if ModemStat and MS_RING_ON <> 0 then
ShowMessage('The ring indicator is on.')
else
showmessage('The ring indicator is off');
if ModemStat and MS_RLSD_ON <> 0 then
ShowMessage('The RLSD (receive-line-signal-detect) is on.')
else
ShowMessage('The RLSD (receive-line-signal-detect) is off.');
end;


{Dial the phone}
NumberWritten:=0;
if WriteFile(hCommFile,PChar(PhoneNumber)^,Length(PhoneNumber),NumberWritten,nil)=false then
begin
ShowMessage('Unable to write to ' + CommPort);
end;
CloseHandle(hCommFile);
end;

请各位大虾帮忙see,或者有什么别的解决办法?
谢谢!
 
现在浮躁得很:)
看看这个或许有帮助.
http://www.yesky.com/33554432/34603008/34668544/34672640/34672672/116001.htm
在DELPHI程序中拨号上网
2000-09-20· 王发军·delhpi技术网
  
 
>>
PhoneNumber := 'ATDT 2918615' + #13 + #10;
改为:
PhoneNumber := 'ATDT2918615' + #13 + #10;
式式!
 
Thank hapcoer ,but itdo
es not work.
the main problems are:
if ModemStat and MS_RING_ON <> 0 then
ShowMessage('The ring indicator is on.')
else
showmessage('The ring indicator is off');
if ModemStat and MS_RLSD_ON <> 0 then
ShowMessage('The RLSD (receive-line-signal-detect) is on.')
else
ShowMessage('The RLSD (receive-line-signal-detect) is off.');
end;
显示结果为:'The ring indicator is off','The RLSD (receive-line-signal-detect
) is off.'。
也即:后两个条件不满足:
为什么?
可以肯定的十:直接拨号正常。
 
多人接受答案了。
 
后退
顶部