#include <ddeml.h> |
HCONV DdeQueryNextServer(hConvList, hConvPrev) | |||||
HCONVLIST hConvList; | /* handle of conversation list | */ | |||
HCONV hConvPrev; | /* previous conversation handle | */ |
The DdeQueryNextServer function obtains the next conversation handle in the given conversation list.
hConvList
Identifies the conversation list. This handle must have been created by a previous call to the DdeConnectList function.
hConvPrev
Identifies the conversation handle previously returned by this function. If this parameter is NULL, this function returns the first conversation handle in the list.
The return value is the next conversation handle in the list if the list contains any more conversation handles. Otherwise, it is NULL.
The following example uses the DdeQueryNextServer function to count the number of conversation handles in a conversation list and to copy the service-name string handles of the servers to a local buffer:
HCONVLIST hconvList; /* conversation list */
DWORD idInst; /* instance identifier */
HSZ hszSystem; /* System topic */
HCONV hconv = NULL; /* conversation handle */
CONVINFO ci; /* holds conversation data */
UINT cConv = 0; /* count of conv. handles */
HSZ *pHsz, *aHsz; /* point to string handles */
/* Connect to all servers that support the System topic. */
hconvList = DdeConnectList(idInst, (HSZ) NULL, hszSystem,
(HCONV) NULL, (LPVOID) NULL);
/* Count the number of handles in the conversation list. */
while ((hconv = DdeQueryNextServer(hconvList, hconv)) != (HCONV) NULL)
cConv++;
/* Allocate a buffer for the string handles. */
hconv = (HCONV) NULL;
aHsz = (HSZ *) LocalAlloc(LMEM_FIXED, cConv * sizeof(HSZ));
/* Copy the string handles to the buffer. */
pHsz = aHsz;
while ((hconv = DdeQueryNextServer(hconvList, hconv)) != (HCONV) NULL) {
DdeQueryConvInfo(hconv, QID_SYNC, (PCONVINFO) &ci);
DdeKeepStringHandle(idInst, ci.hszSvcPartner);
*pHsz++ = ci.hszSvcPartner;
}
.
. /* Use the handles; converse with servers. */
.
/* Free the memory and terminate conversations. */
LocalFree((HANDLE) aHsz);
DdeDisconnectList(hconvList);