MyTetra Share
Делитесь знаниями!
Время создания: 18.05.2020 15:22
Текстовые метки: Wi-Fi, подключение wifi, подключение по кабелю
Раздел: !Закладки - VBA
Запись: xintrea/mytetra_db_adgaver_new/master/base/1589804527sri289tuoi/text.html на raw.githubusercontent.com

Option Compare Database


Sub teat_fun_Connected_WIFI()

Ethernet = fun_Connected_Ethernet()

End Sub


Function fun_Connected_Ethernet() As Boolean

'подключение по кабелю

Dim oObject, adapter, item


Set oObject = GetObject("WINMGMTS:\\.\ROOT\cimv2")

Set adapter = oObject.InstancesOf("Win32_NetworkAdapter")


For Each item In adapter

If item.NetconnectionID = "Ethernet" Then

' Debug.Print item.NetconnectionID '24

' Debug.Print item.AdapterType

' Debug.Print item.NetConnectionStatus

' For Each oPr In item.Properties_

' Debug.Print oPr.Name, "|", oPr.Value

' Next

If item.NetConnectionStatus = 2 Then

fun_Connected_Ethernet = True

GoTo fun_Connected_Ethernet_Exit

End If

End If

Next

fun_Connected_Ethernet_Exit:

Set oObject = Nothing

Set adapter = Nothing

End Function



Sub IsConnected()

'https://progi.pro/excel-vba-proverte-podklyuchen-li-on-k-internetu-i-esli-ego-cherez-wi-fi-ili-ethernet-7671641

Dim oObject

Dim adapter

Dim item 'as SW ' - : Item 1 : : Variant/Object/SWbemObjectEx


Set oObject = GetObject("WINMGMTS:\\.\ROOT\cimv2")

Set adapter = oObject.InstancesOf("Win32_NetworkAdapter")


For Each item In adapter


If item.NetconnectionID <> "null" Then

Debug.Print item.NetconnectionID '24

Debug.Print item.AdapterType

Debug.Print item.NetConnectionStatus

End If

Next

End Sub





NetConnectionStatus

https://docs.microsoft.com/ru-ru/windows/win32/cimwin32prov/win32-networkadapter?redirectedfrom=MSDN&source=docs


Access type: Read-only

State of the network adapter connection to the network.

Disconnected (0)

Connecting (1)

Connected (2)

Disconnecting (3)

Hardware Not Present (4)

Hardware Disabled (5)

Hardware Malfunction (6)

Media Disconnected (7)

Authenticating (8)

Authentication Succeeded (9)

Authentication Failed (10)

Invalid Address (11)

Credentials Required (12)

Так же в этом разделе:
 
MyTetra Share v.0.59
Яндекс индекс цитирования