Downloads:
Features:
- Check connection status
- WiFi scanner
C# Source Code:
- Main.cs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 |
using SimpleWifi; using System; using System.Collections.Generic; using System.Drawing; using System.Runtime.InteropServices; using System.Windows.Forms; namespace WiFi_Scanner { public partial class Main : Form { private static Wifi wifi; // Wifi Connector [DllImport("wininet.dll")] // Connection Status private extern static bool InternetGetConnectedState(out int Description, int ReservedValue); // Connection Status public Main() { InitializeComponent(); } private void Main_Load(object sender, EventArgs e) { int Desc; /// Connection Status if (InternetGetConnectedState(out Desc, 0) == true) { label10.Text = "Connected"; } else { label10.Text = "Not Connected"; } btnSearch.PerformClick(); } private void btnSearch_Click(object sender, EventArgs e) { listView2.Items.Clear(); btnConnect.Enabled = true; wifi = new Wifi(); List<AccessPoint> aps = wifi.GetAccessPoints(); foreach (AccessPoint ap in aps) { ListViewItem listView = new ListViewItem(ap.Name); listView.SubItems.Add(ap.SignalStrength + " % "); listView.Tag = ap; listView2.Items.Add(listView); } } private void btnConnect_Click(object sender, EventArgs e) { if (listView2.SelectedItems.Count > 0 && txtPassword.Text.Length > 0) { label10.Text = " Please Wait .... "; ListViewItem selecteditem = listView2.SelectedItems[0]; AccessPoint ap = (AccessPoint)selecteditem.Tag; if (CTW(ap, txtPassword.Text)) { label10.ForeColor = Color.Green; label10.Text = " Connected Successfully "; txtPassword.Enabled = false; } else { label10.ForeColor = Color.Red; label10.Text = " Connection Failed ! "; } } else { MessageBox.Show(" Please Select a Network \n and Enter Password ! ", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } private void btnDisconnect_Click(object sender, EventArgs e) { wifi = new Wifi(); List<AccessPoint> aps = wifi.GetAccessPoints(); foreach (AccessPoint ap in aps) { ListViewItem listView = new ListViewItem(ap.Name); listView.SubItems.Add(ap.SignalStrength + " % "); listView.Tag = ap; } try { if (wifi.ConnectionStatus == WifiStatus.Connected) { btnConnect.Enabled = true; label10.ForeColor = Color.Black; label10.Text = " Disconnected ! "; wifi.Disconnect(); txtPassword.Enabled = true; } } catch { label10.ForeColor = Color.Black; label10.Text = " Not Connected Yet ! "; txtPassword.Enabled = true; } } private bool CTW(AccessPoint ap, string password) { AuthRequest ar = new AuthRequest(ap); ar.Password = password; return ap.Connect(ar); } } } |