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_ContinentIDToContinentCode

This function retrieves the continent code by the continent ID.

Syntax

Microsoft Visual C++
DWORD __stdcall SWAPI_ContinentIDToContinentCode(
  UCHAR ContinentID,
  PVOID DstBuff,
  DWORD DstSize
);
Borland Delphi
function SWAPI_ContinentIDToContinentCode(
  const ContinentID: Byte;
  const DstBuff: Pointer;
  const DstSize: DWORD
): DWORD; stdcall;
Microsoft Visual Basic
Declare Function SWAPI_ContinentIDToContinentCode Lib "swapimap.dll" (
  ByVal ContinentID As Byte,
  ByVal DstBuff As String,
  ByVal DstSize As Long
) As Long

Parameters

ContinentID
[in] Continent ID retrieved by using the functions for obtaining the continent ID.
DstBuff
[out] Pointer to the buffer to receive the string containing the continent code.
DstSize
[in] Size of the buffer specified by the DstBuff parameter in bytes. This value should be set to 2 or greater.

Return Value

If the function succeeds, the return value is non-zero. If the return value is greater than DstSize, the value returned is the size of DstBuff required to hold the code string. Otherwise, the value returned is the length of the string copied to DstBuff.

If the function fails, the return value is zero.

Remarks

The terminating null character is not copied to the buffer specified by DstBuff. Use the function return value to determine the length of the string copied to DstBuff.

Sample Code

Microsoft Visual C++
DWORD IPAddress;
WORD CountryID;
UCHAR ContinentID;
CString ContinentCode;
LPSTR pStr;

IPAddress = 69956104;
CountryID = SWAPI_IPAddressToCountryID(IPAddress, 0);
if (CountryID == 0) {
  ContinentCode = "Unknown";
} else {
  ContinentID = SWAPI_CountryIDToContinentID(CountryID);
  pStr = ContinentCode.GetBuffer(2);
  pStr[SWAPI_ContinentIDToContinentCode(ContinentID, pStr, 2)] = 0;
  ContinentCode.ReleaseBuffer();
}
AfxMessageBox(ContinentCode);
Borland Delphi
var
  IPAddress: DWORD;
  CountryID: WORD;
  ContinentID: Byte;
  ContinentCode: string;
begin
  IPAddress := 69956104;
  CountryID := SWAPI_IPAddressToCountryID(IPAddress, 0);
  if (CountryID = 0) then
    ContinentCode := 'Unknown'
  else
  begin
    ContinentID := SWAPI_CountryIDToContinentID(CountryID);
    SetLength(ContinentCode, 2);
    SetLength(ContinentCode, SWAPI_ContinentIDToContinentCode(
      ContinentID, Pointer(ContinentCode), 2));
  end;
  ShowMessage(ContinentCode);
end;
Microsoft Visual Basic
Dim IPAddress As Long
Dim CountryID As Integer
Dim ContinentID As Byte
Dim ContinentCode As String
Dim res As String * 2

IPAddress = 69956104
CountryID = SWAPI_IPAddressToCountryID(IPAddress, 0)
If CountryID = 0 Then
  ContinentCode = "Unknown"
Else
  ContinentID = SWAPI_CountryIDToContinentID(CountryID)
  i = SWAPI_ContinentIDToContinentCode(ContinentID, res, 2)
  ContinentCode = Mid$(res, 1, i)
End If
MsgBox(ContinentCode)

Defined In

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

See Also

Functions for Obtaining the Continent ID
SWAPI_CountryIDToContinentCode


Copyright © 2006-2008, TamoSoft