我写了个函数,不用Halcyon控件,程序可小200K左右!
---------------------------------------------------
//读取追捕的IP数据
function GetWryIP2SM(IP:String;FilePath:string):string;
const
stPos = $C2; //第一个地址的位置 194
py = 106; //偏移量 $6A
var
MyFile: TFileStream;
str,ip1,ip2,addMsg,temp:string;
count,j:integer;
begin
try
try
MyFile := TFileStream.Create(FilePath, fmOpenRead);
except
application.MessageBox(pchar('读取IP数据: ' + FilePath + ' 出错!'), '啊D工具包', MB_OK);
Result:='';
exit;
end;
Count := (myfile.Size - 456) div 106;
myfile.Position :=stpos;
for j := 0 to count - 1 do begin
SetLength(str,py);{NumberBytes为接收到的字节数}
myfile.Read(str[1],py);
// myfile.Seek(py-45,soFromCurrent);
ip2:=copy(str,17,15);
if (IP <= ip2) then begin
ip1:=copy(str,1,15);
if (IP >=ip1) then begin
temp:=TrimRight(copy(str,33,14)) + ' ' + TrimRight(copy(str,47,45));
if (length(temp) > length(addMsg)) and (Pos('未知数据',temp) =0) then addMsg:=temp;
// break; Result
end;
end;
end;
if addMsg = '' then addMsg:='未知数据';
finally
MyFile.Free;
Result:=addMsg;
end;
end;