Home
Contents

CountryWhois SDK

 
CountryWhois SDK
About CountryWhois SDK
Using CountryWhois SDK
Functions for Obtaining the Country ID
SWAPI_IPAddressToCountryID
SWAPI_IPStringToCountryID
SWAPI_CountryCodeToCountryID
SWAPI_GetMinCountryID
SWAPI_GetMaxCountryID
Functions for Obtaining Information About a Country
SWAPI_CountryIDToCountryCode
SWAPI_CountryIDToCountryName
SWAPI_CountryIDToContinentCode
SWAPI_CountryIDToContinentName
SWAPI_GetCountryCodeStatus
SWAPI_GetCountryCodeIndex
SWAPI_EnumCountryIPRanges
EnumIPRangesProc
Functions for Obtaining the Continent ID
SWAPI_CountryIDToContinentID
SWAPI_ContinentCodeToContinentID
SWAPI_GetMinContinentID
SWAPI_GetMaxContinentID
Functions for Obtaining Information About a Continent
SWAPI_ContinentIDToContinentCode
SWAPI_ContinentIDToContinentName
SWAPI_EnumContinentIPRanges
SWAPI_EnumContinentCountries
EnumCountriesProc
Country Flags
SWAPI_GetCountryFlagBitmap
SWAPI_GetCountryFlagsImageList
SWAPI_GetCountryFlagsImageListEx
SWAPI_GetCountryFlagsImageListIndex
SWAPI_DestroyCountryFlagsImageList

SWAPI_GetCountryCodeIndex

Use this function to obtain the country ordinal number in the officially assigned ISO 3166-1 list for the given country ID.

Syntax

Microsoft Visual C++
long __stdcall SWAPI_GetCountryCodeIndex(
  WORD CountryID
);
Borland Delphi
function SWAPI_GetCountryCodeIndex(
  const CountryID: WORD
): Longint; stdcall;
Microsoft Visual Basic
Declare Function SWAPI_GetCountryCodeIndex Lib "swapimap.dll" (
  ByVal CountryID As Integer
) As Integer

Parameters

CountryID
[in] Country ID retrieved by using the functions for obtaining the country ID.

Return Value

If the country code corresponding to the given country ID is on the officially assigned ISO 3166-1 list, then the return value is a zero-based ordinal number of the country code on the list. Otherwise, the return value is -1. For example, in the table below the following codes are on the official list: AD, AE, AF, AG, AI, AL, AM, AN, AO.

Code Status ID Index
AA CODE_STATUS_ISO_USER_ASSIGNED 0x0065 -1
AB CODE_STATUS_ISO_UNASSIGNED 0x0066 -1
AC CODE_STATUS_ISO_EXCEPTIONALLY_RESERVED 0x0067 -1
AD CODE_STATUS_ISO_OFFICIALLY_ASSIGNED 0x0068 0
AE CODE_STATUS_ISO_OFFICIALLY_ASSIGNED 0x0069 1
AF CODE_STATUS_ISO_OFFICIALLY_ASSIGNED 0x006A 2
AG CODE_STATUS_ISO_OFFICIALLY_ASSIGNED 0x006B 3
AH CODE_STATUS_ISO_UNASSIGNED 0x006C -1
AI CODE_STATUS_ISO_OFFICIALLY_ASSIGNED 0x006D 4
AJ CODE_STATUS_ISO_UNASSIGNED 0x006E -1
AK CODE_STATUS_ISO_UNASSIGNED 0x006F -1
AL CODE_STATUS_ISO_OFFICIALLY_ASSIGNED 0x0070 5
AM CODE_STATUS_ISO_OFFICIALLY_ASSIGNED 0x0071 6
AN CODE_STATUS_ISO_OFFICIALLY_ASSIGNED 0x0072 7
AO CODE_STATUS_ISO_OFFICIALLY_ASSIGNED 0x0073 8
AP CODE_STATUS_SWAPI_USED 0x0074 -1

Remarks

As the ISO 3166 code list may change in the future, the index of some or all codes may also change. To store data internally in your application, use the country ID instead.

Sample Code

Microsoft Visual C++
int i, minCC, maxCC, cc;
CString CountryIndex;

minCC = GetMinCountryID();
maxCC = GetMaxCountryID();
for (i = minCC; i < maxCC; i++ ) {
  cc = SWAPI_GetCountryCodeIndex(i);
  CountryIndex.Format("%d", cc);
  lstCodes.InsertItem(i, CountryIndex);
}
Borland Delphi
var
  CountryID: WORD;
begin
  for CountryID := SWAPI_GetMinCountryID to SWAPI_GetMaxCountryID do
    Memo1.Lines.Add(IntToStr(SWAPI_GetCountryCodeIndex(CountryID)));
end;
Microsoft Visual Basic
For CountryID = SWAPI_GetMinCountryID() to SWAPI_GetMaxCountryID()
  i = (SWAPI_GetCountryCodeIndex(CountryID)
  CountryCode = Str$(i)
  Memo1.Lines.Add(CountryCode)
Next

Defined In

Microsoft Visual C++
SWAPIMap.h, SWAPIMap.cpp
Borland Delphi
SWAPIMap.pas
Microsoft Visual Basic
SWAPIMap.bas

See Also

Functions for Obtaining the Country ID
SWAPI_GetCountryCodeStatus
ISO 3166-1 Decoding Table


Copyright © 2006-2008, TamoSoft