62,041
社区成员
发帖
与我相关
我的任务
分享
#region 获取国家/区域字符串
private string GetFlagStr(long offSet)
{
int flag = 0;
byte[] buff = new Byte[3];
while (1 == 1)
{
//objfs.Seek(offSet,SeekOrigin.Begin);
objfs.Position = offSet;
flag = objfs.ReadByte();
if (flag == 1 || flag == 2)
{
objfs.Read(buff, 0, 3);
if (flag == 2)
{
this.countryFlag = 2;
this.endIpOff = offSet - 4;
}
offSet = Convert.ToInt64(buff[0].ToString()) + Convert.ToInt64(buff[1].ToString()) * 256 + Convert.ToInt64(buff[2].ToString()) * 256 * 256;
}
else
{
break;
}
}
if (offSet < 12)
return " ";
objfs.Position = offSet;
return GetStr();
}
#endregion
#region GetStr
private string GetStr()
{
byte lowC = 0;
byte upC = 0;
string str = "";
byte[] buff = new byte[2];
while (1 == 1)
{
lowC = (Byte)objfs.ReadByte();
if (lowC == 0)
break;
if (lowC > 127)
{
upC = (byte)objfs.ReadByte();
buff[0] = lowC;
buff[1] = upC;
System.Text.Encoding enc = System.Text.Encoding.GetEncoding("GB2312");
str += enc.GetString(buff);
}
else
{
str += (char)lowC;
}
}
return str;
}
#endregion
#region 获取IP地址
public string IPLocation()
{
this.QQwry();
return this.country + this.local;
}
public string IPLocation(string dataPath, string ip)
{
this.dataPath = dataPath;
this.ip = ip;
this.QQwry();
return this.country + this.local;
}
//调用方法
protected void GetIP()
{
pweb.info.pweb_info pwebinfo = new pweb.info.pweb_info();
string ipaddress = pwebinfo.ClietIp.ToString();
IPScaner objScan = new IPScaner();
string ip = ipaddress;
objScan.DataPath =ConfigurationManager.AppSettings["UpLoadFile"] + "/" + "QQWry.Dat";
objScan.IP = ip;
string addre = objScan.IPLocation();
string err = objScan.ErrMsg;
this.Label1.Text = "您本机IP地址:" + addre;
}