| |
| INT GetLocalAddress(
|
| |
INT nAddressFamily, |
|
| |
LPTSTR lpszAddress, |
|
| |
INT nMaxLength |
|
| );
|
The DnsGetLocalAddress method returns the IP address for
the local host.
- nAddressFamily
- An integer value which specifies the type of address that
should be returned. A value of AF_INET specifies that the IPv4
address for the host should be returned. A value of AF_INET6
specifies that the IPv6 address for the host should be returned. A
value of AF_UNSPEC specifies that if the host only has an IPv6
address, that value should be returned, otherwise return the IPv4
address for the host.
- lpszAddress
- Pointer to the buffer that will contain the IP address, stored
as a null-terminated string in dot notation. This buffer should be
at least 40 characters in length to accommodate both IPv4 and IPv6
addresses.
- nMaxLength
- The maximum length of the string buffer.
Return Value
If the method succeeds, the return value is the number of
characters copied into the host address buffer. If the method
fails, the return value is DNS_ERROR. To get extended error
information, call DnsGetLastError.
Remarks
The GetLocalAddress method may return an address in
either IPv4 or IPv6 format, depending on the address family that is
specified and what records exist for the host. If your application
does not support the IPv6 address format, you must specify the
nAddressFamily parameter as AF_INET to prevent the
possibility of an IPv6 address being returned.
Requirements
Client: Requires Windows 7, Windows Vista or Windows
XP.
Server: Requires Windows Server 2008 or Windows Server
2003.
Header: Include cstools7.h.
Library: Use csdnsav7.lib.
Unicode: Implemented as Unicode and ANSI versions.
See Also
GetHostName, GetHostInfo, GetHostServices, GetMailExchange, GetRecord
|
|