# 用InternetGetConnectedState API function

Posted by 默默 on June 16, 1999 at 11:53:45:

In Reply to: 请教各位高手前辈,如何利用VB写出可侦测网路断线的程式? posted by 鸦蛋 on June 16, 1999 at 01:26:21:

Option Explicit

Public Declare Function InternetGetConnectedState _
Lib "wininet.dll" (ByRef lpdwFlags As Long, _
ByVal dwReserved As Long) As Long

Public Const INTERNET_CONNECTION_LAN As Long = &H2

Public Function IsNetConnectOnline() As Boolean

IsNetConnectOnline = InternetGetConnectedState(0&, 0&)
End Function

Public Function IsNetConnectViaLAN() As Boolean

Dim dwflags As Long
Call InternetGetConnectedState(dwflags, 0&)
IsNetConnectViaLAN = dwflags And INTERNET_CONNECTION_LAN
End Function

'把以上的东东放进bas里, 再去呼叫它们就可以了 :)

Follow Ups: