You are here:

ActiveXperts.com > ActiveSocket > Objects > IPtoCountry

ActiveSocket Toolkit Add network capabilities to any Windows or .NET application

Quicklinks


ActiveSocket - IPtoCountry Object

Today there are millions of internet users around the world. There are also numerous products and services available on the internet.

There are some key benefits of determines the country by IP address:

  • Marketing - adapt your business, web content or language according to the geographic location of the visitor;
  • Restrict access - restrict software or sites for users, based on the geographic location of the visitor;
  • Web server log analysis - restrict software or sites for users, based on the geographic location of the visitor;
  • Reduce credit card fraud.

The IPtoCountry object translates IP address to countries.

The IPtoCountry object is part of the ActiveSocket component. Overview of all ActiveSocket objects:

IPtoCountry Sample code

VBScript sample: convert a hostname to the associated country

Set objIPC  = CreateObject( "ActiveXperts.IPtoCountry" )   ' Create a new IPtoCountry instance
objIPC.Host = "www.activexperts.com"                       ' Host name (or IP address) that you want to resolve
objIPC.Query()                                             ' Host name (or IP address) that you want to resolve
WScript.Echo "Query, result: " & objIPC.LastError          ' Result of Query; 0 means: success
If objIPC.LastError = 0 Then
	WScript.Echo "Host " & strHost & " is located in " & objIPC.CountryName
End If

On ftp.activexperts-labs.com, you can find a lot of ActiveSocket samples. These samples are also part of the ActiveSocket installation.

Visit ftp.activexperts-labs.com