Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- LanMan Library Reference Guide - <b>lm_nbmacaddr()</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 LM_NBMACADDR()
 Get the MAC address(es) of the network adapter(s) in a computer
------------------------------------------------------------------------------

 Syntax

      LM_NbMacAddr( <cComputer> [,<nLanaNumber>]) -> aMacAddr

 Arguments

     <cComputer> is the NetBIOS name of the computer in which to search
     for the MAC address(es) of the network adapter(s). <cComputer> can
     be either the computer on which the application is running or any
     other computer with which it can communicate through the NetBIOS
     Interface. For the local computer, specifying an asterisk ( "*" ) is
     recommended over using the NetBIOS name.

     <nLanaNumber> is an optional LAN adapter number between 0 and 254
     which can be used to limit the result of the MAC address search to
     only one specific LANA.

 Returns

     <aMacAddr>, which is a two-dimensional array containing the MAC
     address(es) of the LAN adapter(s) in <cComputer>. There is one
     element in the first dimension for each LANA. Each such element
     has a sub-array with two elements in the second dimension (#defines
     from LMLIB.CH):

     Element #1   LM_MAC_LANA     Numeric     LANA number
     Element #2   LM_MAC_MACADDR  Character   MAC address

     The MAC address, which in the case of a physical network adapter is
     stored in six bytes in the adapter firmware, is returned in hexadecimal
     format by LM_NbMacAddr(), for example "0001022352F9". The <aMacAddr)
     array is sorted on LANA number.

     If no network adapters are found, or a LANA number was passed and
     there was no corresponding MAC address, an empty array will be
     returned.

 Description

     LM_NbMacAddr() retrieves the MAC addresses of the network adapters
     in <cComputer>. It uses the NetBIOS interface for that purpose. For
     finding the MAC addresses in the computer on which the application
     is running, either the NetBIOS name of the computer or an asterisk
     ( "*" ) may be specified. To find the MAC addresses of adapters in
     another computer, the NetBIOS name of that computer must be used.

     If there is more than one network adapter (either a physical adapter
     or a virtual adapter such as the dialup adapter) or more than one
     transport protocol installed in <cComputer>, there will be one LANA
     number (LAN adapter number) for each adapter/protocol combination. And
     a MAC address is assigned to each used LANA number. But since there is
     a one-to-one relationship between LAN adapters and MAC addresses, each
     MAC address may be assigned to more than one LANA number depending on
     the installed transport protocols.

     LANA numbers can theoretically be between 0 and 254 although only a
     few numbers at the lower end of the range are usually in use. The
     numbers used are not necessarily contiguous. There is no way to
     systematically identify the mapping of a specific transport to a
     specific adapter.

     Often a larger number of MAC addresses will be reported on the local
     computer than if the name of that computer is specified when
     LM_NbMacAddr() is run on another computer. This is because on the
     local machine the NCBASTAT NetBIOS command has access to info on all
     (?) adapters and protocols while that is not necessarily true on a
     remote computer.

     It appears that searching for local MAC addresses by NetBIOS name is
     slower in some environments than when searching the local computer by
     specifying an asterisk for the computer name.

     LM_NbMacAddr() calls the NetBIOS Interface interrupt 5Ch specifying
     the NCBASTAT NetBIOS command to retrieve the MAC addresses. If the
     NetBIOS call fails, an empty array will be returned. The NetBIOS error
     code can then be retrieved by calling LM_Ferror(). Please note that
     NetBIOS error codes have nothing to do with DOS error codes. They are
     simply reported back to the Clipper level using the same error
     reporting system as when other LanMan Library functions fail with DOS
     errors. See the docs for LM_Ferror() for additional info.

     If one or more MAC addresses have already been retrieved when a
     NetBIOS error occurs, no error will be reported since in this case
     the error normally occurs because there simply are no more MAC
     addresses to retrieve.

     The MS Network Client for DOS, and possibly other redirectors too, do
     not report NetBIOS errors correctly, so LM_Ferror() may report no error
     (NetBIOS error 0) in such environments although an error occured.

     LM_NbMacAddr() requires FT_Int86() and supporting functions from the
     Nanforum Toolkit and its companion CPMI library. It is supposed to
     work on any computer where NetBIOS (but not necessarily NetBEUI) is
     installed. It also requires some memory allocation related functions
     from the Low Level Library (indluded with the LanMan Library).

 Examples

     #include "LMLIB.CH"
     local cCompName := '*'                // The local computer
     local aMacAddr := {}
     local i
     aMacAddr := LM_NbMacAddr(cCompName)   // Retrieve all MAC addresses
     if !empty(aMacAddr)
      for i := 1 to len(aMacAddr)
         ? 'Lana: ' + str(aMacAddr[i,LM_MAC_LANA],2) + space(5) +;
         'MAC address:  ' + aMacAddr[i,LM_MAC_MACADDR]
      next
     else
        ? 'Could not get the MAC addresses (NetBIOS Error ' +;
        ltrim(str(LM_Ferror())) + ')'
     endif

 Header File: LMLIB.CH

 Source: MACADDR.PRG

 Author: Klas Engwall <klas.engwall@engwall.com>

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson