• nbtstat a ip 获取MAC地址等


            //nbtstat -a ip 获取MAC地址等
            public static string cmdNbtstat(string macIp2)
            {
                string hostname2 = "               ";
                string domain2 = "               ";
                string username2 = "               ";
                string mac2 = "               ";

                System.Diagnostics.Process process = new System.Diagnostics.Process();
                process.StartInfo.FileName = "nbtstat";
                process.StartInfo.Arguments = "-a "+macIp2;
                process.StartInfo.UseShellExecute = false;
                process.StartInfo.CreateNoWindow = true;
                process.StartInfo.RedirectStandardOutput = true;

                process.Start();

                string output = process.StandardOutput.ReadToEnd();
                int hostname2Length = output.IndexOf("<00>  UNIQUE");
                int domain2Length = output.IndexOf("<00>  GROUP");
                int username2Length = output.LastIndexOf("<03>  UNIQUE");
                int mac2Length = output.IndexOf("MAC Address = ");

                if (hostname2Length > 0)
                {
                    hostname2 = output.Substring(hostname2Length - 15, 15);
                }

                if (domain2Length > 0)
                {
                    domain2 = output.Substring(domain2Length - 15, 15);
                }

                if (username2Length > 0)
                {
                    username2 = output.Substring(username2Length - 15, 15);
                }

                if(mac2Length>0)
                {
                    mac2 = output.Substring(mac2Length+14, 17);
                }
                process.WaitForExit();
                return hostname2 + domain2 + username2 + mac2.Replace("-", ":").Trim();
            }

  • 相关阅读:
    持续集成(Continuous Integration),
    python的几个有趣点
    C++语言发展历史 & 基础知识
    [C++] Windows下的socket编程(这是一个简单的TCP/IP例子)
    office app 代码简析之 task pane app
    佳言玩具
    数据的图形可视化[R语言结果GML引发出来的调查]
    收藏的一系列教程帖子,很适合有一定基础,想要进阶的同学
    各种排序算法总结
    三层架构+存储过程实现分页
  • 原文地址:https://www.cnblogs.com/mossan/p/749846.html
Copyright © 2020-2023  润新知