QQ好像有显示IP功能,查别人的IP地址,是想知道IP地址来自那里吗?如果是这个,网上有1个小工具可以查
usingSystem;usingSystem.Data;usingSystem.Configuration;usingSystem.Web;usingSystem.Web.Security;usingSystem.Web.UI;usingSystem.Web.UI.WebControls;usingSystem.Web.UI.WebControls.WebParts;usingSystem.Web.UI.HtmlControls;//引入的命名空间usingSystem.IO;
//////判断IP归属地类///lassIpSearch{privatestaticobjectlockHelper=newobject();
staticIpSearch(){filePath=HttpContext.Current.Server.MapPath("~/ipdata.config");pcz.SetDbFilePath(filePath);}
//////返回IP查找结果//////要查找的IP地址///publicstaticstringGetAddressWithIP(stringIPValue){lock(lockHelper){stringresult=pcz.GetAddressWithIP(IPValue.Trim());
if(fileIsExsit){if(result.IndexOf("IANA")>=0){return"";}else{returnresult;}}else{returnnull;}}}
//////辅助类,用于保存IP索引信息//////lassCZ_INDEX_INFO{publicUInt32IpSet;publicUInt32IpEnd;publicUInt32Offset;
publicCZ_INDEX_INFO(){IpSet=0;IpEnd=0;Offset=0;}}
//读取纯真IP数据库类lassPHCZIP{protectedboolbFilePathInitialized;protectedstringFilePath;protectedFileStreamFileStrm;protectedUInt32Index_Set;protectedUInt32Index_End;protectedUInt32Index_Count;protectedUInt32Search_Index_Set;protectedUInt32Search_Index_End;protectedCZ_INDEX_INFOSearch_Set;protectedCZ_INDEX_INFOSearch_Mid;protectedCZ_INDEX_INFOSearch_End;
publicPHCZIP(stringdbFilePath){bFilePathInitialized=false;SetDbFilePath(dbFilePath);}
//使用二分法查找索引区,初始化查找区间publicvoidInitialize(){Search_Index_Set=0;Search_Index_End=Index_Count-1;}
//关闭文件publicvoidDispose(){if(bFilePathInitialized){bFilePathInitialized=false;FileStrm.Close();//FileStrm.Dispose();}
publicboolSetDbFilePath(stringdbFilePath){if(dbFilePath==""){returnfalse;}
try{FileStrm=newFileStream(dbFilePath,FileMode.Open,ess.Read,FileShare.Read);}catch{returnfalse;}//检查文件长度if(FileStrm.Length=Search_Set.IpSet