高手请进:局域网内如何根据ip地址查询计算机名称(不是本机),如何用C#实现?
例如,已知一台机器的ip地址为10.41.105.30,如何确定其计算机名称?谢谢!
例如,已知一台机器的ip地址为10.41.105.30,如何确定其计算机名称?谢谢!
解决方案 »
- C#如何响应多个事件
- 奇大怪啦!Spring.Net+NHibernate 事务在Oracle中第一次正常回滚,以后均不正常回滚!!!!!!
- 请教一个关于datagridview定时刷新的问题,大家多多顶贴啊,顶者有分
- 想自己开发矩阵切换器的控制软件,用什么方式实现交叉点切换界面好?
- 求存储过程,万分感谢帮忙的朋友,所有分送上. 只有33分! 但是帮帮忙吧! 谢谢了!
- 请教COMBOX问题和窗体自动刷新问题
- 重写GridView的DataBind方法!
- 有些关于(上传下下载)的想法,希望大家能帮帮忙!
- arraylist最大下标是多少,提示“索引超出了数组界限”是怎么回事
- c# printDocument的内容可以保存的吗?(winform)
- c#中如何判断字符(串)是不是中文?
- 请教关于dpi与分辨率
{
IPAddress myscanip=IPAddress.Parse(myip);
IPHostEntry myscanhost = Dns.GetHostByAddress( myscanip );
string name = myscanhost.HostName.ToString();
return name;
}
Process proc = new Process();
proc.StartInfo.FileName = @"ping.exe";
proc.StartInfo.Arguments = "command"; //command 为dos 命令
proc.StartInfo.UseShellExecute = false;
proc.StartInfo.RedirectStandardOutput = true;
proc.StartInfo.RedirectStandardInput = true;
proc.StartInfo.RedirectStandardError = true;
proc.StartInfo.CreateNoWindow = true;
proc.Start();
string output = proc.StandardOutput.ReadToEnd();
proc.Dispose(); string pingrst = "";
if (output.IndexOf("(0% loss)") != -1)
pingrst = "连接";
else if (output.IndexOf("Destination host unreachable.") != -1)
pingrst = "无法到达目的主机";
else if (output.IndexOf("Request timed out.") != -1)
pingrst = "超时";
else if (output.IndexOf("Unknown host") != -1)
pingrst = "无法解析主机";
else
pingrst = output; MessageBox.Show(pingrst);//只要你会用dos命令找到就研究一下吧
好像不行哦,我以前用這個,好像只能得到IP地址哦。你有沒有測試過啊!