Home » Windows API

InetIsOffline

說明:
InetIsOffline 函式可判斷目前系統是否已連線至網際網路上


引用函式庫:
url


適用系統:
Windows NT 4.0 或 Windows 95以上


函式原型:

Declare Function InetIsOffline Lib "url" Alias "InetIsOffline" ( _
    ByVal dwFlags As Long _
    ) As Long



參數型態及說明:
dwFlagsLong 函式的輸入指標,此參數必須為 0

回傳值:
Long 若系統為連線至網際網路狀態時,將會回傳 False;反之離線狀態時,則回傳 True

.NET Framework API:
My.Computer.Network.IsAvailable


VB範例:

檢視原始碼 Visual Basic
1
2
3
4
5
6
7
8
9
'VB的宣告
Private Declare Function InetIsOffline Lib "url.dll" ( _
	ByVal dwFlags As Long _
	) As Boolean
 
Dim rtvl As Boolean
 
'判斷目前系統是否已連線至網際網路上
rtvl = InetIsOffline(0)

RB範例:

檢視原始碼 REALBasic
1
2
3
4
5
6
7
8
9
'RB的宣告
Declare Function InetIsOffline Lib "url" ( _
	dwFlags As Integer _
	) As Boolean
 
Dim rtvl As Boolean
 
'判斷目前系統是否已連線至網際網路上
rtvl = InetIsOffline(0)

VB.NET範例:

1
2
3
4
5
6
7
8
9
10
11
'VB.NET的宣告
<DllImport("url.dll")> _
Shared Function InetIsOffline( _
	ByVal dwFlags As UInteger _
	) As Boolean
End Function
 
Dim rtvl As Boolean
 
'判斷目前系統是否已連線至網際網路上
rtvl = InetIsOffline(0)

C#範例:

1
2
3
4
5
6
7
8
9
10
//C#的宣告
[DllImport("url")]
public static extern bool InetIsOffline(
	uint dwFlags
	);
 
bool rtvl;
 
//判斷目前系統是否已連線至網際網路上
rtvl = InetIsOffline(0);

註釋:
InetIsOffline 函式所取得的結果不太準確,都顯示為連線的狀態。MSDN中說明:Returns FALSE if the local system is connected to the Internet or if no attempt has yet been made to connect to the Internet.
InternetGetConnectedState 函式取得的結果還比較多元準確。

發表迴響