Modem的能力! (200分)

  • 主题发起人 主题发起人 weicong
  • 开始时间 开始时间
W

weicong

Unregistered / Unconfirmed
GUEST, unregistred user!
在Delphi里怎样能知道MODEM当前连接已经(一挂断就能知道!)挂断了?请提供例子。<br>
 
modem会返回No Carrier
 
我要的是例子,是程序,能提供吗?
 
我也想要,如果谁给我,wqh0329@china.com,再加200分,<br>请给出代码和邮件地址,我会发表一个问题并email你,你来即可
 
you can go through windows registry 注册表, this is Tregistry type in delphi you <br>can use openkey to locate a specify key, i make a component use 嵌套 to find<br>a specify key. this is a websit you can find out info about registry, further you <br>can send me email for that component. leo_aj@i4free.co.nz<br><br>solution<br><br>run regedit<br>USE find to find modem (just type modem) it will bring anything about modem,<br><br>(usally modem is in HKEY_LOCAL_MACHINE/ENUM/PCI/)<br>&nbsp;like <br>which com port that modem is connect with. you can go to http://www.delphibbs.com/delphibbs/dispq.asp?lid=589895<br><br>that code can find out which com port is connet with modem<br>i put my source code there then you can Send &nbsp;AT command to that port see if <br>you can got reply. if not that mean you drop of connection<br><br>
 
<br>获取当前活动的连接及其连接状态<br>  1、获取当前活动的连接<br>    获取当前活动的连接的RasAPI函数为RasEnumConnections,其函数原型为:<br>function RasEnumConnections( var lprasconn : RASCONN ;//接收活动连接的缓冲区的指针<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; var lpcb: DWORD;//缓冲区大小<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; var lpcConnections : DWORD//实际的活动连接数<br>&nbsp; &nbsp;) : DWORD; stdcall;<br>function RasEnumConnections;external RasApiDll name 'RasEnumConnectionsA';<br> 参数lprasconn提供了一个RASCONN类型数组的指针,指向一个接收活动连接的缓冲<br>  区,其中RASCONN的类型说明如下:<br>RASCONN = record<br>&nbsp; &nbsp; dwSize : DWORD;//该结构所占内存的大小(Bytes),一般设置为SizeOf(RASCONN)<br>&nbsp; &nbsp; hrasconn : HRASCONN;//活动连接的句柄<br>&nbsp; &nbsp; szEntryName : array[0..RAS_MaxEntryName] of char;//活动连接的名称<br>&nbsp; &nbsp; szDeviceType : array[0..RAS_MaxDeviceType] of char;//活动连接的所用的设备类型<br>&nbsp; &nbsp; szDeviceName : array[0..RAS_MaxDeviceName] of char;//活动连接的所用的设备名称<br>end;<br>    参数lpcb为缓冲区大小(Bytes).<br>    参数lpcConnections将返回实际的连接数目.<br><br>    函数返回值为0表示执行成功;否则为错误代码.<br><br>  2、获取指定连接的连接状态<br>    获取指定连接的连接状态的RasAPI函数为RasGetConnectStatus,其函数原型为:<br>function RasGetConnectStatus(<br>&nbsp; &nbsp;hrasconn : HRASCONN; //指定活动连接的句柄<br>&nbsp; &nbsp;lprasconnstatus : LPRASCONNSTATUS//连接状态参数<br>&nbsp; &nbsp;) : DWORD; stdcall;<br>function RasGetConnectStatus;external RasApiDll name 'RasGetConnectStatusA';<br>    连接状态参数lprasconnstatus是一个RASCONNSTATUS类型的指针,将返回连接状态参数.<br>  RASCONNSTATUS和LPRASCONNSTATUS的类型说明如下:<br>LPRASCONNSTATUS = ^RASCONNSTATUS;<br>RASCONNSTATUS = record<br>&nbsp; &nbsp; dwSize : DWORD;//该结构所占内存的大小(Bytes),一般设置为SizeOf(RASCONNSTATUS)<br>&nbsp; &nbsp; rasconnstate : RASCONNSTATE;//连接状态标识,一组DWORD类型数值的集合。<br>&nbsp; &nbsp; dwError : DWORD;//错误类型标识符<br>&nbsp; &nbsp; szDeviceType : array[0..RAS_MaxDeviceType] of char;//活动连接的所用的设备类型<br>&nbsp; &nbsp; szDeviceName : array[0..RAS_MaxDeviceName] of char;//活动连接的所用的设备名称<br>end;<br>    函数返回值为0表示执行成功;否则为错误代码.<br><br>    下面是一个应用例子,列出了当前系统中活动的连接的名称及其连接状态.<br> 注意,应在RASCONN缓冲区的第一个RASCONN结构中设置dwSize.<br><br>const<br>&nbsp; &nbsp; &nbsp;MaxConnections = 10;//最多的拨号连接数目<br>var<br>&nbsp; &nbsp;connections : array[0..MaxConnections-1] of RASCONN;<br>&nbsp; &nbsp;longSize : dword;<br>&nbsp; &nbsp;intAvailabelConnections : dword;<br>&nbsp; &nbsp;intIndex : integer;<br>&nbsp; &nbsp;dwResult : DWORD;<br>&nbsp; &nbsp;strTemp : string;<br>&nbsp; &nbsp;RASCONNSTATUSData : RASCONNSTATUS; &nbsp; <br>begin<br>&nbsp; &nbsp; &nbsp;connections[ 0 ].dwSize := sizeof(RASCONN);//结构的大小<br>&nbsp; &nbsp; &nbsp;longSize := MaxConnections * connections[ 0 ].dwSize;//缓冲区大小<br>&nbsp; &nbsp; &nbsp;intAvailabelConnections := 0;//实际的活动连接的数目<br>&nbsp; &nbsp; &nbsp;//获取当前系统中活动的连接<br>&nbsp; &nbsp; &nbsp;dwResult := RasEnumConnections( connections[ 0 ], longSize,intAvailabelConnections );<br>&nbsp; &nbsp; &nbsp;if dwResult &lt;&gt; 0 then //获取当前系统中活动的连接<br>&nbsp; &nbsp; &nbsp; &nbsp; memo1.lines.add( '获取当前系统中活动的连接:' + GetRasError( dwResult ))<br>&nbsp; &nbsp; &nbsp;else<br>&nbsp; &nbsp; &nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;memo1.lines.add( '当前系统中活动的连接' + inttostr( intAvailabelConnections ) <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; + '个,列举如下' );<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;for intIndex := 0 to intAvailabelConnections - 1 do<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; strTemp := '连接名称:' + StrPAS( connections[ intIndex ].szEntryName )<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;+ ' 设备类型:' + StrPAS( connections[ intIndex ].szDeviceType )<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;+ ' 设备名称:' + StrPAS( connections[ intIndex ].szDeviceName );<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //获取连接状态<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dwResult := RasGetConnectStatus( connections[ intIndex ].hRasConn,@RASCONNSTATUSData );<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if 0 &lt;&gt; dwResult &nbsp;then<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;strTemp := strTemp + ' &nbsp;连接状态未知:' + GetRasError( dwResult )<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if RASCONNSTATUSData.rasconnstate = RASCS_Connected then<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;strTemp := strTemp + ' &nbsp;连接状态:已连接'<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;strTemp := strTemp + ' &nbsp;连接状态:(' + <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; inttostr(RASCONNSTATUSData.rasconnstate)+')';<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; memo1.lines.add( strTemp );<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;end;<br>&nbsp; &nbsp; &nbsp; &nbsp; end;<br>end;<br><br>
 
如何检测计算机是否已经拨号上网?<br><br>&nbsp; 在注册表的HKEY_LOCAL_MACHINE/System/CurrentControlSet/Services/RemoteAcces分支下,<br>当未连通因特网时,Remote Connection的键值为00 00 00 00,当连通时,其键值为01 00 00 00,<br>通过这一键值就可以作出判断。<br>&nbsp;
 
在Delphi里怎样能知道MODEM当前连接已经(一挂断就能知道!)挂断了?请提供例子!<br>当前连接已经(一挂断就能知道!)挂断了<br>当前连接已经(一挂断就能知道!)挂断了<br>当前连接已经(一挂断就能知道!)挂断了
 
当前连接已经(一挂断就能知道!)挂断了
 
好像没有那个No Carrier,我试过好多次了。
 
来自http://wenjinshan.yeah.net或wenjinshan.mycool.net的<br>《Delphi串口及语音传真编程》已出版
 
多人接受答案了。
 
后退
顶部