; **************************************************************************** ; * By PBFrance : http://www.pbfrance.com/?url=source&cmd=viewer&val=8 ; **************************************************************************** ; +======================================================+ ; | RECHERCHE DES ADRESSES IP DU POSTE EN LOCAL. | ; +------------------------------------------------------+ ; | COPYRIGHT(C)2007-2012, ALL RIGHT RESERVED KOAKDESIGN | ; +--------------+---------------------------------------+ ; | Program type | PUREBASIC 4.60 | ; +--------------+---------------------------------------+ ; | VER & REV | 0.0.1 | ; +--------------+---------------------------------------+ ; | Program name | main.pb | ; +======================================================+ ; +======================================================+ ; | Original Version: 0.0.1 | ; +--------------+---------------------------------------+ ; | Created by | GallyHomeCorp | ; | Graphix by | | ; +--------------+---------------------------------------+ ; | Comments: | | ; +--------------+ | ; | | ; | | ; | | ; +======================================================+ ; +======================================================+ ; | Système d'Exploitation | ; +--------------+---------------------------------------+ ; | Window | Oui | ; | Linux | Oui | ; | MacOS | Oui | ; +======================================================+ ; **************************************************************************** ; **************************************************************************** ; **************************************************************************** ; **************************************************************************** ; +--------------------------------------------------------------------------+ ; | | ; +--------------------------------------------------------------------------+ ; ;- METHODE 1 AVEC LES APIS WINDOWS. ; Structure DBYTE unused1.b unused2.b EndStructure Structure MIB_IPADDRROW dwAddr.l dwIndex.l dwMask.l dwBCastAddr.l dwReasmSize.l unused1.DBYTE unused2.DBYTE EndStructure Structure MIB_IPADDRTABLE dwNumEntries.l table.MIB_IPADDRROW[400] EndStructure Define i.l Define result.l Define number.l Define ltemps.l = 400 Define IPADDRTABLE.MIB_IPADDRTABLE Define openlibrary.l = OpenLibrary(#PB_Any, "iphlpapi.dll") If openlibrary <> 0 And IsLibrary(openlibrary) result = CallFunction(openlibrary, "GetNumberOfInterfaces", @number) If result = 0 For i=0 To number result = CallFunction(openlibrary, "GetIpAddrTable", @IPADDRTABLE, @ltemps, #True) If IPADDRTABLE\table[i]\dwAddr <> 0 Debug "Méthode 1 : " + IPString(IPADDRTABLE\table[i]\dwAddr) EndIf Next i EndIf CloseLibrary(openlibrary) EndIf ; **************************************************************************** ; **************************************************************************** ; **************************************************************************** ; **************************************************************************** ; +--------------------------------------------------------------------------+ ; | | ; +--------------------------------------------------------------------------+ ; ;- METHODE 2 EN CODE 100% PUREBASIC. ; If InitNetwork() Define lresult.l If ExamineIPAddresses() = #True Repeat lresult = NextIPAddress() If lresult <> 0 Debug "Méthode 2 : " + IPString(lresult) EndIf Until lresult = 0 EndIf EndIf