Hardware [vb.net] 네트워크 어댑터(NetworkAdapter) 사용 안 함/사용함(끄기/켜기)
페이지 정보
본문
ComboBox2.Items.Clear()
Dim wmiQuery = New SelectQuery("SELECT * FROM Win32_NetworkAdapter " & "WHERE NetConnectionId != null ") '& "AND Manufacturer != 'Microsoft' "
Using mosSearcher = New ManagementObjectSearcher(wmiQuery)
For Each moItem As ManagementObject In mosSearcher.[Get]()
ComboBox2.Items.Add(DirectCast(moItem("NetConnectionId"), [String]))
Next
End Using
Private Sub ComboBox2_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox2.SelectedIndexChanged
Dim wmiQuery = New SelectQuery("SELECT * FROM Win32_NetworkAdapter " & "WHERE NetConnectionId != null ") '& "AND Manufacturer != 'Microsoft' "
Using mosSearcher = New ManagementObjectSearcher(wmiQuery)
For Each moItem As ManagementObject In mosSearcher.[Get]()
Using moItem
If DirectCast(moItem("NetConnectionId"), [String]) = ComboBox2.SelectedItem Then
moItem.InvokeMethod("Enable", Nothing)
Else
moItem.InvokeMethod("Disable", Nothing)
End If
End Using
Next
End Using
End Sub
정말 간단하다.
- 다음글[vb.net] 컴퓨터 IP주소 변경 21.08.19
댓글목록
등록된 댓글이 없습니다.