|
INT EnumMailExchanges( |
|
LPCTSTR lpszHostName, |
|
|
LPTSTR *lpszMailExchanges, |
|
|
INT nMaxMailExchanges |
|
); |
The EnumMailExchanges method returns a list of mail
exchanges for the specified host name or IP address.
Parameters
- lpszHostName
- Pointer to the string that contains the hostname or domain name
to be queried.
- lpszMailExchanges
- Pointer to an array of string pointers which specify one or
more mail exchanges. If the application needs to store these
values, a local copy should be made because they are invalidated
when another host name is resolved. The list of mail exchange
records is sorted in priority order, from highest (i.e., those
whose preference value is smallest) to lowest.
- nMaxMailExchanges
- The maximum number of mail exchanges in the array. If this
parameter is 0, then the method will return the number of mail
exchanges, but the list of mail exchanges will not be output in
lpszMailExchanges.
Return Value
If the method succeeds, the return value is the number of mail
exchanges. If the method fails, the return value is DNS_ERROR. To get
extended error information, call GetLastError.
Remarks
The application must never attempt to modify the mail exchange host
names or delete any of the values. This method uses an internal
data structure to store the host information and only one copy of this
structure is allocated per thread. The application must copy any
information it needs before issuing any other method calls.
Example
// Get the number of mail exchanges
if ((nMX = pClient->EnumMailExchanges(szHostName, NULL, 0)) == DNS_ERROR)
{
pClient->ShowError();
}
else
{
// Allocate memory for the list of mail exchanges
lpszMailExchanges = (LPTSTR *)LocalAlloc(LPTR, (nMX * sizeof(LPTSTR)));
// Retrieve the list of mail exchanges
nMX = pClient->EnumMailExchanges(szHostName, lpszMailExchanges, nMX);
// Populate a listbox with the mail exchanges
for (int nIndex = 0; nIndex < nMX; nIndex++)
pListBox->AddString(*lpszMailExchanges++);
LocalFree((HLOCAL)lpszMailExchanges);
}
Requirements
Minimum Desktop Platform: Windows 7 (Service Pack 1)
Minimum Server Platform: Windows Server 2008 R2 (Service Pack 1)
Header File: cstools10.h
Import Library: csdnsv10.lib
Unicode: Implemented as Unicode and ANSI versions.
See Also
GetMailExchange
|
|