本人想在程序中实现基于MAC地址的空间约束的用户登陆及注册,现想求得如何在程序中提取客户机端的MAC地址,有知道的高手给予答复,谢谢!!!

解决方案 »

  1.   

    public string GetCustomerMac(string clientIP)
            {
                string Mac = "";
                System.Diagnostics.Process process = new System.Diagnostics.Process();
                process.StartInfo.FileName = "nbtstat";
                process.StartInfo.Arguments = "-a " + clientIP;
                process.StartInfo.UseShellExecute = false;
                process.StartInfo.CreateNoWindow = true;
                process.StartInfo.RedirectStandardOutput = true;
                process.Start();
                string output = process.StandardOutput.ReadToEnd();
                int length = output.IndexOf("MAC Address = ");
                if (length > 0)
                {
                    Mac = output.Substring(length + 14, 17);
                }
                process.WaitForExit();
                return Mac;
            }