快
快乐大使
Unregistered / Unconfirmed
GUEST, unregistred user!
请指教:如何准确检测计算机已经上网或离线?<br>我使用了以下函数进行判断,但当我把网线拔掉仍然返回true,不知是什么原因?请高手指教,是否有其它准确测试的方法呢?<br>function InternetConnected: Boolean;<br>const<br> // local system uses a modem to connect to the Internet.<br> INTERNET_CONNECTION_MODEM = 1;<br> // local system uses a local area network to connect to the Internet.<br> INTERNET_CONNECTION_LAN = 2;<br> // local system uses a proxy server to connect to the Internet.<br> INTERNET_CONNECTION_PROXY = 4;<br> // local system's modem is busy with a non-Internet connection.<br> INTERNET_CONNECTION_MODEM_BUSY = 8;<br>var<br> dwConnectionTypes : DWORD;<br>begin<br> dwConnectionTypes := INTERNET_CONNECTION_MODEM+ INTERNET_CONNECTION_LAN<br> + INTERNET_CONNECTION_PROXY;<br> Result := InternetGetConnectedState(@dwConnectionTypes, 0);<br>end;<br>