QQWry.Dat 是免费的 IP 库 相对于webservices,在本地用ip库根据ip判断地区是最快的。
.Net代码:
/***********************************************************************
*
* CLR 版本: 4.0.30319.235
* 命名空间: Car.Plugins
* 文 件 名: QQWry
* 创建时间: 2011/11/4 14:58:34
* 版权所有: 王彦杰
* 电子邮件: 0106248486@163.com
* 个人签名: 欲求仙道,先修人道。苍天弃吾,吾宁成魔。
*
************************************************************************/
#region using
using System;
using System.IO;
using System.Text;
using System.Text.RegularExpressions;
#endregion
namespace Car.Plugin
{
///
///
///
public class QQWry
{
public class IpLocation
{
private string _ip;
private string _country;
private string _local;
public string IP
{
get { return _ip; }
set { _ip = value; }
}
public string Country
{
get { return _country; }
set { _country = value; }
}
public string Local
{
get { return _local; }
set { _local = value; }
}
}
public class QQWryLocator
{
private byte[] data;
private Regex regex =
new Regex(@"(((\d{1,2})|(1\d{2})|(2[0-4]\d)|(25[0-5]))\.){3}((\d{1,2})|(1\d{2})|(2[0-4]\d)|(25[0-5]))");
private long firstStartIpOffset;
private long lastStartIpOffset;
private long ipCount;
public long Count
{
get { return ipCount; }
}
public QQWryLocator(string dataPath)
{
using (FileStream fs = new FileStream(dataPath, FileMode.Open, FileAccess.Read, FileShare.Read))
{
data = new byte[fs.Length];
1