1
我試圖在運行此應用程序的計算機上顯示網絡適配器。 爲此,我希望能夠顯示所有網絡適配器,而不管它們具有哪種狀態。 然後,我希望能夠通過按下按鈕來啓用和禁用適配器。Vb.net - 顯示每個網絡適配器,啓用或禁用
我試過使用System.Net.NetworkInformation
,但它好像只包含一個活動的。
' NETWORK ADAPTERS
' Create label
Dim LabelNetworkAdapter As New Label
Dim old As Padding = LabelNetworkAdapter.Margin
LabelNetworkAdapter.Margin = New Padding(old.Left, 8, old.Right, old.Bottom)
' CreateButton
Dim BtnConnectButton As New Button
BtnConnectButton.Height = 23
BtnConnectButton.Width = 60
For Each nic As NetworkInterface In NetworkInterface.GetAllNetworkInterfaces()
Dim strText As String = nic.Description.ToString
TableLayoutPanel_Nettverkskort.Controls.Add(LabelNetworkAdapter)
LabelNetworkAdapter.Text = strText
TableLayoutPanel_Nettverkskort.Controls.Add(BtnConnectButton)
BtnConnectButton.Text = "Koble fra"
Exit For
Next
這就是禁用界面意味着,應用程序無法再看到它。使用WMI代碼創建器來玩WMI查詢。 – 2011-01-29 20:51:16