1、 获取 pc 电脑和平板物理地址这篇文章主要介绍了如何获取 pc 电脑和平板物理地址,需要的朋友可以参考下获取 pc 物理地址命名空间:using system.management;代码如下:/ summary/ 获取 mac 物理地址/ /summary/ returns/returnspublic string getmac()trymanagementobjectsearcher query = new managementobjectsearcher(select * from win32_networkadapterconfiguration);managementobjectco
2、llection querycollection = query.get();foreach (managementobject mo in querycollection)if (moipenabled.tostring() = true)return momacaddress.tostring();return ;catchreturn ;获取平板 mac 地址:命名空间:using ;using system.runtime.interopservices;添加变量:代码如下:protected static string strjavascript = string.empty;dll
3、import(iphlpapi.dll)private static extern int sendarp(int32 dest, int32 host, ref int64 mac, ref int32 length);dllimport(ws2_32.dll)private static extern int32 inet_addr(string ip);代码如下:private void setmac()trystring treatment_id = hid_treatment_id.value;string mac = string.empty;string ip = request
4、.userhostaddress.tostring().trim();trymac = getmac();catch lbl.innertext = w33w; /mac = 00:01:36:d8:9c:c4;/ lbl.innertext = mac + , + ip;if (mac != 您没有联网)int iretn = commonws.getint(crrt/pad-登录, 指定某治疗病人的平板 mac 地址, new string mac, treatment_id );catch lbl.innertext = ww; private string getmac()string
5、 mac = ;string strclientip = request.userhostaddress.tostring().trim();int32 ldest = inet_addr(strclientip); /目的地的 ipint32 lhost = inet_addr(); /本地服务器的 ipint64 macinfo = new int64();int32 len = 6;int res = sendarp(ldest, 0, ref macinfo, ref len);mac = macinfo.tostring(x);trystring arr_mac = new stringmac.length / 2;int k = 0;for (int i = mac.length; i 0; i = i - 2)arr_mack = mac.substring(i - 2, 2);k+;mac = ;foreach (string chars in arr_mac)mac += chars + :;mac = mac.trimend(:);catch return mac;