c#遍歷區域網的幾種方法及比較
2009-07-03 10:08
1、微軟社群上介紹了使用active directory 來遍歷區域網
利用directoryentry元件來檢視網路
**:private void enumcomputers()}}
}效果評價:速度慢,效率低,還有乙個無效結果 computer: schema 使用的過程中注意慮掉。
2、利用dns.gethostbyaddress和iphostentry遍歷區域網
private void enumcomputers()
catch
if (myscanhost != null)} }
效果評價:效率低,速度慢,不是一般的慢。
3、使用system.net.networkinformation.ping來遍歷區域網
private void enumcomputers()
}catch
}private void _myping_pingcompleted(object sender, pingcompletedeventargs e)
}using system;
using system.collections.generic;
using system.componentmodel;
using system.data;
using system.drawing;
using system.text;
using system.windows.forms;
using system.runtime.interopservices;
using system.net;
using system.net.networkinformation;
public partial class form1 : form
private void button1_click(object sender, eventargs e)
private string getmacaddress(string hostip)//獲取遠端ip(不能跨網段)的mac位址
}catch (exception mye)
return mac;
}private void form1_load(object sender, eventargs e)
}private void button2_click(object sender, eventargs e)
private void enumcomputers(int n)
}catch (exception ex)
}private void myping_pingcompleted(object sender, pingcompletedeventargs e)
this.textbox2.text += sb.tostring();}}
} c#的本機ip位址
iphostentry ipentry = dns.gethostentry(dns.gethostname());
string myip = ipentry.addresslist[0].tostring();
這樣,如果沒有安裝ipv6協議,可以取得ip位址. 但是如果安裝了ipv6,就取得的是ipv6的ip位址.
string myip = ipentry.addresslist[1].tostring();
這樣就在ipv6的情況下取得ipv4的ip位址.
但是,如果本機有很多塊網絡卡, 如何得到ipentry.addresslist[多少]才是本機的局網ipv4位址呢?
C 獲取區域網IP和MAC位址
c 遍歷區域網的幾種方法及比較 2009 07 03 10 08 1 微軟社群上介紹了使用active directory 來遍歷區域網 利用directoryentry元件來檢視網路 效果評價 速度慢,效率低,還有乙個無效結果 computer schema 使用的過程中注意慮掉。2 利用dns....
python獲取區域網IP位址
設計思路 設計乙個udp資料報,併發送到公共的dns伺服器當中,udp資料報是盡最大努力不可靠交付,我們只需要獲取到udp頭部資訊即可 import socket def main get wlan ip def get wlan ip try socket.sock dgram代表的是socket...
C 獲取本機IP方法,獲取本機區域網IP位址方法
1.1 private void getip 2 10 2.使用iphostentry獲取本機區域網位址 public static string getlocalip return 192.168.1.124 3.通過向 向一些提供ip查詢的 傳送webrequest,然後分析返回的資料流 1 s...