Exemplo n.º 1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        string MacAddress = string.Empty;

        try
        {
            ManagementClass            MClass         = new ManagementClass("Win32_NetworkAdapterConfiguration");
            ManagementObjectCollection MobjCollection = MClass.GetInstances();
            foreach (ManagementObject MObject in MobjCollection)
            {
                if ((bool)MObject["IPEnabled"] == true)
                {
                    MacAddress = MObject["MacAddress"].ToString();
                }
                MObject.Dispose();
            }

            Response.Write(MacAddress);
            //if (MacAddress == "[ValidationAddress]")
            //    return true;
            //else
            //    return false;
        }
        catch (Exception ex)
        {
            throw ex;
        }
    }