怎样通过限制IP来拒绝网络计算机的访问?

解决方案 »

  1.   

    获取客户端机器IP后在客户端进行限制~
    function GetLocalIpAddr: string;
    var
      aWSA: TWSAData;
      iLen: Integer;
      pHst: PChar;
      pHEn: PHostEnt;
    begin
      Result := '';  WSAStartup($0101, aWSA);
      iLen := $FF;
      pHst := StrAlloc(iLen);
      gethostname(pHst, iLen);
      pHEn := gethostbyname(pHst);
      with pHEn^ do
      begin
        Result :=
          IntToStr(Ord(h_addr^[0])) + '.' +
          IntToStr(Ord(h_addr^[1])) + '.' +
          IntToStr(Ord(h_addr^[2])) + '.' +
          IntToStr(Ord(h_addr^[3]));
      end;
      StrDispose(pHst);
      WSACleanup;
    end;