Private Sub Form_Load()
創(chuàng)新互聯(lián)專注為客戶提供全方位的互聯(lián)網(wǎng)綜合服務(wù),包含不限于網(wǎng)站建設(shè)、成都網(wǎng)站設(shè)計(jì)、巴東網(wǎng)絡(luò)推廣、小程序制作、巴東網(wǎng)絡(luò)營(yíng)銷、巴東企業(yè)策劃、巴東品牌公關(guān)、搜索引擎seo、人物專訪、企業(yè)宣傳片、企業(yè)代運(yùn)營(yíng)等,從售前售中售后,我們都將竭誠(chéng)為您服務(wù),您的肯定,是我們最大的嘉獎(jiǎng);創(chuàng)新互聯(lián)為所有大學(xué)生創(chuàng)業(yè)者提供巴東建站搭建服務(wù),24小時(shí)服務(wù)熱線:028-86922220,官方網(wǎng)址:www.cdcxhl.com
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
這是C#的,你可以轉(zhuǎn)換一下
using System.Management;
//獲取網(wǎng)卡的系列號(hào)
private static string GetMacAddress()
{
string ret = "";
try
{
ManagementClass cimobject = new ManagementClass("Win32_NetworkAdapterConfiguration");
ManagementObjectCollection moc = cimobject.GetInstances();
if (moc.Count == 0)
return "";
else
{
foreach (ManagementObject mo in moc)
{
if ((bool)mo["IPEnabled"] == true)
{
ret = (string)mo.Properties["MacAddress"].Value;
break;
}
}
}
}
catch
{
ret = "";
}
return ret;
}
首先MAC地址在網(wǎng)卡中是固定的,可以修改,但通常不進(jìn)行修改,通過vb.net修改的方式并不清楚但在XP或者W2000里面可以通過更改注冊(cè)表進(jìn)行修改
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
我找了一些C# 的VB。NET 貌似很少不過都是。NET 平臺(tái)。你看看吧都應(yīng)該通用的。
添加對(duì)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í)
其實(shí)這類東西很容易找到答案的,方法非常多,最常見的API模式,你去搜索吧,保證一把一把的
你可以使用WMI來獲取MAC ID。。加上一些特定的條件也可以實(shí)現(xiàn)獲取WLAN MAC_ID