FtpValidateHostName Function  
 
BOOL WINAPI FtpValidateHostName(
  LPCTSTR lpszHostName,  
  LPTSTR lpszAddress,  
  INT nMaxLength  
);

The FtpValidateHostName function determines if the specified host name is valid and returns its IP address.

Parameters

lpszHostName
A null-terminated string which specifies the host name. The function will fail If this parameter is NULL or an empty string.
lpszAddress
A null-terminated string buffer which will contain the IP address of the host. If specified, this string must be large enough to store the complete IP address, including the terminating null character. If this parameter is NULL or the nMaxLength parameter is zero, it will be ignored and the IP address will not be returned.
nMaxLength
An integer value that specifies the maximum number of characters which can be copied into the lpszAddress string buffer. The buffer must be large enough to store the complete address. Because this function can return either an IPv4 or IPv6 address, it is recommended the minimum length for the buffer to be 46 characters. If this parameter is zero, the lpszAddress parameter will be ignored.

Return Value

If the function succeeds, the host name is valid and the return value will be non-zero. If the function fails, the host name could not be resolved to an IP address and the return value will be zero. To get extended error information, call FtpGetLastError.

Remarks

The FtpValidateHostName function provides a convenient way to determine if a host name is valid by attempting to resolve the name into an IP address. If the Unicode version of this function is used, any non-ASCII characters in the host name will be automatically encoded into a compatible format and then resolved to an IP address. If you are unsure if an internationalized domain name will be specified as the host name, it is recommended you use the Unicode version.

If the lpszHostName parameter specifies a valid IPv4 or IPv6 address string instead of a host name, this function will return a copy of that IP address in the buffer provided by the caller. This allows the function to be used in cases where a user may input either a host name or IP address.

If you wish to validate a complete FTP URL instead of a host name, use the FtpValidateUrl function.

Requirements

Minimum Desktop Platform: Windows 7 Service Pack 1
Minimum Server Platform: Windows Server 2008 R2 Service Pack 1
Header File: cstools12.h
Import Library: csftpv12.lib
Unicode: Implemented as Unicode and ANSI versions

See Also