你可以使用WMI來獲取MAC ID。。加上一些特定的條件也可以實(shí)現(xiàn)獲取WLAN MAC_ID
成都創(chuàng)新互聯(lián)致力于網(wǎng)站制作、做網(wǎng)站,成都網(wǎng)站設(shè)計(jì),集團(tuán)網(wǎng)站建設(shè)等服務(wù)標(biāo)準(zhǔn)化,推過標(biāo)準(zhǔn)化降低中小企業(yè)的建站的成本,并持續(xù)提升建站的定制化服務(wù)水平進(jìn)行質(zhì)量交付,讓企業(yè)網(wǎng)站從市場競爭中脫穎而出。 選擇成都創(chuàng)新互聯(lián),就選擇了安全、穩(wěn)定、美觀的網(wǎng)站建設(shè)服務(wù)!
首先MAC地址在網(wǎng)卡中是固定的,可以修改,但通常不進(jìn)行修改,通過vb.net修改的方式并不清楚但在XP或者W2000里面可以通過更改注冊表進(jìn)行修改
我找了一些C# 的VB。NET 貌似很少不過都是。NET 平臺。你看看吧都應(yīng)該通用的。
添加對System.Management的引用
using System.Management;
。。。
//獲取IP,子網(wǎng)掩碼(subnet mask)和默認(rèn)網(wǎng)關(guān)
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類來獲取相應(yīng)的硬件知識
其實(shí)這類東西很容易找到答案的,方法非常多,最常見的API模式,你去搜索吧,保證一把一把的
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
剛剛我自己寫了一段??是引用System.net?來做的???我不喜歡用WMI??主要是查出來的信息不準(zhǔn)確,下面我附上源碼??希望可以加分給我
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)絡(luò)連接:"?+?NetWork.Name?+?Environment.NewLine?+
"網(wǎng)卡序列號:"?+?NetWork.Id?+?Environment.NewLine?+
"網(wǎng)絡(luò)類型:"?+?NetWork.NetworkInterfaceType.ToString()?+?Environment.NewLine?+
"網(wǎng)絡(luò)速度:"?+?(NetWork.Speed?/?1000000).ToString()?+?"MB"?+?Environment.NewLine
Next
End?If
End?Sub
End?Class
Private Sub Form_Load()
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