拨号时的消息是什么? yysun请帮个忙吧。 (100分)

  • 主题发起人 aerobull
  • 开始时间
A

aerobull

Unregistered / Unconfirmed
GUEST, unregistred user!
请问拨号上网连接或者断开后的消息是什么?<br>用 TTimer 不断监测吗? 太惨了!<br>好象是RasConnectionNotification.<br>怎么用呢?有例子吗?<br>
 
使用消息还是回调函数,在RasDial函数中的dwNotifierType参数设定<br>如果选择消息,你要写消息处理函数,你没写过吗?怎么能用Timer来检测啊<br>如果是回调函数,我感觉回调函数好象运行于其他线程,比较麻烦,还不如消息方便
 
RasConnectionNotification.<br>The RasConnectionNotification function specifies an event object that the<br>system sets to the signaled state when a RAS connection is created or terminated.<br><br>http://msdn.microsoft.com/library/psdk/network/rasclnt_4re6.htm
 
其中有一个参数是:<br>hEvent <br>[in] Specifies the handle of an event object. <br>Use the function to create an event object. <br>我应该用什么function来create这个event object?<br>
 
ahm的相关控件有这个功能
 
用RasConnectionNotification,可以测到所有的连接断开消息么?<br>就是说,运行编的程序,再在拨号网络里双击,拨号,也能监测到?????<br>根据,SDK上的说明,好像RasConnectionNotification只支持NT系统,如果是9X呢?
 
procedure TForm5.BitBtn2Click(Sender: TObject);<br>var<br>&nbsp; EventHandle: THandle;<br>begin<br>&nbsp; EventHandle := CreateEvent(nil, False, False, nil);<br>&nbsp; if EventHandle &lt;&gt; Null then<br>&nbsp; begin<br>&nbsp; &nbsp; if RasConnectionNotification(INVALID_HANDLE_VALUE, EventHandle,<br>&nbsp; &nbsp; &nbsp; RASCN_Connection or RASCN_Disconnection) = 0 then<br>&nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; if WaitForSingleObject(EventHandle, INFINITE) = WAIT_OBJECT_0 then<br>&nbsp; &nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; &nbsp; MessageDlg('Ok', mtInformation, [mbOK], 0);<br>&nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; end;<br>&nbsp; &nbsp; CloseHandle(EventHandle);<br>&nbsp; end;<br>end;<br>&nbsp;<br>get ras.pas at http://delphi-jedi.org
 
多人接受答案了。
 

Similar threads

I
回复
0
查看
600
import
I
S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
I
回复
0
查看
514
import
I
I
回复
0
查看
560
import
I
顶部