Downloads:
Features:
- Get your geographic location
- Show external IP address
- Show your internet supplier info
- Show time zone, current date and time
Notes:
- Application won’t work as expected in case you used proxy!
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 |
using Newtonsoft.Json; using System; using System.Globalization; using System.Net; using System.Runtime.InteropServices; using System.Text.RegularExpressions; using System.Windows.Forms; namespace Geographic_Location_and_Internet_Supplier { public partial class Main : Form { [DllImport("wininet.dll")] private extern static bool InternetGetConnectedState(out int Description, int ReservedValue); // Connection Status public Main() { InitializeComponent(); } private void btnGetOnlineInfo_Click(object sender, EventArgs e) { try { int Desc; if (InternetGetConnectedState(out Desc, 0) == true) { OnlieLocationInfo info = new OnlieLocationInfo(); try { string json = new WebClient().DownloadString("http://ip-api.com/json/" + getExternalIp()); JsonConvert.PopulateObject(json, info); if (info.status == "success") { string st = "Success"; txtOLStatus.Text = st; } else { string st = "Fail !"; txtOLStatus.Text = st; } txtOLCountry.Text = info.country + " / " + info.countryCode; txtOLRegion.Text = info.regionName + " / " + info.region; txtOLCity.Text = info.city; txtOLZipCode.Text = info.zip; txtOLTimeZone.Text = info.timezone; txtOLDate.Text = InternetDate(); ; txtOLTime.Text = InternetTime(); txtOLDay.Text = InternetDay(); txtOLOrganization.Text = info.org; txtOLISP.Text = info.isp; txtOLLatitude.Text = info.lat; txtOLLongitude.Text = info.lon; txtOLExternalIP.Text = info.query; txtOLAsNu.Text = info.AS; } catch (Exception) { MessageBox.Show("Network Error !\nCouldn't retrieve data from internet !\nOr try to close other services you're using in the program !\nPlease try again later !"); } } else { MessageBox.Show("Connect to the Internet and try again !"); } } catch { MessageBox.Show("Try to close other services you're using in the program !"); } } 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(); return externalIP; } catch { return null; } } #region Internet Time public string InternetDate() { var myHttpWebRequest = (HttpWebRequest)WebRequest.Create("http://www.microsoft.com"); var response = myHttpWebRequest.GetResponse(); string todaysDates = response.Headers["date"]; DateTime dateTime = DateTime.ParseExact(todaysDates, "ddd, dd MMM yyyy HH:mm:ss 'GMT'", CultureInfo.InvariantCulture.DateTimeFormat, DateTimeStyles.AssumeUniversal); string Date = String.Format("{0 : yyyy / MM / dd}", dateTime); response.Close(); return Date; } public string InternetTime() { var myHttpWebRequest = (HttpWebRequest)WebRequest.Create("http://www.microsoft.com"); var response = myHttpWebRequest.GetResponse(); string todaysDates = response.Headers["date"]; DateTime dateTime = DateTime.ParseExact(todaysDates, "ddd, dd MMM yyyy HH:mm:ss 'GMT'", CultureInfo.InvariantCulture.DateTimeFormat, DateTimeStyles.AssumeUniversal); string Time = String.Format("{0 : HH : mm : ss}", dateTime); response.Close(); return Time; } public string InternetDay() { var myHttpWebRequest = (HttpWebRequest)WebRequest.Create("http://www.microsoft.com"); var response = myHttpWebRequest.GetResponse(); string todaysDates = response.Headers["date"]; DateTime dateTime = DateTime.ParseExact(todaysDates, "ddd, dd MMM yyyy HH:mm:ss 'GMT'", CultureInfo.InvariantCulture.DateTimeFormat, DateTimeStyles.AssumeUniversal); string Day = Convert.ToString(dateTime.DayOfWeek); response.Close(); return Day; } #endregion } } |
- OnlieLocationInfo.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 |
using Newtonsoft.Json; namespace Geographic_Location_and_Internet_Supplier { class OnlieLocationInfo { public string status { get; set; } public string country { get; set; } public string countryCode { get; set; } public string region { get; set; } public string regionName { get; set; } public string city { get; set; } public string zip { get; set; } public string lat { get; set; } public string lon { get; set; } public string timezone { get; set; } public string isp { get; set; } public string org { get; set; } public string query { get; set; } [JsonProperty("as")] public string AS { get; set; } } } |
Screenshots:
NuGet Packages:
- Newtonsoft.Json
Similar Apps:
Unknown
Contact: