基本檢查:
Global Const $NETWORK_ALIVE_LAN = 0x1
Global Const $NETWORK_ALIVE_WAN = 0x2
$x =DLLCall("sensapi.dll","int","IsNetworkAlive","str",$NETWORK_ALIVE_LAN)
msgbox (4096,"測試",$x[0])
應用:
While 1 $connect = _GetNetworkConnect()
If $connect Then
MsgBox(64, "Connections", $connect)
Else
MsgBox(48, "Warning", "There is no connection")
EndIf
sleep(5000)
Wend
Func _GetNetworkConnect()
Local Const $NETWORK_ALIVE_LAN = 0x1 ;net card connection
Local Const $NETWORK_ALIVE_WAN = 0x2 ;RAS (internet) connection
Local Const $NETWORK_ALIVE_AOL = 0x4 ;AOL
Local $aRet, $iResult
$aRet = DllCall("sensapi.dll", "int", "IsNetworkAlive", "int*", 0)
If BitAND($aRet[1], $NETWORK_ALIVE_LAN) Then $iResult &= "LAN connected" & @LF
If BitAND($aRet[1], $NETWORK_ALIVE_WAN) Then $iResult &= "WAN connected" & @LF
If BitAND($aRet[1], $NETWORK_ALIVE_AOL) Then $iResult &= "AOL connected" & @LF
Return $iResult
EndFunc
應用2:
While 1
$connect = _GetNetworkConnect()
If $connect Then
MsgBox(64, "Connections", $connect)
Else
MsgBox(48, "Warning", "There is no connection")
EndIf
sleep(5000)
Wend
Func _GetNetworkConnect()
Local Const $NETWORK_ALIVE_LAN = 0x1 ;net card connection
Local Const $NETWORK_ALIVE_WAN = 0x2 ;RAS (internet) connection
Local Const $NETWORK_ALIVE_AOL = 0x4 ;AOL
Local $aRet, $iResult
$aRet = DllCall("sensapi.dll", "int", "IsNetworkAlive", "int*", 0)
If BitAND($aRet[1], $NETWORK_ALIVE_LAN) Then $iResult &= "LAN connected" & @LF
If BitAND($aRet[1], $NETWORK_ALIVE_WAN) Then $iResult &= "WAN connected" & @LF
If BitAND($aRet[1], $NETWORK_ALIVE_AOL) Then $iResult &= "AOL connected" & @LF
Return $iResult
EndFunc
0 意見:
張貼留言