同一局域网中获取客户端IP及MAC地址
1
using System;
2
using System.Collections.Generic;
3
using System.Text;
4
using System.Web;
5
using System.Web.UI;
6
using System.Web.UI.WebControls;
7
using System.Runtime.InteropServices;
8![]()
9
namespace SkyMac
10
{
11
public class GetMac
12
{
13
[DllImport("Iphlpapi.dll")]
14
private static extern int SendARP(Int32 dest, Int32 host, ref Int64 mac, ref Int32 length);
15
[DllImport("Ws2_32.dll")]
16
private static extern Int32 inet_addr(string ip);
17![]()
18
获取客户IP地址
34![]()
35
获取客户MAC地址
86![]()
87
}
88
}
89![]()
using System;2
using System.Collections.Generic;3
using System.Text;4
using System.Web;5
using System.Web.UI;6
using System.Web.UI.WebControls;7
using System.Runtime.InteropServices;8

9
namespace SkyMac10
{11
public class GetMac12
{13
[DllImport("Iphlpapi.dll")]14
private static extern int SendARP(Int32 dest, Int32 host, ref Int64 mac, ref Int32 length);15
[DllImport("Ws2_32.dll")]16
private static extern Int32 inet_addr(string ip);17

18
获取客户IP地址34

35
获取客户MAC地址86

87
}88
}89



浙公网安备 33010602011771号