This article mainly describes how to obtain PC and tablet physical address, need friends can refer to the following
Get PC Physical Address namespace: Using system.management; code as follows:///<summary> ///get Mac Physical Address /// </summary> ///<returns></returns> public string Getmac () { try { ManagementObjectSearcher query = new ManagementObjectSearcher ("SELECT * FROM Win32_NetworkAdapterConfiguration" ); managementobjectcollection querycollection = query. Get (); foreach (ManagementObject mo in querycollection) { if (mo["ipenabled"]. ToString () = = "True") return mo["MacAddress"]. ToString (); } return ""; } catch { return ""; } } get flat MAC Address: & nbsp namespace: using system.net; using system.runtime.interopservices; Add variable: The code is as follows: protected static string strjavascript = String. empty; [DllImport ("Iphlpapi.dll")] private static extern int Sendarp (Int32 dest, Int32 host, ref Int64 Mac, re f Int32 length); &nBsp [DllImport ("Ws2_32.dll")] private static extern Int32 inet_addr (string IP); code as follows: private void S Etmac () { try { string treatment_id = hid_treatment_id. value; string mac = string. empty; String ip = Request.UserHostAddress.ToString (). Trim (); try { mac = Getmac (); } catch {lbl. innertext = "w33w"; } //mac = "00:01:36:D8:9C:C4"; //LBL. InnerText = Mac + "," + ip; if (Mac!= "You don't have networking") { int iretn = commonws. GetInt ("crrt/pad-login", "Specify a flat MAC address for a treatment patient", new string[] {mac, treatment_id}); } catch {} . innertext = "WW"; } } private string Getmac () { string mac = ""; string strclientip = Request.userhosta Ddress. ToString (). Trim (); Int32 ldest = inet_addr (Strclientip); The destination of the ip Int32 lhost = inet_addr (""); Local server ip Int64 macinfo = new Int64 (); Int32 len = 6; int res = SENDARP (ldest, 0, ref macinfo, ref len); mac = Macinfo. ToString ("X"); try { string[] Arr_mac = new String[mac. length/2]; int k = 0; for (int i = Mac. Length; i > 0; i = i-2) { arr_mac[k] = Mac. Substring (I-2, 2); k++; } mac = ""; foreach (String chars in Arr_mac) { mac = chars + ":"; } mac = Mac. TrimEnd (': '); } catch {} return mac; }