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] 다른 응용 프로그램 실행(Run) 및 종료(Kill) 22.11.04
- 다음글[vb.net] 10진수에서 n진수 변환 22.10.28
댓글목록
등록된 댓글이 없습니다.