CString NL_QQwry::IP2Add(CString szIP) { if(szIP=="") return "请输入IP地址"; return GetCountryLocal(GetIndex(szIP)); }
/********************************************************************* * SaveToFile() * * 保存所有信息到文件 * * 说明: *********************************************************************/ void SEU_QQwry::SaveToFile(CString Name) { FILE *out; CString str1,str2; out=fopen(Name+".txt","wb"); int ioff; m_buf.Format("Total %d\r\n",GetRecordCount());//得到总记录 fwrite(m_buf,1,m_buf.GetLength(),out);//输出 for(m_i=0;m_i<GetRecordCount();m_i++) { ioff=GetStartIPInfo(m_i);//得到开始的IP信息 str1.Format("%d.%d.%d.%d",m_ipoff.b3,m_ipoff.b2,m_ipoff.b1,m_ipoff.b0);//开始IP str2.Format("%d.%d.%d.%d",m_ei.b3,m_ei.b2,m_ei.b1,m_ei.b0);//结束IP m_buf.Format("%-15s %-15s %s\r\n", str1,str2,GetCountryLocal(m_ei.bMode,ioff+4)); fwrite(m_buf,1,m_buf.GetLength(),out); } fclose(out); }
void NL_QQwry::SaveToFile() { // //在内存中操作可能速度更快一些 //利用缓存,就这样了,提高速度就自己解决了 // FILE *out; CString str1,str2; out=fopen("out.txt","wb"); int ioff; m_buf.Format("Total %d\r\n",GetRecordCount()); fwrite(m_buf,1,m_buf.GetLength(),out); for(m_i=0;m_i<GetRecordCount();m_i++) { ioff=GetStartIPInfo(m_i); str1.Format("%d.%d.%d.%d",m_ipoff.b3,m_ipoff.b2,m_ipoff.b1,m_ipoff.b0); str2.Format("%d.%d.%d.%d",m_ei.b3,m_ei.b2,m_ei.b1,m_ei.b0); m_buf.Format("%-15s %-15s %s\r\n", str1,str2,GetCountryLocal(m_ei.bMode,ioff+4)); fwrite(m_buf,1,m_buf.GetLength(),out); } fclose(out); }
CString NL_QQwry::Test() { /* CString str,str1,str2; int ioff = 0; m_buf.Format("Total %d\r\n",GetRecordCount()); for(m_i=0;m_i<GetRecordCount();m_i++) { ioff=GetStartIPInfo(m_i); str1.Format("%d.%d.%d.%d",m_ipoff.b3,m_ipoff.b2,m_ipoff.b1,m_ipoff.b0); str2.Format("%d.%d.%d.%d",m_ei.b3,m_ei.b2,m_ei.b1,m_ei.b0); str.Format("%-15s %-15s %s\r\n", str1,str2,GetCountryLocal(m_ei.bMode,ioff+4)); m_buf+=str; } return m_buf;*/ int ioff; CString str; m_buf.Format("Total %d\r\n",GetRecordCount()); for(m_i=0;m_i<1000;m_i++) { ioff=GetStartIPInfo(m_i); if(m_ei.bMode>=1 && m_ei.bMode<=8) { str.Format("%6d %03d.%03d.%03d.%03d " "%03d.%03d.%03d.%03d %d %06X ", m_i, m_ipoff.b3, m_ipoff.b2, m_ipoff.b1, m_ipoff.b0, m_ei.b3, m_ei.b2, m_ei.b1, m_ei.b0, m_ei.bMode, ioff); m_buf+=str; str=GetCountryLocal(m_ei.bMode,ioff+4); str+="\r\n"; } else { str.Format("%6d %03d.%03d.%03d.%03d " "%03d.%03d.%03d.%03d (%d) %06X ", m_i, m_ipoff.b3, m_ipoff.b2, m_ipoff.b1, m_ipoff.b0, m_ei.b3, m_ei.b2, m_ei.b1, m_ei.b0, m_ei.bMode, ioff); m_buf+=str; str.Format("%02X-%02X-%02X-%02X-%02X " "%02X-%02X-%02X-%02X-%02X " "%02X-%02X-%02X-%02X-%02X " "%02X-%02X-%02X-%02X-%02X\r\n", m_ei.buf[0], m_ei.buf[1], m_ei.buf[2], m_ei.buf[3], m_ei.buf[4], m_ei.buf[5], m_ei.buf[6], m_ei.buf[7], m_ei.buf[8], m_ei.buf[9], m_ei.buf[10], m_ei.buf[11], m_ei.buf[12], m_ei.buf[13], m_ei.buf[14], m_ei.buf[15], m_ei.buf[16], m_ei.buf[17], m_ei.buf[18], m_ei.buf[19]); } m_buf+=str; } return m_buf; }
CString NL_QQwry::GetCountryLocal(int index) { if(index<0 || index>GetRecordCount()-1) return "没有查到"; return GetCountryLocal(m_ei.bMode,GetStartIPInfo(index)+4); }