資源簡介
簡單初級的局域網IP掃描工具及源碼,由VS2010編寫,可用于局域網IP掃描和對應IP計算機名掃描。
代碼片段和文件信息
using?System;
using?System.Collections.Generic;
using?System.ComponentModel;
using?System.Data;
using?System.Drawing;
using?System.Linq;
using?System.Text;
using?System.Windows.Forms;
using?System.Management;
using?System.Net;
using?System.Net.NetworkInformation;
using?System.Diagnostics;
using?System.Threading;
using?System.Runtime.InteropServices;
using?Microsoft.Win32;
using?System.Data.OleDb;
using?System.Reflection;
using?System.IO;
namespace?getIP
{
????public?partial?class?Form1?:?Form
????{
????????public?static?System.Data.DataTable?dtduizhao?=?new?System.Data.DataTable();
????????string[]?adx?=?new?string[256];
????????string[]?adress?=?new?string[256];
????????string[]?adress0?=?new?string[256];
????????int?duqu?=?0;
????????public?Form1()
????????{
????????????InitializeComponent();
????????}
????????[DllImport(“ws2_32.dll“)]
????????private?static?extern?int?inet_addr(string?cp);
????????[DllImport(“IPHLPAPI.dll“)]
????????private?static?extern?int?SendARP(Int32?DestIP?Int32?SrcIP?ref?Int64?pMacAddr?ref?Int32?PhyAddrLen);
????????int?count?=?0;
????????string?ipstart?=?“192.168.10.“;
????????string?iptop?=?“255“;?
????????private?void?Form1_Load(object?sender?EventArgs?e)
????????{
????????????string?strHostName?=?Dns.GetHostName();?//得到本機的主機名???
????????????IPHostEntry?ipEntry?=?Dns.GetHostByName(strHostName);?//取得本機IP???
????????????string?strAddr?=?ipEntry.AddressList[0].ToString();
????????????label4.Text?=“本機IP:“+?strAddr;
????????????progressBar1.Visible?=?false;?
????????????textBox1.Text?=?ipstart;
????????????textBox2.Text?=?iptop;
????????????if?(File.Exists(System.Windows.Forms.Application.StartupPath?+?@“\機名對照表.dat“))
????????????{
????????????????//dtshebei.Columns.Add(“ID“?typeof(string));
????????????????//dtshebei.Columns.Add(“位號“?typeof(string));
????????????????//dtshebei.Columns.Add(“檢維修內容“?typeof(string));
????????????????//dtshebei.Columns.Add(“備注“?typeof(string));
????????????????string?adress?=?System.Windows.Forms.Application.StartupPath?+?@“\機名對照表.dat“;
????????????????dtduizhao?=?GetTxt(adress);
????????????????dataGridView2.DataSource?=?dtduizhao;
????????????????dataGridView2.ClearSelection();
????????????}
????????}
????????private?System.Data.DataTable?GetTxt(string?pths)
????????{
???????????
????????????StreamReader?sr?=?new?StreamReader(pths?Encoding.GetEncoding(“GB2312“));
????????????string?txt?=?sr.ReadToEnd().Replace(“\r\n“?“*“);
????????????string[]?nodes?=?txt.Split(‘*‘);
????????????//#endregion
????????????//#region?填充DataTable
????????????System.Data.DataTable?dt?=?new?System.Data.DataTable();
????????????//dt.Columns.Add(“ID“?typeof(string));
????????????dt.Columns.Add(“讀取機名“?typeof(string));
????????????dt.Columns.Add(“實際機名“?typeof(string));
????????????
????????????foreach?(string?node?in?nodes)
????????????{
????????????????try
????????????????{
????
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件????????490??2016-03-09?13:48??IP掃描工具\getIP\bin\Debug\getIP.vshost.exe.manifest
?????文件?????214016??2018-02-06?14:19??IP掃描工具\getIP\bin\Debug\IP掃描工具.exe
?????文件?????249344??2018-02-06?14:19??IP掃描工具\getIP\bin\Debug\IP掃描工具.pdb
?????文件??????11608??2018-08-28?16:05??IP掃描工具\getIP\bin\Debug\IP掃描工具.vshost.exe
?????文件????????490??2016-03-09?13:48??IP掃描工具\getIP\bin\Debug\IP掃描工具.vshost.exe.manifest
?????文件????????234??2018-01-17?11:22??IP掃描工具\getIP\bin\Debug\機名對照表.dat
?????文件??????76173??2018-02-06?14:19??IP掃描工具\getIP\Form1.cs
?????文件??????15225??2018-02-06?14:17??IP掃描工具\getIP\Form1.Designer.cs
?????文件?????107377??2018-02-06?14:17??IP掃描工具\getIP\Form1.resx
?????文件???????3894??2018-01-17?11:27??IP掃描工具\getIP\getIP.csproj
?????文件???????1229??2018-01-26?16:47??IP掃描工具\getIP\obj\x86\Debug\DesignTimeResolveAssemblyReferences.cache
?????文件???????6340??2018-02-06?14:19??IP掃描工具\getIP\obj\x86\Debug\DesignTimeResolveAssemblyReferencesInput.cache
?????文件???????1985??2018-08-28?16:05??IP掃描工具\getIP\obj\x86\Debug\getIP.csproj.FileListAbsolute.txt
?????文件????????975??2018-02-06?14:18??IP掃描工具\getIP\obj\x86\Debug\getIP.csproj.GenerateResource.Cache
?????文件???????1757??2018-02-01?09:15??IP掃描工具\getIP\obj\x86\Debug\getIP.csprojResolveAssemblyReference.cache
?????文件??????67700??2018-02-06?14:18??IP掃描工具\getIP\obj\x86\Debug\getIP.Form1.resources
?????文件?????214016??2018-02-06?14:19??IP掃描工具\getIP\obj\x86\Debug\IP掃描工具.exe
?????文件?????249344??2018-02-06?14:19??IP掃描工具\getIP\obj\x86\Debug\IP掃描工具.pdb
?????文件????????180??2018-01-17?11:27??IP掃描工具\getIP\obj\x86\Debug\IP掃描工具.Properties.Resources.resources
?????文件???????4608??2018-01-17?11:26??IP掃描工具\getIP\obj\x86\Debug\TempPE\Properties.Resources.Designer.cs.dll
?????文件????????486??2018-01-16?10:07??IP掃描工具\getIP\Program.cs
?????文件???????1360??2018-01-16?10:07??IP掃描工具\getIP\Properties\AssemblyInfo.cs
?????文件???????2868??2018-01-17?11:23??IP掃描工具\getIP\Properties\Resources.Designer.cs
?????文件???????5612??2018-01-16?10:06??IP掃描工具\getIP\Properties\Resources.resx
?????文件???????1114??2018-01-17?11:23??IP掃描工具\getIP\Properties\Settings.Designer.cs
?????文件????????249??2018-01-16?10:06??IP掃描工具\getIP\Properties\Settings.settings
?????文件??????67134??2018-01-17?11:27??IP掃描工具\getIP\search_128px_1191635_easyicon.net.ico
?????文件??????16958??2018-01-17?11:26??IP掃描工具\getIP\search_64px_1127199_easyicon.net.ico
?????文件????????857??2018-01-16?10:07??IP掃描工具\getIP.sln
????..A..H.?????22016??2018-08-28?16:05??IP掃描工具\getIP.suo
............此處省略13個文件信息
評論
共有 條評論