以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  谁知道获取电脑网卡MAC地址和计算机名称的语句是什么?  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=32539)

--  作者:客家阿哥
--  发布时间:2013/5/3 19:13:00
--  谁知道获取电脑网卡MAC地址和计算机名称的语句是什么?
如题!
--  作者:Bin
--  发布时间:2013/5/4 9:23:00
--  
 Dim nics() As System.Net.NetworkInformation.NetworkInterface = System.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces
        messagebox.show(nics(0).GetPhysicalAddress.Tostring) \'获得MAC地址
       messagebox.show(Environment.MachineName) \'获得计算机名称
[此贴子已经被作者于2013-5-4 9:23:40编辑过]

--  作者:客家阿哥
--  发布时间:2013/5/4 10:15:00
--  
谢谢!

和ComputerID 结合,应该能很好的控制那些电脑可以进入程序!

--  作者:hunanwl
--  发布时间:2014/6/29 20:27:00
--  
为什么只能识别到 有线网卡的mac地址呢    无线网卡地址识别不出来啊
--  作者:有点甜
--  发布时间:2014/6/29 20:33:00
--  

 代码

 

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 Convert.ToBoolean(mo("ipEnabled")) = True
        If mo("IPAddress") IsNot Nothing Then          
            MessageBox.Show( mo("IPAddress")(0))
        End If
    End If
Next

 


--  作者:有点甜
--  发布时间:2014/6/29 20:36:00
--  
以下是引用hunanwl在2014-6-29 20:27:00的发言:
为什么只能识别到 有线网卡的mac地址呢    无线网卡地址识别不出来啊

 

图片点击可在新窗口打开查看

 

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("macaddress")) = False Then
        If mo.Item("macaddress") <> "" Then
           output.show(mo.Item("macaddress"))
        End If
    End If
Next


--  作者:hunanwl
--  发布时间:2014/6/29 21:03:00
--  
那如何识别到网卡类型呢
--  作者:有点甜
--  发布时间:2014/6/29 21:14:00
--  
以下是引用hunanwl在2014-6-29 21:03:00的发言:
那如何识别到网卡类型呢

 

Dim nics() As System.Net.NetworkInformation.NetworkInterface = System.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces
For Each nic As object In nics
    output.Show(nic.name)
    output.show(nic.NetworkInterfaceType)
    output.show(nic.Speed / 1000 / 1000 & "MB")
    output.show(nic.GetPhysicalAddress.tostring)
    output.show("----------------")
Next


--  作者:hunanwl
--  发布时间:2014/6/29 21:25:00
--  
Select * from Win32_NetworkAdapterConfiguration where IPEnabled=TRUE

如何用上面这句查询MAC地址呢,我看有些VB代码是用的这个查询  但是在狐表中运行却提示无法找到Win32_NetworkAdapterConfiguration

--  作者:有点甜
--  发布时间:2014/6/29 21:40:00
--  
以下是引用hunanwl在2014-6-29 21:25:00的发言:
Select * from Win32_NetworkAdapterConfiguration where IPEnabled=TRUE

如何用上面这句查询MAC地址呢,我看有些VB代码是用的这个查询  但是在狐表中运行却提示无法找到Win32_NetworkAdapterConfiguration

 

如果是这种,就需要用7楼的方法