Private Sub Form_Load()
十多年的蕉城網(wǎng)站建設經(jīng)驗,針對設計、前端、開發(fā)、售后、文案、推廣等六對一服務,響應快,48小時及時工作處理。成都營銷網(wǎng)站建設的優(yōu)勢是能夠根據(jù)用戶設備顯示端的尺寸不同,自動調整蕉城建站的顯示方式,使網(wǎng)站能夠適用不同顯示終端,在瀏覽器中調整網(wǎng)站的寬度,無論在任何一種瀏覽器上瀏覽網(wǎng)站,都能展現(xiàn)優(yōu)雅布局與設計,從而大程度地提升瀏覽體驗。成都創(chuàng)新互聯(lián)從事“蕉城網(wǎng)站設計”,“蕉城網(wǎng)站推廣”以來,每個客戶項目都認真落實執(zhí)行。
Dim strComputer As String
Dim objWMI As Object
Dim colIP As Object
Dim IP As Object
Dim I As Integer
strComputer = "."
Set objWMI = GetObject("winmgmts://" strComputer "/root/cimv2")
Set colIP = objWMI.ExecQuery _
("Select * from Win32_NetworkAdapterConfiguration where IPEnabled=TRUE")
For Each IP In colIP
If Not IsNull(IP.IPAddress) Then
For I = LBound(IP.IPAddress) To UBound(IP.IPAddress)
MsgBox "IP地址:" IP.IPAddress(I) Chr(10) _
"網(wǎng)卡類型:" IP.Description(I) Chr(10) _
"網(wǎng)卡地址:" IP.Macaddress(I)
Next
End If
Next
End Sub
你可以使用WMI來獲取MAC ID。。加上一些特定的條件也可以實現(xiàn)獲取WLAN MAC_ID
Public Function EnumNetworkAdapters() As String
Try
Dim query As System.Management.ManagementObjectSearcher = New System.Management.ManagementObjectSearcher("SELECT * FROM Win32_NetworkAdapterConfiguration")
Dim queryCollection As System.Management.ManagementObjectCollection = query.Get()
Dim mo As New System.Management.ManagementObject
For Each mo In queryCollection
If IsDBNull(mo.Item("Description")) = False Then
EnumNetworkAdapters = mo.Item("Description") "|||"
End If
If IsDBNull(mo.Item("macaddress")) = False Then
If mo.Item("macaddress") "" Then
EnumNetworkAdapters = mo.Item("macaddress") "|||"
End If
End If
If IsDBNull(mo.Item("IPAddress")) = False Then
Dim temp As String
temp = Join(mo.Item("IPAddress"), ".")
If temp "" Then
EnumNetworkAdapters = temp "|||"
End If
End If
Next
Catch err A* **ception
EnumNetworkAdapters = err.Message err.StackTrace
End Try
End Function
首先MAC地址在網(wǎng)卡中是固定的,可以修改,但通常不進行修改,通過vb.net修改的方式并不清楚但在XP或者W2000里面可以通過更改注冊表進行修改
剛剛我自己寫了一段??是引用System.net?來做的???我不喜歡用WMI??主要是查出來的信息不準確,下面我附上源碼??希望可以加分給我
Imports?System.Net
Imports?System.Net.NetworkInformation
Public?Class?Form1
Private?Sub?btnGetMac_Click(ByVal?sender?As?System.Object,?ByVal?e?As?System.EventArgs)?Handles?btnGetMac.Click
Dim?NetworkInterfaces()?As?NetworkInterface
NetworkInterfaces?=?NetworkInterface.GetAllNetworkInterfaces()
If?NetworkInterfaces.Length??0?Then
For?Each?NetWork?In?NetworkInterfaces
txtMac.Text?=?txtMac.Text?+
"MAC地址:"?+?NetWork.GetPhysicalAddress().ToString()?+?Environment.NewLine?+
"網(wǎng)絡連接:"?+?NetWork.Name?+?Environment.NewLine?+
"網(wǎng)卡序列號:"?+?NetWork.Id?+?Environment.NewLine?+
"網(wǎng)絡類型:"?+?NetWork.NetworkInterfaceType.ToString()?+?Environment.NewLine?+
"網(wǎng)絡速度:"?+?(NetWork.Speed?/?1000000).ToString()?+?"MB"?+?Environment.NewLine
Next
End?If
End?Sub
End?Class
我找了一些C# 的VB。NET 貌似很少不過都是。NET 平臺。你看看吧都應該通用的。
添加對System.Management的引用
using System.Management;
。。。
//獲取IP,子網(wǎng)掩碼(subnet mask)和默認網(wǎng)關
ManagementClass mc = new ManagementClass( "Win32_NetworkAdapterConfiguration ");
ManagementObjectCollection nics = mc.GetInstances();
foreach(ManagementObject nic in nics)
{
if(Convert.ToBoolean(nic[ "ipEnabled "]) == true)
{
Console.WriteLine((nic[ "IPAddress "] as String[])[0]);
Console.WriteLine((nic[ "IPSubnet "] as String[])[0]);
Console.WriteLine((nic[ "DefaultIPGateway "] as String[])[0]);
}
}
獲取硬件信息源代碼:
獲取硬件信息演示程序:
漢化
利用using System.Management類來獲取相應的硬件知識
其實這類東西很容易找到答案的,方法非常多,最常見的API模式,你去搜索吧,保證一把一把的