需要找出用户MAC地址和IP地址 [英] Need to find out User MAC Address and IP Address

查看:125
本文介绍了需要找出用户MAC地址和IP地址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

In my project, we need to find out User MAC Address and IP Address kindly Provide the sample code (using C# Code behind or JavaScript or ActiveX controls). Thanks in Advance

推荐答案

javascript


javascript


var macAddress = "";
    var ipAddress = "";
    var computerName = "";
    var wmi = GetObject("winmgmts:{impersonationLevel=impersonate}");
    e = new Enumerator(wmi.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration     WHERE IPEnabled = True"));
    for(; !e.atEnd(); e.moveNext()) {
        var s = e.item(); 
        macAddress = s.MACAddress;
        ipAddress = s.IPAddress(0);
        computerName = s.DNSHostName;
    } 



C#

使用system.net
使用System.Net.NetworkInformation

IPAddressInformation类(System.Net.NetworkInformation) [ PhysicalAddress类(System.Net.NetworkInformation) [



C#

using system.net
using System.Net.NetworkInformation

IPAddressInformation Class (System.Net.NetworkInformation)[^]


PhysicalAddress Class (System.Net.NetworkInformation)[^] is for mac address


这篇关于需要找出用户MAC地址和IP地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆