如何偵測電腦的網路連線是正常的
出自VFP Wiki
目錄 |
出處
致謝
Thanks a123eric and ge8941!!
Solution
使用Windows API:InternetGetConnectedState
LOCAL nFlags AS Long, lOffline AS Boolean DECLARE SHORT InternetGetConnectedState IN wininet INTEGER @ lpdwFlags, INTEGER dwReserved m.nFlags = 0 m.lOffLine = !InternetGetConnectedState(@m.nFlags, 0) <> 0 return m.lOffLine
使用 ping
local isok ws = createobject("WScript.Shell") isok = ws.run("ping 192.168.1.39",0,"True") if ISOK==0 msg("連線") else msg("斷線") endif <pre>