嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):78630559
本次赞助数额为: 2 元微信扫码支付:2 元
请留下您的邮箱,我们将在2小时内将文件发到您的邮箱
可以获取 省市信息 ,经度,维度,
使用方法: 点击 查询就可以了.
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Net;
using System.Net.NetworkInformation;
using System.Net.Sockets;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
//www.srcfans.com
namespace IP_Location
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
timer1.Enabled = true;
}
private void timer1_Tick(object sender, EventArgs e)
{
timer1.Interval = 1000;
TimeTextBox.Text = DateTime.Now.ToString();
}
private void IPTextBox_TextChanged(object sender, EventArgs e)
{
}
private void ProvinceTextBox_TextChanged(object sender, EventArgs e)
{
}
private void CityTextBox_TextChanged(object sender, EventArgs e)
{
}
private void label5_Click(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
Application.Exit();
}
private void searchbutton_Click(object sender, EventArgs e)
{
//省市、经纬度查询
WebClient client = new WebClient();//用System.Net.WebClient类可以从特定的URI请求文件。System.Net.WebClient是一个非常高级的类,它用简单的命令就能实现一些基本操作
string url = @"http://api.map.baidu.com/location/ip?ak=CRGeKEM99NlIQM3uO6K6vG9H66sHrzPS&coor=bd09ll";
string jsonData = client.DownloadString(url);
IPDataInfo ipInfo = JsonConvert.DeserializeObject<IPDataInfo>(jsonData);
ProvinceTextBox.Text = ipInfo.content.address_detail.province;
CityTextBox.Text = ipInfo.content.address_detail.city;
TBlongitude.Text = ipInfo.content.point.y;
TBlatitude.Text = ipInfo.content.point.x;
//IP地址查询
NetworkInterface[] nics = NetworkInterface.GetAllNetworkInterfaces();
foreach (NetworkInterface adapter in nics)
{
if (adapter.NetworkInterfaceType == NetworkInterfaceType.Ethernet)
{
IPInterfaceProperties ip = adapter.GetIPProperties();
UnicastIPAddressInformationCollection ipCollection = ip.UnicastAddresses;
foreach (UnicastIPAddressInformation ipadd in ipCollection)
{
if (ipadd.Address.AddressFamily == AddressFamily.InterNetwork)
{
string Ipdata = ipadd.Address.ToString();
IPTextBox.Text = Ipdata;
}
}
}
}
}
private void Copybutton_Click(object sender, EventArgs e)
{
WebClient client = new WebClient();//用System.Net.WebClient类可以从特定的URI请求文件。System.Net.WebClient是一个非常高级的类,它用简单的命令就能实现一些基本操作
string url = @"http://api.map.baidu.com/location/ip?ak=CRGeKEM99NlIQM3uO6K6vG9H66sHrzPS&coor=bd09ll";
string jsonData = client.DownloadString(url);
IPDataInfo ipInfo = JsonConvert.DeserializeObject<IPDataInfo>(jsonData);
//合并字符串
string s1 = ipInfo.content.point.y;
string s2 = ipInfo.content.point.x;
this.CopytextBox.Text = s1 "," s2;
//复制经纬度坐标
string str = CopytextBox.Text;
if (!string.IsNullOrEmpty(str))
{
Clipboard.SetDataObject(str);
}
}
private void CopytextBox_TextChanged(object sender, EventArgs e)
{
}
private void Locationbutton_Click(object sender, EventArgs e)
{
System.Diagnostics.Process.Start("http://www.gpsspg.com/maps.htm");
}
}
}