Вот сделал пример отображающий состояние подключения в GUI (на основе этого примера на vb):
Код:
#include <GUIConstantsEx.au3>
#include <EditConstants.au3>
#include <WindowsConstants.au3>
#include <WinAPI.au3>
$aConnection_State = _InternetGetConnectedState()
GUICreate("_InternetGetConnectedState", 270, 320)
GUICtrlCreateLabel("Connected via MODEM:", 20, 20)
GUICtrlCreateInput($aConnection_State[1][0], 150, 17, 100)
GUICtrlCreateLabel("Connected via LAN:", 20, 50)
GUICtrlCreateInput($aConnection_State[2][0], 150, 47, 100)
GUICtrlCreateLabel("Connected via PROXY:", 20, 80)
GUICtrlCreateInput($aConnection_State[3][0], 150, 77, 100)
GUICtrlCreateLabel("Modem busy:", 20, 110)
GUICtrlCreateInput($aConnection_State[4][0], 150, 107, 100)
GUICtrlCreateLabel("Connection RAS installed:", 20, 140)
GUICtrlCreateInput($aConnection_State[5][0], 150, 137, 100)
GUICtrlCreateLabel("Connection is offline:", 20, 170)
GUICtrlCreateInput($aConnection_State[6][0], 150, 167, 100)
GUICtrlCreateLabel("Connection description:", 20, 200)
GUICtrlCreateEdit("", 20, 220, 230, 80, $ES_WANTRETURN)
For $i = 1 To $aConnection_State[0][0]
If $aConnection_State[$i][0] Then GUICtrlSetData(-1, "* " & $aConnection_State[$i][1] & @CRLF, 1)
Next
GUISetState(@SW_SHOW)
While 1
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
Exit
EndSwitch
WEnd
Func _InternetGetConnectedState()
Local Const $INTERNET_CONNECTION_MODEM = 0x1 ;Local system uses a modem to connect to the Internet.
Local Const $INTERNET_CONNECTION_LAN = 0x2 ;Local system uses a local area network to connect to the Internet.
Local Const $INTERNET_CONNECTION_PROXY = 0x4 ;Local system uses a proxy server to connect to the Internet.
Local Const $INTERNET_CONNECTION_MODEM_BUSY = 0x8 ;No longer used.
Local Const $INTERNET_RAS_INSTALLED = 0x10 ;Remote Access Services are installed on this system.
Local Const $INTERNET_CONNECTION_OFFLINE = 0x20 ;Local system is in offline mode.
Local Const $INTERNET_CONNECTION_CONFIGURED = 0x40 ;Local system has a valid connection to the Internet, but it might or might not be currently connected.
Local $aRetState[7][2] = [[UBound($aRetState)-1]]
Local $aRet = DllCall("WinInet.dll", "int", "InternetGetConnectedState", "int*", 0, "int", 0)
;For AutoIt < 3.2.10.0 the next line should be used
;Local $aRet = DllCall("WinInet.dll", "int", "InternetGetConnectedState", "int_ptr", 0, "int", 0)
If UBound($aRet) > 0 And $aRet[0] Then
$aRetState[1][0] = BitAND($aRet[1], $INTERNET_CONNECTION_MODEM) <> 0
$aRetState[1][1] = "The local system uses a modem to connect to the Internet."
$aRetState[2][0] = BitAND($aRet[1], $INTERNET_CONNECTION_LAN) <> 0
$aRetState[2][1] = "The local system connects to the Internet via a LAN"
$aRetState[3][0] = BitAND($aRet[1], $INTERNET_CONNECTION_PROXY) <> 0
$aRetState[3][1] = "The local system uses a proxy server to connect to the Internet."
If $aRetState[3][0] Then
$aRetState[2][1] &= ", and uses a proxy server."
Else
$aRetState[2][1] &= "."
EndIf
$aRetState[4][0] = BitAND($aRet[1], $INTERNET_CONNECTION_MODEM_BUSY) <> 0
$aRetState[4][1] = "The local system's modem is busy with a non-Internet connection."
$aRetState[5][0] = BitAND($aRet[1], $INTERNET_RAS_INSTALLED) <> 0
$aRetState[5][1] = "Remote Access Services are installed on this system."
$aRetState[6][0] = BitAND($aRet[1], $INTERNET_CONNECTION_OFFLINE) <> 0
$aRetState[6][1] = "The connection is currently offline."
Else
Return SetError(1, 0, _WinAPI_GetLastErrorMessage())
EndIf
Return $aRetState
EndFunc
|