New Function GetNetCardInfo

New Function GetNetCardInfo

Postby Daniel Garcia-Gil » Tue May 31, 2011 2:13 am

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  Expand view

#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
 
User avatar
Daniel Garcia-Gil
 
Posts: 2365
Joined: Wed Nov 02, 2005 11:46 pm
Location: Isla de Margarita

Re: New Function GetNetCardInfo

Postby lailton.webmaster » Tue May 31, 2011 2:50 am

xBrowse( GETALLMACADDRESS() )

Code: Select all  Expand view
#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
lailton.webmaster
 
Posts: 603
Joined: Sun May 04, 2008 8:44 pm

Re: New Function GetNetCardInfo

Postby lailton.webmaster » Tue May 31, 2011 3:56 am

Solved =)

:D
lailton.webmaster
 
Posts: 603
Joined: Sun May 04, 2008 8:44 pm

Re: New Function GetNetCardInfo

Postby AIDA » Sat Nov 23, 2019 5:36 am

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  Expand view

#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:
Que es mejor que programar? creo que nada :)
Atropellada pero aqui ando :P

I love Fivewin

séʌǝɹ ןɐ ɐʇsǝ opunɯ ǝʇsǝ
User avatar
AIDA
 
Posts: 879
Joined: Fri Jan 12, 2007 8:35 pm


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 80 guests