你可以使用WMI來獲取MAC ID。。加上一些特定的條件也可以實現獲取WLAN MAC_ID
成都創新互聯致力于網站制作、做網站,成都網站設計,集團網站建設等服務標準化,推過標準化降低中小企業的建站的成本,并持續提升建站的定制化服務水平進行質量交付,讓企業網站從市場競爭中脫穎而出。 選擇成都創新互聯,就選擇了安全、穩定、美觀的網站建設服務!
首先MAC地址在網卡中是固定的,可以修改,但通常不進行修改,通過vb.net修改的方式并不清楚但在XP或者W2000里面可以通過更改注冊表進行修改
我找了一些C# 的VB。NET 貌似很少不過都是。NET 平臺。你看看吧都應該通用的。
添加對System.Management的引用
using System.Management;
。。。
//獲取IP,子網掩碼(subnet mask)和默認網關
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模式,你去搜索吧,保證一把一把的
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??主要是查出來的信息不準確,下面我附上源碼??希望可以加分給我
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?+
"網絡連接:"?+?NetWork.Name?+?Environment.NewLine?+
"網卡序列號:"?+?NetWork.Id?+?Environment.NewLine?+
"網絡類型:"?+?NetWork.NetworkInterfaceType.ToString()?+?Environment.NewLine?+
"網絡速度:"?+?(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) _
"網卡類型:" IP.Description(I) Chr(10) _
"網卡地址:" IP.Macaddress(I)
Next
End If
Next
End Sub
當前標題:關于vbnetMac的信息
文章URL:http://vcdvsql.cn/article40/hsoeeo.html
成都網站建設公司_創新互聯,為您提供定制網站、移動網站建設、網站營銷、靜態網站、網站收錄、定制開發
聲明:本網站發布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網站立場,如需處理請聯系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經允許不得轉載,或轉載時需注明來源: 創新互聯