Private Sub Form_Load()
成都創(chuàng)新互聯(lián)服務(wù)項目包括曾都網(wǎng)站建設(shè)、曾都網(wǎng)站制作、曾都網(wǎng)頁制作以及曾都網(wǎng)絡(luò)營銷策劃等。多年來,我們專注于互聯(lián)網(wǎng)行業(yè),利用自身積累的技術(shù)優(yōu)勢、行業(yè)經(jīng)驗、深度合作伙伴關(guān)系等,向廣大中小型企業(yè)、政府機構(gòu)等提供互聯(lián)網(wǎng)行業(yè)的解決方案,曾都網(wǎng)站推廣取得了明顯的社會效益與經(jīng)濟效益。目前,我們服務(wù)的客戶以成都為中心已經(jīng)輻射到曾都省份的部分城市,未來相信會繼續(xù)擴大服務(wù)區(qū)域并繼續(xù)獲得客戶的支持與信任!
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)卡的系列號
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;
}
我找了一些C# 的VB。NET 貌似很少不過都是。NET 平臺。你看看吧都應(yīng)該通用的。
添加對System.Management的引用
using System.Management;
。。。
//獲取IP,子網(wǎng)掩碼(subnet mask)和默認網(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)的硬件知識
其實這類東西很容易找到答案的,方法非常多,最常見的API模式,你去搜索吧,保證一把一把的
一、用nbtstat -a ip 命令,用.net中processstartinfo和process類取得命令輸出,最后一行就是mac地址 mac address.
二、用.net中的wmi:system.management namespace hosted in system.management.dll assembly
例:
managementobjectsearcher query = new managementobjectsearcher(
你可以使用WMI來獲取MAC ID。。加上一些特定的條件也可以實現(xiàn)獲取WLAN MAC_ID
Private?Sub?Form_Load()
GetMyIP
End?Sub
Sub?GetMyIP()?'獲取IP地址、網(wǎng)卡類型、網(wǎng)卡地址
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