Page 1 of 1

New Function GetNetCardInfo

Posted: Tue May 31, 2011 2:13 am
by Daniel Garcia-Gil
Hello

New function GetNetCardInfo() return a array with information about a particular network adapter on the local computer.
the source code is reserved by fivewin...

example

http://www.sitasoft.net/fivewin/samples/getmac.zip

Code: Select all

#include "fivewin.ch"


//positions inside array returned by GetNetCardInfo()

#define ADP_NAME        1  //An ANSI character string of the name of the adapter. (STRING)
#define ADP_DESCRIPTION 2  //An ANSI character string that contains the description 
                           //of the adapter. (STRING)
#define ADP_ADDRESS     3  //The hardware address for the adapter (STRING)
#define ADP_INDEX       4  //The adapter index. 
                           //The adapter index may change when an adapter is disabled 
                           //and then enabled, or under other circumstances, 
                           //and should not be considered persistent.(NUMERIC)
#define ADP_TYPE        5  //The adapter type. see define list type (bellow) (NUMERIC)
#define ADP_DHCPENABLED 6  //An option value that specifies whether the dynamic host 
                           //configuration protocol (DHCP) is enabled for this adapter.(LOGICAL)
                           
#define ADP_ADDRESSLIST 7  //The list of IPv4 addresses associated with this adapter(STRING)
#define ADP_GATEWAY     8  //The IPv4 address of the gateway for this adapter (STRING)
#define ADP_DHCPSERVER  9  //The IPv4 address of the DHCP server for this adapter represented(STRING)
#define ADP_HAVEWINS    10 //An option value that specifies whether this adapter uses (LOGICAL)
                           //the Windows Internet Name Service (WINS).(LOGICAL)
#define ADP_PRIMARY     11 //the IPv4 address of the primary WINS server
#define ADP_SECUNDARY   12 //The IPv4 address of the secondary WINS server


//Types
#define MIB_IF_TYPE_OTHER      1 //Some other type of network interface.
#define MIB_IF_TYPE_ETHERNET   6 //An Ethernet network interface.
#define MIB_IF_TYPE_TOKENRING  9
#define MIB_IF_TYPE_PPP       23 //A PPP network interface.
#define MIB_IF_TYPE_LOOPBACK  24 //A software loopback network interface.
#define MIB_IF_TYPE_SLIP      28 //An ATM network interface.
#define IF_TYPE_IEEE80211     71 //An IEEE 802.11 wireless network interface.
                                 //Note  This adapter type is returned on Windows Vista and later. 
                                 //On Windows Server 2003 and Windows XP , 
                                 //an IEEE 802.11 wireless network interface returns an adapter 
                                 //type of MIB_IF_TYPE_ETHERNET.




function main()

   xbrowse( GetNetCardInfo() )

return nil
 

Re: New Function GetNetCardInfo

Posted: Tue May 31, 2011 2:50 am
by lailton.webmaster
xBrowse( GETALLMACADDRESS() )

Code: Select all

#pragma BEGINDUMP

#include <Windows.h>
#include <Iphlpapi.h>
#include <Assert.h>
#include "hbapi.h"
#include "hbapiitm.h"


HB_FUNC(GETALLMACADDRESS)
{
IP_ADAPTER_INFO AdapterInfo[16]; // Allocate information for up to 16 NICs
DWORD dwBufLen = sizeof(AdapterInfo); // Save the memory size of buffer
unsigned char ret[ 20 ] ={0};
PHB_ITEM pArray;
PHB_ITEM pItem;

DWORD dwStatus = GetAdaptersInfo( // Call GetAdapterInfo
AdapterInfo, // [out] buffer to receive data
&dwBufLen); // [in] size of receive data buffer
PIP_ADAPTER_INFO pAdapterInfo = AdapterInfo; // Contains pointer to current adapter info
pArray = hb_itemNew( NULL );
hb_arrayNew( pArray, 0 );

assert(dwStatus == ERROR_SUCCESS); // Verify return value is valid, no buffer overflow

do
{
sprintf(ret,"%02X-%02X-%02X-%02X-%02X-%02X", pAdapterInfo->Address[0],
pAdapterInfo->Address[1], pAdapterInfo->Address[2],
pAdapterInfo->Address[3], pAdapterInfo->Address[4],
pAdapterInfo->Address[5]);
pItem = hb_itemPutC( NULL, ( char * ) ret );
hb_arrayAddForward( pArray, pItem );
hb_itemRelease( pItem ) ;


pAdapterInfo = pAdapterInfo->Next; // Progress through linked list
}
while(pAdapterInfo); // Terminate if last adapter

hb_itemReturnForward( pArray );
hb_itemRelease( pArray );

}
#pragma ENDDUMP
How i can use it on LINUX ?

thanks

Re: New Function GetNetCardInfo

Posted: Tue May 31, 2011 3:56 am
by lailton.webmaster
Solved =)

:D

Re: New Function GetNetCardInfo

Posted: Sat Nov 23, 2019 5:36 am
by AIDA
Daniel Garcia-Gil wrote:Hello

New function GetNetCardInfo() return a array with information about a particular network adapter on the local computer.
the source code is reserved by fivewin...

example

http://www.sitasoft.net/fivewin/samples/getmac.zip

Code: Select all

#include "fivewin.ch"


//positions inside array returned by GetNetCardInfo()

#define ADP_NAME        1  //An ANSI character string of the name of the adapter. (STRING)
#define ADP_DESCRIPTION 2  //An ANSI character string that contains the description 
                           //of the adapter. (STRING)
#define ADP_ADDRESS     3  //The hardware address for the adapter (STRING)
#define ADP_INDEX       4  //The adapter index. 
                           //The adapter index may change when an adapter is disabled 
                           //and then enabled, or under other circumstances, 
                           //and should not be considered persistent.(NUMERIC)
#define ADP_TYPE        5  //The adapter type. see define list type (bellow) (NUMERIC)
#define ADP_DHCPENABLED 6  //An option value that specifies whether the dynamic host 
                           //configuration protocol (DHCP) is enabled for this adapter.(LOGICAL)
                           
#define ADP_ADDRESSLIST 7  //The list of IPv4 addresses associated with this adapter(STRING)
#define ADP_GATEWAY     8  //The IPv4 address of the gateway for this adapter (STRING)
#define ADP_DHCPSERVER  9  //The IPv4 address of the DHCP server for this adapter represented(STRING)
#define ADP_HAVEWINS    10 //An option value that specifies whether this adapter uses (LOGICAL)
                           //the Windows Internet Name Service (WINS).(LOGICAL)
#define ADP_PRIMARY     11 //the IPv4 address of the primary WINS server
#define ADP_SECUNDARY   12 //The IPv4 address of the secondary WINS server


//Types
#define MIB_IF_TYPE_OTHER      1 //Some other type of network interface.
#define MIB_IF_TYPE_ETHERNET   6 //An Ethernet network interface.
#define MIB_IF_TYPE_TOKENRING  9
#define MIB_IF_TYPE_PPP       23 //A PPP network interface.
#define MIB_IF_TYPE_LOOPBACK  24 //A software loopback network interface.
#define MIB_IF_TYPE_SLIP      28 //An ATM network interface.
#define IF_TYPE_IEEE80211     71 //An IEEE 802.11 wireless network interface.
                                 //Note  This adapter type is returned on Windows Vista and later. 
                                 //On Windows Server 2003 and Windows XP , 
                                 //an IEEE 802.11 wireless network interface returns an adapter 
                                 //type of MIB_IF_TYPE_ETHERNET.




function main()

   xbrowse( GetNetCardInfo() )

return nil
 
hola como puedo sacar la ip de internet y de la computadora en donde se ejecute una aplicación :roll:

Gracias.
Saluditos :wink: