system
November 8, 2010, 5:55am
1
how I get local physical address?
Or Do I have to use C# dll?
using UnityEngine;
using System.Collections;
using System.Net.NetworkInformation;
using System;
public class getMac : MonoBehaviour
{
void Start()
{
NetworkInterface[] nics = NetworkInterface.GetAllNetworkInterfaces();
print ( nics.Length + " nics");
}
}
=>>>>result : 0
The following should display relevant MAC addresses on the client machine. Make sure you include System.Net.NetworkInformation
This is pretty heavily referenced from the net, but the code below works in Unity and will display physical addresses in the console.
public void ShowNetworkInterfaces()
{
IPGlobalProperties computerProperties = IPGlobalProperties.GetIPGlobalProperties();
NetworkInterface[] nics = NetworkInterface.GetAllNetworkInterfaces();
foreach (NetworkInterface adapter in nics)
{
PhysicalAddress address = adapter.GetPhysicalAddress();
byte[] bytes = address.GetAddressBytes();
string mac = null;
for (int i = 0; i < bytes.Length; i++)
{
mac = string.Concat(mac +(string.Format("{0}", bytes*.ToString("X2"))));*
if (i != bytes.Length - 1)
{
mac = string.Concat(mac + “-”);
}
}
";*
info += "
";*
}
Debug.Log(info);*
}
This code worked for me:
#pragma strict
import System.Net;
import System.Net.NetworkInformation;
var MacLicence = "50E54949E73D";
function Start () {
if(GetMacAddress() != MacLicence)
Application.Quit();
}
function Update () {
}
function GetMacAddress()
{
var macAdress = "";
var nics : NetworkInterface[] = NetworkInterface.GetAllNetworkInterfaces();
var i = 0;
for (var adapter: NetworkInterface in nics)
{
var address: PhysicalAddress = adapter.GetPhysicalAddress();
if(address.ToString() != "")
{
macAdress = address.ToString();
return macAdress;
}
}
return "error lectura mac address";
}
It worked on Windows7 at first time (not tested on Macintosh, niether mobile devices).
Hope it helps.
system
November 8, 2010, 8:07am
2
On XP, very simple, Start/Run/ type "cmd', then on the DOS console type ipconfig /all
Just chose the physical adress (MAC) of the adapter you are looking for.
Here is how to Know Mac Address / Physical address in Windows 10 PC
1> -Using Command Prompt
1: – Search for CMD in windows 10 search box and click on the result to open it.
2: – Once the command prompt window opens, run the command given below.
getmac /v /fo list
2 >– Using Network Connections
1: – Right click on start menu located at the bottom left of your screen. You can also press windows key + x together
2: – In the menu that appears, just click on network connections.
3: – Now, scroll down and click on view network properties.
4: – Your Physical address or MAC address is right there on this page.
Source:- http://merabheja.com/mac-address-in-windows-10/