cs_bloops
Messages postés5Date d'inscriptionmercredi 18 juin 2003StatutMembreDernière intervention27 octobre 2003
-
25 oct. 2003 à 14:04
gasy72
Messages postés23Date d'inscriptionjeudi 2 mars 2006StatutMembreDernière intervention11 août 2006
-
4 mars 2006 à 02:23
salut,
j'aimerais savoir si qqn aurait une idée pour obtenir les ip de chaque interface sur un pc un truc a la ifconfig sous nux par exemple..
cs_bloops
Messages postés5Date d'inscriptionmercredi 18 juin 2003StatutMembreDernière intervention27 octobre 2003 25 oct. 2003 à 21:51
c'est déjà plus ou moins la fonction que j'ai, le probleme est que si tu as plusieurs interface, exemple:
un mec qui a son modem 56k et donc une ip 1.2.3.4 et une carte réseau avec une ip 192.168.1.2, ce genre de fonction te renvera seulement l'ip de la carte réseau, moi ce que je voudrais faire c'est stocker les adresses de chaque interface dans différents char * ou quelque chose du genre...
mirlaine
Messages postés32Date d'inscriptionsamedi 9 août 2003StatutMembreDernière intervention24 août 2005 26 oct. 2003 à 03:52
jai les source de ipconfig :)
-----------------------code-----------------------------------
/******************************************************************************\
* This is a part of the Microsoft Source Code Samples.
* Copyright 1996 - 1998 Microsoft Corporation.
* All rights reserved.
* This source code is only intended as a supplement to
* Microsoft Development Tools and/or WinHelp documentation.
* See these sources for detailed information regarding the
* Microsoft samples programs.
\******************************************************************************/
/*
Module Name:
Ipconfig.cpp
Abstract:
This module illustrates how to programmatically retrieve IP configuration
information similar to the IPCONFIG.EXE utility. It demonstrates how to use
the IP Helper APIs GetNetworkParams() and GetAdaptersInfo().
To execute this application, simply build the application using the Microsoft Visual C++
nmake.exe program generation utility to make an executable ipconfig.exe. After the
build is complete, simply execute the resulting ipconfig.exe program.
//
// Get the main IP configuration information for this machine using a FIXED_INFO structure
//
if ((Err = GetNetworkParams(NULL, &FixedInfoSize)) != 0)
{
if (Err != ERROR_BUFFER_OVERFLOW)
{
printf("GetNetworkParams sizing failed with error %d\n", Err);
return;
}
}
//
// Enumerate all of the adapter specific information using the IP_ADAPTER_INFO structure.
// Note: IP_ADAPTER_INFO contains a linked list of adapter entries.
//
AdapterInfoSize = 0;
if ((Err = GetAdaptersInfo(NULL, &AdapterInfoSize)) != 0)
{
if (Err != ERROR_BUFFER_OVERFLOW)
{
printf("GetAdaptersInfo sizing failed with error %d\n", Err);
return;
}
}
// Allocate memory from sizing information if ((pAdapterInfo (PIP_ADAPTER_INFO) GlobalAlloc(GPTR, AdapterInfoSize)) NULL)
{
printf("Memory allocation error\n");
return;
}
// Get actual adapter information
if ((Err = GetAdaptersInfo(pAdapterInfo, &AdapterInfoSize)) != 0)
{
printf("GetAdaptersInfo failed with error %d\n", Err);
return;
}
pAdapt = pAdapterInfo;
while (pAdapt)
{
switch (pAdapt->Type)
{
case MIB_IF_TYPE_ETHERNET:
printf("\nEthernet adapter ");
break;
case MIB_IF_TYPE_TOKENRING:
printf("\nToken Ring adapter ");
break;
case MIB_IF_TYPE_FDDI:
printf("\nFDDI adapter ");
break;
case MIB_IF_TYPE_PPP:
printf("\nPPP adapter ");
break;
case MIB_IF_TYPE_LOOPBACK:
printf("\nLoopback adapter ");
break;
case MIB_IF_TYPE_SLIP:
printf("\nSlip adapter ");
break;
case MIB_IF_TYPE_OTHER:
default:
printf("\nOther adapter ");
}
printf("%s:\n\n", pAdapt->AdapterName);
vdox
Messages postés5Date d'inscriptionvendredi 10 octobre 2003StatutMembreDernière intervention17 juin 2013 31 oct. 2003 à 13:42
Salut
Vous sauriez pas comment faire dans un programme pour récupérer les différentes IP qui sont sur l' ordi ...
J' utilise Cpp Builder 5 et quand j' essaye avec les sources présentes sur cppfrance je n' y arrive pas, je suis sur qu' il y a un objet dans builder que gère ça tout à fait correctement mais je ne trouve pas ...
svp une petite aide ...