Downloads:
Features:
- Get external ip address & MAC address for connected device
- Get local ip address and connection status
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 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 |
using System; using System.Net.NetworkInformation; using System.Text.RegularExpressions; using System.Windows.Forms; using System.Net.Sockets; using System.Net; using System.Runtime.InteropServices; namespace IP_Address { public partial class Main : Form { [DllImport("wininet.dll")] private extern static bool InternetGetConnectedState(out int Description, int ReservedValue); // Connection Status public string IP; public Main() { InitializeComponent(); } private void btnGIlocal_Click(object sender, EventArgs e) { ////// IP Address To Loop and Check all over again ! IPHostEntry host; String LocalIP = "?"; host = Dns.GetHostEntry(Dns.GetHostName()); foreach (IPAddress ip in host.AddressList) { if (ip.AddressFamily.ToString() == "InterNetwork") { LocalIP = ip.ToString(); metroTextBox14.Text = LocalIP; } } try { int Desc; /// Connection Status if (InternetGetConnectedState(out Desc, 0) == true) { metroTextBox12.Text = "Connected"; } else { metroTextBox12.Text = "Not Connected"; } } catch { } } public void btnGIexternal_Click(object sender, EventArgs e) { int Desc; if (InternetGetConnectedState(out Desc, 0) == true) { try { metroTextBox56.Text = "Please Wait ..."; metroTextBox56.Text = getExternalIp(); } catch { metroTextBox56.Text = "Network Error !"; } try { metroTextBox65.Text = "Please Wait ..."; metroTextBox65.Text = GetMacAddress(); } catch { metroTextBox65.Text = "Unknown Error !"; } } else { metroTextBox56.Text = ""; metroTextBox65.Text = ""; metroTextBox56.Text = "Internet Required !"; metroTextBox65.Text = "Internet Required !"; } } public string getExternalIp() { try { string externalIP; externalIP = (new WebClient()).DownloadString("http://ipinfo.io/"); externalIP = (new Regex(@"\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}")) .Matches(externalIP)[0].ToString(); IP = externalIP; return externalIP; } catch { return null; } } public string GetMacAddress() { foreach (NetworkInterface NetI in NetworkInterface.GetAllNetworkInterfaces()) { if (NetI.NetworkInterfaceType == NetworkInterfaceType.Wireless80211 || NetI.NetworkInterfaceType == NetworkInterfaceType.Ethernet && NetI.OperationalStatus == OperationalStatus.Up) { bool found = false; foreach (UnicastIPAddressInformation UniIpAddrInfo in NetI.GetIPProperties().UnicastAddresses) { if (UniIpAddrInfo.Address.AddressFamily != AddressFamily.InterNetwork || UniIpAddrInfo.AddressPreferredLifetime == UInt32.MaxValue) continue; found = (UniIpAddrInfo.Address.ToString() == IP); } if (found) { string macAddr = NetI.GetPhysicalAddress().ToString(); return (macAddr.Length != 12) ? "00:00:00:00:00:00" : Regex.Replace(macAddr, "(.{2})(.{2})(.{2})(.{2})(.{2})(.{2})", "$1:$2:$3:$4:$5:$6"); } } } return "Unknown"; } } } |
Screenshots:
Unsupported devices:
- Netgear wifi extender n300, etc…
Similar Apps:
Unknown
Contact: