New Function GetNetCardInfo

Post Reply
User avatar
Daniel Garcia-Gil
Posts: 2365
Joined: Wed Nov 02, 2005 11:46 pm
Location: Isla de Margarita
Contact:

New Function GetNetCardInfo

Post 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
 
our best documentation is the source code
Isla de Margarita Venezuela.
danielgarciagil@gmail.com
http://tdolphin.blogspot.com/
https://www.dropbox.com/referrals/NTI5N ... rc=global9
lailton.webmaster
Posts: 603
Joined: Sun May 04, 2008 8:44 pm

Re: New Function GetNetCardInfo

Post 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
lailton.webmaster
Posts: 603
Joined: Sun May 04, 2008 8:44 pm

Re: New Function GetNetCardInfo

Post by lailton.webmaster »

Solved =)

:D
User avatar
AIDA
Posts: 782
Joined: Fri Jan 12, 2007 8:35 pm

Re: New Function GetNetCardInfo

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

I love Fivewin

séʌǝɹ ןɐ ɐʇsǝ opunɯ ǝʇsǝ
Post Reply