Novell is now a part of Micro Focus

Retrieving the MAC Address on Win32

Articles and Tips: tip

Wolfgang Schreiber
Novell, Inc.

01 Feb 2002

The application layer normally does not need to know about your workstation's MAC address, since the address is mainly used by the transport layer through a protocol (such as IPX, UDP, or NetBIOS).

Applications typically do not talk to the MAC layer, but only to the transport layer to transmit data over the network. Consequently, there are no Win32 APIs that directly retrieve the MAC address. However, the transport protocol APIs do include functions to retrieve the MAC address, and you can use these if you need to identify the MAC address of your workstation. This implies that you need to call transport-protocol specific APIs to retrieve your MAC address.

To retrieve the MAC address from the IPX protocol layer, you can use the functions:

NWSipxOpenSocket() NWSipxGetInternetAddress()

To retrieve the MAC address from the IP protocol layer, the easiest way is to use the function GetIfTable() from the IPHLPAPI.DLL, which is available on WinNT/Win2k/Win98 systems (see the MSDN for details).

To retrieve the MAC address from the NetBIOS protocol layer, you can use the function NetBios(), and first call the NCBRESET subfunction, then the NCBASTAT subfunction. As a workaround on Win32 systems, you can also use an OLE API CoCreateGUID(). A part of the returned GUID is the workstation's MAC address.

* Originally published in Novell AppNotes


The origin of this information may be internal or external to Novell. While Novell makes all reasonable efforts to verify this information, Novell does not make explicit or implied claims to its validity.

© Micro Focus