| |
 |
SWAPI_EnumContinentIPRanges
This function enumerates the IP address ranges of the given continent by passing the information on the range borders one by one to an application-defined callback function. The function doesn't return until all the IP ranges of the given continent are enumerated or the callback function returns FALSE.
Syntax
| Microsoft Visual C++ |
BOOL __stdcall SWAPI_EnumContinentIPRanges( UCHAR ContinentID, WORD CodeStatus, EnumIPRangesProc EnumProc, DWORD IPFlags, DWORD UserData ); |
|
| Borland Delphi |
function SWAPI_EnumContinentIPRanges( const ContinentID: Byte; const CodeStatus: WORD; const EnumProc: TEnumIPRangesProc; const IPFlags: DWORD; const UserData: DWORD ): BOOL; stdcall; |
|
| Microsoft Visual Basic |
Declare Function SWAPI_EnumContinentIPRanges Lib "swapimap.dll" ( ByVal ContinentID As Byte, ByVal CodeStatus As Integer, ByVal EnumProc As Long, ByVal IPFlags As Long, ByRef UserData As Any ) As Boolean |
|
Parameters
| ContinentID |
[in] Continent ID for which the IP ranges are being enumerated. Must be within the range returned by SWAPI_GetMinContinentID and SWAPI_GetMaxContinentID, otherwise the function will fail. |
| CodeStatus |
[in] Ranges of only those countries will be enumerated for which the ISO 3166-1 code status matches the status in this parameter. A single or combination of several statuses returned by SWAPI_GetCountryCodeStatus are allowed. The default value is CODE_STATUS_ISO_OFFICIALLY_ASSIGNED. |
| EnumProc |
[in] Pointer to an application-defined callback function. For more information, see EnumIPRangesProc. |
| IPFlags |
[in] Reserved parameter, must be set to zero. |
| UserData |
| [in] Specifies an application-defined value to be passed to the callback function. |
Return Value
If the function succeeds, the return value is nonzero.
If the function fails, the return value is zero.
Remarks
The ranges are enumerated in ascending order.
Sample Code
| Microsoft Visual C++ |
CString IPToStr(DWORD IP) { CString str;
str.Format("%d.%d.%d.%d", IP & 0xFF, (IP >> 8) & 0xFF, (IP >> 16) & 0xFF, (IP >> 24) & 0xFF); return str; }
BOOL __stdcall FillIPRangesProc(WORD CountryID, DWORD RangeBegin, DWORD RangeEnd, DWORD UserData) { CListBox *lb = (CListBox *)UserData; lb->AddString(IPToStr(RangeBegin) + " - " + IPToStr(RangeEnd)); return TRUE; }
void CMainDlg::ListRanges(UCHAR ContinentID) { m_cRangeList.ResetContent(); SWAPI_EnumContinentIPRanges(ContinentID, CODE_STATUS_ISO_OFFICIALLY_ASSIGNED, &FillIPRangesProc, 0, (DWORD)&m_cRangeList); m_cRangeList.UpdateWindow(); } |
|
| Borland Delphi |
function IPToStr(const IP: DWORD): string; begin Result := Format('%d.%d.%d.%d', [(IP shl 24) shr 24, (IP shl 16) shr 24, (IP shl 8) shr 24, IP shr 24]); end;
function EnumIPRangesProc(const CountryID: WORD; const RangeBegin, RangeEnd, UserData: DWORD): BOOL; stdcall; begin Result := True; TMemo(UserData).Lines.Add(IPToStr(RangeBegin) + '-' + IPToStr(RangeEnd)); end;
procedure TMainForm.ListRanges(const ContinentID: Byte); begin Memo1.Lines.BeginUpdate; try Memo1.Clear; SWAPI_EnumContinentIPRanges(ContinentID, CODE_STATUS_ISO_OFFICIALLY_ASSIGNED, EnumIPRangesProc, 0, DWORD(Memo1)); finally Memo1.Lines.EndUpdate; end; end; |
|
| Microsoft Visual Basic |
' Module Function IPToStr(ByVal IP As Long) As String Dim L As myLong Dim B As myBytes L.Val = IP LSet B = L IPToStr = Trim(Str$(B.B1)) + "." + Trim(Str$(B.B2)) + "." + Trim(Str$(B.B3)) + "." + Trim(Str$(B.B4)) End Function
Public Function EnumIPRangesProc(ByVal CountryID As Integer, ByVal RangeBegin As Long, ByVal RangeEnd As Long, ByRef lb As ListBox) As Boolean Dim sItem As String sItem = IPToStr(RangeBegin) + "-" + IPToStr(RangeEnd) lb.AddItem sItem EnumIPRangesProc = True End Function
' Form Private Sub ListRanges(ContinentID As Byte) List1.Clear SWAPI_EnumContinentIPRanges ContinentID, CODE_STATUS_ISO_OFFICIALLY_ASSIGNED, AddressOf EnumIPRangesProc, 0, List1 End Sub |
|
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 EnumCountryIPRanges EnumIPRangesProc SWAPI_GetMinContinentID SWAPI_GetMaxContinentID SWAPI_GetCountryCodeStatus
Copyright © 2006-2008, TamoSoft
|