這裡將介紹如何利用巧妙的方式來獲取區域網內所有機器:
// 1.先呼叫系統api判斷網路是否處於連線狀態
[dllimport("wininet.dll")]
private static extern bool internetgetconnectedstate(out int connectiondescription, int reservedvalue);
public static bool islocalconnection()
//2.再呼叫底層硬體獲取本地閘道器位址資訊
static string getgatewayaddress()
}
}
}
return "";
} //3.分別向本地網關內機器傳送icmp資料報
bool pinging(string addr, int id, uint taskid)
catch (exception e)
return true;
}//4.定義本地機器節點資訊類
public class localmachine
public string machinemac
public string machinename
}//5.根據arp原理,最後通過以下方式讀取arp列表節點資訊,其實這裡還可以imcp包響應來獲取主機響應,
//不過我個人認為用直接讀取列表的方式更加快速有效。
static arraylist getalllocalmachines()
}
return list;
}//6.最後,你還可以通過以下方法來獲取網絡卡的mac位址資訊
[dllimport("netapi32.dll")]
public static extern char netbios(ref macaddress.ncb ncb);
public string getmacaddress()
}catch{}}
C 查詢區域網內所有電腦
本文主要示例winform中的非同步呼叫,至於活動目錄等相關知識,還需另查資料.要完成本例的除錯,需在乙個窗體上加乙個richtextbox1和一button1.點button1時會在richtextbox1中顯示所有網域名稱及其下的各計算機名稱和ip位址.一台電計算機顯示一行,如果有多個ip也顯示...
區域網內所有的IP 檢視
區域網內所有的ip,比如區域網的zhi閘道器是192.168.0.1,那個這個dao區域網的所有ip就是版192.168.0.100到192.168.0.254這個範圍權內,一共有155個ip位址。要如何檢視區域網內正在使用的電腦的ip一共分以下幾個步驟 第一步 點選電腦左下角的 開始 然後再點選 ...
區域網中的所有機器都能連線MySQL資料庫
我們要想讓區域網中的所有機器都能連線mysql資料庫,首先要給mysql開啟遠端連線的功能,在mysql伺服器上mysql命令列執行以下命令 命令 如下 grant all privileges on to root identified by abc with grant option flush...