BOOL WINAPI InetGetPhysicalAddress( |
|
LPTSTR lpszAddress, |
|
|
UINT nMaxLength |
|
); |
Return the media access control (MAC) address for the primary
network adapter.
Parameters
- lpszAddress
- A string buffer that will contain the address in a printable
format when the function returns. This parameter cannot be NULL.
- nMaxLength
- The maximum number of characters that can be copied into the
buffer, including the terminating null character.
Return Value
If the function succeeds, the return value is non-zero. If the
function fails, the return value is zero. To get extended error
information, call InetGetLastError.
Remarks
The InetGetPhysicalAddress function returns the media access
control (MAC) address for the primary network adapter. This is a 48
bit or 64 bit address that is assigned to each network interface and
is used for identification and access control. All network devices on
the same subnet must be assigned their own unique MAC address. Unlike
IP addresses which may be assigned dynamically and can be frequently
changed, MAC addresses are considered to be more permanent because
they are usually assigned by the device manufacturer and stored in
firmware. Note that in some cases it is possible to change the address
assigned to a device, and virtual network interfaces may have
configurable MAC addresses.
This function returns the MAC address as a printable string,
with each byte of the address as a two-digit hexadecimal value
separated by a colon. The string buffer passed to the function should
be at least 20 characters long to accommodate the address and
terminating null character. An example of a 48 bit address would be
"01:23:45:67:89:AB". If the local system is multi-homed (having
more than one network adapter) then this function will return the MAC
address for the primary network adapter.
This function is provided for backwards compatibility with previous
versions of the library and it is recommended that new applications
use the InetGetAdapterAddress function.
Requirements
Minimum Desktop Platform: Windows 7 (Service Pack 1)
Minimum Server Platform: Windows Server 2008 R2 (Service Pack 1)
Header: Include cswsock10.h
Import Library: cswskv10.lib
Unicode: Implemented as Unicode and ANSI versions.
See Also
InetEnumNetworkAddresses,
InetGetAdapterAddress,
InetGetLocalName,
InetGetHostAddress
|