This distribution provides a Delphi reader for the MaxMind DB file format.
Delphi 10.2 Tokyo or newer.
uses uMMDBReader;
var
LMMDBReader: TMMDBReader;
LIPAddress: TMMDBIPAddress;
LIPInfo: TMMDBIPCountryInfo;
prefixLength: Integer;
begin
LIPInfo := TMMDBIPCountryInfo.Create;
LMMDBReader := TMMDBReader.Create('C:\GeoIP2\GeoLite2-Country.mmdb');
try
LIPAddress := TMMDBIPAddress.Parse('8.8.8.8');
if LMMDBReader.Find<TMMDBIPCountryInfo>(LIPAddress, prefixLength, LIPInfo) then
ShowMessage(Format('country_iso_code: "%s", country_geoname_id: %s', [LIPInfo.Country.ISOCode, IntToStr(LIPInfo.country.GeonameId)]))
else
ShowMessage('Not found');
finally
LMMDBReader.Free;
LIPInfo.Free;
end;
end;
BSD 2-Clause License.
BigNumbers by Rudy Velthuis (https://github.com/rvelthuis/DelphiBigNumbers).
MMDB Reader uses modified IPTypesX module from Albert de Weerd (included in source).
- Sign up for DigitalOcean and get $200 in credit over 60 days (referral link)